diff --git a/.eslintrc.yml b/.eslintrc.yml index 65f1dce6..73eeec27 100644 --- a/.eslintrc.yml +++ b/.eslintrc.yml @@ -12,3 +12,4 @@ rules: eqeqeq: error no-warning-comments: warn no-var: error + prefer-const: error diff --git a/package.json b/package.json index dc9ab987..a882d5e1 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,8 @@ "lint": "eslint src/ samples/ system-test/ test/", "prettier": "prettier --write src/*.js src/*/*.js samples/*.js samples/*/*.js test/*.js test/*/*.js system-test/*.js system-test/*/*.js", "docs": "jsdoc -c .jsdoc.js", - "system-test": "mocha system-test/ smoke-test/ --timeout 600000" + "system-test": "mocha system-test/ smoke-test/ --timeout 600000", + "fix": "eslint '**/*.js' --fix && npm run prettier" }, "dependencies": { "google-gax": "^0.20.0", diff --git a/src/v1/key_management_service_client.js b/src/v1/key_management_service_client.js index 6b60737a..d549572b 100644 --- a/src/v1/key_management_service_client.js +++ b/src/v1/key_management_service_client.js @@ -81,13 +81,13 @@ class KeyManagementServiceClient { // Create a `gaxGrpc` object, with any grpc-specific options // sent to the client. opts.scopes = this.constructor.scopes; - let gaxGrpc = new gax.GrpcClient(opts); + const gaxGrpc = new gax.GrpcClient(opts); // Save the auth object to the client, for use by other methods. this.auth = gaxGrpc.auth; // Determine the client header string. - let clientHeader = [ + const clientHeader = [ `gl-node/${process.version}`, `grpc/${gaxGrpc.grpcVersion}`, `gax/${gax.version}`, @@ -98,7 +98,7 @@ class KeyManagementServiceClient { } // Load the applicable protos. - let protos = merge( + const protos = merge( {}, gaxGrpc.loadProto( path.join(__dirname, '..', '..', 'protos'), @@ -153,7 +153,7 @@ class KeyManagementServiceClient { }; // Put together the default options sent with requests. - let defaults = gaxGrpc.constructSettings( + const defaults = gaxGrpc.constructSettings( 'google.cloud.kms.v1.KeyManagementService', gapicConfig, opts.clientConfig, @@ -167,14 +167,14 @@ class KeyManagementServiceClient { // Put together the "service stub" for // google.cloud.kms.v1.KeyManagementService. - let keyManagementServiceStub = gaxGrpc.createStub( + const keyManagementServiceStub = gaxGrpc.createStub( protos.google.cloud.kms.v1.KeyManagementService, opts ); // Iterate over each of the methods that the service provides // and create an API call method for each. - let keyManagementServiceStubMethods = [ + const keyManagementServiceStubMethods = [ 'listKeyRings', 'listCryptoKeys', 'listCryptoKeyVersions', @@ -192,12 +192,12 @@ class KeyManagementServiceClient { 'destroyCryptoKeyVersion', 'restoreCryptoKeyVersion', ]; - for (let methodName of keyManagementServiceStubMethods) { + for (const methodName of keyManagementServiceStubMethods) { this._innerApiCalls[methodName] = gax.createApiCall( keyManagementServiceStub.then( stub => function() { - let args = Array.prototype.slice.call(arguments, 0); + const args = Array.prototype.slice.call(arguments, 0); return stub[methodName].apply(stub, args); } ), @@ -208,24 +208,24 @@ class KeyManagementServiceClient { // Put together the "service stub" for // google.iam.v1.IAMPolicy. - let iamPolicyStub = gaxGrpc.createStub( + const iamPolicyStub = gaxGrpc.createStub( protos.google.iam.v1.IAMPolicy, opts ); // Iterate over each of the methods that the service provides // and create an API call method for each. - let iamPolicyStubMethods = [ + const iamPolicyStubMethods = [ 'setIamPolicy', 'getIamPolicy', 'testIamPermissions', ]; - for (let methodName of iamPolicyStubMethods) { + for (const methodName of iamPolicyStubMethods) { this._innerApiCalls[methodName] = gax.createApiCall( iamPolicyStub.then( stub => function() { - let args = Array.prototype.slice.call(arguments, 0); + const args = Array.prototype.slice.call(arguments, 0); return stub[methodName].apply(stub, args); } ), diff --git a/test/gapic-v1.js b/test/gapic-v1.js index bd60e46d..fdaeac1a 100644 --- a/test/gapic-v1.js +++ b/test/gapic-v1.js @@ -18,30 +18,30 @@ const assert = require('assert'); const kmsModule = require('../src'); -let FAKE_STATUS_CODE = 1; -let error = new Error(); +const FAKE_STATUS_CODE = 1; +const error = new Error(); error.code = FAKE_STATUS_CODE; describe('KeyManagementServiceClient', () => { describe('listKeyRings', () => { it('invokes listKeyRings without error', done => { - let client = new kmsModule.v1.KeyManagementServiceClient({ + const client = new kmsModule.v1.KeyManagementServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); // Mock request - let formattedParent = client.locationPath('[PROJECT]', '[LOCATION]'); - let request = { + const formattedParent = client.locationPath('[PROJECT]', '[LOCATION]'); + const request = { parent: formattedParent, }; // Mock response - let nextPageToken = ''; - let totalSize = 705419236; - let keyRingsElement = {}; - let keyRings = [keyRingsElement]; - let expectedResponse = { + const nextPageToken = ''; + const totalSize = 705419236; + const keyRingsElement = {}; + const keyRings = [keyRingsElement]; + const expectedResponse = { nextPageToken: nextPageToken, totalSize: totalSize, keyRings: keyRings, @@ -65,14 +65,14 @@ describe('KeyManagementServiceClient', () => { }); it('invokes listKeyRings with error', done => { - let client = new kmsModule.v1.KeyManagementServiceClient({ + const client = new kmsModule.v1.KeyManagementServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); // Mock request - let formattedParent = client.locationPath('[PROJECT]', '[LOCATION]'); - let request = { + const formattedParent = client.locationPath('[PROJECT]', '[LOCATION]'); + const request = { parent: formattedParent, }; @@ -94,27 +94,27 @@ describe('KeyManagementServiceClient', () => { describe('listCryptoKeys', () => { it('invokes listCryptoKeys without error', done => { - let client = new kmsModule.v1.KeyManagementServiceClient({ + const client = new kmsModule.v1.KeyManagementServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); // Mock request - let formattedParent = client.keyRingPath( + const formattedParent = client.keyRingPath( '[PROJECT]', '[LOCATION]', '[KEY_RING]' ); - let request = { + const request = { parent: formattedParent, }; // Mock response - let nextPageToken = ''; - let totalSize = 705419236; - let cryptoKeysElement = {}; - let cryptoKeys = [cryptoKeysElement]; - let expectedResponse = { + const nextPageToken = ''; + const totalSize = 705419236; + const cryptoKeysElement = {}; + const cryptoKeys = [cryptoKeysElement]; + const expectedResponse = { nextPageToken: nextPageToken, totalSize: totalSize, cryptoKeys: cryptoKeys, @@ -138,18 +138,18 @@ describe('KeyManagementServiceClient', () => { }); it('invokes listCryptoKeys with error', done => { - let client = new kmsModule.v1.KeyManagementServiceClient({ + const client = new kmsModule.v1.KeyManagementServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); // Mock request - let formattedParent = client.keyRingPath( + const formattedParent = client.keyRingPath( '[PROJECT]', '[LOCATION]', '[KEY_RING]' ); - let request = { + const request = { parent: formattedParent, }; @@ -171,28 +171,28 @@ describe('KeyManagementServiceClient', () => { describe('listCryptoKeyVersions', () => { it('invokes listCryptoKeyVersions without error', done => { - let client = new kmsModule.v1.KeyManagementServiceClient({ + const client = new kmsModule.v1.KeyManagementServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); // Mock request - let formattedParent = client.cryptoKeyPath( + const formattedParent = client.cryptoKeyPath( '[PROJECT]', '[LOCATION]', '[KEY_RING]', '[CRYPTO_KEY]' ); - let request = { + const request = { parent: formattedParent, }; // Mock response - let nextPageToken = ''; - let totalSize = 705419236; - let cryptoKeyVersionsElement = {}; - let cryptoKeyVersions = [cryptoKeyVersionsElement]; - let expectedResponse = { + const nextPageToken = ''; + const totalSize = 705419236; + const cryptoKeyVersionsElement = {}; + const cryptoKeyVersions = [cryptoKeyVersionsElement]; + const expectedResponse = { nextPageToken: nextPageToken, totalSize: totalSize, cryptoKeyVersions: cryptoKeyVersions, @@ -216,19 +216,19 @@ describe('KeyManagementServiceClient', () => { }); it('invokes listCryptoKeyVersions with error', done => { - let client = new kmsModule.v1.KeyManagementServiceClient({ + const client = new kmsModule.v1.KeyManagementServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); // Mock request - let formattedParent = client.cryptoKeyPath( + const formattedParent = client.cryptoKeyPath( '[PROJECT]', '[LOCATION]', '[KEY_RING]', '[CRYPTO_KEY]' ); - let request = { + const request = { parent: formattedParent, }; @@ -250,24 +250,24 @@ describe('KeyManagementServiceClient', () => { describe('getKeyRing', () => { it('invokes getKeyRing without error', done => { - let client = new kmsModule.v1.KeyManagementServiceClient({ + const client = new kmsModule.v1.KeyManagementServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); // Mock request - let formattedName = client.keyRingPath( + const formattedName = client.keyRingPath( '[PROJECT]', '[LOCATION]', '[KEY_RING]' ); - let request = { + const request = { name: formattedName, }; // Mock response - let name2 = 'name2-1052831874'; - let expectedResponse = { + const name2 = 'name2-1052831874'; + const expectedResponse = { name: name2, }; @@ -285,18 +285,18 @@ describe('KeyManagementServiceClient', () => { }); it('invokes getKeyRing with error', done => { - let client = new kmsModule.v1.KeyManagementServiceClient({ + const client = new kmsModule.v1.KeyManagementServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); // Mock request - let formattedName = client.keyRingPath( + const formattedName = client.keyRingPath( '[PROJECT]', '[LOCATION]', '[KEY_RING]' ); - let request = { + const request = { name: formattedName, }; @@ -318,25 +318,25 @@ describe('KeyManagementServiceClient', () => { describe('getCryptoKey', () => { it('invokes getCryptoKey without error', done => { - let client = new kmsModule.v1.KeyManagementServiceClient({ + const client = new kmsModule.v1.KeyManagementServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); // Mock request - let formattedName = client.cryptoKeyPath( + const formattedName = client.cryptoKeyPath( '[PROJECT]', '[LOCATION]', '[KEY_RING]', '[CRYPTO_KEY]' ); - let request = { + const request = { name: formattedName, }; // Mock response - let name2 = 'name2-1052831874'; - let expectedResponse = { + const name2 = 'name2-1052831874'; + const expectedResponse = { name: name2, }; @@ -354,19 +354,19 @@ describe('KeyManagementServiceClient', () => { }); it('invokes getCryptoKey with error', done => { - let client = new kmsModule.v1.KeyManagementServiceClient({ + const client = new kmsModule.v1.KeyManagementServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); // Mock request - let formattedName = client.cryptoKeyPath( + const formattedName = client.cryptoKeyPath( '[PROJECT]', '[LOCATION]', '[KEY_RING]', '[CRYPTO_KEY]' ); - let request = { + const request = { name: formattedName, }; @@ -388,26 +388,26 @@ describe('KeyManagementServiceClient', () => { describe('getCryptoKeyVersion', () => { it('invokes getCryptoKeyVersion without error', done => { - let client = new kmsModule.v1.KeyManagementServiceClient({ + const client = new kmsModule.v1.KeyManagementServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); // Mock request - let formattedName = client.cryptoKeyVersionPath( + const formattedName = client.cryptoKeyVersionPath( '[PROJECT]', '[LOCATION]', '[KEY_RING]', '[CRYPTO_KEY]', '[CRYPTO_KEY_VERSION]' ); - let request = { + const request = { name: formattedName, }; // Mock response - let name2 = 'name2-1052831874'; - let expectedResponse = { + const name2 = 'name2-1052831874'; + const expectedResponse = { name: name2, }; @@ -425,20 +425,20 @@ describe('KeyManagementServiceClient', () => { }); it('invokes getCryptoKeyVersion with error', done => { - let client = new kmsModule.v1.KeyManagementServiceClient({ + const client = new kmsModule.v1.KeyManagementServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); // Mock request - let formattedName = client.cryptoKeyVersionPath( + const formattedName = client.cryptoKeyVersionPath( '[PROJECT]', '[LOCATION]', '[KEY_RING]', '[CRYPTO_KEY]', '[CRYPTO_KEY_VERSION]' ); - let request = { + const request = { name: formattedName, }; @@ -460,24 +460,24 @@ describe('KeyManagementServiceClient', () => { describe('createKeyRing', () => { it('invokes createKeyRing without error', done => { - let client = new kmsModule.v1.KeyManagementServiceClient({ + const client = new kmsModule.v1.KeyManagementServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); // Mock request - let formattedParent = client.locationPath('[PROJECT]', '[LOCATION]'); - let keyRingId = 'keyRingId-2056646742'; - let keyRing = {}; - let request = { + const formattedParent = client.locationPath('[PROJECT]', '[LOCATION]'); + const keyRingId = 'keyRingId-2056646742'; + const keyRing = {}; + const request = { parent: formattedParent, keyRingId: keyRingId, keyRing: keyRing, }; // Mock response - let name = 'name3373707'; - let expectedResponse = { + const name = 'name3373707'; + const expectedResponse = { name: name, }; @@ -495,16 +495,16 @@ describe('KeyManagementServiceClient', () => { }); it('invokes createKeyRing with error', done => { - let client = new kmsModule.v1.KeyManagementServiceClient({ + const client = new kmsModule.v1.KeyManagementServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); // Mock request - let formattedParent = client.locationPath('[PROJECT]', '[LOCATION]'); - let keyRingId = 'keyRingId-2056646742'; - let keyRing = {}; - let request = { + const formattedParent = client.locationPath('[PROJECT]', '[LOCATION]'); + const keyRingId = 'keyRingId-2056646742'; + const keyRing = {}; + const request = { parent: formattedParent, keyRingId: keyRingId, keyRing: keyRing, @@ -528,41 +528,41 @@ describe('KeyManagementServiceClient', () => { describe('createCryptoKey', () => { it('invokes createCryptoKey without error', done => { - let client = new kmsModule.v1.KeyManagementServiceClient({ + const client = new kmsModule.v1.KeyManagementServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); // Mock request - let formattedParent = client.keyRingPath( + const formattedParent = client.keyRingPath( '[PROJECT]', '[LOCATION]', '[KEY_RING]' ); - let cryptoKeyId = 'my-app-key'; - let purpose = 'ENCRYPT_DECRYPT'; - let seconds = 2147483647; - let nextRotationTime = { + const cryptoKeyId = 'my-app-key'; + const purpose = 'ENCRYPT_DECRYPT'; + const seconds = 2147483647; + const nextRotationTime = { seconds: seconds, }; - let seconds2 = 604800; - let rotationPeriod = { + const seconds2 = 604800; + const rotationPeriod = { seconds: seconds2, }; - let cryptoKey = { + const cryptoKey = { purpose: purpose, nextRotationTime: nextRotationTime, rotationPeriod: rotationPeriod, }; - let request = { + const request = { parent: formattedParent, cryptoKeyId: cryptoKeyId, cryptoKey: cryptoKey, }; // Mock response - let name = 'name3373707'; - let expectedResponse = { + const name = 'name3373707'; + const expectedResponse = { name: name, }; @@ -580,33 +580,33 @@ describe('KeyManagementServiceClient', () => { }); it('invokes createCryptoKey with error', done => { - let client = new kmsModule.v1.KeyManagementServiceClient({ + const client = new kmsModule.v1.KeyManagementServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); // Mock request - let formattedParent = client.keyRingPath( + const formattedParent = client.keyRingPath( '[PROJECT]', '[LOCATION]', '[KEY_RING]' ); - let cryptoKeyId = 'my-app-key'; - let purpose = 'ENCRYPT_DECRYPT'; - let seconds = 2147483647; - let nextRotationTime = { + const cryptoKeyId = 'my-app-key'; + const purpose = 'ENCRYPT_DECRYPT'; + const seconds = 2147483647; + const nextRotationTime = { seconds: seconds, }; - let seconds2 = 604800; - let rotationPeriod = { + const seconds2 = 604800; + const rotationPeriod = { seconds: seconds2, }; - let cryptoKey = { + const cryptoKey = { purpose: purpose, nextRotationTime: nextRotationTime, rotationPeriod: rotationPeriod, }; - let request = { + const request = { parent: formattedParent, cryptoKeyId: cryptoKeyId, cryptoKey: cryptoKey, @@ -630,27 +630,27 @@ describe('KeyManagementServiceClient', () => { describe('createCryptoKeyVersion', () => { it('invokes createCryptoKeyVersion without error', done => { - let client = new kmsModule.v1.KeyManagementServiceClient({ + const client = new kmsModule.v1.KeyManagementServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); // Mock request - let formattedParent = client.cryptoKeyPath( + const formattedParent = client.cryptoKeyPath( '[PROJECT]', '[LOCATION]', '[KEY_RING]', '[CRYPTO_KEY]' ); - let cryptoKeyVersion = {}; - let request = { + const cryptoKeyVersion = {}; + const request = { parent: formattedParent, cryptoKeyVersion: cryptoKeyVersion, }; // Mock response - let name = 'name3373707'; - let expectedResponse = { + const name = 'name3373707'; + const expectedResponse = { name: name, }; @@ -668,20 +668,20 @@ describe('KeyManagementServiceClient', () => { }); it('invokes createCryptoKeyVersion with error', done => { - let client = new kmsModule.v1.KeyManagementServiceClient({ + const client = new kmsModule.v1.KeyManagementServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); // Mock request - let formattedParent = client.cryptoKeyPath( + const formattedParent = client.cryptoKeyPath( '[PROJECT]', '[LOCATION]', '[KEY_RING]', '[CRYPTO_KEY]' ); - let cryptoKeyVersion = {}; - let request = { + const cryptoKeyVersion = {}; + const request = { parent: formattedParent, cryptoKeyVersion: cryptoKeyVersion, }; @@ -704,22 +704,22 @@ describe('KeyManagementServiceClient', () => { describe('updateCryptoKey', () => { it('invokes updateCryptoKey without error', done => { - let client = new kmsModule.v1.KeyManagementServiceClient({ + const client = new kmsModule.v1.KeyManagementServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); // Mock request - let cryptoKey = {}; - let updateMask = {}; - let request = { + const cryptoKey = {}; + const updateMask = {}; + const request = { cryptoKey: cryptoKey, updateMask: updateMask, }; // Mock response - let name = 'name3373707'; - let expectedResponse = { + const name = 'name3373707'; + const expectedResponse = { name: name, }; @@ -737,15 +737,15 @@ describe('KeyManagementServiceClient', () => { }); it('invokes updateCryptoKey with error', done => { - let client = new kmsModule.v1.KeyManagementServiceClient({ + const client = new kmsModule.v1.KeyManagementServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); // Mock request - let cryptoKey = {}; - let updateMask = {}; - let request = { + const cryptoKey = {}; + const updateMask = {}; + const request = { cryptoKey: cryptoKey, updateMask: updateMask, }; @@ -768,22 +768,22 @@ describe('KeyManagementServiceClient', () => { describe('updateCryptoKeyVersion', () => { it('invokes updateCryptoKeyVersion without error', done => { - let client = new kmsModule.v1.KeyManagementServiceClient({ + const client = new kmsModule.v1.KeyManagementServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); // Mock request - let cryptoKeyVersion = {}; - let updateMask = {}; - let request = { + const cryptoKeyVersion = {}; + const updateMask = {}; + const request = { cryptoKeyVersion: cryptoKeyVersion, updateMask: updateMask, }; // Mock response - let name = 'name3373707'; - let expectedResponse = { + const name = 'name3373707'; + const expectedResponse = { name: name, }; @@ -801,15 +801,15 @@ describe('KeyManagementServiceClient', () => { }); it('invokes updateCryptoKeyVersion with error', done => { - let client = new kmsModule.v1.KeyManagementServiceClient({ + const client = new kmsModule.v1.KeyManagementServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); // Mock request - let cryptoKeyVersion = {}; - let updateMask = {}; - let request = { + const cryptoKeyVersion = {}; + const updateMask = {}; + const request = { cryptoKeyVersion: cryptoKeyVersion, updateMask: updateMask, }; @@ -832,28 +832,28 @@ describe('KeyManagementServiceClient', () => { describe('encrypt', () => { it('invokes encrypt without error', done => { - let client = new kmsModule.v1.KeyManagementServiceClient({ + const client = new kmsModule.v1.KeyManagementServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); // Mock request - let formattedName = client.cryptoKeyPathPath( + const formattedName = client.cryptoKeyPathPath( '[PROJECT]', '[LOCATION]', '[KEY_RING]', '[CRYPTO_KEY_PATH]' ); - let plaintext = '-9'; - let request = { + const plaintext = '-9'; + const request = { name: formattedName, plaintext: plaintext, }; // Mock response - let name2 = 'name2-1052831874'; - let ciphertext = '-72'; - let expectedResponse = { + const name2 = 'name2-1052831874'; + const ciphertext = '-72'; + const expectedResponse = { name: name2, ciphertext: ciphertext, }; @@ -872,20 +872,20 @@ describe('KeyManagementServiceClient', () => { }); it('invokes encrypt with error', done => { - let client = new kmsModule.v1.KeyManagementServiceClient({ + const client = new kmsModule.v1.KeyManagementServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); // Mock request - let formattedName = client.cryptoKeyPathPath( + const formattedName = client.cryptoKeyPathPath( '[PROJECT]', '[LOCATION]', '[KEY_RING]', '[CRYPTO_KEY_PATH]' ); - let plaintext = '-9'; - let request = { + const plaintext = '-9'; + const request = { name: formattedName, plaintext: plaintext, }; @@ -908,27 +908,27 @@ describe('KeyManagementServiceClient', () => { describe('decrypt', () => { it('invokes decrypt without error', done => { - let client = new kmsModule.v1.KeyManagementServiceClient({ + const client = new kmsModule.v1.KeyManagementServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); // Mock request - let formattedName = client.cryptoKeyPath( + const formattedName = client.cryptoKeyPath( '[PROJECT]', '[LOCATION]', '[KEY_RING]', '[CRYPTO_KEY]' ); - let ciphertext = '-72'; - let request = { + const ciphertext = '-72'; + const request = { name: formattedName, ciphertext: ciphertext, }; // Mock response - let plaintext = '-9'; - let expectedResponse = { + const plaintext = '-9'; + const expectedResponse = { plaintext: plaintext, }; @@ -946,20 +946,20 @@ describe('KeyManagementServiceClient', () => { }); it('invokes decrypt with error', done => { - let client = new kmsModule.v1.KeyManagementServiceClient({ + const client = new kmsModule.v1.KeyManagementServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); // Mock request - let formattedName = client.cryptoKeyPath( + const formattedName = client.cryptoKeyPath( '[PROJECT]', '[LOCATION]', '[KEY_RING]', '[CRYPTO_KEY]' ); - let ciphertext = '-72'; - let request = { + const ciphertext = '-72'; + const request = { name: formattedName, ciphertext: ciphertext, }; @@ -982,27 +982,27 @@ describe('KeyManagementServiceClient', () => { describe('updateCryptoKeyPrimaryVersion', () => { it('invokes updateCryptoKeyPrimaryVersion without error', done => { - let client = new kmsModule.v1.KeyManagementServiceClient({ + const client = new kmsModule.v1.KeyManagementServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); // Mock request - let formattedName = client.cryptoKeyPath( + const formattedName = client.cryptoKeyPath( '[PROJECT]', '[LOCATION]', '[KEY_RING]', '[CRYPTO_KEY]' ); - let cryptoKeyVersionId = 'cryptoKeyVersionId729489152'; - let request = { + const cryptoKeyVersionId = 'cryptoKeyVersionId729489152'; + const request = { name: formattedName, cryptoKeyVersionId: cryptoKeyVersionId, }; // Mock response - let name2 = 'name2-1052831874'; - let expectedResponse = { + const name2 = 'name2-1052831874'; + const expectedResponse = { name: name2, }; @@ -1020,20 +1020,20 @@ describe('KeyManagementServiceClient', () => { }); it('invokes updateCryptoKeyPrimaryVersion with error', done => { - let client = new kmsModule.v1.KeyManagementServiceClient({ + const client = new kmsModule.v1.KeyManagementServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); // Mock request - let formattedName = client.cryptoKeyPath( + const formattedName = client.cryptoKeyPath( '[PROJECT]', '[LOCATION]', '[KEY_RING]', '[CRYPTO_KEY]' ); - let cryptoKeyVersionId = 'cryptoKeyVersionId729489152'; - let request = { + const cryptoKeyVersionId = 'cryptoKeyVersionId729489152'; + const request = { name: formattedName, cryptoKeyVersionId: cryptoKeyVersionId, }; @@ -1056,26 +1056,26 @@ describe('KeyManagementServiceClient', () => { describe('destroyCryptoKeyVersion', () => { it('invokes destroyCryptoKeyVersion without error', done => { - let client = new kmsModule.v1.KeyManagementServiceClient({ + const client = new kmsModule.v1.KeyManagementServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); // Mock request - let formattedName = client.cryptoKeyVersionPath( + const formattedName = client.cryptoKeyVersionPath( '[PROJECT]', '[LOCATION]', '[KEY_RING]', '[CRYPTO_KEY]', '[CRYPTO_KEY_VERSION]' ); - let request = { + const request = { name: formattedName, }; // Mock response - let name2 = 'name2-1052831874'; - let expectedResponse = { + const name2 = 'name2-1052831874'; + const expectedResponse = { name: name2, }; @@ -1093,20 +1093,20 @@ describe('KeyManagementServiceClient', () => { }); it('invokes destroyCryptoKeyVersion with error', done => { - let client = new kmsModule.v1.KeyManagementServiceClient({ + const client = new kmsModule.v1.KeyManagementServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); // Mock request - let formattedName = client.cryptoKeyVersionPath( + const formattedName = client.cryptoKeyVersionPath( '[PROJECT]', '[LOCATION]', '[KEY_RING]', '[CRYPTO_KEY]', '[CRYPTO_KEY_VERSION]' ); - let request = { + const request = { name: formattedName, }; @@ -1128,26 +1128,26 @@ describe('KeyManagementServiceClient', () => { describe('restoreCryptoKeyVersion', () => { it('invokes restoreCryptoKeyVersion without error', done => { - let client = new kmsModule.v1.KeyManagementServiceClient({ + const client = new kmsModule.v1.KeyManagementServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); // Mock request - let formattedName = client.cryptoKeyVersionPath( + const formattedName = client.cryptoKeyVersionPath( '[PROJECT]', '[LOCATION]', '[KEY_RING]', '[CRYPTO_KEY]', '[CRYPTO_KEY_VERSION]' ); - let request = { + const request = { name: formattedName, }; // Mock response - let name2 = 'name2-1052831874'; - let expectedResponse = { + const name2 = 'name2-1052831874'; + const expectedResponse = { name: name2, }; @@ -1165,20 +1165,20 @@ describe('KeyManagementServiceClient', () => { }); it('invokes restoreCryptoKeyVersion with error', done => { - let client = new kmsModule.v1.KeyManagementServiceClient({ + const client = new kmsModule.v1.KeyManagementServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); // Mock request - let formattedName = client.cryptoKeyVersionPath( + const formattedName = client.cryptoKeyVersionPath( '[PROJECT]', '[LOCATION]', '[KEY_RING]', '[CRYPTO_KEY]', '[CRYPTO_KEY_VERSION]' ); - let request = { + const request = { name: formattedName, }; @@ -1200,27 +1200,27 @@ describe('KeyManagementServiceClient', () => { describe('setIamPolicy', () => { it('invokes setIamPolicy without error', done => { - let client = new kmsModule.v1.KeyManagementServiceClient({ + const client = new kmsModule.v1.KeyManagementServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); // Mock request - let formattedResource = client.keyRingPath( + const formattedResource = client.keyRingPath( '[PROJECT]', '[LOCATION]', '[KEY_RING]' ); - let policy = {}; - let request = { + const policy = {}; + const request = { resource: formattedResource, policy: policy, }; // Mock response - let version = 351608024; - let etag = '21'; - let expectedResponse = { + const version = 351608024; + const etag = '21'; + const expectedResponse = { version: version, etag: etag, }; @@ -1239,19 +1239,19 @@ describe('KeyManagementServiceClient', () => { }); it('invokes setIamPolicy with error', done => { - let client = new kmsModule.v1.KeyManagementServiceClient({ + const client = new kmsModule.v1.KeyManagementServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); // Mock request - let formattedResource = client.keyRingPath( + const formattedResource = client.keyRingPath( '[PROJECT]', '[LOCATION]', '[KEY_RING]' ); - let policy = {}; - let request = { + const policy = {}; + const request = { resource: formattedResource, policy: policy, }; @@ -1274,25 +1274,25 @@ describe('KeyManagementServiceClient', () => { describe('getIamPolicy', () => { it('invokes getIamPolicy without error', done => { - let client = new kmsModule.v1.KeyManagementServiceClient({ + const client = new kmsModule.v1.KeyManagementServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); // Mock request - let formattedResource = client.keyRingPath( + const formattedResource = client.keyRingPath( '[PROJECT]', '[LOCATION]', '[KEY_RING]' ); - let request = { + const request = { resource: formattedResource, }; // Mock response - let version = 351608024; - let etag = '21'; - let expectedResponse = { + const version = 351608024; + const etag = '21'; + const expectedResponse = { version: version, etag: etag, }; @@ -1311,18 +1311,18 @@ describe('KeyManagementServiceClient', () => { }); it('invokes getIamPolicy with error', done => { - let client = new kmsModule.v1.KeyManagementServiceClient({ + const client = new kmsModule.v1.KeyManagementServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); // Mock request - let formattedResource = client.keyRingPath( + const formattedResource = client.keyRingPath( '[PROJECT]', '[LOCATION]', '[KEY_RING]' ); - let request = { + const request = { resource: formattedResource, }; @@ -1344,25 +1344,25 @@ describe('KeyManagementServiceClient', () => { describe('testIamPermissions', () => { it('invokes testIamPermissions without error', done => { - let client = new kmsModule.v1.KeyManagementServiceClient({ + const client = new kmsModule.v1.KeyManagementServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); // Mock request - let formattedResource = client.keyRingPath( + const formattedResource = client.keyRingPath( '[PROJECT]', '[LOCATION]', '[KEY_RING]' ); - let permissions = []; - let request = { + const permissions = []; + const request = { resource: formattedResource, permissions: permissions, }; // Mock response - let expectedResponse = {}; + const expectedResponse = {}; // Mock Grpc layer client._innerApiCalls.testIamPermissions = mockSimpleGrpcMethod( @@ -1378,19 +1378,19 @@ describe('KeyManagementServiceClient', () => { }); it('invokes testIamPermissions with error', done => { - let client = new kmsModule.v1.KeyManagementServiceClient({ + const client = new kmsModule.v1.KeyManagementServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); // Mock request - let formattedResource = client.keyRingPath( + const formattedResource = client.keyRingPath( '[PROJECT]', '[LOCATION]', '[KEY_RING]' ); - let permissions = []; - let request = { + const permissions = []; + const request = { resource: formattedResource, permissions: permissions, };