blob: 28077b1e17c940d6eb25eaddd95356935d154a73 [file] [log] [blame]
library googleapis.cloudkms.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/cloudkms/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);
}
buildUnnamed1435() {
var o = new core.List<api.AuditLogConfig>();
o.add(buildAuditLogConfig());
o.add(buildAuditLogConfig());
return o;
}
checkUnnamed1435(core.List<api.AuditLogConfig> o) {
unittest.expect(o, unittest.hasLength(2));
checkAuditLogConfig(o[0]);
checkAuditLogConfig(o[1]);
}
buildUnnamed1436() {
var o = new core.List<core.String>();
o.add("foo");
o.add("foo");
return o;
}
checkUnnamed1436(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 buildCounterAuditConfig = 0;
buildAuditConfig() {
var o = new api.AuditConfig();
buildCounterAuditConfig++;
if (buildCounterAuditConfig < 3) {
o.auditLogConfigs = buildUnnamed1435();
o.exemptedMembers = buildUnnamed1436();
o.service = "foo";
}
buildCounterAuditConfig--;
return o;
}
checkAuditConfig(api.AuditConfig o) {
buildCounterAuditConfig++;
if (buildCounterAuditConfig < 3) {
checkUnnamed1435(o.auditLogConfigs);
checkUnnamed1436(o.exemptedMembers);
unittest.expect(o.service, unittest.equals('foo'));
}
buildCounterAuditConfig--;
}
buildUnnamed1437() {
var o = new core.List<core.String>();
o.add("foo");
o.add("foo");
return o;
}
checkUnnamed1437(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 buildCounterAuditLogConfig = 0;
buildAuditLogConfig() {
var o = new api.AuditLogConfig();
buildCounterAuditLogConfig++;
if (buildCounterAuditLogConfig < 3) {
o.exemptedMembers = buildUnnamed1437();
o.logType = "foo";
}
buildCounterAuditLogConfig--;
return o;
}
checkAuditLogConfig(api.AuditLogConfig o) {
buildCounterAuditLogConfig++;
if (buildCounterAuditLogConfig < 3) {
checkUnnamed1437(o.exemptedMembers);
unittest.expect(o.logType, unittest.equals('foo'));
}
buildCounterAuditLogConfig--;
}
buildUnnamed1438() {
var o = new core.List<core.String>();
o.add("foo");
o.add("foo");
return o;
}
checkUnnamed1438(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.condition = buildExpr();
o.members = buildUnnamed1438();
o.role = "foo";
}
buildCounterBinding--;
return o;
}
checkBinding(api.Binding o) {
buildCounterBinding++;
if (buildCounterBinding < 3) {
checkExpr(o.condition);
checkUnnamed1438(o.members);
unittest.expect(o.role, unittest.equals('foo'));
}
buildCounterBinding--;
}
buildUnnamed1439() {
var o = new core.Map<core.String, core.String>();
o["x"] = "foo";
o["y"] = "foo";
return o;
}
checkUnnamed1439(core.Map<core.String, core.String> o) {
unittest.expect(o, unittest.hasLength(2));
unittest.expect(o["x"], unittest.equals('foo'));
unittest.expect(o["y"], unittest.equals('foo'));
}
core.int buildCounterCryptoKey = 0;
buildCryptoKey() {
var o = new api.CryptoKey();
buildCounterCryptoKey++;
if (buildCounterCryptoKey < 3) {
o.createTime = "foo";
o.labels = buildUnnamed1439();
o.name = "foo";
o.nextRotationTime = "foo";
o.primary = buildCryptoKeyVersion();
o.purpose = "foo";
o.rotationPeriod = "foo";
}
buildCounterCryptoKey--;
return o;
}
checkCryptoKey(api.CryptoKey o) {
buildCounterCryptoKey++;
if (buildCounterCryptoKey < 3) {
unittest.expect(o.createTime, unittest.equals('foo'));
checkUnnamed1439(o.labels);
unittest.expect(o.name, unittest.equals('foo'));
unittest.expect(o.nextRotationTime, unittest.equals('foo'));
checkCryptoKeyVersion(o.primary);
unittest.expect(o.purpose, unittest.equals('foo'));
unittest.expect(o.rotationPeriod, unittest.equals('foo'));
}
buildCounterCryptoKey--;
}
core.int buildCounterCryptoKeyVersion = 0;
buildCryptoKeyVersion() {
var o = new api.CryptoKeyVersion();
buildCounterCryptoKeyVersion++;
if (buildCounterCryptoKeyVersion < 3) {
o.createTime = "foo";
o.destroyEventTime = "foo";
o.destroyTime = "foo";
o.name = "foo";
o.state = "foo";
}
buildCounterCryptoKeyVersion--;
return o;
}
checkCryptoKeyVersion(api.CryptoKeyVersion o) {
buildCounterCryptoKeyVersion++;
if (buildCounterCryptoKeyVersion < 3) {
unittest.expect(o.createTime, unittest.equals('foo'));
unittest.expect(o.destroyEventTime, unittest.equals('foo'));
unittest.expect(o.destroyTime, unittest.equals('foo'));
unittest.expect(o.name, unittest.equals('foo'));
unittest.expect(o.state, unittest.equals('foo'));
}
buildCounterCryptoKeyVersion--;
}
core.int buildCounterDecryptRequest = 0;
buildDecryptRequest() {
var o = new api.DecryptRequest();
buildCounterDecryptRequest++;
if (buildCounterDecryptRequest < 3) {
o.additionalAuthenticatedData = "foo";
o.ciphertext = "foo";
}
buildCounterDecryptRequest--;
return o;
}
checkDecryptRequest(api.DecryptRequest o) {
buildCounterDecryptRequest++;
if (buildCounterDecryptRequest < 3) {
unittest.expect(o.additionalAuthenticatedData, unittest.equals('foo'));
unittest.expect(o.ciphertext, unittest.equals('foo'));
}
buildCounterDecryptRequest--;
}
core.int buildCounterDecryptResponse = 0;
buildDecryptResponse() {
var o = new api.DecryptResponse();
buildCounterDecryptResponse++;
if (buildCounterDecryptResponse < 3) {
o.plaintext = "foo";
}
buildCounterDecryptResponse--;
return o;
}
checkDecryptResponse(api.DecryptResponse o) {
buildCounterDecryptResponse++;
if (buildCounterDecryptResponse < 3) {
unittest.expect(o.plaintext, unittest.equals('foo'));
}
buildCounterDecryptResponse--;
}
core.int buildCounterDestroyCryptoKeyVersionRequest = 0;
buildDestroyCryptoKeyVersionRequest() {
var o = new api.DestroyCryptoKeyVersionRequest();
buildCounterDestroyCryptoKeyVersionRequest++;
if (buildCounterDestroyCryptoKeyVersionRequest < 3) {}
buildCounterDestroyCryptoKeyVersionRequest--;
return o;
}
checkDestroyCryptoKeyVersionRequest(api.DestroyCryptoKeyVersionRequest o) {
buildCounterDestroyCryptoKeyVersionRequest++;
if (buildCounterDestroyCryptoKeyVersionRequest < 3) {}
buildCounterDestroyCryptoKeyVersionRequest--;
}
core.int buildCounterEncryptRequest = 0;
buildEncryptRequest() {
var o = new api.EncryptRequest();
buildCounterEncryptRequest++;
if (buildCounterEncryptRequest < 3) {
o.additionalAuthenticatedData = "foo";
o.plaintext = "foo";
}
buildCounterEncryptRequest--;
return o;
}
checkEncryptRequest(api.EncryptRequest o) {
buildCounterEncryptRequest++;
if (buildCounterEncryptRequest < 3) {
unittest.expect(o.additionalAuthenticatedData, unittest.equals('foo'));
unittest.expect(o.plaintext, unittest.equals('foo'));
}
buildCounterEncryptRequest--;
}
core.int buildCounterEncryptResponse = 0;
buildEncryptResponse() {
var o = new api.EncryptResponse();
buildCounterEncryptResponse++;
if (buildCounterEncryptResponse < 3) {
o.ciphertext = "foo";
o.name = "foo";
}
buildCounterEncryptResponse--;
return o;
}
checkEncryptResponse(api.EncryptResponse o) {
buildCounterEncryptResponse++;
if (buildCounterEncryptResponse < 3) {
unittest.expect(o.ciphertext, unittest.equals('foo'));
unittest.expect(o.name, unittest.equals('foo'));
}
buildCounterEncryptResponse--;
}
core.int buildCounterExpr = 0;
buildExpr() {
var o = new api.Expr();
buildCounterExpr++;
if (buildCounterExpr < 3) {
o.description = "foo";
o.expression = "foo";
o.location = "foo";
o.title = "foo";
}
buildCounterExpr--;
return o;
}
checkExpr(api.Expr o) {
buildCounterExpr++;
if (buildCounterExpr < 3) {
unittest.expect(o.description, unittest.equals('foo'));
unittest.expect(o.expression, unittest.equals('foo'));
unittest.expect(o.location, unittest.equals('foo'));
unittest.expect(o.title, unittest.equals('foo'));
}
buildCounterExpr--;
}
core.int buildCounterKeyRing = 0;
buildKeyRing() {
var o = new api.KeyRing();
buildCounterKeyRing++;
if (buildCounterKeyRing < 3) {
o.createTime = "foo";
o.name = "foo";
}
buildCounterKeyRing--;
return o;
}
checkKeyRing(api.KeyRing o) {
buildCounterKeyRing++;
if (buildCounterKeyRing < 3) {
unittest.expect(o.createTime, unittest.equals('foo'));
unittest.expect(o.name, unittest.equals('foo'));
}
buildCounterKeyRing--;
}
buildUnnamed1440() {
var o = new core.List<api.CryptoKeyVersion>();
o.add(buildCryptoKeyVersion());
o.add(buildCryptoKeyVersion());
return o;
}
checkUnnamed1440(core.List<api.CryptoKeyVersion> o) {
unittest.expect(o, unittest.hasLength(2));
checkCryptoKeyVersion(o[0]);
checkCryptoKeyVersion(o[1]);
}
core.int buildCounterListCryptoKeyVersionsResponse = 0;
buildListCryptoKeyVersionsResponse() {
var o = new api.ListCryptoKeyVersionsResponse();
buildCounterListCryptoKeyVersionsResponse++;
if (buildCounterListCryptoKeyVersionsResponse < 3) {
o.cryptoKeyVersions = buildUnnamed1440();
o.nextPageToken = "foo";
o.totalSize = 42;
}
buildCounterListCryptoKeyVersionsResponse--;
return o;
}
checkListCryptoKeyVersionsResponse(api.ListCryptoKeyVersionsResponse o) {
buildCounterListCryptoKeyVersionsResponse++;
if (buildCounterListCryptoKeyVersionsResponse < 3) {
checkUnnamed1440(o.cryptoKeyVersions);
unittest.expect(o.nextPageToken, unittest.equals('foo'));
unittest.expect(o.totalSize, unittest.equals(42));
}
buildCounterListCryptoKeyVersionsResponse--;
}
buildUnnamed1441() {
var o = new core.List<api.CryptoKey>();
o.add(buildCryptoKey());
o.add(buildCryptoKey());
return o;
}
checkUnnamed1441(core.List<api.CryptoKey> o) {
unittest.expect(o, unittest.hasLength(2));
checkCryptoKey(o[0]);
checkCryptoKey(o[1]);
}
core.int buildCounterListCryptoKeysResponse = 0;
buildListCryptoKeysResponse() {
var o = new api.ListCryptoKeysResponse();
buildCounterListCryptoKeysResponse++;
if (buildCounterListCryptoKeysResponse < 3) {
o.cryptoKeys = buildUnnamed1441();
o.nextPageToken = "foo";
o.totalSize = 42;
}
buildCounterListCryptoKeysResponse--;
return o;
}
checkListCryptoKeysResponse(api.ListCryptoKeysResponse o) {
buildCounterListCryptoKeysResponse++;
if (buildCounterListCryptoKeysResponse < 3) {
checkUnnamed1441(o.cryptoKeys);
unittest.expect(o.nextPageToken, unittest.equals('foo'));
unittest.expect(o.totalSize, unittest.equals(42));
}
buildCounterListCryptoKeysResponse--;
}
buildUnnamed1442() {
var o = new core.List<api.KeyRing>();
o.add(buildKeyRing());
o.add(buildKeyRing());
return o;
}
checkUnnamed1442(core.List<api.KeyRing> o) {
unittest.expect(o, unittest.hasLength(2));
checkKeyRing(o[0]);
checkKeyRing(o[1]);
}
core.int buildCounterListKeyRingsResponse = 0;
buildListKeyRingsResponse() {
var o = new api.ListKeyRingsResponse();
buildCounterListKeyRingsResponse++;
if (buildCounterListKeyRingsResponse < 3) {
o.keyRings = buildUnnamed1442();
o.nextPageToken = "foo";
o.totalSize = 42;
}
buildCounterListKeyRingsResponse--;
return o;
}
checkListKeyRingsResponse(api.ListKeyRingsResponse o) {
buildCounterListKeyRingsResponse++;
if (buildCounterListKeyRingsResponse < 3) {
checkUnnamed1442(o.keyRings);
unittest.expect(o.nextPageToken, unittest.equals('foo'));
unittest.expect(o.totalSize, unittest.equals(42));
}
buildCounterListKeyRingsResponse--;
}
buildUnnamed1443() {
var o = new core.List<api.Location>();
o.add(buildLocation());
o.add(buildLocation());
return o;
}
checkUnnamed1443(core.List<api.Location> o) {
unittest.expect(o, unittest.hasLength(2));
checkLocation(o[0]);
checkLocation(o[1]);
}
core.int buildCounterListLocationsResponse = 0;
buildListLocationsResponse() {
var o = new api.ListLocationsResponse();
buildCounterListLocationsResponse++;
if (buildCounterListLocationsResponse < 3) {
o.locations = buildUnnamed1443();
o.nextPageToken = "foo";
}
buildCounterListLocationsResponse--;
return o;
}
checkListLocationsResponse(api.ListLocationsResponse o) {
buildCounterListLocationsResponse++;
if (buildCounterListLocationsResponse < 3) {
checkUnnamed1443(o.locations);
unittest.expect(o.nextPageToken, unittest.equals('foo'));
}
buildCounterListLocationsResponse--;
}
buildUnnamed1444() {
var o = new core.Map<core.String, core.String>();
o["x"] = "foo";
o["y"] = "foo";
return o;
}
checkUnnamed1444(core.Map<core.String, core.String> o) {
unittest.expect(o, unittest.hasLength(2));
unittest.expect(o["x"], unittest.equals('foo'));
unittest.expect(o["y"], unittest.equals('foo'));
}
buildUnnamed1445() {
var o = new core.Map<core.String, core.Object>();
o["x"] = {
'list': [1, 2, 3],
'bool': true,
'string': 'foo'
};
o["y"] = {
'list': [1, 2, 3],
'bool': true,
'string': 'foo'
};
return o;
}
checkUnnamed1445(core.Map<core.String, core.Object> o) {
unittest.expect(o, unittest.hasLength(2));
var casted1 = (o["x"]) as core.Map;
unittest.expect(casted1, unittest.hasLength(3));
unittest.expect(casted1["list"], unittest.equals([1, 2, 3]));
unittest.expect(casted1["bool"], unittest.equals(true));
unittest.expect(casted1["string"], unittest.equals('foo'));
var casted2 = (o["y"]) as core.Map;
unittest.expect(casted2, unittest.hasLength(3));
unittest.expect(casted2["list"], unittest.equals([1, 2, 3]));
unittest.expect(casted2["bool"], unittest.equals(true));
unittest.expect(casted2["string"], unittest.equals('foo'));
}
core.int buildCounterLocation = 0;
buildLocation() {
var o = new api.Location();
buildCounterLocation++;
if (buildCounterLocation < 3) {
o.labels = buildUnnamed1444();
o.locationId = "foo";
o.metadata = buildUnnamed1445();
o.name = "foo";
}
buildCounterLocation--;
return o;
}
checkLocation(api.Location o) {
buildCounterLocation++;
if (buildCounterLocation < 3) {
checkUnnamed1444(o.labels);
unittest.expect(o.locationId, unittest.equals('foo'));
checkUnnamed1445(o.metadata);
unittest.expect(o.name, unittest.equals('foo'));
}
buildCounterLocation--;
}
buildUnnamed1446() {
var o = new core.List<api.AuditConfig>();
o.add(buildAuditConfig());
o.add(buildAuditConfig());
return o;
}
checkUnnamed1446(core.List<api.AuditConfig> o) {
unittest.expect(o, unittest.hasLength(2));
checkAuditConfig(o[0]);
checkAuditConfig(o[1]);
}
buildUnnamed1447() {
var o = new core.List<api.Binding>();
o.add(buildBinding());
o.add(buildBinding());
return o;
}
checkUnnamed1447(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.auditConfigs = buildUnnamed1446();
o.bindings = buildUnnamed1447();
o.etag = "foo";
o.iamOwned = true;
o.version = 42;
}
buildCounterPolicy--;
return o;
}
checkPolicy(api.Policy o) {
buildCounterPolicy++;
if (buildCounterPolicy < 3) {
checkUnnamed1446(o.auditConfigs);
checkUnnamed1447(o.bindings);
unittest.expect(o.etag, unittest.equals('foo'));
unittest.expect(o.iamOwned, unittest.isTrue);
unittest.expect(o.version, unittest.equals(42));
}
buildCounterPolicy--;
}
core.int buildCounterRestoreCryptoKeyVersionRequest = 0;
buildRestoreCryptoKeyVersionRequest() {
var o = new api.RestoreCryptoKeyVersionRequest();
buildCounterRestoreCryptoKeyVersionRequest++;
if (buildCounterRestoreCryptoKeyVersionRequest < 3) {}
buildCounterRestoreCryptoKeyVersionRequest--;
return o;
}
checkRestoreCryptoKeyVersionRequest(api.RestoreCryptoKeyVersionRequest o) {
buildCounterRestoreCryptoKeyVersionRequest++;
if (buildCounterRestoreCryptoKeyVersionRequest < 3) {}
buildCounterRestoreCryptoKeyVersionRequest--;
}
core.int buildCounterSetIamPolicyRequest = 0;
buildSetIamPolicyRequest() {
var o = new api.SetIamPolicyRequest();
buildCounterSetIamPolicyRequest++;
if (buildCounterSetIamPolicyRequest < 3) {
o.policy = buildPolicy();
o.updateMask = "foo";
}
buildCounterSetIamPolicyRequest--;
return o;
}
checkSetIamPolicyRequest(api.SetIamPolicyRequest o) {
buildCounterSetIamPolicyRequest++;
if (buildCounterSetIamPolicyRequest < 3) {
checkPolicy(o.policy);
unittest.expect(o.updateMask, unittest.equals('foo'));
}
buildCounterSetIamPolicyRequest--;
}
buildUnnamed1448() {
var o = new core.List<core.String>();
o.add("foo");
o.add("foo");
return o;
}
checkUnnamed1448(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 = buildUnnamed1448();
}
buildCounterTestIamPermissionsRequest--;
return o;
}
checkTestIamPermissionsRequest(api.TestIamPermissionsRequest o) {
buildCounterTestIamPermissionsRequest++;
if (buildCounterTestIamPermissionsRequest < 3) {
checkUnnamed1448(o.permissions);
}
buildCounterTestIamPermissionsRequest--;
}
buildUnnamed1449() {
var o = new core.List<core.String>();
o.add("foo");
o.add("foo");
return o;
}
checkUnnamed1449(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 = buildUnnamed1449();
}
buildCounterTestIamPermissionsResponse--;
return o;
}
checkTestIamPermissionsResponse(api.TestIamPermissionsResponse o) {
buildCounterTestIamPermissionsResponse++;
if (buildCounterTestIamPermissionsResponse < 3) {
checkUnnamed1449(o.permissions);
}
buildCounterTestIamPermissionsResponse--;
}
core.int buildCounterUpdateCryptoKeyPrimaryVersionRequest = 0;
buildUpdateCryptoKeyPrimaryVersionRequest() {
var o = new api.UpdateCryptoKeyPrimaryVersionRequest();
buildCounterUpdateCryptoKeyPrimaryVersionRequest++;
if (buildCounterUpdateCryptoKeyPrimaryVersionRequest < 3) {
o.cryptoKeyVersionId = "foo";
}
buildCounterUpdateCryptoKeyPrimaryVersionRequest--;
return o;
}
checkUpdateCryptoKeyPrimaryVersionRequest(
api.UpdateCryptoKeyPrimaryVersionRequest o) {
buildCounterUpdateCryptoKeyPrimaryVersionRequest++;
if (buildCounterUpdateCryptoKeyPrimaryVersionRequest < 3) {
unittest.expect(o.cryptoKeyVersionId, unittest.equals('foo'));
}
buildCounterUpdateCryptoKeyPrimaryVersionRequest--;
}
main() {
unittest.group("obj-schema-AuditConfig", () {
unittest.test("to-json--from-json", () {
var o = buildAuditConfig();
var od = new api.AuditConfig.fromJson(o.toJson());
checkAuditConfig(od);
});
});
unittest.group("obj-schema-AuditLogConfig", () {
unittest.test("to-json--from-json", () {
var o = buildAuditLogConfig();
var od = new api.AuditLogConfig.fromJson(o.toJson());
checkAuditLogConfig(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-CryptoKey", () {
unittest.test("to-json--from-json", () {
var o = buildCryptoKey();
var od = new api.CryptoKey.fromJson(o.toJson());
checkCryptoKey(od);
});
});
unittest.group("obj-schema-CryptoKeyVersion", () {
unittest.test("to-json--from-json", () {
var o = buildCryptoKeyVersion();
var od = new api.CryptoKeyVersion.fromJson(o.toJson());
checkCryptoKeyVersion(od);
});
});
unittest.group("obj-schema-DecryptRequest", () {
unittest.test("to-json--from-json", () {
var o = buildDecryptRequest();
var od = new api.DecryptRequest.fromJson(o.toJson());
checkDecryptRequest(od);
});
});
unittest.group("obj-schema-DecryptResponse", () {
unittest.test("to-json--from-json", () {
var o = buildDecryptResponse();
var od = new api.DecryptResponse.fromJson(o.toJson());
checkDecryptResponse(od);
});
});
unittest.group("obj-schema-DestroyCryptoKeyVersionRequest", () {
unittest.test("to-json--from-json", () {
var o = buildDestroyCryptoKeyVersionRequest();
var od = new api.DestroyCryptoKeyVersionRequest.fromJson(o.toJson());
checkDestroyCryptoKeyVersionRequest(od);
});
});
unittest.group("obj-schema-EncryptRequest", () {
unittest.test("to-json--from-json", () {
var o = buildEncryptRequest();
var od = new api.EncryptRequest.fromJson(o.toJson());
checkEncryptRequest(od);
});
});
unittest.group("obj-schema-EncryptResponse", () {
unittest.test("to-json--from-json", () {
var o = buildEncryptResponse();
var od = new api.EncryptResponse.fromJson(o.toJson());
checkEncryptResponse(od);
});
});
unittest.group("obj-schema-Expr", () {
unittest.test("to-json--from-json", () {
var o = buildExpr();
var od = new api.Expr.fromJson(o.toJson());
checkExpr(od);
});
});
unittest.group("obj-schema-KeyRing", () {
unittest.test("to-json--from-json", () {
var o = buildKeyRing();
var od = new api.KeyRing.fromJson(o.toJson());
checkKeyRing(od);
});
});
unittest.group("obj-schema-ListCryptoKeyVersionsResponse", () {
unittest.test("to-json--from-json", () {
var o = buildListCryptoKeyVersionsResponse();
var od = new api.ListCryptoKeyVersionsResponse.fromJson(o.toJson());
checkListCryptoKeyVersionsResponse(od);
});
});
unittest.group("obj-schema-ListCryptoKeysResponse", () {
unittest.test("to-json--from-json", () {
var o = buildListCryptoKeysResponse();
var od = new api.ListCryptoKeysResponse.fromJson(o.toJson());
checkListCryptoKeysResponse(od);
});
});
unittest.group("obj-schema-ListKeyRingsResponse", () {
unittest.test("to-json--from-json", () {
var o = buildListKeyRingsResponse();
var od = new api.ListKeyRingsResponse.fromJson(o.toJson());
checkListKeyRingsResponse(od);
});
});
unittest.group("obj-schema-ListLocationsResponse", () {
unittest.test("to-json--from-json", () {
var o = buildListLocationsResponse();
var od = new api.ListLocationsResponse.fromJson(o.toJson());
checkListLocationsResponse(od);
});
});
unittest.group("obj-schema-Location", () {
unittest.test("to-json--from-json", () {
var o = buildLocation();
var od = new api.Location.fromJson(o.toJson());
checkLocation(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-RestoreCryptoKeyVersionRequest", () {
unittest.test("to-json--from-json", () {
var o = buildRestoreCryptoKeyVersionRequest();
var od = new api.RestoreCryptoKeyVersionRequest.fromJson(o.toJson());
checkRestoreCryptoKeyVersionRequest(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-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-UpdateCryptoKeyPrimaryVersionRequest", () {
unittest.test("to-json--from-json", () {
var o = buildUpdateCryptoKeyPrimaryVersionRequest();
var od =
new api.UpdateCryptoKeyPrimaryVersionRequest.fromJson(o.toJson());
checkUpdateCryptoKeyPrimaryVersionRequest(od);
});
});
unittest.group("resource-ProjectsLocationsResourceApi", () {
unittest.test("method--get", () {
var mock = new HttpServerMock();
api.ProjectsLocationsResourceApi res =
new api.CloudkmsApi(mock).projects.locations;
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(buildLocation());
return new async.Future.value(stringResponse(200, h, resp));
}), true);
res
.get(arg_name, $fields: arg_$fields)
.then(unittest.expectAsync1(((api.Location response) {
checkLocation(response);
})));
});
unittest.test("method--list", () {
var mock = new HttpServerMock();
api.ProjectsLocationsResourceApi res =
new api.CloudkmsApi(mock).projects.locations;
var arg_name = "foo";
var arg_pageSize = 42;
var arg_filter = "foo";
var arg_pageToken = "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(core.int.parse(queryMap["pageSize"].first),
unittest.equals(arg_pageSize));
unittest.expect(queryMap["filter"].first, unittest.equals(arg_filter));
unittest.expect(
queryMap["pageToken"].first, unittest.equals(arg_pageToken));
unittest.expect(queryMap["fields"].first, unittest.equals(arg_$fields));
var h = {
"content-type": "application/json; charset=utf-8",
};
var resp = convert.JSON.encode(buildListLocationsResponse());
return new async.Future.value(stringResponse(200, h, resp));
}), true);
res
.list(arg_name,
pageSize: arg_pageSize,
filter: arg_filter,
pageToken: arg_pageToken,
$fields: arg_$fields)
.then(unittest.expectAsync1(((api.ListLocationsResponse response) {
checkListLocationsResponse(response);
})));
});
});
unittest.group("resource-ProjectsLocationsKeyRingsResourceApi", () {
unittest.test("method--create", () {
var mock = new HttpServerMock();
api.ProjectsLocationsKeyRingsResourceApi res =
new api.CloudkmsApi(mock).projects.locations.keyRings;
var arg_request = buildKeyRing();
var arg_parent = "foo";
var arg_keyRingId = "foo";
var arg_$fields = "foo";
mock.register(unittest.expectAsync2((http.BaseRequest req, json) {
var obj = new api.KeyRing.fromJson(json);
checkKeyRing(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["keyRingId"].first, unittest.equals(arg_keyRingId));
unittest.expect(queryMap["fields"].first, unittest.equals(arg_$fields));
var h = {
"content-type": "application/json; charset=utf-8",
};
var resp = convert.JSON.encode(buildKeyRing());
return new async.Future.value(stringResponse(200, h, resp));
}), true);
res
.create(arg_request, arg_parent,
keyRingId: arg_keyRingId, $fields: arg_$fields)
.then(unittest.expectAsync1(((api.KeyRing response) {
checkKeyRing(response);
})));
});
unittest.test("method--get", () {
var mock = new HttpServerMock();
api.ProjectsLocationsKeyRingsResourceApi res =
new api.CloudkmsApi(mock).projects.locations.keyRings;
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(buildKeyRing());
return new async.Future.value(stringResponse(200, h, resp));
}), true);
res
.get(arg_name, $fields: arg_$fields)
.then(unittest.expectAsync1(((api.KeyRing response) {
checkKeyRing(response);
})));
});
unittest.test("method--getIamPolicy", () {
var mock = new HttpServerMock();
api.ProjectsLocationsKeyRingsResourceApi res =
new api.CloudkmsApi(mock).projects.locations.keyRings;
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.ProjectsLocationsKeyRingsResourceApi res =
new api.CloudkmsApi(mock).projects.locations.keyRings;
var arg_parent = "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(buildListKeyRingsResponse());
return new async.Future.value(stringResponse(200, h, resp));
}), true);
res
.list(arg_parent,
pageToken: arg_pageToken,
pageSize: arg_pageSize,
$fields: arg_$fields)
.then(unittest.expectAsync1(((api.ListKeyRingsResponse response) {
checkListKeyRingsResponse(response);
})));
});
unittest.test("method--setIamPolicy", () {
var mock = new HttpServerMock();
api.ProjectsLocationsKeyRingsResourceApi res =
new api.CloudkmsApi(mock).projects.locations.keyRings;
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--testIamPermissions", () {
var mock = new HttpServerMock();
api.ProjectsLocationsKeyRingsResourceApi res =
new api.CloudkmsApi(mock).projects.locations.keyRings;
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.group("resource-ProjectsLocationsKeyRingsCryptoKeysResourceApi", () {
unittest.test("method--create", () {
var mock = new HttpServerMock();
api.ProjectsLocationsKeyRingsCryptoKeysResourceApi res =
new api.CloudkmsApi(mock).projects.locations.keyRings.cryptoKeys;
var arg_request = buildCryptoKey();
var arg_parent = "foo";
var arg_cryptoKeyId = "foo";
var arg_$fields = "foo";
mock.register(unittest.expectAsync2((http.BaseRequest req, json) {
var obj = new api.CryptoKey.fromJson(json);
checkCryptoKey(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["cryptoKeyId"].first, unittest.equals(arg_cryptoKeyId));
unittest.expect(queryMap["fields"].first, unittest.equals(arg_$fields));
var h = {
"content-type": "application/json; charset=utf-8",
};
var resp = convert.JSON.encode(buildCryptoKey());
return new async.Future.value(stringResponse(200, h, resp));
}), true);
res
.create(arg_request, arg_parent,
cryptoKeyId: arg_cryptoKeyId, $fields: arg_$fields)
.then(unittest.expectAsync1(((api.CryptoKey response) {
checkCryptoKey(response);
})));
});
unittest.test("method--decrypt", () {
var mock = new HttpServerMock();
api.ProjectsLocationsKeyRingsCryptoKeysResourceApi res =
new api.CloudkmsApi(mock).projects.locations.keyRings.cryptoKeys;
var arg_request = buildDecryptRequest();
var arg_name = "foo";
var arg_$fields = "foo";
mock.register(unittest.expectAsync2((http.BaseRequest req, json) {
var obj = new api.DecryptRequest.fromJson(json);
checkDecryptRequest(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(buildDecryptResponse());
return new async.Future.value(stringResponse(200, h, resp));
}), true);
res
.decrypt(arg_request, arg_name, $fields: arg_$fields)
.then(unittest.expectAsync1(((api.DecryptResponse response) {
checkDecryptResponse(response);
})));
});
unittest.test("method--encrypt", () {
var mock = new HttpServerMock();
api.ProjectsLocationsKeyRingsCryptoKeysResourceApi res =
new api.CloudkmsApi(mock).projects.locations.keyRings.cryptoKeys;
var arg_request = buildEncryptRequest();
var arg_name = "foo";
var arg_$fields = "foo";
mock.register(unittest.expectAsync2((http.BaseRequest req, json) {
var obj = new api.EncryptRequest.fromJson(json);
checkEncryptRequest(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(buildEncryptResponse());
return new async.Future.value(stringResponse(200, h, resp));
}), true);
res
.encrypt(arg_request, arg_name, $fields: arg_$fields)
.then(unittest.expectAsync1(((api.EncryptResponse response) {
checkEncryptResponse(response);
})));
});
unittest.test("method--get", () {
var mock = new HttpServerMock();
api.ProjectsLocationsKeyRingsCryptoKeysResourceApi res =
new api.CloudkmsApi(mock).projects.locations.keyRings.cryptoKeys;
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(buildCryptoKey());
return new async.Future.value(stringResponse(200, h, resp));
}), true);
res
.get(arg_name, $fields: arg_$fields)
.then(unittest.expectAsync1(((api.CryptoKey response) {
checkCryptoKey(response);
})));
});
unittest.test("method--getIamPolicy", () {
var mock = new HttpServerMock();
api.ProjectsLocationsKeyRingsCryptoKeysResourceApi res =
new api.CloudkmsApi(mock).projects.locations.keyRings.cryptoKeys;
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.ProjectsLocationsKeyRingsCryptoKeysResourceApi res =
new api.CloudkmsApi(mock).projects.locations.keyRings.cryptoKeys;
var arg_parent = "foo";
var arg_pageSize = 42;
var arg_pageToken = "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(core.int.parse(queryMap["pageSize"].first),
unittest.equals(arg_pageSize));
unittest.expect(
queryMap["pageToken"].first, unittest.equals(arg_pageToken));
unittest.expect(queryMap["fields"].first, unittest.equals(arg_$fields));
var h = {
"content-type": "application/json; charset=utf-8",
};
var resp = convert.JSON.encode(buildListCryptoKeysResponse());
return new async.Future.value(stringResponse(200, h, resp));
}), true);
res
.list(arg_parent,
pageSize: arg_pageSize,
pageToken: arg_pageToken,
$fields: arg_$fields)
.then(unittest.expectAsync1(((api.ListCryptoKeysResponse response) {
checkListCryptoKeysResponse(response);
})));
});
unittest.test("method--patch", () {
var mock = new HttpServerMock();
api.ProjectsLocationsKeyRingsCryptoKeysResourceApi res =
new api.CloudkmsApi(mock).projects.locations.keyRings.cryptoKeys;
var arg_request = buildCryptoKey();
var arg_name = "foo";
var arg_updateMask = "foo";
var arg_$fields = "foo";
mock.register(unittest.expectAsync2((http.BaseRequest req, json) {
var obj = new api.CryptoKey.fromJson(json);
checkCryptoKey(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(buildCryptoKey());
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.CryptoKey response) {
checkCryptoKey(response);
})));
});
unittest.test("method--setIamPolicy", () {
var mock = new HttpServerMock();
api.ProjectsLocationsKeyRingsCryptoKeysResourceApi res =
new api.CloudkmsApi(mock).projects.locations.keyRings.cryptoKeys;
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--testIamPermissions", () {
var mock = new HttpServerMock();
api.ProjectsLocationsKeyRingsCryptoKeysResourceApi res =
new api.CloudkmsApi(mock).projects.locations.keyRings.cryptoKeys;
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--updatePrimaryVersion", () {
var mock = new HttpServerMock();
api.ProjectsLocationsKeyRingsCryptoKeysResourceApi res =
new api.CloudkmsApi(mock).projects.locations.keyRings.cryptoKeys;
var arg_request = buildUpdateCryptoKeyPrimaryVersionRequest();
var arg_name = "foo";
var arg_$fields = "foo";
mock.register(unittest.expectAsync2((http.BaseRequest req, json) {
var obj = new api.UpdateCryptoKeyPrimaryVersionRequest.fromJson(json);
checkUpdateCryptoKeyPrimaryVersionRequest(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(buildCryptoKey());
return new async.Future.value(stringResponse(200, h, resp));
}), true);
res
.updatePrimaryVersion(arg_request, arg_name, $fields: arg_$fields)
.then(unittest.expectAsync1(((api.CryptoKey response) {
checkCryptoKey(response);
})));
});
});
unittest.group(
"resource-ProjectsLocationsKeyRingsCryptoKeysCryptoKeyVersionsResourceApi",
() {
unittest.test("method--create", () {
var mock = new HttpServerMock();
api.ProjectsLocationsKeyRingsCryptoKeysCryptoKeyVersionsResourceApi res =
new api.CloudkmsApi(mock)
.projects
.locations
.keyRings
.cryptoKeys
.cryptoKeyVersions;
var arg_request = buildCryptoKeyVersion();
var arg_parent = "foo";
var arg_$fields = "foo";
mock.register(unittest.expectAsync2((http.BaseRequest req, json) {
var obj = new api.CryptoKeyVersion.fromJson(json);
checkCryptoKeyVersion(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(buildCryptoKeyVersion());
return new async.Future.value(stringResponse(200, h, resp));
}), true);
res
.create(arg_request, arg_parent, $fields: arg_$fields)
.then(unittest.expectAsync1(((api.CryptoKeyVersion response) {
checkCryptoKeyVersion(response);
})));
});
unittest.test("method--destroy", () {
var mock = new HttpServerMock();
api.ProjectsLocationsKeyRingsCryptoKeysCryptoKeyVersionsResourceApi res =
new api.CloudkmsApi(mock)
.projects
.locations
.keyRings
.cryptoKeys
.cryptoKeyVersions;
var arg_request = buildDestroyCryptoKeyVersionRequest();
var arg_name = "foo";
var arg_$fields = "foo";
mock.register(unittest.expectAsync2((http.BaseRequest req, json) {
var obj = new api.DestroyCryptoKeyVersionRequest.fromJson(json);
checkDestroyCryptoKeyVersionRequest(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(buildCryptoKeyVersion());
return new async.Future.value(stringResponse(200, h, resp));
}), true);
res
.destroy(arg_request, arg_name, $fields: arg_$fields)
.then(unittest.expectAsync1(((api.CryptoKeyVersion response) {
checkCryptoKeyVersion(response);
})));
});
unittest.test("method--get", () {
var mock = new HttpServerMock();
api.ProjectsLocationsKeyRingsCryptoKeysCryptoKeyVersionsResourceApi res =
new api.CloudkmsApi(mock)
.projects
.locations
.keyRings
.cryptoKeys
.cryptoKeyVersions;
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(buildCryptoKeyVersion());
return new async.Future.value(stringResponse(200, h, resp));
}), true);
res
.get(arg_name, $fields: arg_$fields)
.then(unittest.expectAsync1(((api.CryptoKeyVersion response) {
checkCryptoKeyVersion(response);
})));
});
unittest.test("method--list", () {
var mock = new HttpServerMock();
api.ProjectsLocationsKeyRingsCryptoKeysCryptoKeyVersionsResourceApi res =
new api.CloudkmsApi(mock)
.projects
.locations
.keyRings
.cryptoKeys
.cryptoKeyVersions;
var arg_parent = "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(buildListCryptoKeyVersionsResponse());
return new async.Future.value(stringResponse(200, h, resp));
}), true);
res
.list(arg_parent,
pageToken: arg_pageToken,
pageSize: arg_pageSize,
$fields: arg_$fields)
.then(unittest
.expectAsync1(((api.ListCryptoKeyVersionsResponse response) {
checkListCryptoKeyVersionsResponse(response);
})));
});
unittest.test("method--patch", () {
var mock = new HttpServerMock();
api.ProjectsLocationsKeyRingsCryptoKeysCryptoKeyVersionsResourceApi res =
new api.CloudkmsApi(mock)
.projects
.locations
.keyRings
.cryptoKeys
.cryptoKeyVersions;
var arg_request = buildCryptoKeyVersion();
var arg_name = "foo";
var arg_updateMask = "foo";
var arg_$fields = "foo";
mock.register(unittest.expectAsync2((http.BaseRequest req, json) {
var obj = new api.CryptoKeyVersion.fromJson(json);
checkCryptoKeyVersion(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(buildCryptoKeyVersion());
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.CryptoKeyVersion response) {
checkCryptoKeyVersion(response);
})));
});
unittest.test("method--restore", () {
var mock = new HttpServerMock();
api.ProjectsLocationsKeyRingsCryptoKeysCryptoKeyVersionsResourceApi res =
new api.CloudkmsApi(mock)
.projects
.locations
.keyRings
.cryptoKeys
.cryptoKeyVersions;
var arg_request = buildRestoreCryptoKeyVersionRequest();
var arg_name = "foo";
var arg_$fields = "foo";
mock.register(unittest.expectAsync2((http.BaseRequest req, json) {
var obj = new api.RestoreCryptoKeyVersionRequest.fromJson(json);
checkRestoreCryptoKeyVersionRequest(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(buildCryptoKeyVersion());
return new async.Future.value(stringResponse(200, h, resp));
}), true);
res
.restore(arg_request, arg_name, $fields: arg_$fields)
.then(unittest.expectAsync1(((api.CryptoKeyVersion response) {
checkCryptoKeyVersion(response);
})));
});
});
}