| library googleapis.iam.v1.test; |
| |
| import "dart:core" as core; |
| import "dart:async" as async; |
| import "dart:convert" as convert; |
| |
| import 'package:http/http.dart' as http; |
| import 'package:test/test.dart' as unittest; |
| |
| import 'package:googleapis/iam/v1.dart' as api; |
| |
| class HttpServerMock extends http.BaseClient { |
| core.Function _callback; |
| core.bool _expectJson; |
| |
| void register(core.Function callback, core.bool expectJson) { |
| _callback = callback; |
| _expectJson = expectJson; |
| } |
| |
| async.Future<http.StreamedResponse> send(http.BaseRequest request) { |
| if (_expectJson) { |
| return request |
| .finalize() |
| .transform(convert.UTF8.decoder) |
| .join('') |
| .then((core.String jsonString) { |
| if (jsonString.isEmpty) { |
| return _callback(request, null); |
| } else { |
| return _callback(request, convert.JSON.decode(jsonString)); |
| } |
| }); |
| } else { |
| var stream = request.finalize(); |
| if (stream == null) { |
| return _callback(request, []); |
| } else { |
| return stream.toBytes().then((data) { |
| return _callback(request, data); |
| }); |
| } |
| } |
| } |
| } |
| |
| http.StreamedResponse stringResponse(core.int status, |
| core.Map<core.String, core.String> headers, core.String body) { |
| var stream = new async.Stream.fromIterable([convert.UTF8.encode(body)]); |
| return new http.StreamedResponse(stream, status, headers: headers); |
| } |
| |
| core.int buildCounterAuditData = 0; |
| buildAuditData() { |
| var o = new api.AuditData(); |
| buildCounterAuditData++; |
| if (buildCounterAuditData < 3) { |
| o.policyDelta = buildPolicyDelta(); |
| } |
| buildCounterAuditData--; |
| return o; |
| } |
| |
| checkAuditData(api.AuditData o) { |
| buildCounterAuditData++; |
| if (buildCounterAuditData < 3) { |
| checkPolicyDelta(o.policyDelta); |
| } |
| buildCounterAuditData--; |
| } |
| |
| buildUnnamed1291() { |
| var o = new core.List<core.String>(); |
| o.add("foo"); |
| o.add("foo"); |
| return o; |
| } |
| |
| checkUnnamed1291(core.List<core.String> o) { |
| unittest.expect(o, unittest.hasLength(2)); |
| unittest.expect(o[0], unittest.equals('foo')); |
| unittest.expect(o[1], unittest.equals('foo')); |
| } |
| |
| core.int buildCounterBinding = 0; |
| buildBinding() { |
| var o = new api.Binding(); |
| buildCounterBinding++; |
| if (buildCounterBinding < 3) { |
| o.members = buildUnnamed1291(); |
| o.role = "foo"; |
| } |
| buildCounterBinding--; |
| return o; |
| } |
| |
| checkBinding(api.Binding o) { |
| buildCounterBinding++; |
| if (buildCounterBinding < 3) { |
| checkUnnamed1291(o.members); |
| unittest.expect(o.role, unittest.equals('foo')); |
| } |
| buildCounterBinding--; |
| } |
| |
| core.int buildCounterBindingDelta = 0; |
| buildBindingDelta() { |
| var o = new api.BindingDelta(); |
| buildCounterBindingDelta++; |
| if (buildCounterBindingDelta < 3) { |
| o.action = "foo"; |
| o.member = "foo"; |
| o.role = "foo"; |
| } |
| buildCounterBindingDelta--; |
| return o; |
| } |
| |
| checkBindingDelta(api.BindingDelta o) { |
| buildCounterBindingDelta++; |
| if (buildCounterBindingDelta < 3) { |
| unittest.expect(o.action, unittest.equals('foo')); |
| unittest.expect(o.member, unittest.equals('foo')); |
| unittest.expect(o.role, unittest.equals('foo')); |
| } |
| buildCounterBindingDelta--; |
| } |
| |
| core.int buildCounterCreateRoleRequest = 0; |
| buildCreateRoleRequest() { |
| var o = new api.CreateRoleRequest(); |
| buildCounterCreateRoleRequest++; |
| if (buildCounterCreateRoleRequest < 3) { |
| o.role = buildRole(); |
| o.roleId = "foo"; |
| } |
| buildCounterCreateRoleRequest--; |
| return o; |
| } |
| |
| checkCreateRoleRequest(api.CreateRoleRequest o) { |
| buildCounterCreateRoleRequest++; |
| if (buildCounterCreateRoleRequest < 3) { |
| checkRole(o.role); |
| unittest.expect(o.roleId, unittest.equals('foo')); |
| } |
| buildCounterCreateRoleRequest--; |
| } |
| |
| core.int buildCounterCreateServiceAccountKeyRequest = 0; |
| buildCreateServiceAccountKeyRequest() { |
| var o = new api.CreateServiceAccountKeyRequest(); |
| buildCounterCreateServiceAccountKeyRequest++; |
| if (buildCounterCreateServiceAccountKeyRequest < 3) { |
| o.keyAlgorithm = "foo"; |
| o.privateKeyType = "foo"; |
| } |
| buildCounterCreateServiceAccountKeyRequest--; |
| return o; |
| } |
| |
| checkCreateServiceAccountKeyRequest(api.CreateServiceAccountKeyRequest o) { |
| buildCounterCreateServiceAccountKeyRequest++; |
| if (buildCounterCreateServiceAccountKeyRequest < 3) { |
| unittest.expect(o.keyAlgorithm, unittest.equals('foo')); |
| unittest.expect(o.privateKeyType, unittest.equals('foo')); |
| } |
| buildCounterCreateServiceAccountKeyRequest--; |
| } |
| |
| core.int buildCounterCreateServiceAccountRequest = 0; |
| buildCreateServiceAccountRequest() { |
| var o = new api.CreateServiceAccountRequest(); |
| buildCounterCreateServiceAccountRequest++; |
| if (buildCounterCreateServiceAccountRequest < 3) { |
| o.accountId = "foo"; |
| o.serviceAccount = buildServiceAccount(); |
| } |
| buildCounterCreateServiceAccountRequest--; |
| return o; |
| } |
| |
| checkCreateServiceAccountRequest(api.CreateServiceAccountRequest o) { |
| buildCounterCreateServiceAccountRequest++; |
| if (buildCounterCreateServiceAccountRequest < 3) { |
| unittest.expect(o.accountId, unittest.equals('foo')); |
| checkServiceAccount(o.serviceAccount); |
| } |
| buildCounterCreateServiceAccountRequest--; |
| } |
| |
| core.int buildCounterEmpty = 0; |
| buildEmpty() { |
| var o = new api.Empty(); |
| buildCounterEmpty++; |
| if (buildCounterEmpty < 3) {} |
| buildCounterEmpty--; |
| return o; |
| } |
| |
| checkEmpty(api.Empty o) { |
| buildCounterEmpty++; |
| if (buildCounterEmpty < 3) {} |
| buildCounterEmpty--; |
| } |
| |
| buildUnnamed1292() { |
| var o = new core.List<api.Role>(); |
| o.add(buildRole()); |
| o.add(buildRole()); |
| return o; |
| } |
| |
| checkUnnamed1292(core.List<api.Role> o) { |
| unittest.expect(o, unittest.hasLength(2)); |
| checkRole(o[0]); |
| checkRole(o[1]); |
| } |
| |
| core.int buildCounterListRolesResponse = 0; |
| buildListRolesResponse() { |
| var o = new api.ListRolesResponse(); |
| buildCounterListRolesResponse++; |
| if (buildCounterListRolesResponse < 3) { |
| o.nextPageToken = "foo"; |
| o.roles = buildUnnamed1292(); |
| } |
| buildCounterListRolesResponse--; |
| return o; |
| } |
| |
| checkListRolesResponse(api.ListRolesResponse o) { |
| buildCounterListRolesResponse++; |
| if (buildCounterListRolesResponse < 3) { |
| unittest.expect(o.nextPageToken, unittest.equals('foo')); |
| checkUnnamed1292(o.roles); |
| } |
| buildCounterListRolesResponse--; |
| } |
| |
| buildUnnamed1293() { |
| var o = new core.List<api.ServiceAccountKey>(); |
| o.add(buildServiceAccountKey()); |
| o.add(buildServiceAccountKey()); |
| return o; |
| } |
| |
| checkUnnamed1293(core.List<api.ServiceAccountKey> o) { |
| unittest.expect(o, unittest.hasLength(2)); |
| checkServiceAccountKey(o[0]); |
| checkServiceAccountKey(o[1]); |
| } |
| |
| core.int buildCounterListServiceAccountKeysResponse = 0; |
| buildListServiceAccountKeysResponse() { |
| var o = new api.ListServiceAccountKeysResponse(); |
| buildCounterListServiceAccountKeysResponse++; |
| if (buildCounterListServiceAccountKeysResponse < 3) { |
| o.keys = buildUnnamed1293(); |
| } |
| buildCounterListServiceAccountKeysResponse--; |
| return o; |
| } |
| |
| checkListServiceAccountKeysResponse(api.ListServiceAccountKeysResponse o) { |
| buildCounterListServiceAccountKeysResponse++; |
| if (buildCounterListServiceAccountKeysResponse < 3) { |
| checkUnnamed1293(o.keys); |
| } |
| buildCounterListServiceAccountKeysResponse--; |
| } |
| |
| buildUnnamed1294() { |
| var o = new core.List<api.ServiceAccount>(); |
| o.add(buildServiceAccount()); |
| o.add(buildServiceAccount()); |
| return o; |
| } |
| |
| checkUnnamed1294(core.List<api.ServiceAccount> o) { |
| unittest.expect(o, unittest.hasLength(2)); |
| checkServiceAccount(o[0]); |
| checkServiceAccount(o[1]); |
| } |
| |
| core.int buildCounterListServiceAccountsResponse = 0; |
| buildListServiceAccountsResponse() { |
| var o = new api.ListServiceAccountsResponse(); |
| buildCounterListServiceAccountsResponse++; |
| if (buildCounterListServiceAccountsResponse < 3) { |
| o.accounts = buildUnnamed1294(); |
| o.nextPageToken = "foo"; |
| } |
| buildCounterListServiceAccountsResponse--; |
| return o; |
| } |
| |
| checkListServiceAccountsResponse(api.ListServiceAccountsResponse o) { |
| buildCounterListServiceAccountsResponse++; |
| if (buildCounterListServiceAccountsResponse < 3) { |
| checkUnnamed1294(o.accounts); |
| unittest.expect(o.nextPageToken, unittest.equals('foo')); |
| } |
| buildCounterListServiceAccountsResponse--; |
| } |
| |
| core.int buildCounterPermission = 0; |
| buildPermission() { |
| var o = new api.Permission(); |
| buildCounterPermission++; |
| if (buildCounterPermission < 3) { |
| o.customRolesSupportLevel = "foo"; |
| o.description = "foo"; |
| o.name = "foo"; |
| o.onlyInPredefinedRoles = true; |
| o.stage = "foo"; |
| o.title = "foo"; |
| } |
| buildCounterPermission--; |
| return o; |
| } |
| |
| checkPermission(api.Permission o) { |
| buildCounterPermission++; |
| if (buildCounterPermission < 3) { |
| unittest.expect(o.customRolesSupportLevel, unittest.equals('foo')); |
| unittest.expect(o.description, unittest.equals('foo')); |
| unittest.expect(o.name, unittest.equals('foo')); |
| unittest.expect(o.onlyInPredefinedRoles, unittest.isTrue); |
| unittest.expect(o.stage, unittest.equals('foo')); |
| unittest.expect(o.title, unittest.equals('foo')); |
| } |
| buildCounterPermission--; |
| } |
| |
| buildUnnamed1295() { |
| var o = new core.List<api.Binding>(); |
| o.add(buildBinding()); |
| o.add(buildBinding()); |
| return o; |
| } |
| |
| checkUnnamed1295(core.List<api.Binding> o) { |
| unittest.expect(o, unittest.hasLength(2)); |
| checkBinding(o[0]); |
| checkBinding(o[1]); |
| } |
| |
| core.int buildCounterPolicy = 0; |
| buildPolicy() { |
| var o = new api.Policy(); |
| buildCounterPolicy++; |
| if (buildCounterPolicy < 3) { |
| o.bindings = buildUnnamed1295(); |
| o.etag = "foo"; |
| o.version = 42; |
| } |
| buildCounterPolicy--; |
| return o; |
| } |
| |
| checkPolicy(api.Policy o) { |
| buildCounterPolicy++; |
| if (buildCounterPolicy < 3) { |
| checkUnnamed1295(o.bindings); |
| unittest.expect(o.etag, unittest.equals('foo')); |
| unittest.expect(o.version, unittest.equals(42)); |
| } |
| buildCounterPolicy--; |
| } |
| |
| buildUnnamed1296() { |
| var o = new core.List<api.BindingDelta>(); |
| o.add(buildBindingDelta()); |
| o.add(buildBindingDelta()); |
| return o; |
| } |
| |
| checkUnnamed1296(core.List<api.BindingDelta> o) { |
| unittest.expect(o, unittest.hasLength(2)); |
| checkBindingDelta(o[0]); |
| checkBindingDelta(o[1]); |
| } |
| |
| core.int buildCounterPolicyDelta = 0; |
| buildPolicyDelta() { |
| var o = new api.PolicyDelta(); |
| buildCounterPolicyDelta++; |
| if (buildCounterPolicyDelta < 3) { |
| o.bindingDeltas = buildUnnamed1296(); |
| } |
| buildCounterPolicyDelta--; |
| return o; |
| } |
| |
| checkPolicyDelta(api.PolicyDelta o) { |
| buildCounterPolicyDelta++; |
| if (buildCounterPolicyDelta < 3) { |
| checkUnnamed1296(o.bindingDeltas); |
| } |
| buildCounterPolicyDelta--; |
| } |
| |
| core.int buildCounterQueryGrantableRolesRequest = 0; |
| buildQueryGrantableRolesRequest() { |
| var o = new api.QueryGrantableRolesRequest(); |
| buildCounterQueryGrantableRolesRequest++; |
| if (buildCounterQueryGrantableRolesRequest < 3) { |
| o.fullResourceName = "foo"; |
| o.pageSize = 42; |
| o.pageToken = "foo"; |
| o.view = "foo"; |
| } |
| buildCounterQueryGrantableRolesRequest--; |
| return o; |
| } |
| |
| checkQueryGrantableRolesRequest(api.QueryGrantableRolesRequest o) { |
| buildCounterQueryGrantableRolesRequest++; |
| if (buildCounterQueryGrantableRolesRequest < 3) { |
| unittest.expect(o.fullResourceName, unittest.equals('foo')); |
| unittest.expect(o.pageSize, unittest.equals(42)); |
| unittest.expect(o.pageToken, unittest.equals('foo')); |
| unittest.expect(o.view, unittest.equals('foo')); |
| } |
| buildCounterQueryGrantableRolesRequest--; |
| } |
| |
| buildUnnamed1297() { |
| var o = new core.List<api.Role>(); |
| o.add(buildRole()); |
| o.add(buildRole()); |
| return o; |
| } |
| |
| checkUnnamed1297(core.List<api.Role> o) { |
| unittest.expect(o, unittest.hasLength(2)); |
| checkRole(o[0]); |
| checkRole(o[1]); |
| } |
| |
| core.int buildCounterQueryGrantableRolesResponse = 0; |
| buildQueryGrantableRolesResponse() { |
| var o = new api.QueryGrantableRolesResponse(); |
| buildCounterQueryGrantableRolesResponse++; |
| if (buildCounterQueryGrantableRolesResponse < 3) { |
| o.nextPageToken = "foo"; |
| o.roles = buildUnnamed1297(); |
| } |
| buildCounterQueryGrantableRolesResponse--; |
| return o; |
| } |
| |
| checkQueryGrantableRolesResponse(api.QueryGrantableRolesResponse o) { |
| buildCounterQueryGrantableRolesResponse++; |
| if (buildCounterQueryGrantableRolesResponse < 3) { |
| unittest.expect(o.nextPageToken, unittest.equals('foo')); |
| checkUnnamed1297(o.roles); |
| } |
| buildCounterQueryGrantableRolesResponse--; |
| } |
| |
| core.int buildCounterQueryTestablePermissionsRequest = 0; |
| buildQueryTestablePermissionsRequest() { |
| var o = new api.QueryTestablePermissionsRequest(); |
| buildCounterQueryTestablePermissionsRequest++; |
| if (buildCounterQueryTestablePermissionsRequest < 3) { |
| o.fullResourceName = "foo"; |
| o.pageSize = 42; |
| o.pageToken = "foo"; |
| } |
| buildCounterQueryTestablePermissionsRequest--; |
| return o; |
| } |
| |
| checkQueryTestablePermissionsRequest(api.QueryTestablePermissionsRequest o) { |
| buildCounterQueryTestablePermissionsRequest++; |
| if (buildCounterQueryTestablePermissionsRequest < 3) { |
| unittest.expect(o.fullResourceName, unittest.equals('foo')); |
| unittest.expect(o.pageSize, unittest.equals(42)); |
| unittest.expect(o.pageToken, unittest.equals('foo')); |
| } |
| buildCounterQueryTestablePermissionsRequest--; |
| } |
| |
| buildUnnamed1298() { |
| var o = new core.List<api.Permission>(); |
| o.add(buildPermission()); |
| o.add(buildPermission()); |
| return o; |
| } |
| |
| checkUnnamed1298(core.List<api.Permission> o) { |
| unittest.expect(o, unittest.hasLength(2)); |
| checkPermission(o[0]); |
| checkPermission(o[1]); |
| } |
| |
| core.int buildCounterQueryTestablePermissionsResponse = 0; |
| buildQueryTestablePermissionsResponse() { |
| var o = new api.QueryTestablePermissionsResponse(); |
| buildCounterQueryTestablePermissionsResponse++; |
| if (buildCounterQueryTestablePermissionsResponse < 3) { |
| o.nextPageToken = "foo"; |
| o.permissions = buildUnnamed1298(); |
| } |
| buildCounterQueryTestablePermissionsResponse--; |
| return o; |
| } |
| |
| checkQueryTestablePermissionsResponse(api.QueryTestablePermissionsResponse o) { |
| buildCounterQueryTestablePermissionsResponse++; |
| if (buildCounterQueryTestablePermissionsResponse < 3) { |
| unittest.expect(o.nextPageToken, unittest.equals('foo')); |
| checkUnnamed1298(o.permissions); |
| } |
| buildCounterQueryTestablePermissionsResponse--; |
| } |
| |
| buildUnnamed1299() { |
| var o = new core.List<core.String>(); |
| o.add("foo"); |
| o.add("foo"); |
| return o; |
| } |
| |
| checkUnnamed1299(core.List<core.String> o) { |
| unittest.expect(o, unittest.hasLength(2)); |
| unittest.expect(o[0], unittest.equals('foo')); |
| unittest.expect(o[1], unittest.equals('foo')); |
| } |
| |
| core.int buildCounterRole = 0; |
| buildRole() { |
| var o = new api.Role(); |
| buildCounterRole++; |
| if (buildCounterRole < 3) { |
| o.deleted = true; |
| o.description = "foo"; |
| o.etag = "foo"; |
| o.includedPermissions = buildUnnamed1299(); |
| o.name = "foo"; |
| o.stage = "foo"; |
| o.title = "foo"; |
| } |
| buildCounterRole--; |
| return o; |
| } |
| |
| checkRole(api.Role o) { |
| buildCounterRole++; |
| if (buildCounterRole < 3) { |
| unittest.expect(o.deleted, unittest.isTrue); |
| unittest.expect(o.description, unittest.equals('foo')); |
| unittest.expect(o.etag, unittest.equals('foo')); |
| checkUnnamed1299(o.includedPermissions); |
| unittest.expect(o.name, unittest.equals('foo')); |
| unittest.expect(o.stage, unittest.equals('foo')); |
| unittest.expect(o.title, unittest.equals('foo')); |
| } |
| buildCounterRole--; |
| } |
| |
| core.int buildCounterServiceAccount = 0; |
| buildServiceAccount() { |
| var o = new api.ServiceAccount(); |
| buildCounterServiceAccount++; |
| if (buildCounterServiceAccount < 3) { |
| o.displayName = "foo"; |
| o.email = "foo"; |
| o.etag = "foo"; |
| o.name = "foo"; |
| o.oauth2ClientId = "foo"; |
| o.projectId = "foo"; |
| o.uniqueId = "foo"; |
| } |
| buildCounterServiceAccount--; |
| return o; |
| } |
| |
| checkServiceAccount(api.ServiceAccount o) { |
| buildCounterServiceAccount++; |
| if (buildCounterServiceAccount < 3) { |
| unittest.expect(o.displayName, unittest.equals('foo')); |
| unittest.expect(o.email, unittest.equals('foo')); |
| unittest.expect(o.etag, unittest.equals('foo')); |
| unittest.expect(o.name, unittest.equals('foo')); |
| unittest.expect(o.oauth2ClientId, unittest.equals('foo')); |
| unittest.expect(o.projectId, unittest.equals('foo')); |
| unittest.expect(o.uniqueId, unittest.equals('foo')); |
| } |
| buildCounterServiceAccount--; |
| } |
| |
| core.int buildCounterServiceAccountKey = 0; |
| buildServiceAccountKey() { |
| var o = new api.ServiceAccountKey(); |
| buildCounterServiceAccountKey++; |
| if (buildCounterServiceAccountKey < 3) { |
| o.keyAlgorithm = "foo"; |
| o.name = "foo"; |
| o.privateKeyData = "foo"; |
| o.privateKeyType = "foo"; |
| o.publicKeyData = "foo"; |
| o.validAfterTime = "foo"; |
| o.validBeforeTime = "foo"; |
| } |
| buildCounterServiceAccountKey--; |
| return o; |
| } |
| |
| checkServiceAccountKey(api.ServiceAccountKey o) { |
| buildCounterServiceAccountKey++; |
| if (buildCounterServiceAccountKey < 3) { |
| unittest.expect(o.keyAlgorithm, unittest.equals('foo')); |
| unittest.expect(o.name, unittest.equals('foo')); |
| unittest.expect(o.privateKeyData, unittest.equals('foo')); |
| unittest.expect(o.privateKeyType, unittest.equals('foo')); |
| unittest.expect(o.publicKeyData, unittest.equals('foo')); |
| unittest.expect(o.validAfterTime, unittest.equals('foo')); |
| unittest.expect(o.validBeforeTime, unittest.equals('foo')); |
| } |
| buildCounterServiceAccountKey--; |
| } |
| |
| core.int buildCounterSetIamPolicyRequest = 0; |
| buildSetIamPolicyRequest() { |
| var o = new api.SetIamPolicyRequest(); |
| buildCounterSetIamPolicyRequest++; |
| if (buildCounterSetIamPolicyRequest < 3) { |
| o.policy = buildPolicy(); |
| } |
| buildCounterSetIamPolicyRequest--; |
| return o; |
| } |
| |
| checkSetIamPolicyRequest(api.SetIamPolicyRequest o) { |
| buildCounterSetIamPolicyRequest++; |
| if (buildCounterSetIamPolicyRequest < 3) { |
| checkPolicy(o.policy); |
| } |
| buildCounterSetIamPolicyRequest--; |
| } |
| |
| core.int buildCounterSignBlobRequest = 0; |
| buildSignBlobRequest() { |
| var o = new api.SignBlobRequest(); |
| buildCounterSignBlobRequest++; |
| if (buildCounterSignBlobRequest < 3) { |
| o.bytesToSign = "foo"; |
| } |
| buildCounterSignBlobRequest--; |
| return o; |
| } |
| |
| checkSignBlobRequest(api.SignBlobRequest o) { |
| buildCounterSignBlobRequest++; |
| if (buildCounterSignBlobRequest < 3) { |
| unittest.expect(o.bytesToSign, unittest.equals('foo')); |
| } |
| buildCounterSignBlobRequest--; |
| } |
| |
| core.int buildCounterSignBlobResponse = 0; |
| buildSignBlobResponse() { |
| var o = new api.SignBlobResponse(); |
| buildCounterSignBlobResponse++; |
| if (buildCounterSignBlobResponse < 3) { |
| o.keyId = "foo"; |
| o.signature = "foo"; |
| } |
| buildCounterSignBlobResponse--; |
| return o; |
| } |
| |
| checkSignBlobResponse(api.SignBlobResponse o) { |
| buildCounterSignBlobResponse++; |
| if (buildCounterSignBlobResponse < 3) { |
| unittest.expect(o.keyId, unittest.equals('foo')); |
| unittest.expect(o.signature, unittest.equals('foo')); |
| } |
| buildCounterSignBlobResponse--; |
| } |
| |
| core.int buildCounterSignJwtRequest = 0; |
| buildSignJwtRequest() { |
| var o = new api.SignJwtRequest(); |
| buildCounterSignJwtRequest++; |
| if (buildCounterSignJwtRequest < 3) { |
| o.payload = "foo"; |
| } |
| buildCounterSignJwtRequest--; |
| return o; |
| } |
| |
| checkSignJwtRequest(api.SignJwtRequest o) { |
| buildCounterSignJwtRequest++; |
| if (buildCounterSignJwtRequest < 3) { |
| unittest.expect(o.payload, unittest.equals('foo')); |
| } |
| buildCounterSignJwtRequest--; |
| } |
| |
| core.int buildCounterSignJwtResponse = 0; |
| buildSignJwtResponse() { |
| var o = new api.SignJwtResponse(); |
| buildCounterSignJwtResponse++; |
| if (buildCounterSignJwtResponse < 3) { |
| o.keyId = "foo"; |
| o.signedJwt = "foo"; |
| } |
| buildCounterSignJwtResponse--; |
| return o; |
| } |
| |
| checkSignJwtResponse(api.SignJwtResponse o) { |
| buildCounterSignJwtResponse++; |
| if (buildCounterSignJwtResponse < 3) { |
| unittest.expect(o.keyId, unittest.equals('foo')); |
| unittest.expect(o.signedJwt, unittest.equals('foo')); |
| } |
| buildCounterSignJwtResponse--; |
| } |
| |
| buildUnnamed1300() { |
| var o = new core.List<core.String>(); |
| o.add("foo"); |
| o.add("foo"); |
| return o; |
| } |
| |
| checkUnnamed1300(core.List<core.String> o) { |
| unittest.expect(o, unittest.hasLength(2)); |
| unittest.expect(o[0], unittest.equals('foo')); |
| unittest.expect(o[1], unittest.equals('foo')); |
| } |
| |
| core.int buildCounterTestIamPermissionsRequest = 0; |
| buildTestIamPermissionsRequest() { |
| var o = new api.TestIamPermissionsRequest(); |
| buildCounterTestIamPermissionsRequest++; |
| if (buildCounterTestIamPermissionsRequest < 3) { |
| o.permissions = buildUnnamed1300(); |
| } |
| buildCounterTestIamPermissionsRequest--; |
| return o; |
| } |
| |
| checkTestIamPermissionsRequest(api.TestIamPermissionsRequest o) { |
| buildCounterTestIamPermissionsRequest++; |
| if (buildCounterTestIamPermissionsRequest < 3) { |
| checkUnnamed1300(o.permissions); |
| } |
| buildCounterTestIamPermissionsRequest--; |
| } |
| |
| buildUnnamed1301() { |
| var o = new core.List<core.String>(); |
| o.add("foo"); |
| o.add("foo"); |
| return o; |
| } |
| |
| checkUnnamed1301(core.List<core.String> o) { |
| unittest.expect(o, unittest.hasLength(2)); |
| unittest.expect(o[0], unittest.equals('foo')); |
| unittest.expect(o[1], unittest.equals('foo')); |
| } |
| |
| core.int buildCounterTestIamPermissionsResponse = 0; |
| buildTestIamPermissionsResponse() { |
| var o = new api.TestIamPermissionsResponse(); |
| buildCounterTestIamPermissionsResponse++; |
| if (buildCounterTestIamPermissionsResponse < 3) { |
| o.permissions = buildUnnamed1301(); |
| } |
| buildCounterTestIamPermissionsResponse--; |
| return o; |
| } |
| |
| checkTestIamPermissionsResponse(api.TestIamPermissionsResponse o) { |
| buildCounterTestIamPermissionsResponse++; |
| if (buildCounterTestIamPermissionsResponse < 3) { |
| checkUnnamed1301(o.permissions); |
| } |
| buildCounterTestIamPermissionsResponse--; |
| } |
| |
| core.int buildCounterUndeleteRoleRequest = 0; |
| buildUndeleteRoleRequest() { |
| var o = new api.UndeleteRoleRequest(); |
| buildCounterUndeleteRoleRequest++; |
| if (buildCounterUndeleteRoleRequest < 3) { |
| o.etag = "foo"; |
| } |
| buildCounterUndeleteRoleRequest--; |
| return o; |
| } |
| |
| checkUndeleteRoleRequest(api.UndeleteRoleRequest o) { |
| buildCounterUndeleteRoleRequest++; |
| if (buildCounterUndeleteRoleRequest < 3) { |
| unittest.expect(o.etag, unittest.equals('foo')); |
| } |
| buildCounterUndeleteRoleRequest--; |
| } |
| |
| buildUnnamed1302() { |
| var o = new core.List<core.String>(); |
| o.add("foo"); |
| o.add("foo"); |
| return o; |
| } |
| |
| checkUnnamed1302(core.List<core.String> o) { |
| unittest.expect(o, unittest.hasLength(2)); |
| unittest.expect(o[0], unittest.equals('foo')); |
| unittest.expect(o[1], unittest.equals('foo')); |
| } |
| |
| main() { |
| unittest.group("obj-schema-AuditData", () { |
| unittest.test("to-json--from-json", () { |
| var o = buildAuditData(); |
| var od = new api.AuditData.fromJson(o.toJson()); |
| checkAuditData(od); |
| }); |
| }); |
| |
| unittest.group("obj-schema-Binding", () { |
| unittest.test("to-json--from-json", () { |
| var o = buildBinding(); |
| var od = new api.Binding.fromJson(o.toJson()); |
| checkBinding(od); |
| }); |
| }); |
| |
| unittest.group("obj-schema-BindingDelta", () { |
| unittest.test("to-json--from-json", () { |
| var o = buildBindingDelta(); |
| var od = new api.BindingDelta.fromJson(o.toJson()); |
| checkBindingDelta(od); |
| }); |
| }); |
| |
| unittest.group("obj-schema-CreateRoleRequest", () { |
| unittest.test("to-json--from-json", () { |
| var o = buildCreateRoleRequest(); |
| var od = new api.CreateRoleRequest.fromJson(o.toJson()); |
| checkCreateRoleRequest(od); |
| }); |
| }); |
| |
| unittest.group("obj-schema-CreateServiceAccountKeyRequest", () { |
| unittest.test("to-json--from-json", () { |
| var o = buildCreateServiceAccountKeyRequest(); |
| var od = new api.CreateServiceAccountKeyRequest.fromJson(o.toJson()); |
| checkCreateServiceAccountKeyRequest(od); |
| }); |
| }); |
| |
| unittest.group("obj-schema-CreateServiceAccountRequest", () { |
| unittest.test("to-json--from-json", () { |
| var o = buildCreateServiceAccountRequest(); |
| var od = new api.CreateServiceAccountRequest.fromJson(o.toJson()); |
| checkCreateServiceAccountRequest(od); |
| }); |
| }); |
| |
| unittest.group("obj-schema-Empty", () { |
| unittest.test("to-json--from-json", () { |
| var o = buildEmpty(); |
| var od = new api.Empty.fromJson(o.toJson()); |
| checkEmpty(od); |
| }); |
| }); |
| |
| unittest.group("obj-schema-ListRolesResponse", () { |
| unittest.test("to-json--from-json", () { |
| var o = buildListRolesResponse(); |
| var od = new api.ListRolesResponse.fromJson(o.toJson()); |
| checkListRolesResponse(od); |
| }); |
| }); |
| |
| unittest.group("obj-schema-ListServiceAccountKeysResponse", () { |
| unittest.test("to-json--from-json", () { |
| var o = buildListServiceAccountKeysResponse(); |
| var od = new api.ListServiceAccountKeysResponse.fromJson(o.toJson()); |
| checkListServiceAccountKeysResponse(od); |
| }); |
| }); |
| |
| unittest.group("obj-schema-ListServiceAccountsResponse", () { |
| unittest.test("to-json--from-json", () { |
| var o = buildListServiceAccountsResponse(); |
| var od = new api.ListServiceAccountsResponse.fromJson(o.toJson()); |
| checkListServiceAccountsResponse(od); |
| }); |
| }); |
| |
| unittest.group("obj-schema-Permission", () { |
| unittest.test("to-json--from-json", () { |
| var o = buildPermission(); |
| var od = new api.Permission.fromJson(o.toJson()); |
| checkPermission(od); |
| }); |
| }); |
| |
| unittest.group("obj-schema-Policy", () { |
| unittest.test("to-json--from-json", () { |
| var o = buildPolicy(); |
| var od = new api.Policy.fromJson(o.toJson()); |
| checkPolicy(od); |
| }); |
| }); |
| |
| unittest.group("obj-schema-PolicyDelta", () { |
| unittest.test("to-json--from-json", () { |
| var o = buildPolicyDelta(); |
| var od = new api.PolicyDelta.fromJson(o.toJson()); |
| checkPolicyDelta(od); |
| }); |
| }); |
| |
| unittest.group("obj-schema-QueryGrantableRolesRequest", () { |
| unittest.test("to-json--from-json", () { |
| var o = buildQueryGrantableRolesRequest(); |
| var od = new api.QueryGrantableRolesRequest.fromJson(o.toJson()); |
| checkQueryGrantableRolesRequest(od); |
| }); |
| }); |
| |
| unittest.group("obj-schema-QueryGrantableRolesResponse", () { |
| unittest.test("to-json--from-json", () { |
| var o = buildQueryGrantableRolesResponse(); |
| var od = new api.QueryGrantableRolesResponse.fromJson(o.toJson()); |
| checkQueryGrantableRolesResponse(od); |
| }); |
| }); |
| |
| unittest.group("obj-schema-QueryTestablePermissionsRequest", () { |
| unittest.test("to-json--from-json", () { |
| var o = buildQueryTestablePermissionsRequest(); |
| var od = new api.QueryTestablePermissionsRequest.fromJson(o.toJson()); |
| checkQueryTestablePermissionsRequest(od); |
| }); |
| }); |
| |
| unittest.group("obj-schema-QueryTestablePermissionsResponse", () { |
| unittest.test("to-json--from-json", () { |
| var o = buildQueryTestablePermissionsResponse(); |
| var od = new api.QueryTestablePermissionsResponse.fromJson(o.toJson()); |
| checkQueryTestablePermissionsResponse(od); |
| }); |
| }); |
| |
| unittest.group("obj-schema-Role", () { |
| unittest.test("to-json--from-json", () { |
| var o = buildRole(); |
| var od = new api.Role.fromJson(o.toJson()); |
| checkRole(od); |
| }); |
| }); |
| |
| unittest.group("obj-schema-ServiceAccount", () { |
| unittest.test("to-json--from-json", () { |
| var o = buildServiceAccount(); |
| var od = new api.ServiceAccount.fromJson(o.toJson()); |
| checkServiceAccount(od); |
| }); |
| }); |
| |
| unittest.group("obj-schema-ServiceAccountKey", () { |
| unittest.test("to-json--from-json", () { |
| var o = buildServiceAccountKey(); |
| var od = new api.ServiceAccountKey.fromJson(o.toJson()); |
| checkServiceAccountKey(od); |
| }); |
| }); |
| |
| unittest.group("obj-schema-SetIamPolicyRequest", () { |
| unittest.test("to-json--from-json", () { |
| var o = buildSetIamPolicyRequest(); |
| var od = new api.SetIamPolicyRequest.fromJson(o.toJson()); |
| checkSetIamPolicyRequest(od); |
| }); |
| }); |
| |
| unittest.group("obj-schema-SignBlobRequest", () { |
| unittest.test("to-json--from-json", () { |
| var o = buildSignBlobRequest(); |
| var od = new api.SignBlobRequest.fromJson(o.toJson()); |
| checkSignBlobRequest(od); |
| }); |
| }); |
| |
| unittest.group("obj-schema-SignBlobResponse", () { |
| unittest.test("to-json--from-json", () { |
| var o = buildSignBlobResponse(); |
| var od = new api.SignBlobResponse.fromJson(o.toJson()); |
| checkSignBlobResponse(od); |
| }); |
| }); |
| |
| unittest.group("obj-schema-SignJwtRequest", () { |
| unittest.test("to-json--from-json", () { |
| var o = buildSignJwtRequest(); |
| var od = new api.SignJwtRequest.fromJson(o.toJson()); |
| checkSignJwtRequest(od); |
| }); |
| }); |
| |
| unittest.group("obj-schema-SignJwtResponse", () { |
| unittest.test("to-json--from-json", () { |
| var o = buildSignJwtResponse(); |
| var od = new api.SignJwtResponse.fromJson(o.toJson()); |
| checkSignJwtResponse(od); |
| }); |
| }); |
| |
| unittest.group("obj-schema-TestIamPermissionsRequest", () { |
| unittest.test("to-json--from-json", () { |
| var o = buildTestIamPermissionsRequest(); |
| var od = new api.TestIamPermissionsRequest.fromJson(o.toJson()); |
| checkTestIamPermissionsRequest(od); |
| }); |
| }); |
| |
| unittest.group("obj-schema-TestIamPermissionsResponse", () { |
| unittest.test("to-json--from-json", () { |
| var o = buildTestIamPermissionsResponse(); |
| var od = new api.TestIamPermissionsResponse.fromJson(o.toJson()); |
| checkTestIamPermissionsResponse(od); |
| }); |
| }); |
| |
| unittest.group("obj-schema-UndeleteRoleRequest", () { |
| unittest.test("to-json--from-json", () { |
| var o = buildUndeleteRoleRequest(); |
| var od = new api.UndeleteRoleRequest.fromJson(o.toJson()); |
| checkUndeleteRoleRequest(od); |
| }); |
| }); |
| |
| unittest.group("resource-OrganizationsRolesResourceApi", () { |
| unittest.test("method--create", () { |
| var mock = new HttpServerMock(); |
| api.OrganizationsRolesResourceApi res = |
| new api.IamApi(mock).organizations.roles; |
| var arg_request = buildCreateRoleRequest(); |
| var arg_parent = "foo"; |
| var arg_$fields = "foo"; |
| mock.register(unittest.expectAsync2((http.BaseRequest req, json) { |
| var obj = new api.CreateRoleRequest.fromJson(json); |
| checkCreateRoleRequest(obj); |
| |
| var path = (req.url).path; |
| var pathOffset = 0; |
| var index; |
| var subPart; |
| unittest.expect( |
| path.substring(pathOffset, pathOffset + 1), unittest.equals("/")); |
| pathOffset += 1; |
| unittest.expect( |
| path.substring(pathOffset, pathOffset + 3), unittest.equals("v1/")); |
| pathOffset += 3; |
| // NOTE: We cannot test reserved expansions due to the inability to reverse the operation; |
| |
| var query = (req.url).query; |
| var queryOffset = 0; |
| var queryMap = {}; |
| addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); |
| parseBool(n) { |
| if (n == "true") return true; |
| if (n == "false") return false; |
| if (n == null) return null; |
| throw new core.ArgumentError("Invalid boolean: $n"); |
| } |
| |
| if (query.length > 0) { |
| for (var part in query.split("&")) { |
| var keyvalue = part.split("="); |
| addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), |
| core.Uri.decodeQueryComponent(keyvalue[1])); |
| } |
| } |
| unittest.expect(queryMap["fields"].first, unittest.equals(arg_$fields)); |
| |
| var h = { |
| "content-type": "application/json; charset=utf-8", |
| }; |
| var resp = convert.JSON.encode(buildRole()); |
| return new async.Future.value(stringResponse(200, h, resp)); |
| }), true); |
| res |
| .create(arg_request, arg_parent, $fields: arg_$fields) |
| .then(unittest.expectAsync1(((api.Role response) { |
| checkRole(response); |
| }))); |
| }); |
| |
| unittest.test("method--delete", () { |
| var mock = new HttpServerMock(); |
| api.OrganizationsRolesResourceApi res = |
| new api.IamApi(mock).organizations.roles; |
| var arg_name = "foo"; |
| var arg_etag = "foo"; |
| var arg_$fields = "foo"; |
| mock.register(unittest.expectAsync2((http.BaseRequest req, json) { |
| var path = (req.url).path; |
| var pathOffset = 0; |
| var index; |
| var subPart; |
| unittest.expect( |
| path.substring(pathOffset, pathOffset + 1), unittest.equals("/")); |
| pathOffset += 1; |
| unittest.expect( |
| path.substring(pathOffset, pathOffset + 3), unittest.equals("v1/")); |
| pathOffset += 3; |
| // NOTE: We cannot test reserved expansions due to the inability to reverse the operation; |
| |
| var query = (req.url).query; |
| var queryOffset = 0; |
| var queryMap = {}; |
| addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); |
| parseBool(n) { |
| if (n == "true") return true; |
| if (n == "false") return false; |
| if (n == null) return null; |
| throw new core.ArgumentError("Invalid boolean: $n"); |
| } |
| |
| if (query.length > 0) { |
| for (var part in query.split("&")) { |
| var keyvalue = part.split("="); |
| addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), |
| core.Uri.decodeQueryComponent(keyvalue[1])); |
| } |
| } |
| unittest.expect(queryMap["etag"].first, unittest.equals(arg_etag)); |
| unittest.expect(queryMap["fields"].first, unittest.equals(arg_$fields)); |
| |
| var h = { |
| "content-type": "application/json; charset=utf-8", |
| }; |
| var resp = convert.JSON.encode(buildRole()); |
| return new async.Future.value(stringResponse(200, h, resp)); |
| }), true); |
| res |
| .delete(arg_name, etag: arg_etag, $fields: arg_$fields) |
| .then(unittest.expectAsync1(((api.Role response) { |
| checkRole(response); |
| }))); |
| }); |
| |
| unittest.test("method--get", () { |
| var mock = new HttpServerMock(); |
| api.OrganizationsRolesResourceApi res = |
| new api.IamApi(mock).organizations.roles; |
| var arg_name = "foo"; |
| var arg_$fields = "foo"; |
| mock.register(unittest.expectAsync2((http.BaseRequest req, json) { |
| var path = (req.url).path; |
| var pathOffset = 0; |
| var index; |
| var subPart; |
| unittest.expect( |
| path.substring(pathOffset, pathOffset + 1), unittest.equals("/")); |
| pathOffset += 1; |
| unittest.expect( |
| path.substring(pathOffset, pathOffset + 3), unittest.equals("v1/")); |
| pathOffset += 3; |
| // NOTE: We cannot test reserved expansions due to the inability to reverse the operation; |
| |
| var query = (req.url).query; |
| var queryOffset = 0; |
| var queryMap = {}; |
| addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); |
| parseBool(n) { |
| if (n == "true") return true; |
| if (n == "false") return false; |
| if (n == null) return null; |
| throw new core.ArgumentError("Invalid boolean: $n"); |
| } |
| |
| if (query.length > 0) { |
| for (var part in query.split("&")) { |
| var keyvalue = part.split("="); |
| addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), |
| core.Uri.decodeQueryComponent(keyvalue[1])); |
| } |
| } |
| unittest.expect(queryMap["fields"].first, unittest.equals(arg_$fields)); |
| |
| var h = { |
| "content-type": "application/json; charset=utf-8", |
| }; |
| var resp = convert.JSON.encode(buildRole()); |
| return new async.Future.value(stringResponse(200, h, resp)); |
| }), true); |
| res |
| .get(arg_name, $fields: arg_$fields) |
| .then(unittest.expectAsync1(((api.Role response) { |
| checkRole(response); |
| }))); |
| }); |
| |
| unittest.test("method--list", () { |
| var mock = new HttpServerMock(); |
| api.OrganizationsRolesResourceApi res = |
| new api.IamApi(mock).organizations.roles; |
| var arg_parent = "foo"; |
| var arg_pageToken = "foo"; |
| var arg_pageSize = 42; |
| var arg_view = "foo"; |
| var arg_showDeleted = true; |
| var arg_$fields = "foo"; |
| mock.register(unittest.expectAsync2((http.BaseRequest req, json) { |
| var path = (req.url).path; |
| var pathOffset = 0; |
| var index; |
| var subPart; |
| unittest.expect( |
| path.substring(pathOffset, pathOffset + 1), unittest.equals("/")); |
| pathOffset += 1; |
| unittest.expect( |
| path.substring(pathOffset, pathOffset + 3), unittest.equals("v1/")); |
| pathOffset += 3; |
| // NOTE: We cannot test reserved expansions due to the inability to reverse the operation; |
| |
| var query = (req.url).query; |
| var queryOffset = 0; |
| var queryMap = {}; |
| addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); |
| parseBool(n) { |
| if (n == "true") return true; |
| if (n == "false") return false; |
| if (n == null) return null; |
| throw new core.ArgumentError("Invalid boolean: $n"); |
| } |
| |
| if (query.length > 0) { |
| for (var part in query.split("&")) { |
| var keyvalue = part.split("="); |
| addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), |
| core.Uri.decodeQueryComponent(keyvalue[1])); |
| } |
| } |
| unittest.expect( |
| queryMap["pageToken"].first, unittest.equals(arg_pageToken)); |
| unittest.expect(core.int.parse(queryMap["pageSize"].first), |
| unittest.equals(arg_pageSize)); |
| unittest.expect(queryMap["view"].first, unittest.equals(arg_view)); |
| unittest.expect( |
| queryMap["showDeleted"].first, unittest.equals("$arg_showDeleted")); |
| unittest.expect(queryMap["fields"].first, unittest.equals(arg_$fields)); |
| |
| var h = { |
| "content-type": "application/json; charset=utf-8", |
| }; |
| var resp = convert.JSON.encode(buildListRolesResponse()); |
| return new async.Future.value(stringResponse(200, h, resp)); |
| }), true); |
| res |
| .list(arg_parent, |
| pageToken: arg_pageToken, |
| pageSize: arg_pageSize, |
| view: arg_view, |
| showDeleted: arg_showDeleted, |
| $fields: arg_$fields) |
| .then(unittest.expectAsync1(((api.ListRolesResponse response) { |
| checkListRolesResponse(response); |
| }))); |
| }); |
| |
| unittest.test("method--patch", () { |
| var mock = new HttpServerMock(); |
| api.OrganizationsRolesResourceApi res = |
| new api.IamApi(mock).organizations.roles; |
| var arg_request = buildRole(); |
| var arg_name = "foo"; |
| var arg_updateMask = "foo"; |
| var arg_$fields = "foo"; |
| mock.register(unittest.expectAsync2((http.BaseRequest req, json) { |
| var obj = new api.Role.fromJson(json); |
| checkRole(obj); |
| |
| var path = (req.url).path; |
| var pathOffset = 0; |
| var index; |
| var subPart; |
| unittest.expect( |
| path.substring(pathOffset, pathOffset + 1), unittest.equals("/")); |
| pathOffset += 1; |
| unittest.expect( |
| path.substring(pathOffset, pathOffset + 3), unittest.equals("v1/")); |
| pathOffset += 3; |
| // NOTE: We cannot test reserved expansions due to the inability to reverse the operation; |
| |
| var query = (req.url).query; |
| var queryOffset = 0; |
| var queryMap = {}; |
| addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); |
| parseBool(n) { |
| if (n == "true") return true; |
| if (n == "false") return false; |
| if (n == null) return null; |
| throw new core.ArgumentError("Invalid boolean: $n"); |
| } |
| |
| if (query.length > 0) { |
| for (var part in query.split("&")) { |
| var keyvalue = part.split("="); |
| addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), |
| core.Uri.decodeQueryComponent(keyvalue[1])); |
| } |
| } |
| unittest.expect( |
| queryMap["updateMask"].first, unittest.equals(arg_updateMask)); |
| unittest.expect(queryMap["fields"].first, unittest.equals(arg_$fields)); |
| |
| var h = { |
| "content-type": "application/json; charset=utf-8", |
| }; |
| var resp = convert.JSON.encode(buildRole()); |
| return new async.Future.value(stringResponse(200, h, resp)); |
| }), true); |
| res |
| .patch(arg_request, arg_name, |
| updateMask: arg_updateMask, $fields: arg_$fields) |
| .then(unittest.expectAsync1(((api.Role response) { |
| checkRole(response); |
| }))); |
| }); |
| |
| unittest.test("method--undelete", () { |
| var mock = new HttpServerMock(); |
| api.OrganizationsRolesResourceApi res = |
| new api.IamApi(mock).organizations.roles; |
| var arg_request = buildUndeleteRoleRequest(); |
| var arg_name = "foo"; |
| var arg_$fields = "foo"; |
| mock.register(unittest.expectAsync2((http.BaseRequest req, json) { |
| var obj = new api.UndeleteRoleRequest.fromJson(json); |
| checkUndeleteRoleRequest(obj); |
| |
| var path = (req.url).path; |
| var pathOffset = 0; |
| var index; |
| var subPart; |
| unittest.expect( |
| path.substring(pathOffset, pathOffset + 1), unittest.equals("/")); |
| pathOffset += 1; |
| unittest.expect( |
| path.substring(pathOffset, pathOffset + 3), unittest.equals("v1/")); |
| pathOffset += 3; |
| // NOTE: We cannot test reserved expansions due to the inability to reverse the operation; |
| |
| var query = (req.url).query; |
| var queryOffset = 0; |
| var queryMap = {}; |
| addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); |
| parseBool(n) { |
| if (n == "true") return true; |
| if (n == "false") return false; |
| if (n == null) return null; |
| throw new core.ArgumentError("Invalid boolean: $n"); |
| } |
| |
| if (query.length > 0) { |
| for (var part in query.split("&")) { |
| var keyvalue = part.split("="); |
| addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), |
| core.Uri.decodeQueryComponent(keyvalue[1])); |
| } |
| } |
| unittest.expect(queryMap["fields"].first, unittest.equals(arg_$fields)); |
| |
| var h = { |
| "content-type": "application/json; charset=utf-8", |
| }; |
| var resp = convert.JSON.encode(buildRole()); |
| return new async.Future.value(stringResponse(200, h, resp)); |
| }), true); |
| res |
| .undelete(arg_request, arg_name, $fields: arg_$fields) |
| .then(unittest.expectAsync1(((api.Role response) { |
| checkRole(response); |
| }))); |
| }); |
| }); |
| |
| unittest.group("resource-PermissionsResourceApi", () { |
| unittest.test("method--queryTestablePermissions", () { |
| var mock = new HttpServerMock(); |
| api.PermissionsResourceApi res = new api.IamApi(mock).permissions; |
| var arg_request = buildQueryTestablePermissionsRequest(); |
| var arg_$fields = "foo"; |
| mock.register(unittest.expectAsync2((http.BaseRequest req, json) { |
| var obj = new api.QueryTestablePermissionsRequest.fromJson(json); |
| checkQueryTestablePermissionsRequest(obj); |
| |
| var path = (req.url).path; |
| var pathOffset = 0; |
| var index; |
| var subPart; |
| unittest.expect( |
| path.substring(pathOffset, pathOffset + 1), unittest.equals("/")); |
| pathOffset += 1; |
| unittest.expect(path.substring(pathOffset, pathOffset + 39), |
| unittest.equals("v1/permissions:queryTestablePermissions")); |
| pathOffset += 39; |
| |
| var query = (req.url).query; |
| var queryOffset = 0; |
| var queryMap = {}; |
| addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); |
| parseBool(n) { |
| if (n == "true") return true; |
| if (n == "false") return false; |
| if (n == null) return null; |
| throw new core.ArgumentError("Invalid boolean: $n"); |
| } |
| |
| if (query.length > 0) { |
| for (var part in query.split("&")) { |
| var keyvalue = part.split("="); |
| addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), |
| core.Uri.decodeQueryComponent(keyvalue[1])); |
| } |
| } |
| unittest.expect(queryMap["fields"].first, unittest.equals(arg_$fields)); |
| |
| var h = { |
| "content-type": "application/json; charset=utf-8", |
| }; |
| var resp = convert.JSON.encode(buildQueryTestablePermissionsResponse()); |
| return new async.Future.value(stringResponse(200, h, resp)); |
| }), true); |
| res.queryTestablePermissions(arg_request, $fields: arg_$fields).then( |
| unittest |
| .expectAsync1(((api.QueryTestablePermissionsResponse response) { |
| checkQueryTestablePermissionsResponse(response); |
| }))); |
| }); |
| }); |
| |
| unittest.group("resource-ProjectsRolesResourceApi", () { |
| unittest.test("method--create", () { |
| var mock = new HttpServerMock(); |
| api.ProjectsRolesResourceApi res = new api.IamApi(mock).projects.roles; |
| var arg_request = buildCreateRoleRequest(); |
| var arg_parent = "foo"; |
| var arg_$fields = "foo"; |
| mock.register(unittest.expectAsync2((http.BaseRequest req, json) { |
| var obj = new api.CreateRoleRequest.fromJson(json); |
| checkCreateRoleRequest(obj); |
| |
| var path = (req.url).path; |
| var pathOffset = 0; |
| var index; |
| var subPart; |
| unittest.expect( |
| path.substring(pathOffset, pathOffset + 1), unittest.equals("/")); |
| pathOffset += 1; |
| unittest.expect( |
| path.substring(pathOffset, pathOffset + 3), unittest.equals("v1/")); |
| pathOffset += 3; |
| // NOTE: We cannot test reserved expansions due to the inability to reverse the operation; |
| |
| var query = (req.url).query; |
| var queryOffset = 0; |
| var queryMap = {}; |
| addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); |
| parseBool(n) { |
| if (n == "true") return true; |
| if (n == "false") return false; |
| if (n == null) return null; |
| throw new core.ArgumentError("Invalid boolean: $n"); |
| } |
| |
| if (query.length > 0) { |
| for (var part in query.split("&")) { |
| var keyvalue = part.split("="); |
| addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), |
| core.Uri.decodeQueryComponent(keyvalue[1])); |
| } |
| } |
| unittest.expect(queryMap["fields"].first, unittest.equals(arg_$fields)); |
| |
| var h = { |
| "content-type": "application/json; charset=utf-8", |
| }; |
| var resp = convert.JSON.encode(buildRole()); |
| return new async.Future.value(stringResponse(200, h, resp)); |
| }), true); |
| res |
| .create(arg_request, arg_parent, $fields: arg_$fields) |
| .then(unittest.expectAsync1(((api.Role response) { |
| checkRole(response); |
| }))); |
| }); |
| |
| unittest.test("method--delete", () { |
| var mock = new HttpServerMock(); |
| api.ProjectsRolesResourceApi res = new api.IamApi(mock).projects.roles; |
| var arg_name = "foo"; |
| var arg_etag = "foo"; |
| var arg_$fields = "foo"; |
| mock.register(unittest.expectAsync2((http.BaseRequest req, json) { |
| var path = (req.url).path; |
| var pathOffset = 0; |
| var index; |
| var subPart; |
| unittest.expect( |
| path.substring(pathOffset, pathOffset + 1), unittest.equals("/")); |
| pathOffset += 1; |
| unittest.expect( |
| path.substring(pathOffset, pathOffset + 3), unittest.equals("v1/")); |
| pathOffset += 3; |
| // NOTE: We cannot test reserved expansions due to the inability to reverse the operation; |
| |
| var query = (req.url).query; |
| var queryOffset = 0; |
| var queryMap = {}; |
| addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); |
| parseBool(n) { |
| if (n == "true") return true; |
| if (n == "false") return false; |
| if (n == null) return null; |
| throw new core.ArgumentError("Invalid boolean: $n"); |
| } |
| |
| if (query.length > 0) { |
| for (var part in query.split("&")) { |
| var keyvalue = part.split("="); |
| addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), |
| core.Uri.decodeQueryComponent(keyvalue[1])); |
| } |
| } |
| unittest.expect(queryMap["etag"].first, unittest.equals(arg_etag)); |
| unittest.expect(queryMap["fields"].first, unittest.equals(arg_$fields)); |
| |
| var h = { |
| "content-type": "application/json; charset=utf-8", |
| }; |
| var resp = convert.JSON.encode(buildRole()); |
| return new async.Future.value(stringResponse(200, h, resp)); |
| }), true); |
| res |
| .delete(arg_name, etag: arg_etag, $fields: arg_$fields) |
| .then(unittest.expectAsync1(((api.Role response) { |
| checkRole(response); |
| }))); |
| }); |
| |
| unittest.test("method--get", () { |
| var mock = new HttpServerMock(); |
| api.ProjectsRolesResourceApi res = new api.IamApi(mock).projects.roles; |
| var arg_name = "foo"; |
| var arg_$fields = "foo"; |
| mock.register(unittest.expectAsync2((http.BaseRequest req, json) { |
| var path = (req.url).path; |
| var pathOffset = 0; |
| var index; |
| var subPart; |
| unittest.expect( |
| path.substring(pathOffset, pathOffset + 1), unittest.equals("/")); |
| pathOffset += 1; |
| unittest.expect( |
| path.substring(pathOffset, pathOffset + 3), unittest.equals("v1/")); |
| pathOffset += 3; |
| // NOTE: We cannot test reserved expansions due to the inability to reverse the operation; |
| |
| var query = (req.url).query; |
| var queryOffset = 0; |
| var queryMap = {}; |
| addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); |
| parseBool(n) { |
| if (n == "true") return true; |
| if (n == "false") return false; |
| if (n == null) return null; |
| throw new core.ArgumentError("Invalid boolean: $n"); |
| } |
| |
| if (query.length > 0) { |
| for (var part in query.split("&")) { |
| var keyvalue = part.split("="); |
| addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), |
| core.Uri.decodeQueryComponent(keyvalue[1])); |
| } |
| } |
| unittest.expect(queryMap["fields"].first, unittest.equals(arg_$fields)); |
| |
| var h = { |
| "content-type": "application/json; charset=utf-8", |
| }; |
| var resp = convert.JSON.encode(buildRole()); |
| return new async.Future.value(stringResponse(200, h, resp)); |
| }), true); |
| res |
| .get(arg_name, $fields: arg_$fields) |
| .then(unittest.expectAsync1(((api.Role response) { |
| checkRole(response); |
| }))); |
| }); |
| |
| unittest.test("method--list", () { |
| var mock = new HttpServerMock(); |
| api.ProjectsRolesResourceApi res = new api.IamApi(mock).projects.roles; |
| var arg_parent = "foo"; |
| var arg_showDeleted = true; |
| var arg_pageToken = "foo"; |
| var arg_pageSize = 42; |
| var arg_view = "foo"; |
| var arg_$fields = "foo"; |
| mock.register(unittest.expectAsync2((http.BaseRequest req, json) { |
| var path = (req.url).path; |
| var pathOffset = 0; |
| var index; |
| var subPart; |
| unittest.expect( |
| path.substring(pathOffset, pathOffset + 1), unittest.equals("/")); |
| pathOffset += 1; |
| unittest.expect( |
| path.substring(pathOffset, pathOffset + 3), unittest.equals("v1/")); |
| pathOffset += 3; |
| // NOTE: We cannot test reserved expansions due to the inability to reverse the operation; |
| |
| var query = (req.url).query; |
| var queryOffset = 0; |
| var queryMap = {}; |
| addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); |
| parseBool(n) { |
| if (n == "true") return true; |
| if (n == "false") return false; |
| if (n == null) return null; |
| throw new core.ArgumentError("Invalid boolean: $n"); |
| } |
| |
| if (query.length > 0) { |
| for (var part in query.split("&")) { |
| var keyvalue = part.split("="); |
| addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), |
| core.Uri.decodeQueryComponent(keyvalue[1])); |
| } |
| } |
| unittest.expect( |
| queryMap["showDeleted"].first, unittest.equals("$arg_showDeleted")); |
| unittest.expect( |
| queryMap["pageToken"].first, unittest.equals(arg_pageToken)); |
| unittest.expect(core.int.parse(queryMap["pageSize"].first), |
| unittest.equals(arg_pageSize)); |
| unittest.expect(queryMap["view"].first, unittest.equals(arg_view)); |
| unittest.expect(queryMap["fields"].first, unittest.equals(arg_$fields)); |
| |
| var h = { |
| "content-type": "application/json; charset=utf-8", |
| }; |
| var resp = convert.JSON.encode(buildListRolesResponse()); |
| return new async.Future.value(stringResponse(200, h, resp)); |
| }), true); |
| res |
| .list(arg_parent, |
| showDeleted: arg_showDeleted, |
| pageToken: arg_pageToken, |
| pageSize: arg_pageSize, |
| view: arg_view, |
| $fields: arg_$fields) |
| .then(unittest.expectAsync1(((api.ListRolesResponse response) { |
| checkListRolesResponse(response); |
| }))); |
| }); |
| |
| unittest.test("method--patch", () { |
| var mock = new HttpServerMock(); |
| api.ProjectsRolesResourceApi res = new api.IamApi(mock).projects.roles; |
| var arg_request = buildRole(); |
| var arg_name = "foo"; |
| var arg_updateMask = "foo"; |
| var arg_$fields = "foo"; |
| mock.register(unittest.expectAsync2((http.BaseRequest req, json) { |
| var obj = new api.Role.fromJson(json); |
| checkRole(obj); |
| |
| var path = (req.url).path; |
| var pathOffset = 0; |
| var index; |
| var subPart; |
| unittest.expect( |
| path.substring(pathOffset, pathOffset + 1), unittest.equals("/")); |
| pathOffset += 1; |
| unittest.expect( |
| path.substring(pathOffset, pathOffset + 3), unittest.equals("v1/")); |
| pathOffset += 3; |
| // NOTE: We cannot test reserved expansions due to the inability to reverse the operation; |
| |
| var query = (req.url).query; |
| var queryOffset = 0; |
| var queryMap = {}; |
| addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); |
| parseBool(n) { |
| if (n == "true") return true; |
| if (n == "false") return false; |
| if (n == null) return null; |
| throw new core.ArgumentError("Invalid boolean: $n"); |
| } |
| |
| if (query.length > 0) { |
| for (var part in query.split("&")) { |
| var keyvalue = part.split("="); |
| addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), |
| core.Uri.decodeQueryComponent(keyvalue[1])); |
| } |
| } |
| unittest.expect( |
| queryMap["updateMask"].first, unittest.equals(arg_updateMask)); |
| unittest.expect(queryMap["fields"].first, unittest.equals(arg_$fields)); |
| |
| var h = { |
| "content-type": "application/json; charset=utf-8", |
| }; |
| var resp = convert.JSON.encode(buildRole()); |
| return new async.Future.value(stringResponse(200, h, resp)); |
| }), true); |
| res |
| .patch(arg_request, arg_name, |
| updateMask: arg_updateMask, $fields: arg_$fields) |
| .then(unittest.expectAsync1(((api.Role response) { |
| checkRole(response); |
| }))); |
| }); |
| |
| unittest.test("method--undelete", () { |
| var mock = new HttpServerMock(); |
| api.ProjectsRolesResourceApi res = new api.IamApi(mock).projects.roles; |
| var arg_request = buildUndeleteRoleRequest(); |
| var arg_name = "foo"; |
| var arg_$fields = "foo"; |
| mock.register(unittest.expectAsync2((http.BaseRequest req, json) { |
| var obj = new api.UndeleteRoleRequest.fromJson(json); |
| checkUndeleteRoleRequest(obj); |
| |
| var path = (req.url).path; |
| var pathOffset = 0; |
| var index; |
| var subPart; |
| unittest.expect( |
| path.substring(pathOffset, pathOffset + 1), unittest.equals("/")); |
| pathOffset += 1; |
| unittest.expect( |
| path.substring(pathOffset, pathOffset + 3), unittest.equals("v1/")); |
| pathOffset += 3; |
| // NOTE: We cannot test reserved expansions due to the inability to reverse the operation; |
| |
| var query = (req.url).query; |
| var queryOffset = 0; |
| var queryMap = {}; |
| addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); |
| parseBool(n) { |
| if (n == "true") return true; |
| if (n == "false") return false; |
| if (n == null) return null; |
| throw new core.ArgumentError("Invalid boolean: $n"); |
| } |
| |
| if (query.length > 0) { |
| for (var part in query.split("&")) { |
| var keyvalue = part.split("="); |
| addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), |
| core.Uri.decodeQueryComponent(keyvalue[1])); |
| } |
| } |
| unittest.expect(queryMap["fields"].first, unittest.equals(arg_$fields)); |
| |
| var h = { |
| "content-type": "application/json; charset=utf-8", |
| }; |
| var resp = convert.JSON.encode(buildRole()); |
| return new async.Future.value(stringResponse(200, h, resp)); |
| }), true); |
| res |
| .undelete(arg_request, arg_name, $fields: arg_$fields) |
| .then(unittest.expectAsync1(((api.Role response) { |
| checkRole(response); |
| }))); |
| }); |
| }); |
| |
| unittest.group("resource-ProjectsServiceAccountsResourceApi", () { |
| unittest.test("method--create", () { |
| var mock = new HttpServerMock(); |
| api.ProjectsServiceAccountsResourceApi res = |
| new api.IamApi(mock).projects.serviceAccounts; |
| var arg_request = buildCreateServiceAccountRequest(); |
| var arg_name = "foo"; |
| var arg_$fields = "foo"; |
| mock.register(unittest.expectAsync2((http.BaseRequest req, json) { |
| var obj = new api.CreateServiceAccountRequest.fromJson(json); |
| checkCreateServiceAccountRequest(obj); |
| |
| var path = (req.url).path; |
| var pathOffset = 0; |
| var index; |
| var subPart; |
| unittest.expect( |
| path.substring(pathOffset, pathOffset + 1), unittest.equals("/")); |
| pathOffset += 1; |
| unittest.expect( |
| path.substring(pathOffset, pathOffset + 3), unittest.equals("v1/")); |
| pathOffset += 3; |
| // NOTE: We cannot test reserved expansions due to the inability to reverse the operation; |
| |
| var query = (req.url).query; |
| var queryOffset = 0; |
| var queryMap = {}; |
| addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); |
| parseBool(n) { |
| if (n == "true") return true; |
| if (n == "false") return false; |
| if (n == null) return null; |
| throw new core.ArgumentError("Invalid boolean: $n"); |
| } |
| |
| if (query.length > 0) { |
| for (var part in query.split("&")) { |
| var keyvalue = part.split("="); |
| addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), |
| core.Uri.decodeQueryComponent(keyvalue[1])); |
| } |
| } |
| unittest.expect(queryMap["fields"].first, unittest.equals(arg_$fields)); |
| |
| var h = { |
| "content-type": "application/json; charset=utf-8", |
| }; |
| var resp = convert.JSON.encode(buildServiceAccount()); |
| return new async.Future.value(stringResponse(200, h, resp)); |
| }), true); |
| res |
| .create(arg_request, arg_name, $fields: arg_$fields) |
| .then(unittest.expectAsync1(((api.ServiceAccount response) { |
| checkServiceAccount(response); |
| }))); |
| }); |
| |
| unittest.test("method--delete", () { |
| var mock = new HttpServerMock(); |
| api.ProjectsServiceAccountsResourceApi res = |
| new api.IamApi(mock).projects.serviceAccounts; |
| var arg_name = "foo"; |
| var arg_$fields = "foo"; |
| mock.register(unittest.expectAsync2((http.BaseRequest req, json) { |
| var path = (req.url).path; |
| var pathOffset = 0; |
| var index; |
| var subPart; |
| unittest.expect( |
| path.substring(pathOffset, pathOffset + 1), unittest.equals("/")); |
| pathOffset += 1; |
| unittest.expect( |
| path.substring(pathOffset, pathOffset + 3), unittest.equals("v1/")); |
| pathOffset += 3; |
| // NOTE: We cannot test reserved expansions due to the inability to reverse the operation; |
| |
| var query = (req.url).query; |
| var queryOffset = 0; |
| var queryMap = {}; |
| addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); |
| parseBool(n) { |
| if (n == "true") return true; |
| if (n == "false") return false; |
| if (n == null) return null; |
| throw new core.ArgumentError("Invalid boolean: $n"); |
| } |
| |
| if (query.length > 0) { |
| for (var part in query.split("&")) { |
| var keyvalue = part.split("="); |
| addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), |
| core.Uri.decodeQueryComponent(keyvalue[1])); |
| } |
| } |
| unittest.expect(queryMap["fields"].first, unittest.equals(arg_$fields)); |
| |
| var h = { |
| "content-type": "application/json; charset=utf-8", |
| }; |
| var resp = convert.JSON.encode(buildEmpty()); |
| return new async.Future.value(stringResponse(200, h, resp)); |
| }), true); |
| res |
| .delete(arg_name, $fields: arg_$fields) |
| .then(unittest.expectAsync1(((api.Empty response) { |
| checkEmpty(response); |
| }))); |
| }); |
| |
| unittest.test("method--get", () { |
| var mock = new HttpServerMock(); |
| api.ProjectsServiceAccountsResourceApi res = |
| new api.IamApi(mock).projects.serviceAccounts; |
| var arg_name = "foo"; |
| var arg_$fields = "foo"; |
| mock.register(unittest.expectAsync2((http.BaseRequest req, json) { |
| var path = (req.url).path; |
| var pathOffset = 0; |
| var index; |
| var subPart; |
| unittest.expect( |
| path.substring(pathOffset, pathOffset + 1), unittest.equals("/")); |
| pathOffset += 1; |
| unittest.expect( |
| path.substring(pathOffset, pathOffset + 3), unittest.equals("v1/")); |
| pathOffset += 3; |
| // NOTE: We cannot test reserved expansions due to the inability to reverse the operation; |
| |
| var query = (req.url).query; |
| var queryOffset = 0; |
| var queryMap = {}; |
| addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); |
| parseBool(n) { |
| if (n == "true") return true; |
| if (n == "false") return false; |
| if (n == null) return null; |
| throw new core.ArgumentError("Invalid boolean: $n"); |
| } |
| |
| if (query.length > 0) { |
| for (var part in query.split("&")) { |
| var keyvalue = part.split("="); |
| addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), |
| core.Uri.decodeQueryComponent(keyvalue[1])); |
| } |
| } |
| unittest.expect(queryMap["fields"].first, unittest.equals(arg_$fields)); |
| |
| var h = { |
| "content-type": "application/json; charset=utf-8", |
| }; |
| var resp = convert.JSON.encode(buildServiceAccount()); |
| return new async.Future.value(stringResponse(200, h, resp)); |
| }), true); |
| res |
| .get(arg_name, $fields: arg_$fields) |
| .then(unittest.expectAsync1(((api.ServiceAccount response) { |
| checkServiceAccount(response); |
| }))); |
| }); |
| |
| unittest.test("method--getIamPolicy", () { |
| var mock = new HttpServerMock(); |
| api.ProjectsServiceAccountsResourceApi res = |
| new api.IamApi(mock).projects.serviceAccounts; |
| var arg_resource = "foo"; |
| var arg_$fields = "foo"; |
| mock.register(unittest.expectAsync2((http.BaseRequest req, json) { |
| var path = (req.url).path; |
| var pathOffset = 0; |
| var index; |
| var subPart; |
| unittest.expect( |
| path.substring(pathOffset, pathOffset + 1), unittest.equals("/")); |
| pathOffset += 1; |
| unittest.expect( |
| path.substring(pathOffset, pathOffset + 3), unittest.equals("v1/")); |
| pathOffset += 3; |
| // NOTE: We cannot test reserved expansions due to the inability to reverse the operation; |
| |
| var query = (req.url).query; |
| var queryOffset = 0; |
| var queryMap = {}; |
| addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); |
| parseBool(n) { |
| if (n == "true") return true; |
| if (n == "false") return false; |
| if (n == null) return null; |
| throw new core.ArgumentError("Invalid boolean: $n"); |
| } |
| |
| if (query.length > 0) { |
| for (var part in query.split("&")) { |
| var keyvalue = part.split("="); |
| addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), |
| core.Uri.decodeQueryComponent(keyvalue[1])); |
| } |
| } |
| unittest.expect(queryMap["fields"].first, unittest.equals(arg_$fields)); |
| |
| var h = { |
| "content-type": "application/json; charset=utf-8", |
| }; |
| var resp = convert.JSON.encode(buildPolicy()); |
| return new async.Future.value(stringResponse(200, h, resp)); |
| }), true); |
| res |
| .getIamPolicy(arg_resource, $fields: arg_$fields) |
| .then(unittest.expectAsync1(((api.Policy response) { |
| checkPolicy(response); |
| }))); |
| }); |
| |
| unittest.test("method--list", () { |
| var mock = new HttpServerMock(); |
| api.ProjectsServiceAccountsResourceApi res = |
| new api.IamApi(mock).projects.serviceAccounts; |
| var arg_name = "foo"; |
| var arg_pageToken = "foo"; |
| var arg_pageSize = 42; |
| var arg_$fields = "foo"; |
| mock.register(unittest.expectAsync2((http.BaseRequest req, json) { |
| var path = (req.url).path; |
| var pathOffset = 0; |
| var index; |
| var subPart; |
| unittest.expect( |
| path.substring(pathOffset, pathOffset + 1), unittest.equals("/")); |
| pathOffset += 1; |
| unittest.expect( |
| path.substring(pathOffset, pathOffset + 3), unittest.equals("v1/")); |
| pathOffset += 3; |
| // NOTE: We cannot test reserved expansions due to the inability to reverse the operation; |
| |
| var query = (req.url).query; |
| var queryOffset = 0; |
| var queryMap = {}; |
| addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); |
| parseBool(n) { |
| if (n == "true") return true; |
| if (n == "false") return false; |
| if (n == null) return null; |
| throw new core.ArgumentError("Invalid boolean: $n"); |
| } |
| |
| if (query.length > 0) { |
| for (var part in query.split("&")) { |
| var keyvalue = part.split("="); |
| addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), |
| core.Uri.decodeQueryComponent(keyvalue[1])); |
| } |
| } |
| unittest.expect( |
| queryMap["pageToken"].first, unittest.equals(arg_pageToken)); |
| unittest.expect(core.int.parse(queryMap["pageSize"].first), |
| unittest.equals(arg_pageSize)); |
| unittest.expect(queryMap["fields"].first, unittest.equals(arg_$fields)); |
| |
| var h = { |
| "content-type": "application/json; charset=utf-8", |
| }; |
| var resp = convert.JSON.encode(buildListServiceAccountsResponse()); |
| return new async.Future.value(stringResponse(200, h, resp)); |
| }), true); |
| res |
| .list(arg_name, |
| pageToken: arg_pageToken, |
| pageSize: arg_pageSize, |
| $fields: arg_$fields) |
| .then(unittest |
| .expectAsync1(((api.ListServiceAccountsResponse response) { |
| checkListServiceAccountsResponse(response); |
| }))); |
| }); |
| |
| unittest.test("method--setIamPolicy", () { |
| var mock = new HttpServerMock(); |
| api.ProjectsServiceAccountsResourceApi res = |
| new api.IamApi(mock).projects.serviceAccounts; |
| var arg_request = buildSetIamPolicyRequest(); |
| var arg_resource = "foo"; |
| var arg_$fields = "foo"; |
| mock.register(unittest.expectAsync2((http.BaseRequest req, json) { |
| var obj = new api.SetIamPolicyRequest.fromJson(json); |
| checkSetIamPolicyRequest(obj); |
| |
| var path = (req.url).path; |
| var pathOffset = 0; |
| var index; |
| var subPart; |
| unittest.expect( |
| path.substring(pathOffset, pathOffset + 1), unittest.equals("/")); |
| pathOffset += 1; |
| unittest.expect( |
| path.substring(pathOffset, pathOffset + 3), unittest.equals("v1/")); |
| pathOffset += 3; |
| // NOTE: We cannot test reserved expansions due to the inability to reverse the operation; |
| |
| var query = (req.url).query; |
| var queryOffset = 0; |
| var queryMap = {}; |
| addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); |
| parseBool(n) { |
| if (n == "true") return true; |
| if (n == "false") return false; |
| if (n == null) return null; |
| throw new core.ArgumentError("Invalid boolean: $n"); |
| } |
| |
| if (query.length > 0) { |
| for (var part in query.split("&")) { |
| var keyvalue = part.split("="); |
| addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), |
| core.Uri.decodeQueryComponent(keyvalue[1])); |
| } |
| } |
| unittest.expect(queryMap["fields"].first, unittest.equals(arg_$fields)); |
| |
| var h = { |
| "content-type": "application/json; charset=utf-8", |
| }; |
| var resp = convert.JSON.encode(buildPolicy()); |
| return new async.Future.value(stringResponse(200, h, resp)); |
| }), true); |
| res |
| .setIamPolicy(arg_request, arg_resource, $fields: arg_$fields) |
| .then(unittest.expectAsync1(((api.Policy response) { |
| checkPolicy(response); |
| }))); |
| }); |
| |
| unittest.test("method--signBlob", () { |
| var mock = new HttpServerMock(); |
| api.ProjectsServiceAccountsResourceApi res = |
| new api.IamApi(mock).projects.serviceAccounts; |
| var arg_request = buildSignBlobRequest(); |
| var arg_name = "foo"; |
| var arg_$fields = "foo"; |
| mock.register(unittest.expectAsync2((http.BaseRequest req, json) { |
| var obj = new api.SignBlobRequest.fromJson(json); |
| checkSignBlobRequest(obj); |
| |
| var path = (req.url).path; |
| var pathOffset = 0; |
| var index; |
| var subPart; |
| unittest.expect( |
| path.substring(pathOffset, pathOffset + 1), unittest.equals("/")); |
| pathOffset += 1; |
| unittest.expect( |
| path.substring(pathOffset, pathOffset + 3), unittest.equals("v1/")); |
| pathOffset += 3; |
| // NOTE: We cannot test reserved expansions due to the inability to reverse the operation; |
| |
| var query = (req.url).query; |
| var queryOffset = 0; |
| var queryMap = {}; |
| addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); |
| parseBool(n) { |
| if (n == "true") return true; |
| if (n == "false") return false; |
| if (n == null) return null; |
| throw new core.ArgumentError("Invalid boolean: $n"); |
| } |
| |
| if (query.length > 0) { |
| for (var part in query.split("&")) { |
| var keyvalue = part.split("="); |
| addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), |
| core.Uri.decodeQueryComponent(keyvalue[1])); |
| } |
| } |
| unittest.expect(queryMap["fields"].first, unittest.equals(arg_$fields)); |
| |
| var h = { |
| "content-type": "application/json; charset=utf-8", |
| }; |
| var resp = convert.JSON.encode(buildSignBlobResponse()); |
| return new async.Future.value(stringResponse(200, h, resp)); |
| }), true); |
| res |
| .signBlob(arg_request, arg_name, $fields: arg_$fields) |
| .then(unittest.expectAsync1(((api.SignBlobResponse response) { |
| checkSignBlobResponse(response); |
| }))); |
| }); |
| |
| unittest.test("method--signJwt", () { |
| var mock = new HttpServerMock(); |
| api.ProjectsServiceAccountsResourceApi res = |
| new api.IamApi(mock).projects.serviceAccounts; |
| var arg_request = buildSignJwtRequest(); |
| var arg_name = "foo"; |
| var arg_$fields = "foo"; |
| mock.register(unittest.expectAsync2((http.BaseRequest req, json) { |
| var obj = new api.SignJwtRequest.fromJson(json); |
| checkSignJwtRequest(obj); |
| |
| var path = (req.url).path; |
| var pathOffset = 0; |
| var index; |
| var subPart; |
| unittest.expect( |
| path.substring(pathOffset, pathOffset + 1), unittest.equals("/")); |
| pathOffset += 1; |
| unittest.expect( |
| path.substring(pathOffset, pathOffset + 3), unittest.equals("v1/")); |
| pathOffset += 3; |
| // NOTE: We cannot test reserved expansions due to the inability to reverse the operation; |
| |
| var query = (req.url).query; |
| var queryOffset = 0; |
| var queryMap = {}; |
| addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); |
| parseBool(n) { |
| if (n == "true") return true; |
| if (n == "false") return false; |
| if (n == null) return null; |
| throw new core.ArgumentError("Invalid boolean: $n"); |
| } |
| |
| if (query.length > 0) { |
| for (var part in query.split("&")) { |
| var keyvalue = part.split("="); |
| addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), |
| core.Uri.decodeQueryComponent(keyvalue[1])); |
| } |
| } |
| unittest.expect(queryMap["fields"].first, unittest.equals(arg_$fields)); |
| |
| var h = { |
| "content-type": "application/json; charset=utf-8", |
| }; |
| var resp = convert.JSON.encode(buildSignJwtResponse()); |
| return new async.Future.value(stringResponse(200, h, resp)); |
| }), true); |
| res |
| .signJwt(arg_request, arg_name, $fields: arg_$fields) |
| .then(unittest.expectAsync1(((api.SignJwtResponse response) { |
| checkSignJwtResponse(response); |
| }))); |
| }); |
| |
| unittest.test("method--testIamPermissions", () { |
| var mock = new HttpServerMock(); |
| api.ProjectsServiceAccountsResourceApi res = |
| new api.IamApi(mock).projects.serviceAccounts; |
| var arg_request = buildTestIamPermissionsRequest(); |
| var arg_resource = "foo"; |
| var arg_$fields = "foo"; |
| mock.register(unittest.expectAsync2((http.BaseRequest req, json) { |
| var obj = new api.TestIamPermissionsRequest.fromJson(json); |
| checkTestIamPermissionsRequest(obj); |
| |
| var path = (req.url).path; |
| var pathOffset = 0; |
| var index; |
| var subPart; |
| unittest.expect( |
| path.substring(pathOffset, pathOffset + 1), unittest.equals("/")); |
| pathOffset += 1; |
| unittest.expect( |
| path.substring(pathOffset, pathOffset + 3), unittest.equals("v1/")); |
| pathOffset += 3; |
| // NOTE: We cannot test reserved expansions due to the inability to reverse the operation; |
| |
| var query = (req.url).query; |
| var queryOffset = 0; |
| var queryMap = {}; |
| addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); |
| parseBool(n) { |
| if (n == "true") return true; |
| if (n == "false") return false; |
| if (n == null) return null; |
| throw new core.ArgumentError("Invalid boolean: $n"); |
| } |
| |
| if (query.length > 0) { |
| for (var part in query.split("&")) { |
| var keyvalue = part.split("="); |
| addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), |
| core.Uri.decodeQueryComponent(keyvalue[1])); |
| } |
| } |
| unittest.expect(queryMap["fields"].first, unittest.equals(arg_$fields)); |
| |
| var h = { |
| "content-type": "application/json; charset=utf-8", |
| }; |
| var resp = convert.JSON.encode(buildTestIamPermissionsResponse()); |
| return new async.Future.value(stringResponse(200, h, resp)); |
| }), true); |
| res |
| .testIamPermissions(arg_request, arg_resource, $fields: arg_$fields) |
| .then( |
| unittest.expectAsync1(((api.TestIamPermissionsResponse response) { |
| checkTestIamPermissionsResponse(response); |
| }))); |
| }); |
| |
| unittest.test("method--update", () { |
| var mock = new HttpServerMock(); |
| api.ProjectsServiceAccountsResourceApi res = |
| new api.IamApi(mock).projects.serviceAccounts; |
| var arg_request = buildServiceAccount(); |
| var arg_name = "foo"; |
| var arg_$fields = "foo"; |
| mock.register(unittest.expectAsync2((http.BaseRequest req, json) { |
| var obj = new api.ServiceAccount.fromJson(json); |
| checkServiceAccount(obj); |
| |
| var path = (req.url).path; |
| var pathOffset = 0; |
| var index; |
| var subPart; |
| unittest.expect( |
| path.substring(pathOffset, pathOffset + 1), unittest.equals("/")); |
| pathOffset += 1; |
| unittest.expect( |
| path.substring(pathOffset, pathOffset + 3), unittest.equals("v1/")); |
| pathOffset += 3; |
| // NOTE: We cannot test reserved expansions due to the inability to reverse the operation; |
| |
| var query = (req.url).query; |
| var queryOffset = 0; |
| var queryMap = {}; |
| addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); |
| parseBool(n) { |
| if (n == "true") return true; |
| if (n == "false") return false; |
| if (n == null) return null; |
| throw new core.ArgumentError("Invalid boolean: $n"); |
| } |
| |
| if (query.length > 0) { |
| for (var part in query.split("&")) { |
| var keyvalue = part.split("="); |
| addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), |
| core.Uri.decodeQueryComponent(keyvalue[1])); |
| } |
| } |
| unittest.expect(queryMap["fields"].first, unittest.equals(arg_$fields)); |
| |
| var h = { |
| "content-type": "application/json; charset=utf-8", |
| }; |
| var resp = convert.JSON.encode(buildServiceAccount()); |
| return new async.Future.value(stringResponse(200, h, resp)); |
| }), true); |
| res |
| .update(arg_request, arg_name, $fields: arg_$fields) |
| .then(unittest.expectAsync1(((api.ServiceAccount response) { |
| checkServiceAccount(response); |
| }))); |
| }); |
| }); |
| |
| unittest.group("resource-ProjectsServiceAccountsKeysResourceApi", () { |
| unittest.test("method--create", () { |
| var mock = new HttpServerMock(); |
| api.ProjectsServiceAccountsKeysResourceApi res = |
| new api.IamApi(mock).projects.serviceAccounts.keys; |
| var arg_request = buildCreateServiceAccountKeyRequest(); |
| var arg_name = "foo"; |
| var arg_$fields = "foo"; |
| mock.register(unittest.expectAsync2((http.BaseRequest req, json) { |
| var obj = new api.CreateServiceAccountKeyRequest.fromJson(json); |
| checkCreateServiceAccountKeyRequest(obj); |
| |
| var path = (req.url).path; |
| var pathOffset = 0; |
| var index; |
| var subPart; |
| unittest.expect( |
| path.substring(pathOffset, pathOffset + 1), unittest.equals("/")); |
| pathOffset += 1; |
| unittest.expect( |
| path.substring(pathOffset, pathOffset + 3), unittest.equals("v1/")); |
| pathOffset += 3; |
| // NOTE: We cannot test reserved expansions due to the inability to reverse the operation; |
| |
| var query = (req.url).query; |
| var queryOffset = 0; |
| var queryMap = {}; |
| addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); |
| parseBool(n) { |
| if (n == "true") return true; |
| if (n == "false") return false; |
| if (n == null) return null; |
| throw new core.ArgumentError("Invalid boolean: $n"); |
| } |
| |
| if (query.length > 0) { |
| for (var part in query.split("&")) { |
| var keyvalue = part.split("="); |
| addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), |
| core.Uri.decodeQueryComponent(keyvalue[1])); |
| } |
| } |
| unittest.expect(queryMap["fields"].first, unittest.equals(arg_$fields)); |
| |
| var h = { |
| "content-type": "application/json; charset=utf-8", |
| }; |
| var resp = convert.JSON.encode(buildServiceAccountKey()); |
| return new async.Future.value(stringResponse(200, h, resp)); |
| }), true); |
| res |
| .create(arg_request, arg_name, $fields: arg_$fields) |
| .then(unittest.expectAsync1(((api.ServiceAccountKey response) { |
| checkServiceAccountKey(response); |
| }))); |
| }); |
| |
| unittest.test("method--delete", () { |
| var mock = new HttpServerMock(); |
| api.ProjectsServiceAccountsKeysResourceApi res = |
| new api.IamApi(mock).projects.serviceAccounts.keys; |
| var arg_name = "foo"; |
| var arg_$fields = "foo"; |
| mock.register(unittest.expectAsync2((http.BaseRequest req, json) { |
| var path = (req.url).path; |
| var pathOffset = 0; |
| var index; |
| var subPart; |
| unittest.expect( |
| path.substring(pathOffset, pathOffset + 1), unittest.equals("/")); |
| pathOffset += 1; |
| unittest.expect( |
| path.substring(pathOffset, pathOffset + 3), unittest.equals("v1/")); |
| pathOffset += 3; |
| // NOTE: We cannot test reserved expansions due to the inability to reverse the operation; |
| |
| var query = (req.url).query; |
| var queryOffset = 0; |
| var queryMap = {}; |
| addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); |
| parseBool(n) { |
| if (n == "true") return true; |
| if (n == "false") return false; |
| if (n == null) return null; |
| throw new core.ArgumentError("Invalid boolean: $n"); |
| } |
| |
| if (query.length > 0) { |
| for (var part in query.split("&")) { |
| var keyvalue = part.split("="); |
| addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), |
| core.Uri.decodeQueryComponent(keyvalue[1])); |
| } |
| } |
| unittest.expect(queryMap["fields"].first, unittest.equals(arg_$fields)); |
| |
| var h = { |
| "content-type": "application/json; charset=utf-8", |
| }; |
| var resp = convert.JSON.encode(buildEmpty()); |
| return new async.Future.value(stringResponse(200, h, resp)); |
| }), true); |
| res |
| .delete(arg_name, $fields: arg_$fields) |
| .then(unittest.expectAsync1(((api.Empty response) { |
| checkEmpty(response); |
| }))); |
| }); |
| |
| unittest.test("method--get", () { |
| var mock = new HttpServerMock(); |
| api.ProjectsServiceAccountsKeysResourceApi res = |
| new api.IamApi(mock).projects.serviceAccounts.keys; |
| var arg_name = "foo"; |
| var arg_publicKeyType = "foo"; |
| var arg_$fields = "foo"; |
| mock.register(unittest.expectAsync2((http.BaseRequest req, json) { |
| var path = (req.url).path; |
| var pathOffset = 0; |
| var index; |
| var subPart; |
| unittest.expect( |
| path.substring(pathOffset, pathOffset + 1), unittest.equals("/")); |
| pathOffset += 1; |
| unittest.expect( |
| path.substring(pathOffset, pathOffset + 3), unittest.equals("v1/")); |
| pathOffset += 3; |
| // NOTE: We cannot test reserved expansions due to the inability to reverse the operation; |
| |
| var query = (req.url).query; |
| var queryOffset = 0; |
| var queryMap = {}; |
| addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); |
| parseBool(n) { |
| if (n == "true") return true; |
| if (n == "false") return false; |
| if (n == null) return null; |
| throw new core.ArgumentError("Invalid boolean: $n"); |
| } |
| |
| if (query.length > 0) { |
| for (var part in query.split("&")) { |
| var keyvalue = part.split("="); |
| addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), |
| core.Uri.decodeQueryComponent(keyvalue[1])); |
| } |
| } |
| unittest.expect(queryMap["publicKeyType"].first, |
| unittest.equals(arg_publicKeyType)); |
| unittest.expect(queryMap["fields"].first, unittest.equals(arg_$fields)); |
| |
| var h = { |
| "content-type": "application/json; charset=utf-8", |
| }; |
| var resp = convert.JSON.encode(buildServiceAccountKey()); |
| return new async.Future.value(stringResponse(200, h, resp)); |
| }), true); |
| res |
| .get(arg_name, publicKeyType: arg_publicKeyType, $fields: arg_$fields) |
| .then(unittest.expectAsync1(((api.ServiceAccountKey response) { |
| checkServiceAccountKey(response); |
| }))); |
| }); |
| |
| unittest.test("method--list", () { |
| var mock = new HttpServerMock(); |
| api.ProjectsServiceAccountsKeysResourceApi res = |
| new api.IamApi(mock).projects.serviceAccounts.keys; |
| var arg_name = "foo"; |
| var arg_keyTypes = buildUnnamed1302(); |
| var arg_$fields = "foo"; |
| mock.register(unittest.expectAsync2((http.BaseRequest req, json) { |
| var path = (req.url).path; |
| var pathOffset = 0; |
| var index; |
| var subPart; |
| unittest.expect( |
| path.substring(pathOffset, pathOffset + 1), unittest.equals("/")); |
| pathOffset += 1; |
| unittest.expect( |
| path.substring(pathOffset, pathOffset + 3), unittest.equals("v1/")); |
| pathOffset += 3; |
| // NOTE: We cannot test reserved expansions due to the inability to reverse the operation; |
| |
| var query = (req.url).query; |
| var queryOffset = 0; |
| var queryMap = {}; |
| addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); |
| parseBool(n) { |
| if (n == "true") return true; |
| if (n == "false") return false; |
| if (n == null) return null; |
| throw new core.ArgumentError("Invalid boolean: $n"); |
| } |
| |
| if (query.length > 0) { |
| for (var part in query.split("&")) { |
| var keyvalue = part.split("="); |
| addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), |
| core.Uri.decodeQueryComponent(keyvalue[1])); |
| } |
| } |
| unittest.expect(queryMap["keyTypes"], unittest.equals(arg_keyTypes)); |
| unittest.expect(queryMap["fields"].first, unittest.equals(arg_$fields)); |
| |
| var h = { |
| "content-type": "application/json; charset=utf-8", |
| }; |
| var resp = convert.JSON.encode(buildListServiceAccountKeysResponse()); |
| return new async.Future.value(stringResponse(200, h, resp)); |
| }), true); |
| res.list(arg_name, keyTypes: arg_keyTypes, $fields: arg_$fields).then( |
| unittest.expectAsync1(((api.ListServiceAccountKeysResponse response) { |
| checkListServiceAccountKeysResponse(response); |
| }))); |
| }); |
| }); |
| |
| unittest.group("resource-RolesResourceApi", () { |
| unittest.test("method--get", () { |
| var mock = new HttpServerMock(); |
| api.RolesResourceApi res = new api.IamApi(mock).roles; |
| var arg_name = "foo"; |
| var arg_$fields = "foo"; |
| mock.register(unittest.expectAsync2((http.BaseRequest req, json) { |
| var path = (req.url).path; |
| var pathOffset = 0; |
| var index; |
| var subPart; |
| unittest.expect( |
| path.substring(pathOffset, pathOffset + 1), unittest.equals("/")); |
| pathOffset += 1; |
| unittest.expect( |
| path.substring(pathOffset, pathOffset + 3), unittest.equals("v1/")); |
| pathOffset += 3; |
| // NOTE: We cannot test reserved expansions due to the inability to reverse the operation; |
| |
| var query = (req.url).query; |
| var queryOffset = 0; |
| var queryMap = {}; |
| addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); |
| parseBool(n) { |
| if (n == "true") return true; |
| if (n == "false") return false; |
| if (n == null) return null; |
| throw new core.ArgumentError("Invalid boolean: $n"); |
| } |
| |
| if (query.length > 0) { |
| for (var part in query.split("&")) { |
| var keyvalue = part.split("="); |
| addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), |
| core.Uri.decodeQueryComponent(keyvalue[1])); |
| } |
| } |
| unittest.expect(queryMap["fields"].first, unittest.equals(arg_$fields)); |
| |
| var h = { |
| "content-type": "application/json; charset=utf-8", |
| }; |
| var resp = convert.JSON.encode(buildRole()); |
| return new async.Future.value(stringResponse(200, h, resp)); |
| }), true); |
| res |
| .get(arg_name, $fields: arg_$fields) |
| .then(unittest.expectAsync1(((api.Role response) { |
| checkRole(response); |
| }))); |
| }); |
| |
| unittest.test("method--list", () { |
| var mock = new HttpServerMock(); |
| api.RolesResourceApi res = new api.IamApi(mock).roles; |
| var arg_pageToken = "foo"; |
| var arg_pageSize = 42; |
| var arg_view = "foo"; |
| var arg_parent = "foo"; |
| var arg_showDeleted = true; |
| var arg_$fields = "foo"; |
| mock.register(unittest.expectAsync2((http.BaseRequest req, json) { |
| var path = (req.url).path; |
| var pathOffset = 0; |
| var index; |
| var subPart; |
| unittest.expect( |
| path.substring(pathOffset, pathOffset + 1), unittest.equals("/")); |
| pathOffset += 1; |
| unittest.expect(path.substring(pathOffset, pathOffset + 8), |
| unittest.equals("v1/roles")); |
| pathOffset += 8; |
| |
| var query = (req.url).query; |
| var queryOffset = 0; |
| var queryMap = {}; |
| addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); |
| parseBool(n) { |
| if (n == "true") return true; |
| if (n == "false") return false; |
| if (n == null) return null; |
| throw new core.ArgumentError("Invalid boolean: $n"); |
| } |
| |
| if (query.length > 0) { |
| for (var part in query.split("&")) { |
| var keyvalue = part.split("="); |
| addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), |
| core.Uri.decodeQueryComponent(keyvalue[1])); |
| } |
| } |
| unittest.expect( |
| queryMap["pageToken"].first, unittest.equals(arg_pageToken)); |
| unittest.expect(core.int.parse(queryMap["pageSize"].first), |
| unittest.equals(arg_pageSize)); |
| unittest.expect(queryMap["view"].first, unittest.equals(arg_view)); |
| unittest.expect(queryMap["parent"].first, unittest.equals(arg_parent)); |
| unittest.expect( |
| queryMap["showDeleted"].first, unittest.equals("$arg_showDeleted")); |
| unittest.expect(queryMap["fields"].first, unittest.equals(arg_$fields)); |
| |
| var h = { |
| "content-type": "application/json; charset=utf-8", |
| }; |
| var resp = convert.JSON.encode(buildListRolesResponse()); |
| return new async.Future.value(stringResponse(200, h, resp)); |
| }), true); |
| res |
| .list( |
| pageToken: arg_pageToken, |
| pageSize: arg_pageSize, |
| view: arg_view, |
| parent: arg_parent, |
| showDeleted: arg_showDeleted, |
| $fields: arg_$fields) |
| .then(unittest.expectAsync1(((api.ListRolesResponse response) { |
| checkListRolesResponse(response); |
| }))); |
| }); |
| |
| unittest.test("method--queryGrantableRoles", () { |
| var mock = new HttpServerMock(); |
| api.RolesResourceApi res = new api.IamApi(mock).roles; |
| var arg_request = buildQueryGrantableRolesRequest(); |
| var arg_$fields = "foo"; |
| mock.register(unittest.expectAsync2((http.BaseRequest req, json) { |
| var obj = new api.QueryGrantableRolesRequest.fromJson(json); |
| checkQueryGrantableRolesRequest(obj); |
| |
| var path = (req.url).path; |
| var pathOffset = 0; |
| var index; |
| var subPart; |
| unittest.expect( |
| path.substring(pathOffset, pathOffset + 1), unittest.equals("/")); |
| pathOffset += 1; |
| unittest.expect(path.substring(pathOffset, pathOffset + 28), |
| unittest.equals("v1/roles:queryGrantableRoles")); |
| pathOffset += 28; |
| |
| var query = (req.url).query; |
| var queryOffset = 0; |
| var queryMap = {}; |
| addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); |
| parseBool(n) { |
| if (n == "true") return true; |
| if (n == "false") return false; |
| if (n == null) return null; |
| throw new core.ArgumentError("Invalid boolean: $n"); |
| } |
| |
| if (query.length > 0) { |
| for (var part in query.split("&")) { |
| var keyvalue = part.split("="); |
| addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), |
| core.Uri.decodeQueryComponent(keyvalue[1])); |
| } |
| } |
| unittest.expect(queryMap["fields"].first, unittest.equals(arg_$fields)); |
| |
| var h = { |
| "content-type": "application/json; charset=utf-8", |
| }; |
| var resp = convert.JSON.encode(buildQueryGrantableRolesResponse()); |
| return new async.Future.value(stringResponse(200, h, resp)); |
| }), true); |
| res.queryGrantableRoles(arg_request, $fields: arg_$fields).then( |
| unittest.expectAsync1(((api.QueryGrantableRolesResponse response) { |
| checkQueryGrantableRolesResponse(response); |
| }))); |
| }); |
| }); |
| } |