| OLD | NEW |
| (Empty) | |
| 1 library googleapis.iam.v1.test; |
| 2 |
| 3 import "dart:core" as core; |
| 4 import "dart:collection" as collection; |
| 5 import "dart:async" as async; |
| 6 import "dart:convert" as convert; |
| 7 |
| 8 import 'package:http/http.dart' as http; |
| 9 import 'package:http/testing.dart' as http_testing; |
| 10 import 'package:unittest/unittest.dart' as unittest; |
| 11 |
| 12 import 'package:googleapis/iam/v1.dart' as api; |
| 13 |
| 14 class HttpServerMock extends http.BaseClient { |
| 15 core.Function _callback; |
| 16 core.bool _expectJson; |
| 17 |
| 18 void register(core.Function callback, core.bool expectJson) { |
| 19 _callback = callback; |
| 20 _expectJson = expectJson; |
| 21 } |
| 22 |
| 23 async.Future<http.StreamedResponse> send(http.BaseRequest request) { |
| 24 if (_expectJson) { |
| 25 return request.finalize() |
| 26 .transform(convert.UTF8.decoder) |
| 27 .join('') |
| 28 .then((core.String jsonString) { |
| 29 if (jsonString.isEmpty) { |
| 30 return _callback(request, null); |
| 31 } else { |
| 32 return _callback(request, convert.JSON.decode(jsonString)); |
| 33 } |
| 34 }); |
| 35 } else { |
| 36 var stream = request.finalize(); |
| 37 if (stream == null) { |
| 38 return _callback(request, []); |
| 39 } else { |
| 40 return stream.toBytes().then((data) { |
| 41 return _callback(request, data); |
| 42 }); |
| 43 } |
| 44 } |
| 45 } |
| 46 } |
| 47 |
| 48 http.StreamedResponse stringResponse( |
| 49 core.int status, core.Map headers, core.String body) { |
| 50 var stream = new async.Stream.fromIterable([convert.UTF8.encode(body)]); |
| 51 return new http.StreamedResponse(stream, status, headers: headers); |
| 52 } |
| 53 |
| 54 buildUnnamed1604() { |
| 55 var o = new core.List<core.String>(); |
| 56 o.add("foo"); |
| 57 o.add("foo"); |
| 58 return o; |
| 59 } |
| 60 |
| 61 checkUnnamed1604(core.List<core.String> o) { |
| 62 unittest.expect(o, unittest.hasLength(2)); |
| 63 unittest.expect(o[0], unittest.equals('foo')); |
| 64 unittest.expect(o[1], unittest.equals('foo')); |
| 65 } |
| 66 |
| 67 core.int buildCounterBinding = 0; |
| 68 buildBinding() { |
| 69 var o = new api.Binding(); |
| 70 buildCounterBinding++; |
| 71 if (buildCounterBinding < 3) { |
| 72 o.members = buildUnnamed1604(); |
| 73 o.role = "foo"; |
| 74 } |
| 75 buildCounterBinding--; |
| 76 return o; |
| 77 } |
| 78 |
| 79 checkBinding(api.Binding o) { |
| 80 buildCounterBinding++; |
| 81 if (buildCounterBinding < 3) { |
| 82 checkUnnamed1604(o.members); |
| 83 unittest.expect(o.role, unittest.equals('foo')); |
| 84 } |
| 85 buildCounterBinding--; |
| 86 } |
| 87 |
| 88 core.int buildCounterCloudAuditOptions = 0; |
| 89 buildCloudAuditOptions() { |
| 90 var o = new api.CloudAuditOptions(); |
| 91 buildCounterCloudAuditOptions++; |
| 92 if (buildCounterCloudAuditOptions < 3) { |
| 93 } |
| 94 buildCounterCloudAuditOptions--; |
| 95 return o; |
| 96 } |
| 97 |
| 98 checkCloudAuditOptions(api.CloudAuditOptions o) { |
| 99 buildCounterCloudAuditOptions++; |
| 100 if (buildCounterCloudAuditOptions < 3) { |
| 101 } |
| 102 buildCounterCloudAuditOptions--; |
| 103 } |
| 104 |
| 105 buildUnnamed1605() { |
| 106 var o = new core.List<core.String>(); |
| 107 o.add("foo"); |
| 108 o.add("foo"); |
| 109 return o; |
| 110 } |
| 111 |
| 112 checkUnnamed1605(core.List<core.String> o) { |
| 113 unittest.expect(o, unittest.hasLength(2)); |
| 114 unittest.expect(o[0], unittest.equals('foo')); |
| 115 unittest.expect(o[1], unittest.equals('foo')); |
| 116 } |
| 117 |
| 118 core.int buildCounterCondition = 0; |
| 119 buildCondition() { |
| 120 var o = new api.Condition(); |
| 121 buildCounterCondition++; |
| 122 if (buildCounterCondition < 3) { |
| 123 o.iam = "foo"; |
| 124 o.op = "foo"; |
| 125 o.svc = "foo"; |
| 126 o.sys = "foo"; |
| 127 o.value = "foo"; |
| 128 o.values = buildUnnamed1605(); |
| 129 } |
| 130 buildCounterCondition--; |
| 131 return o; |
| 132 } |
| 133 |
| 134 checkCondition(api.Condition o) { |
| 135 buildCounterCondition++; |
| 136 if (buildCounterCondition < 3) { |
| 137 unittest.expect(o.iam, unittest.equals('foo')); |
| 138 unittest.expect(o.op, unittest.equals('foo')); |
| 139 unittest.expect(o.svc, unittest.equals('foo')); |
| 140 unittest.expect(o.sys, unittest.equals('foo')); |
| 141 unittest.expect(o.value, unittest.equals('foo')); |
| 142 checkUnnamed1605(o.values); |
| 143 } |
| 144 buildCounterCondition--; |
| 145 } |
| 146 |
| 147 core.int buildCounterCounterOptions = 0; |
| 148 buildCounterOptions() { |
| 149 var o = new api.CounterOptions(); |
| 150 buildCounterCounterOptions++; |
| 151 if (buildCounterCounterOptions < 3) { |
| 152 o.field = "foo"; |
| 153 o.metric = "foo"; |
| 154 } |
| 155 buildCounterCounterOptions--; |
| 156 return o; |
| 157 } |
| 158 |
| 159 checkCounterOptions(api.CounterOptions o) { |
| 160 buildCounterCounterOptions++; |
| 161 if (buildCounterCounterOptions < 3) { |
| 162 unittest.expect(o.field, unittest.equals('foo')); |
| 163 unittest.expect(o.metric, unittest.equals('foo')); |
| 164 } |
| 165 buildCounterCounterOptions--; |
| 166 } |
| 167 |
| 168 core.int buildCounterCreateServiceAccountKeyRequest = 0; |
| 169 buildCreateServiceAccountKeyRequest() { |
| 170 var o = new api.CreateServiceAccountKeyRequest(); |
| 171 buildCounterCreateServiceAccountKeyRequest++; |
| 172 if (buildCounterCreateServiceAccountKeyRequest < 3) { |
| 173 o.privateKeyType = "foo"; |
| 174 } |
| 175 buildCounterCreateServiceAccountKeyRequest--; |
| 176 return o; |
| 177 } |
| 178 |
| 179 checkCreateServiceAccountKeyRequest(api.CreateServiceAccountKeyRequest o) { |
| 180 buildCounterCreateServiceAccountKeyRequest++; |
| 181 if (buildCounterCreateServiceAccountKeyRequest < 3) { |
| 182 unittest.expect(o.privateKeyType, unittest.equals('foo')); |
| 183 } |
| 184 buildCounterCreateServiceAccountKeyRequest--; |
| 185 } |
| 186 |
| 187 core.int buildCounterCreateServiceAccountRequest = 0; |
| 188 buildCreateServiceAccountRequest() { |
| 189 var o = new api.CreateServiceAccountRequest(); |
| 190 buildCounterCreateServiceAccountRequest++; |
| 191 if (buildCounterCreateServiceAccountRequest < 3) { |
| 192 o.accountId = "foo"; |
| 193 o.serviceAccount = buildServiceAccount(); |
| 194 } |
| 195 buildCounterCreateServiceAccountRequest--; |
| 196 return o; |
| 197 } |
| 198 |
| 199 checkCreateServiceAccountRequest(api.CreateServiceAccountRequest o) { |
| 200 buildCounterCreateServiceAccountRequest++; |
| 201 if (buildCounterCreateServiceAccountRequest < 3) { |
| 202 unittest.expect(o.accountId, unittest.equals('foo')); |
| 203 checkServiceAccount(o.serviceAccount); |
| 204 } |
| 205 buildCounterCreateServiceAccountRequest--; |
| 206 } |
| 207 |
| 208 core.int buildCounterDataAccessOptions = 0; |
| 209 buildDataAccessOptions() { |
| 210 var o = new api.DataAccessOptions(); |
| 211 buildCounterDataAccessOptions++; |
| 212 if (buildCounterDataAccessOptions < 3) { |
| 213 } |
| 214 buildCounterDataAccessOptions--; |
| 215 return o; |
| 216 } |
| 217 |
| 218 checkDataAccessOptions(api.DataAccessOptions o) { |
| 219 buildCounterDataAccessOptions++; |
| 220 if (buildCounterDataAccessOptions < 3) { |
| 221 } |
| 222 buildCounterDataAccessOptions--; |
| 223 } |
| 224 |
| 225 core.int buildCounterEmpty = 0; |
| 226 buildEmpty() { |
| 227 var o = new api.Empty(); |
| 228 buildCounterEmpty++; |
| 229 if (buildCounterEmpty < 3) { |
| 230 } |
| 231 buildCounterEmpty--; |
| 232 return o; |
| 233 } |
| 234 |
| 235 checkEmpty(api.Empty o) { |
| 236 buildCounterEmpty++; |
| 237 if (buildCounterEmpty < 3) { |
| 238 } |
| 239 buildCounterEmpty--; |
| 240 } |
| 241 |
| 242 buildUnnamed1606() { |
| 243 var o = new core.List<api.ServiceAccountKey>(); |
| 244 o.add(buildServiceAccountKey()); |
| 245 o.add(buildServiceAccountKey()); |
| 246 return o; |
| 247 } |
| 248 |
| 249 checkUnnamed1606(core.List<api.ServiceAccountKey> o) { |
| 250 unittest.expect(o, unittest.hasLength(2)); |
| 251 checkServiceAccountKey(o[0]); |
| 252 checkServiceAccountKey(o[1]); |
| 253 } |
| 254 |
| 255 core.int buildCounterListServiceAccountKeysResponse = 0; |
| 256 buildListServiceAccountKeysResponse() { |
| 257 var o = new api.ListServiceAccountKeysResponse(); |
| 258 buildCounterListServiceAccountKeysResponse++; |
| 259 if (buildCounterListServiceAccountKeysResponse < 3) { |
| 260 o.keys = buildUnnamed1606(); |
| 261 } |
| 262 buildCounterListServiceAccountKeysResponse--; |
| 263 return o; |
| 264 } |
| 265 |
| 266 checkListServiceAccountKeysResponse(api.ListServiceAccountKeysResponse o) { |
| 267 buildCounterListServiceAccountKeysResponse++; |
| 268 if (buildCounterListServiceAccountKeysResponse < 3) { |
| 269 checkUnnamed1606(o.keys); |
| 270 } |
| 271 buildCounterListServiceAccountKeysResponse--; |
| 272 } |
| 273 |
| 274 buildUnnamed1607() { |
| 275 var o = new core.List<api.ServiceAccount>(); |
| 276 o.add(buildServiceAccount()); |
| 277 o.add(buildServiceAccount()); |
| 278 return o; |
| 279 } |
| 280 |
| 281 checkUnnamed1607(core.List<api.ServiceAccount> o) { |
| 282 unittest.expect(o, unittest.hasLength(2)); |
| 283 checkServiceAccount(o[0]); |
| 284 checkServiceAccount(o[1]); |
| 285 } |
| 286 |
| 287 core.int buildCounterListServiceAccountsResponse = 0; |
| 288 buildListServiceAccountsResponse() { |
| 289 var o = new api.ListServiceAccountsResponse(); |
| 290 buildCounterListServiceAccountsResponse++; |
| 291 if (buildCounterListServiceAccountsResponse < 3) { |
| 292 o.accounts = buildUnnamed1607(); |
| 293 o.nextPageToken = "foo"; |
| 294 } |
| 295 buildCounterListServiceAccountsResponse--; |
| 296 return o; |
| 297 } |
| 298 |
| 299 checkListServiceAccountsResponse(api.ListServiceAccountsResponse o) { |
| 300 buildCounterListServiceAccountsResponse++; |
| 301 if (buildCounterListServiceAccountsResponse < 3) { |
| 302 checkUnnamed1607(o.accounts); |
| 303 unittest.expect(o.nextPageToken, unittest.equals('foo')); |
| 304 } |
| 305 buildCounterListServiceAccountsResponse--; |
| 306 } |
| 307 |
| 308 core.int buildCounterLogConfig = 0; |
| 309 buildLogConfig() { |
| 310 var o = new api.LogConfig(); |
| 311 buildCounterLogConfig++; |
| 312 if (buildCounterLogConfig < 3) { |
| 313 o.cloudAudit = buildCloudAuditOptions(); |
| 314 o.counter = buildCounterOptions(); |
| 315 o.dataAccess = buildDataAccessOptions(); |
| 316 } |
| 317 buildCounterLogConfig--; |
| 318 return o; |
| 319 } |
| 320 |
| 321 checkLogConfig(api.LogConfig o) { |
| 322 buildCounterLogConfig++; |
| 323 if (buildCounterLogConfig < 3) { |
| 324 checkCloudAuditOptions(o.cloudAudit); |
| 325 checkCounterOptions(o.counter); |
| 326 checkDataAccessOptions(o.dataAccess); |
| 327 } |
| 328 buildCounterLogConfig--; |
| 329 } |
| 330 |
| 331 buildUnnamed1608() { |
| 332 var o = new core.List<api.Binding>(); |
| 333 o.add(buildBinding()); |
| 334 o.add(buildBinding()); |
| 335 return o; |
| 336 } |
| 337 |
| 338 checkUnnamed1608(core.List<api.Binding> o) { |
| 339 unittest.expect(o, unittest.hasLength(2)); |
| 340 checkBinding(o[0]); |
| 341 checkBinding(o[1]); |
| 342 } |
| 343 |
| 344 buildUnnamed1609() { |
| 345 var o = new core.List<api.Rule>(); |
| 346 o.add(buildRule()); |
| 347 o.add(buildRule()); |
| 348 return o; |
| 349 } |
| 350 |
| 351 checkUnnamed1609(core.List<api.Rule> o) { |
| 352 unittest.expect(o, unittest.hasLength(2)); |
| 353 checkRule(o[0]); |
| 354 checkRule(o[1]); |
| 355 } |
| 356 |
| 357 core.int buildCounterPolicy = 0; |
| 358 buildPolicy() { |
| 359 var o = new api.Policy(); |
| 360 buildCounterPolicy++; |
| 361 if (buildCounterPolicy < 3) { |
| 362 o.bindings = buildUnnamed1608(); |
| 363 o.etag = "foo"; |
| 364 o.rules = buildUnnamed1609(); |
| 365 o.version = 42; |
| 366 } |
| 367 buildCounterPolicy--; |
| 368 return o; |
| 369 } |
| 370 |
| 371 checkPolicy(api.Policy o) { |
| 372 buildCounterPolicy++; |
| 373 if (buildCounterPolicy < 3) { |
| 374 checkUnnamed1608(o.bindings); |
| 375 unittest.expect(o.etag, unittest.equals('foo')); |
| 376 checkUnnamed1609(o.rules); |
| 377 unittest.expect(o.version, unittest.equals(42)); |
| 378 } |
| 379 buildCounterPolicy--; |
| 380 } |
| 381 |
| 382 buildUnnamed1610() { |
| 383 var o = new core.List<api.Condition>(); |
| 384 o.add(buildCondition()); |
| 385 o.add(buildCondition()); |
| 386 return o; |
| 387 } |
| 388 |
| 389 checkUnnamed1610(core.List<api.Condition> o) { |
| 390 unittest.expect(o, unittest.hasLength(2)); |
| 391 checkCondition(o[0]); |
| 392 checkCondition(o[1]); |
| 393 } |
| 394 |
| 395 buildUnnamed1611() { |
| 396 var o = new core.List<core.String>(); |
| 397 o.add("foo"); |
| 398 o.add("foo"); |
| 399 return o; |
| 400 } |
| 401 |
| 402 checkUnnamed1611(core.List<core.String> o) { |
| 403 unittest.expect(o, unittest.hasLength(2)); |
| 404 unittest.expect(o[0], unittest.equals('foo')); |
| 405 unittest.expect(o[1], unittest.equals('foo')); |
| 406 } |
| 407 |
| 408 buildUnnamed1612() { |
| 409 var o = new core.List<api.LogConfig>(); |
| 410 o.add(buildLogConfig()); |
| 411 o.add(buildLogConfig()); |
| 412 return o; |
| 413 } |
| 414 |
| 415 checkUnnamed1612(core.List<api.LogConfig> o) { |
| 416 unittest.expect(o, unittest.hasLength(2)); |
| 417 checkLogConfig(o[0]); |
| 418 checkLogConfig(o[1]); |
| 419 } |
| 420 |
| 421 buildUnnamed1613() { |
| 422 var o = new core.List<core.String>(); |
| 423 o.add("foo"); |
| 424 o.add("foo"); |
| 425 return o; |
| 426 } |
| 427 |
| 428 checkUnnamed1613(core.List<core.String> o) { |
| 429 unittest.expect(o, unittest.hasLength(2)); |
| 430 unittest.expect(o[0], unittest.equals('foo')); |
| 431 unittest.expect(o[1], unittest.equals('foo')); |
| 432 } |
| 433 |
| 434 buildUnnamed1614() { |
| 435 var o = new core.List<core.String>(); |
| 436 o.add("foo"); |
| 437 o.add("foo"); |
| 438 return o; |
| 439 } |
| 440 |
| 441 checkUnnamed1614(core.List<core.String> o) { |
| 442 unittest.expect(o, unittest.hasLength(2)); |
| 443 unittest.expect(o[0], unittest.equals('foo')); |
| 444 unittest.expect(o[1], unittest.equals('foo')); |
| 445 } |
| 446 |
| 447 core.int buildCounterRule = 0; |
| 448 buildRule() { |
| 449 var o = new api.Rule(); |
| 450 buildCounterRule++; |
| 451 if (buildCounterRule < 3) { |
| 452 o.action = "foo"; |
| 453 o.conditions = buildUnnamed1610(); |
| 454 o.description = "foo"; |
| 455 o.in_ = buildUnnamed1611(); |
| 456 o.logConfig = buildUnnamed1612(); |
| 457 o.notIn = buildUnnamed1613(); |
| 458 o.permissions = buildUnnamed1614(); |
| 459 } |
| 460 buildCounterRule--; |
| 461 return o; |
| 462 } |
| 463 |
| 464 checkRule(api.Rule o) { |
| 465 buildCounterRule++; |
| 466 if (buildCounterRule < 3) { |
| 467 unittest.expect(o.action, unittest.equals('foo')); |
| 468 checkUnnamed1610(o.conditions); |
| 469 unittest.expect(o.description, unittest.equals('foo')); |
| 470 checkUnnamed1611(o.in_); |
| 471 checkUnnamed1612(o.logConfig); |
| 472 checkUnnamed1613(o.notIn); |
| 473 checkUnnamed1614(o.permissions); |
| 474 } |
| 475 buildCounterRule--; |
| 476 } |
| 477 |
| 478 core.int buildCounterServiceAccount = 0; |
| 479 buildServiceAccount() { |
| 480 var o = new api.ServiceAccount(); |
| 481 buildCounterServiceAccount++; |
| 482 if (buildCounterServiceAccount < 3) { |
| 483 o.displayName = "foo"; |
| 484 o.email = "foo"; |
| 485 o.etag = "foo"; |
| 486 o.name = "foo"; |
| 487 o.oauth2ClientId = "foo"; |
| 488 o.projectId = "foo"; |
| 489 o.uniqueId = "foo"; |
| 490 } |
| 491 buildCounterServiceAccount--; |
| 492 return o; |
| 493 } |
| 494 |
| 495 checkServiceAccount(api.ServiceAccount o) { |
| 496 buildCounterServiceAccount++; |
| 497 if (buildCounterServiceAccount < 3) { |
| 498 unittest.expect(o.displayName, unittest.equals('foo')); |
| 499 unittest.expect(o.email, unittest.equals('foo')); |
| 500 unittest.expect(o.etag, unittest.equals('foo')); |
| 501 unittest.expect(o.name, unittest.equals('foo')); |
| 502 unittest.expect(o.oauth2ClientId, unittest.equals('foo')); |
| 503 unittest.expect(o.projectId, unittest.equals('foo')); |
| 504 unittest.expect(o.uniqueId, unittest.equals('foo')); |
| 505 } |
| 506 buildCounterServiceAccount--; |
| 507 } |
| 508 |
| 509 core.int buildCounterServiceAccountKey = 0; |
| 510 buildServiceAccountKey() { |
| 511 var o = new api.ServiceAccountKey(); |
| 512 buildCounterServiceAccountKey++; |
| 513 if (buildCounterServiceAccountKey < 3) { |
| 514 o.name = "foo"; |
| 515 o.privateKeyData = "foo"; |
| 516 o.privateKeyType = "foo"; |
| 517 o.validAfterTime = "foo"; |
| 518 o.validBeforeTime = "foo"; |
| 519 } |
| 520 buildCounterServiceAccountKey--; |
| 521 return o; |
| 522 } |
| 523 |
| 524 checkServiceAccountKey(api.ServiceAccountKey o) { |
| 525 buildCounterServiceAccountKey++; |
| 526 if (buildCounterServiceAccountKey < 3) { |
| 527 unittest.expect(o.name, unittest.equals('foo')); |
| 528 unittest.expect(o.privateKeyData, unittest.equals('foo')); |
| 529 unittest.expect(o.privateKeyType, unittest.equals('foo')); |
| 530 unittest.expect(o.validAfterTime, unittest.equals('foo')); |
| 531 unittest.expect(o.validBeforeTime, unittest.equals('foo')); |
| 532 } |
| 533 buildCounterServiceAccountKey--; |
| 534 } |
| 535 |
| 536 core.int buildCounterSetIamPolicyRequest = 0; |
| 537 buildSetIamPolicyRequest() { |
| 538 var o = new api.SetIamPolicyRequest(); |
| 539 buildCounterSetIamPolicyRequest++; |
| 540 if (buildCounterSetIamPolicyRequest < 3) { |
| 541 o.policy = buildPolicy(); |
| 542 } |
| 543 buildCounterSetIamPolicyRequest--; |
| 544 return o; |
| 545 } |
| 546 |
| 547 checkSetIamPolicyRequest(api.SetIamPolicyRequest o) { |
| 548 buildCounterSetIamPolicyRequest++; |
| 549 if (buildCounterSetIamPolicyRequest < 3) { |
| 550 checkPolicy(o.policy); |
| 551 } |
| 552 buildCounterSetIamPolicyRequest--; |
| 553 } |
| 554 |
| 555 core.int buildCounterSignBlobRequest = 0; |
| 556 buildSignBlobRequest() { |
| 557 var o = new api.SignBlobRequest(); |
| 558 buildCounterSignBlobRequest++; |
| 559 if (buildCounterSignBlobRequest < 3) { |
| 560 o.bytesToSign = "foo"; |
| 561 } |
| 562 buildCounterSignBlobRequest--; |
| 563 return o; |
| 564 } |
| 565 |
| 566 checkSignBlobRequest(api.SignBlobRequest o) { |
| 567 buildCounterSignBlobRequest++; |
| 568 if (buildCounterSignBlobRequest < 3) { |
| 569 unittest.expect(o.bytesToSign, unittest.equals('foo')); |
| 570 } |
| 571 buildCounterSignBlobRequest--; |
| 572 } |
| 573 |
| 574 core.int buildCounterSignBlobResponse = 0; |
| 575 buildSignBlobResponse() { |
| 576 var o = new api.SignBlobResponse(); |
| 577 buildCounterSignBlobResponse++; |
| 578 if (buildCounterSignBlobResponse < 3) { |
| 579 o.keyId = "foo"; |
| 580 o.signature = "foo"; |
| 581 } |
| 582 buildCounterSignBlobResponse--; |
| 583 return o; |
| 584 } |
| 585 |
| 586 checkSignBlobResponse(api.SignBlobResponse o) { |
| 587 buildCounterSignBlobResponse++; |
| 588 if (buildCounterSignBlobResponse < 3) { |
| 589 unittest.expect(o.keyId, unittest.equals('foo')); |
| 590 unittest.expect(o.signature, unittest.equals('foo')); |
| 591 } |
| 592 buildCounterSignBlobResponse--; |
| 593 } |
| 594 |
| 595 buildUnnamed1615() { |
| 596 var o = new core.List<core.String>(); |
| 597 o.add("foo"); |
| 598 o.add("foo"); |
| 599 return o; |
| 600 } |
| 601 |
| 602 checkUnnamed1615(core.List<core.String> o) { |
| 603 unittest.expect(o, unittest.hasLength(2)); |
| 604 unittest.expect(o[0], unittest.equals('foo')); |
| 605 unittest.expect(o[1], unittest.equals('foo')); |
| 606 } |
| 607 |
| 608 core.int buildCounterTestIamPermissionsRequest = 0; |
| 609 buildTestIamPermissionsRequest() { |
| 610 var o = new api.TestIamPermissionsRequest(); |
| 611 buildCounterTestIamPermissionsRequest++; |
| 612 if (buildCounterTestIamPermissionsRequest < 3) { |
| 613 o.permissions = buildUnnamed1615(); |
| 614 } |
| 615 buildCounterTestIamPermissionsRequest--; |
| 616 return o; |
| 617 } |
| 618 |
| 619 checkTestIamPermissionsRequest(api.TestIamPermissionsRequest o) { |
| 620 buildCounterTestIamPermissionsRequest++; |
| 621 if (buildCounterTestIamPermissionsRequest < 3) { |
| 622 checkUnnamed1615(o.permissions); |
| 623 } |
| 624 buildCounterTestIamPermissionsRequest--; |
| 625 } |
| 626 |
| 627 buildUnnamed1616() { |
| 628 var o = new core.List<core.String>(); |
| 629 o.add("foo"); |
| 630 o.add("foo"); |
| 631 return o; |
| 632 } |
| 633 |
| 634 checkUnnamed1616(core.List<core.String> o) { |
| 635 unittest.expect(o, unittest.hasLength(2)); |
| 636 unittest.expect(o[0], unittest.equals('foo')); |
| 637 unittest.expect(o[1], unittest.equals('foo')); |
| 638 } |
| 639 |
| 640 core.int buildCounterTestIamPermissionsResponse = 0; |
| 641 buildTestIamPermissionsResponse() { |
| 642 var o = new api.TestIamPermissionsResponse(); |
| 643 buildCounterTestIamPermissionsResponse++; |
| 644 if (buildCounterTestIamPermissionsResponse < 3) { |
| 645 o.permissions = buildUnnamed1616(); |
| 646 } |
| 647 buildCounterTestIamPermissionsResponse--; |
| 648 return o; |
| 649 } |
| 650 |
| 651 checkTestIamPermissionsResponse(api.TestIamPermissionsResponse o) { |
| 652 buildCounterTestIamPermissionsResponse++; |
| 653 if (buildCounterTestIamPermissionsResponse < 3) { |
| 654 checkUnnamed1616(o.permissions); |
| 655 } |
| 656 buildCounterTestIamPermissionsResponse--; |
| 657 } |
| 658 |
| 659 buildUnnamed1617() { |
| 660 var o = new core.List<core.String>(); |
| 661 o.add("foo"); |
| 662 o.add("foo"); |
| 663 return o; |
| 664 } |
| 665 |
| 666 checkUnnamed1617(core.List<core.String> o) { |
| 667 unittest.expect(o, unittest.hasLength(2)); |
| 668 unittest.expect(o[0], unittest.equals('foo')); |
| 669 unittest.expect(o[1], unittest.equals('foo')); |
| 670 } |
| 671 |
| 672 |
| 673 main() { |
| 674 unittest.group("obj-schema-Binding", () { |
| 675 unittest.test("to-json--from-json", () { |
| 676 var o = buildBinding(); |
| 677 var od = new api.Binding.fromJson(o.toJson()); |
| 678 checkBinding(od); |
| 679 }); |
| 680 }); |
| 681 |
| 682 |
| 683 unittest.group("obj-schema-CloudAuditOptions", () { |
| 684 unittest.test("to-json--from-json", () { |
| 685 var o = buildCloudAuditOptions(); |
| 686 var od = new api.CloudAuditOptions.fromJson(o.toJson()); |
| 687 checkCloudAuditOptions(od); |
| 688 }); |
| 689 }); |
| 690 |
| 691 |
| 692 unittest.group("obj-schema-Condition", () { |
| 693 unittest.test("to-json--from-json", () { |
| 694 var o = buildCondition(); |
| 695 var od = new api.Condition.fromJson(o.toJson()); |
| 696 checkCondition(od); |
| 697 }); |
| 698 }); |
| 699 |
| 700 |
| 701 unittest.group("obj-schema-CounterOptions", () { |
| 702 unittest.test("to-json--from-json", () { |
| 703 var o = buildCounterOptions(); |
| 704 var od = new api.CounterOptions.fromJson(o.toJson()); |
| 705 checkCounterOptions(od); |
| 706 }); |
| 707 }); |
| 708 |
| 709 |
| 710 unittest.group("obj-schema-CreateServiceAccountKeyRequest", () { |
| 711 unittest.test("to-json--from-json", () { |
| 712 var o = buildCreateServiceAccountKeyRequest(); |
| 713 var od = new api.CreateServiceAccountKeyRequest.fromJson(o.toJson()); |
| 714 checkCreateServiceAccountKeyRequest(od); |
| 715 }); |
| 716 }); |
| 717 |
| 718 |
| 719 unittest.group("obj-schema-CreateServiceAccountRequest", () { |
| 720 unittest.test("to-json--from-json", () { |
| 721 var o = buildCreateServiceAccountRequest(); |
| 722 var od = new api.CreateServiceAccountRequest.fromJson(o.toJson()); |
| 723 checkCreateServiceAccountRequest(od); |
| 724 }); |
| 725 }); |
| 726 |
| 727 |
| 728 unittest.group("obj-schema-DataAccessOptions", () { |
| 729 unittest.test("to-json--from-json", () { |
| 730 var o = buildDataAccessOptions(); |
| 731 var od = new api.DataAccessOptions.fromJson(o.toJson()); |
| 732 checkDataAccessOptions(od); |
| 733 }); |
| 734 }); |
| 735 |
| 736 |
| 737 unittest.group("obj-schema-Empty", () { |
| 738 unittest.test("to-json--from-json", () { |
| 739 var o = buildEmpty(); |
| 740 var od = new api.Empty.fromJson(o.toJson()); |
| 741 checkEmpty(od); |
| 742 }); |
| 743 }); |
| 744 |
| 745 |
| 746 unittest.group("obj-schema-ListServiceAccountKeysResponse", () { |
| 747 unittest.test("to-json--from-json", () { |
| 748 var o = buildListServiceAccountKeysResponse(); |
| 749 var od = new api.ListServiceAccountKeysResponse.fromJson(o.toJson()); |
| 750 checkListServiceAccountKeysResponse(od); |
| 751 }); |
| 752 }); |
| 753 |
| 754 |
| 755 unittest.group("obj-schema-ListServiceAccountsResponse", () { |
| 756 unittest.test("to-json--from-json", () { |
| 757 var o = buildListServiceAccountsResponse(); |
| 758 var od = new api.ListServiceAccountsResponse.fromJson(o.toJson()); |
| 759 checkListServiceAccountsResponse(od); |
| 760 }); |
| 761 }); |
| 762 |
| 763 |
| 764 unittest.group("obj-schema-LogConfig", () { |
| 765 unittest.test("to-json--from-json", () { |
| 766 var o = buildLogConfig(); |
| 767 var od = new api.LogConfig.fromJson(o.toJson()); |
| 768 checkLogConfig(od); |
| 769 }); |
| 770 }); |
| 771 |
| 772 |
| 773 unittest.group("obj-schema-Policy", () { |
| 774 unittest.test("to-json--from-json", () { |
| 775 var o = buildPolicy(); |
| 776 var od = new api.Policy.fromJson(o.toJson()); |
| 777 checkPolicy(od); |
| 778 }); |
| 779 }); |
| 780 |
| 781 |
| 782 unittest.group("obj-schema-Rule", () { |
| 783 unittest.test("to-json--from-json", () { |
| 784 var o = buildRule(); |
| 785 var od = new api.Rule.fromJson(o.toJson()); |
| 786 checkRule(od); |
| 787 }); |
| 788 }); |
| 789 |
| 790 |
| 791 unittest.group("obj-schema-ServiceAccount", () { |
| 792 unittest.test("to-json--from-json", () { |
| 793 var o = buildServiceAccount(); |
| 794 var od = new api.ServiceAccount.fromJson(o.toJson()); |
| 795 checkServiceAccount(od); |
| 796 }); |
| 797 }); |
| 798 |
| 799 |
| 800 unittest.group("obj-schema-ServiceAccountKey", () { |
| 801 unittest.test("to-json--from-json", () { |
| 802 var o = buildServiceAccountKey(); |
| 803 var od = new api.ServiceAccountKey.fromJson(o.toJson()); |
| 804 checkServiceAccountKey(od); |
| 805 }); |
| 806 }); |
| 807 |
| 808 |
| 809 unittest.group("obj-schema-SetIamPolicyRequest", () { |
| 810 unittest.test("to-json--from-json", () { |
| 811 var o = buildSetIamPolicyRequest(); |
| 812 var od = new api.SetIamPolicyRequest.fromJson(o.toJson()); |
| 813 checkSetIamPolicyRequest(od); |
| 814 }); |
| 815 }); |
| 816 |
| 817 |
| 818 unittest.group("obj-schema-SignBlobRequest", () { |
| 819 unittest.test("to-json--from-json", () { |
| 820 var o = buildSignBlobRequest(); |
| 821 var od = new api.SignBlobRequest.fromJson(o.toJson()); |
| 822 checkSignBlobRequest(od); |
| 823 }); |
| 824 }); |
| 825 |
| 826 |
| 827 unittest.group("obj-schema-SignBlobResponse", () { |
| 828 unittest.test("to-json--from-json", () { |
| 829 var o = buildSignBlobResponse(); |
| 830 var od = new api.SignBlobResponse.fromJson(o.toJson()); |
| 831 checkSignBlobResponse(od); |
| 832 }); |
| 833 }); |
| 834 |
| 835 |
| 836 unittest.group("obj-schema-TestIamPermissionsRequest", () { |
| 837 unittest.test("to-json--from-json", () { |
| 838 var o = buildTestIamPermissionsRequest(); |
| 839 var od = new api.TestIamPermissionsRequest.fromJson(o.toJson()); |
| 840 checkTestIamPermissionsRequest(od); |
| 841 }); |
| 842 }); |
| 843 |
| 844 |
| 845 unittest.group("obj-schema-TestIamPermissionsResponse", () { |
| 846 unittest.test("to-json--from-json", () { |
| 847 var o = buildTestIamPermissionsResponse(); |
| 848 var od = new api.TestIamPermissionsResponse.fromJson(o.toJson()); |
| 849 checkTestIamPermissionsResponse(od); |
| 850 }); |
| 851 }); |
| 852 |
| 853 |
| 854 unittest.group("resource-ProjectsServiceAccountsResourceApi", () { |
| 855 unittest.test("method--create", () { |
| 856 |
| 857 var mock = new HttpServerMock(); |
| 858 api.ProjectsServiceAccountsResourceApi res = new api.IamApi(mock).projects
.serviceAccounts; |
| 859 var arg_request = buildCreateServiceAccountRequest(); |
| 860 var arg_name = "foo"; |
| 861 mock.register(unittest.expectAsync((http.BaseRequest req, json) { |
| 862 var obj = new api.CreateServiceAccountRequest.fromJson(json); |
| 863 checkCreateServiceAccountRequest(obj); |
| 864 |
| 865 var path = (req.url).path; |
| 866 var pathOffset = 0; |
| 867 var index; |
| 868 var subPart; |
| 869 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ
als("/")); |
| 870 pathOffset += 1; |
| 871 unittest.expect(path.substring(pathOffset, pathOffset + 3), unittest.equ
als("v1/")); |
| 872 pathOffset += 3; |
| 873 // NOTE: We cannot test reserved expansions due to the inability to reve
rse the operation; |
| 874 |
| 875 var query = (req.url).query; |
| 876 var queryOffset = 0; |
| 877 var queryMap = {}; |
| 878 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); |
| 879 parseBool(n) { |
| 880 if (n == "true") return true; |
| 881 if (n == "false") return false; |
| 882 if (n == null) return null; |
| 883 throw new core.ArgumentError("Invalid boolean: $n"); |
| 884 } |
| 885 if (query.length > 0) { |
| 886 for (var part in query.split("&")) { |
| 887 var keyvalue = part.split("="); |
| 888 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); |
| 889 } |
| 890 } |
| 891 |
| 892 |
| 893 var h = { |
| 894 "content-type" : "application/json; charset=utf-8", |
| 895 }; |
| 896 var resp = convert.JSON.encode(buildServiceAccount()); |
| 897 return new async.Future.value(stringResponse(200, h, resp)); |
| 898 }), true); |
| 899 res.create(arg_request, arg_name).then(unittest.expectAsync(((api.ServiceA
ccount response) { |
| 900 checkServiceAccount(response); |
| 901 }))); |
| 902 }); |
| 903 |
| 904 unittest.test("method--delete", () { |
| 905 |
| 906 var mock = new HttpServerMock(); |
| 907 api.ProjectsServiceAccountsResourceApi res = new api.IamApi(mock).projects
.serviceAccounts; |
| 908 var arg_name = "foo"; |
| 909 mock.register(unittest.expectAsync((http.BaseRequest req, json) { |
| 910 var path = (req.url).path; |
| 911 var pathOffset = 0; |
| 912 var index; |
| 913 var subPart; |
| 914 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ
als("/")); |
| 915 pathOffset += 1; |
| 916 unittest.expect(path.substring(pathOffset, pathOffset + 3), unittest.equ
als("v1/")); |
| 917 pathOffset += 3; |
| 918 // NOTE: We cannot test reserved expansions due to the inability to reve
rse the operation; |
| 919 |
| 920 var query = (req.url).query; |
| 921 var queryOffset = 0; |
| 922 var queryMap = {}; |
| 923 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); |
| 924 parseBool(n) { |
| 925 if (n == "true") return true; |
| 926 if (n == "false") return false; |
| 927 if (n == null) return null; |
| 928 throw new core.ArgumentError("Invalid boolean: $n"); |
| 929 } |
| 930 if (query.length > 0) { |
| 931 for (var part in query.split("&")) { |
| 932 var keyvalue = part.split("="); |
| 933 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); |
| 934 } |
| 935 } |
| 936 |
| 937 |
| 938 var h = { |
| 939 "content-type" : "application/json; charset=utf-8", |
| 940 }; |
| 941 var resp = convert.JSON.encode(buildEmpty()); |
| 942 return new async.Future.value(stringResponse(200, h, resp)); |
| 943 }), true); |
| 944 res.delete(arg_name).then(unittest.expectAsync(((api.Empty response) { |
| 945 checkEmpty(response); |
| 946 }))); |
| 947 }); |
| 948 |
| 949 unittest.test("method--get", () { |
| 950 |
| 951 var mock = new HttpServerMock(); |
| 952 api.ProjectsServiceAccountsResourceApi res = new api.IamApi(mock).projects
.serviceAccounts; |
| 953 var arg_name = "foo"; |
| 954 mock.register(unittest.expectAsync((http.BaseRequest req, json) { |
| 955 var path = (req.url).path; |
| 956 var pathOffset = 0; |
| 957 var index; |
| 958 var subPart; |
| 959 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ
als("/")); |
| 960 pathOffset += 1; |
| 961 unittest.expect(path.substring(pathOffset, pathOffset + 3), unittest.equ
als("v1/")); |
| 962 pathOffset += 3; |
| 963 // NOTE: We cannot test reserved expansions due to the inability to reve
rse the operation; |
| 964 |
| 965 var query = (req.url).query; |
| 966 var queryOffset = 0; |
| 967 var queryMap = {}; |
| 968 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); |
| 969 parseBool(n) { |
| 970 if (n == "true") return true; |
| 971 if (n == "false") return false; |
| 972 if (n == null) return null; |
| 973 throw new core.ArgumentError("Invalid boolean: $n"); |
| 974 } |
| 975 if (query.length > 0) { |
| 976 for (var part in query.split("&")) { |
| 977 var keyvalue = part.split("="); |
| 978 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); |
| 979 } |
| 980 } |
| 981 |
| 982 |
| 983 var h = { |
| 984 "content-type" : "application/json; charset=utf-8", |
| 985 }; |
| 986 var resp = convert.JSON.encode(buildServiceAccount()); |
| 987 return new async.Future.value(stringResponse(200, h, resp)); |
| 988 }), true); |
| 989 res.get(arg_name).then(unittest.expectAsync(((api.ServiceAccount response)
{ |
| 990 checkServiceAccount(response); |
| 991 }))); |
| 992 }); |
| 993 |
| 994 unittest.test("method--getIamPolicy", () { |
| 995 |
| 996 var mock = new HttpServerMock(); |
| 997 api.ProjectsServiceAccountsResourceApi res = new api.IamApi(mock).projects
.serviceAccounts; |
| 998 var arg_resource = "foo"; |
| 999 mock.register(unittest.expectAsync((http.BaseRequest req, json) { |
| 1000 var path = (req.url).path; |
| 1001 var pathOffset = 0; |
| 1002 var index; |
| 1003 var subPart; |
| 1004 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ
als("/")); |
| 1005 pathOffset += 1; |
| 1006 unittest.expect(path.substring(pathOffset, pathOffset + 3), unittest.equ
als("v1/")); |
| 1007 pathOffset += 3; |
| 1008 // NOTE: We cannot test reserved expansions due to the inability to reve
rse the operation; |
| 1009 |
| 1010 var query = (req.url).query; |
| 1011 var queryOffset = 0; |
| 1012 var queryMap = {}; |
| 1013 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); |
| 1014 parseBool(n) { |
| 1015 if (n == "true") return true; |
| 1016 if (n == "false") return false; |
| 1017 if (n == null) return null; |
| 1018 throw new core.ArgumentError("Invalid boolean: $n"); |
| 1019 } |
| 1020 if (query.length > 0) { |
| 1021 for (var part in query.split("&")) { |
| 1022 var keyvalue = part.split("="); |
| 1023 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); |
| 1024 } |
| 1025 } |
| 1026 |
| 1027 |
| 1028 var h = { |
| 1029 "content-type" : "application/json; charset=utf-8", |
| 1030 }; |
| 1031 var resp = convert.JSON.encode(buildPolicy()); |
| 1032 return new async.Future.value(stringResponse(200, h, resp)); |
| 1033 }), true); |
| 1034 res.getIamPolicy(arg_resource).then(unittest.expectAsync(((api.Policy resp
onse) { |
| 1035 checkPolicy(response); |
| 1036 }))); |
| 1037 }); |
| 1038 |
| 1039 unittest.test("method--list", () { |
| 1040 |
| 1041 var mock = new HttpServerMock(); |
| 1042 api.ProjectsServiceAccountsResourceApi res = new api.IamApi(mock).projects
.serviceAccounts; |
| 1043 var arg_name = "foo"; |
| 1044 var arg_pageSize = 42; |
| 1045 var arg_pageToken = "foo"; |
| 1046 mock.register(unittest.expectAsync((http.BaseRequest req, json) { |
| 1047 var path = (req.url).path; |
| 1048 var pathOffset = 0; |
| 1049 var index; |
| 1050 var subPart; |
| 1051 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ
als("/")); |
| 1052 pathOffset += 1; |
| 1053 unittest.expect(path.substring(pathOffset, pathOffset + 3), unittest.equ
als("v1/")); |
| 1054 pathOffset += 3; |
| 1055 // NOTE: We cannot test reserved expansions due to the inability to reve
rse the operation; |
| 1056 |
| 1057 var query = (req.url).query; |
| 1058 var queryOffset = 0; |
| 1059 var queryMap = {}; |
| 1060 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); |
| 1061 parseBool(n) { |
| 1062 if (n == "true") return true; |
| 1063 if (n == "false") return false; |
| 1064 if (n == null) return null; |
| 1065 throw new core.ArgumentError("Invalid boolean: $n"); |
| 1066 } |
| 1067 if (query.length > 0) { |
| 1068 for (var part in query.split("&")) { |
| 1069 var keyvalue = part.split("="); |
| 1070 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); |
| 1071 } |
| 1072 } |
| 1073 unittest.expect(core.int.parse(queryMap["pageSize"].first), unittest.equ
als(arg_pageSize)); |
| 1074 unittest.expect(queryMap["pageToken"].first, unittest.equals(arg_pageTok
en)); |
| 1075 |
| 1076 |
| 1077 var h = { |
| 1078 "content-type" : "application/json; charset=utf-8", |
| 1079 }; |
| 1080 var resp = convert.JSON.encode(buildListServiceAccountsResponse()); |
| 1081 return new async.Future.value(stringResponse(200, h, resp)); |
| 1082 }), true); |
| 1083 res.list(arg_name, pageSize: arg_pageSize, pageToken: arg_pageToken).then(
unittest.expectAsync(((api.ListServiceAccountsResponse response) { |
| 1084 checkListServiceAccountsResponse(response); |
| 1085 }))); |
| 1086 }); |
| 1087 |
| 1088 unittest.test("method--setIamPolicy", () { |
| 1089 |
| 1090 var mock = new HttpServerMock(); |
| 1091 api.ProjectsServiceAccountsResourceApi res = new api.IamApi(mock).projects
.serviceAccounts; |
| 1092 var arg_request = buildSetIamPolicyRequest(); |
| 1093 var arg_resource = "foo"; |
| 1094 mock.register(unittest.expectAsync((http.BaseRequest req, json) { |
| 1095 var obj = new api.SetIamPolicyRequest.fromJson(json); |
| 1096 checkSetIamPolicyRequest(obj); |
| 1097 |
| 1098 var path = (req.url).path; |
| 1099 var pathOffset = 0; |
| 1100 var index; |
| 1101 var subPart; |
| 1102 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ
als("/")); |
| 1103 pathOffset += 1; |
| 1104 unittest.expect(path.substring(pathOffset, pathOffset + 3), unittest.equ
als("v1/")); |
| 1105 pathOffset += 3; |
| 1106 // NOTE: We cannot test reserved expansions due to the inability to reve
rse the operation; |
| 1107 |
| 1108 var query = (req.url).query; |
| 1109 var queryOffset = 0; |
| 1110 var queryMap = {}; |
| 1111 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); |
| 1112 parseBool(n) { |
| 1113 if (n == "true") return true; |
| 1114 if (n == "false") return false; |
| 1115 if (n == null) return null; |
| 1116 throw new core.ArgumentError("Invalid boolean: $n"); |
| 1117 } |
| 1118 if (query.length > 0) { |
| 1119 for (var part in query.split("&")) { |
| 1120 var keyvalue = part.split("="); |
| 1121 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); |
| 1122 } |
| 1123 } |
| 1124 |
| 1125 |
| 1126 var h = { |
| 1127 "content-type" : "application/json; charset=utf-8", |
| 1128 }; |
| 1129 var resp = convert.JSON.encode(buildPolicy()); |
| 1130 return new async.Future.value(stringResponse(200, h, resp)); |
| 1131 }), true); |
| 1132 res.setIamPolicy(arg_request, arg_resource).then(unittest.expectAsync(((ap
i.Policy response) { |
| 1133 checkPolicy(response); |
| 1134 }))); |
| 1135 }); |
| 1136 |
| 1137 unittest.test("method--signBlob", () { |
| 1138 |
| 1139 var mock = new HttpServerMock(); |
| 1140 api.ProjectsServiceAccountsResourceApi res = new api.IamApi(mock).projects
.serviceAccounts; |
| 1141 var arg_request = buildSignBlobRequest(); |
| 1142 var arg_name = "foo"; |
| 1143 mock.register(unittest.expectAsync((http.BaseRequest req, json) { |
| 1144 var obj = new api.SignBlobRequest.fromJson(json); |
| 1145 checkSignBlobRequest(obj); |
| 1146 |
| 1147 var path = (req.url).path; |
| 1148 var pathOffset = 0; |
| 1149 var index; |
| 1150 var subPart; |
| 1151 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ
als("/")); |
| 1152 pathOffset += 1; |
| 1153 unittest.expect(path.substring(pathOffset, pathOffset + 3), unittest.equ
als("v1/")); |
| 1154 pathOffset += 3; |
| 1155 // NOTE: We cannot test reserved expansions due to the inability to reve
rse the operation; |
| 1156 |
| 1157 var query = (req.url).query; |
| 1158 var queryOffset = 0; |
| 1159 var queryMap = {}; |
| 1160 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); |
| 1161 parseBool(n) { |
| 1162 if (n == "true") return true; |
| 1163 if (n == "false") return false; |
| 1164 if (n == null) return null; |
| 1165 throw new core.ArgumentError("Invalid boolean: $n"); |
| 1166 } |
| 1167 if (query.length > 0) { |
| 1168 for (var part in query.split("&")) { |
| 1169 var keyvalue = part.split("="); |
| 1170 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); |
| 1171 } |
| 1172 } |
| 1173 |
| 1174 |
| 1175 var h = { |
| 1176 "content-type" : "application/json; charset=utf-8", |
| 1177 }; |
| 1178 var resp = convert.JSON.encode(buildSignBlobResponse()); |
| 1179 return new async.Future.value(stringResponse(200, h, resp)); |
| 1180 }), true); |
| 1181 res.signBlob(arg_request, arg_name).then(unittest.expectAsync(((api.SignBl
obResponse response) { |
| 1182 checkSignBlobResponse(response); |
| 1183 }))); |
| 1184 }); |
| 1185 |
| 1186 unittest.test("method--testIamPermissions", () { |
| 1187 |
| 1188 var mock = new HttpServerMock(); |
| 1189 api.ProjectsServiceAccountsResourceApi res = new api.IamApi(mock).projects
.serviceAccounts; |
| 1190 var arg_request = buildTestIamPermissionsRequest(); |
| 1191 var arg_resource = "foo"; |
| 1192 mock.register(unittest.expectAsync((http.BaseRequest req, json) { |
| 1193 var obj = new api.TestIamPermissionsRequest.fromJson(json); |
| 1194 checkTestIamPermissionsRequest(obj); |
| 1195 |
| 1196 var path = (req.url).path; |
| 1197 var pathOffset = 0; |
| 1198 var index; |
| 1199 var subPart; |
| 1200 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ
als("/")); |
| 1201 pathOffset += 1; |
| 1202 unittest.expect(path.substring(pathOffset, pathOffset + 3), unittest.equ
als("v1/")); |
| 1203 pathOffset += 3; |
| 1204 // NOTE: We cannot test reserved expansions due to the inability to reve
rse the operation; |
| 1205 |
| 1206 var query = (req.url).query; |
| 1207 var queryOffset = 0; |
| 1208 var queryMap = {}; |
| 1209 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); |
| 1210 parseBool(n) { |
| 1211 if (n == "true") return true; |
| 1212 if (n == "false") return false; |
| 1213 if (n == null) return null; |
| 1214 throw new core.ArgumentError("Invalid boolean: $n"); |
| 1215 } |
| 1216 if (query.length > 0) { |
| 1217 for (var part in query.split("&")) { |
| 1218 var keyvalue = part.split("="); |
| 1219 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); |
| 1220 } |
| 1221 } |
| 1222 |
| 1223 |
| 1224 var h = { |
| 1225 "content-type" : "application/json; charset=utf-8", |
| 1226 }; |
| 1227 var resp = convert.JSON.encode(buildTestIamPermissionsResponse()); |
| 1228 return new async.Future.value(stringResponse(200, h, resp)); |
| 1229 }), true); |
| 1230 res.testIamPermissions(arg_request, arg_resource).then(unittest.expectAsyn
c(((api.TestIamPermissionsResponse response) { |
| 1231 checkTestIamPermissionsResponse(response); |
| 1232 }))); |
| 1233 }); |
| 1234 |
| 1235 unittest.test("method--update", () { |
| 1236 |
| 1237 var mock = new HttpServerMock(); |
| 1238 api.ProjectsServiceAccountsResourceApi res = new api.IamApi(mock).projects
.serviceAccounts; |
| 1239 var arg_request = buildServiceAccount(); |
| 1240 var arg_name = "foo"; |
| 1241 mock.register(unittest.expectAsync((http.BaseRequest req, json) { |
| 1242 var obj = new api.ServiceAccount.fromJson(json); |
| 1243 checkServiceAccount(obj); |
| 1244 |
| 1245 var path = (req.url).path; |
| 1246 var pathOffset = 0; |
| 1247 var index; |
| 1248 var subPart; |
| 1249 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ
als("/")); |
| 1250 pathOffset += 1; |
| 1251 unittest.expect(path.substring(pathOffset, pathOffset + 3), unittest.equ
als("v1/")); |
| 1252 pathOffset += 3; |
| 1253 // NOTE: We cannot test reserved expansions due to the inability to reve
rse the operation; |
| 1254 |
| 1255 var query = (req.url).query; |
| 1256 var queryOffset = 0; |
| 1257 var queryMap = {}; |
| 1258 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); |
| 1259 parseBool(n) { |
| 1260 if (n == "true") return true; |
| 1261 if (n == "false") return false; |
| 1262 if (n == null) return null; |
| 1263 throw new core.ArgumentError("Invalid boolean: $n"); |
| 1264 } |
| 1265 if (query.length > 0) { |
| 1266 for (var part in query.split("&")) { |
| 1267 var keyvalue = part.split("="); |
| 1268 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); |
| 1269 } |
| 1270 } |
| 1271 |
| 1272 |
| 1273 var h = { |
| 1274 "content-type" : "application/json; charset=utf-8", |
| 1275 }; |
| 1276 var resp = convert.JSON.encode(buildServiceAccount()); |
| 1277 return new async.Future.value(stringResponse(200, h, resp)); |
| 1278 }), true); |
| 1279 res.update(arg_request, arg_name).then(unittest.expectAsync(((api.ServiceA
ccount response) { |
| 1280 checkServiceAccount(response); |
| 1281 }))); |
| 1282 }); |
| 1283 |
| 1284 }); |
| 1285 |
| 1286 |
| 1287 unittest.group("resource-ProjectsServiceAccountsKeysResourceApi", () { |
| 1288 unittest.test("method--create", () { |
| 1289 |
| 1290 var mock = new HttpServerMock(); |
| 1291 api.ProjectsServiceAccountsKeysResourceApi res = new api.IamApi(mock).proj
ects.serviceAccounts.keys; |
| 1292 var arg_request = buildCreateServiceAccountKeyRequest(); |
| 1293 var arg_name = "foo"; |
| 1294 mock.register(unittest.expectAsync((http.BaseRequest req, json) { |
| 1295 var obj = new api.CreateServiceAccountKeyRequest.fromJson(json); |
| 1296 checkCreateServiceAccountKeyRequest(obj); |
| 1297 |
| 1298 var path = (req.url).path; |
| 1299 var pathOffset = 0; |
| 1300 var index; |
| 1301 var subPart; |
| 1302 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ
als("/")); |
| 1303 pathOffset += 1; |
| 1304 unittest.expect(path.substring(pathOffset, pathOffset + 3), unittest.equ
als("v1/")); |
| 1305 pathOffset += 3; |
| 1306 // NOTE: We cannot test reserved expansions due to the inability to reve
rse the operation; |
| 1307 |
| 1308 var query = (req.url).query; |
| 1309 var queryOffset = 0; |
| 1310 var queryMap = {}; |
| 1311 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); |
| 1312 parseBool(n) { |
| 1313 if (n == "true") return true; |
| 1314 if (n == "false") return false; |
| 1315 if (n == null) return null; |
| 1316 throw new core.ArgumentError("Invalid boolean: $n"); |
| 1317 } |
| 1318 if (query.length > 0) { |
| 1319 for (var part in query.split("&")) { |
| 1320 var keyvalue = part.split("="); |
| 1321 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); |
| 1322 } |
| 1323 } |
| 1324 |
| 1325 |
| 1326 var h = { |
| 1327 "content-type" : "application/json; charset=utf-8", |
| 1328 }; |
| 1329 var resp = convert.JSON.encode(buildServiceAccountKey()); |
| 1330 return new async.Future.value(stringResponse(200, h, resp)); |
| 1331 }), true); |
| 1332 res.create(arg_request, arg_name).then(unittest.expectAsync(((api.ServiceA
ccountKey response) { |
| 1333 checkServiceAccountKey(response); |
| 1334 }))); |
| 1335 }); |
| 1336 |
| 1337 unittest.test("method--delete", () { |
| 1338 |
| 1339 var mock = new HttpServerMock(); |
| 1340 api.ProjectsServiceAccountsKeysResourceApi res = new api.IamApi(mock).proj
ects.serviceAccounts.keys; |
| 1341 var arg_name = "foo"; |
| 1342 mock.register(unittest.expectAsync((http.BaseRequest req, json) { |
| 1343 var path = (req.url).path; |
| 1344 var pathOffset = 0; |
| 1345 var index; |
| 1346 var subPart; |
| 1347 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ
als("/")); |
| 1348 pathOffset += 1; |
| 1349 unittest.expect(path.substring(pathOffset, pathOffset + 3), unittest.equ
als("v1/")); |
| 1350 pathOffset += 3; |
| 1351 // NOTE: We cannot test reserved expansions due to the inability to reve
rse the operation; |
| 1352 |
| 1353 var query = (req.url).query; |
| 1354 var queryOffset = 0; |
| 1355 var queryMap = {}; |
| 1356 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); |
| 1357 parseBool(n) { |
| 1358 if (n == "true") return true; |
| 1359 if (n == "false") return false; |
| 1360 if (n == null) return null; |
| 1361 throw new core.ArgumentError("Invalid boolean: $n"); |
| 1362 } |
| 1363 if (query.length > 0) { |
| 1364 for (var part in query.split("&")) { |
| 1365 var keyvalue = part.split("="); |
| 1366 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); |
| 1367 } |
| 1368 } |
| 1369 |
| 1370 |
| 1371 var h = { |
| 1372 "content-type" : "application/json; charset=utf-8", |
| 1373 }; |
| 1374 var resp = convert.JSON.encode(buildEmpty()); |
| 1375 return new async.Future.value(stringResponse(200, h, resp)); |
| 1376 }), true); |
| 1377 res.delete(arg_name).then(unittest.expectAsync(((api.Empty response) { |
| 1378 checkEmpty(response); |
| 1379 }))); |
| 1380 }); |
| 1381 |
| 1382 unittest.test("method--get", () { |
| 1383 |
| 1384 var mock = new HttpServerMock(); |
| 1385 api.ProjectsServiceAccountsKeysResourceApi res = new api.IamApi(mock).proj
ects.serviceAccounts.keys; |
| 1386 var arg_name = "foo"; |
| 1387 mock.register(unittest.expectAsync((http.BaseRequest req, json) { |
| 1388 var path = (req.url).path; |
| 1389 var pathOffset = 0; |
| 1390 var index; |
| 1391 var subPart; |
| 1392 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ
als("/")); |
| 1393 pathOffset += 1; |
| 1394 unittest.expect(path.substring(pathOffset, pathOffset + 3), unittest.equ
als("v1/")); |
| 1395 pathOffset += 3; |
| 1396 // NOTE: We cannot test reserved expansions due to the inability to reve
rse the operation; |
| 1397 |
| 1398 var query = (req.url).query; |
| 1399 var queryOffset = 0; |
| 1400 var queryMap = {}; |
| 1401 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); |
| 1402 parseBool(n) { |
| 1403 if (n == "true") return true; |
| 1404 if (n == "false") return false; |
| 1405 if (n == null) return null; |
| 1406 throw new core.ArgumentError("Invalid boolean: $n"); |
| 1407 } |
| 1408 if (query.length > 0) { |
| 1409 for (var part in query.split("&")) { |
| 1410 var keyvalue = part.split("="); |
| 1411 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); |
| 1412 } |
| 1413 } |
| 1414 |
| 1415 |
| 1416 var h = { |
| 1417 "content-type" : "application/json; charset=utf-8", |
| 1418 }; |
| 1419 var resp = convert.JSON.encode(buildServiceAccountKey()); |
| 1420 return new async.Future.value(stringResponse(200, h, resp)); |
| 1421 }), true); |
| 1422 res.get(arg_name).then(unittest.expectAsync(((api.ServiceAccountKey respon
se) { |
| 1423 checkServiceAccountKey(response); |
| 1424 }))); |
| 1425 }); |
| 1426 |
| 1427 unittest.test("method--list", () { |
| 1428 |
| 1429 var mock = new HttpServerMock(); |
| 1430 api.ProjectsServiceAccountsKeysResourceApi res = new api.IamApi(mock).proj
ects.serviceAccounts.keys; |
| 1431 var arg_name = "foo"; |
| 1432 var arg_keyTypes = buildUnnamed1617(); |
| 1433 mock.register(unittest.expectAsync((http.BaseRequest req, json) { |
| 1434 var path = (req.url).path; |
| 1435 var pathOffset = 0; |
| 1436 var index; |
| 1437 var subPart; |
| 1438 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ
als("/")); |
| 1439 pathOffset += 1; |
| 1440 unittest.expect(path.substring(pathOffset, pathOffset + 3), unittest.equ
als("v1/")); |
| 1441 pathOffset += 3; |
| 1442 // NOTE: We cannot test reserved expansions due to the inability to reve
rse the operation; |
| 1443 |
| 1444 var query = (req.url).query; |
| 1445 var queryOffset = 0; |
| 1446 var queryMap = {}; |
| 1447 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); |
| 1448 parseBool(n) { |
| 1449 if (n == "true") return true; |
| 1450 if (n == "false") return false; |
| 1451 if (n == null) return null; |
| 1452 throw new core.ArgumentError("Invalid boolean: $n"); |
| 1453 } |
| 1454 if (query.length > 0) { |
| 1455 for (var part in query.split("&")) { |
| 1456 var keyvalue = part.split("="); |
| 1457 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); |
| 1458 } |
| 1459 } |
| 1460 unittest.expect(queryMap["keyTypes"], unittest.equals(arg_keyTypes)); |
| 1461 |
| 1462 |
| 1463 var h = { |
| 1464 "content-type" : "application/json; charset=utf-8", |
| 1465 }; |
| 1466 var resp = convert.JSON.encode(buildListServiceAccountKeysResponse()); |
| 1467 return new async.Future.value(stringResponse(200, h, resp)); |
| 1468 }), true); |
| 1469 res.list(arg_name, keyTypes: arg_keyTypes).then(unittest.expectAsync(((api
.ListServiceAccountKeysResponse response) { |
| 1470 checkListServiceAccountKeysResponse(response); |
| 1471 }))); |
| 1472 }); |
| 1473 |
| 1474 }); |
| 1475 |
| 1476 |
| 1477 } |
| 1478 |
| OLD | NEW |