Skip to content

Commit 63dfc1f

Browse files
feat!: drop node8 support, support for async iterators (#300)
BREAKING CHANGE: The library now supports Node.js v10+. The last version to support Node.js v8 is tagged legacy-8 on NPM. New feature: methods with pagination now support async iteration.
1 parent 5dbf7ff commit 63dfc1f

File tree

2 files changed

+43
-43
lines changed

2 files changed

+43
-43
lines changed

kms/quickstart.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ async function quickstart(
3636
console.log('Key rings:');
3737
keyRings.forEach(keyRing => console.log(keyRing.name));
3838
} else {
39-
console.log(`No key rings found.`);
39+
console.log('No key rings found.');
4040
}
4141
}
4242
// [END kms_quickstart]

kms/system-test/kms.test.js

+42-42
Original file line numberDiff line numberDiff line change
@@ -14,25 +14,25 @@
1414

1515
'use strict';
1616

17-
const fs = require(`fs`);
18-
const path = require(`path`);
17+
const fs = require('fs');
18+
const path = require('path');
1919
const {assert} = require('chai');
2020
const {describe, it, before, after} = require('mocha');
2121
const cp = require('child_process');
2222
const {promisify} = require('util');
23-
const {v4} = require(`uuid`);
23+
const {v4} = require('uuid');
2424
const unlink = promisify(fs.unlink);
2525

2626
const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'});
2727

2828
const keyRingName = `test-ring-${v4()}`;
2929
const keyNameOne = `test-key-${v4()}`;
30-
const member = `allAuthenticatedUsers`;
31-
const role = `roles/viewer`;
30+
const member = 'allAuthenticatedUsers';
31+
const role = 'roles/viewer';
3232
const projectId = process.env.GCLOUD_PROJECT;
33-
const plaintext = path.join(__dirname, `../resources/plaintext.txt`);
34-
const ciphertext = path.join(__dirname, `../resources/plaintext.txt.encrypted`);
35-
const decrypted = path.join(__dirname, `../resources/plaintext.txt.decrypted`);
33+
const plaintext = path.join(__dirname, '../resources/plaintext.txt');
34+
const ciphertext = path.join(__dirname, '../resources/plaintext.txt.encrypted');
35+
const decrypted = path.join(__dirname, '../resources/plaintext.txt.decrypted');
3636

3737
const unspecifiedKeyRingName = `projects/${projectId}/locations/global/keyRings/`;
3838
const formattedKeyRingName = `projects/${projectId}/locations/global/keyRings/${keyRingName}`;
@@ -65,7 +65,7 @@ describe('kms sample tests', () => {
6565
assert.match(output, /\/locations\/global\/keyRings\//);
6666
});
6767

68-
it(`should create a key ring`, async () => {
68+
it('should create a key ring', async () => {
6969
const output = execSync(
7070
`node createKeyring.js "${projectId}" "${keyRingName}"`
7171
);
@@ -77,18 +77,18 @@ describe('kms sample tests', () => {
7777
}
7878
});
7979

80-
it(`should list key rings`, async () => {
80+
it('should list key rings', async () => {
8181
const output = execSync(`node listKeyrings.js ${projectId}`);
8282
assert.match(output, new RegExp(unspecifiedKeyRingName));
8383
});
8484

85-
it(`should get a key ring`, async () => {
85+
it('should get a key ring', async () => {
8686
const output = execSync(`node getKeyring ${projectId} ${keyRingName}`);
8787
assert.match(output, new RegExp(`Name: ${formattedKeyRingName}`));
8888
assert.match(output, /Created: /);
8989
});
9090

91-
it(`should get a key ring's empty IAM policy`, async () => {
91+
it("should get a key ring's empty IAM policy", async () => {
9292
const output = execSync(
9393
`node getKeyringIamPolicy.js ${projectId} ${keyRingName}`
9494
);
@@ -98,7 +98,7 @@ describe('kms sample tests', () => {
9898
);
9999
});
100100

101-
it(`should grant access to a key ring`, async () => {
101+
it('should grant access to a key ring', async () => {
102102
const output = execSync(
103103
`node addMemberToKeyRingPolicy.js ${projectId} ${keyRingName} ${member} ${role}`
104104
);
@@ -110,15 +110,15 @@ describe('kms sample tests', () => {
110110
);
111111
});
112112

113-
it(`should get a key ring's updated IAM policy`, async () => {
113+
it("should get a key ring's updated IAM policy", async () => {
114114
const output = execSync(
115115
`node getKeyringIamPolicy.js ${projectId} ${keyRingName}`
116116
);
117117
assert.match(output, new RegExp(`${role}:`));
118118
assert.match(output, new RegExp(` ${member}`));
119119
});
120120

121-
it(`should revoke access to a key ring`, async () => {
121+
it('should revoke access to a key ring', async () => {
122122
const output = execSync(
123123
`node removeMemberFromKeyRingPolicy.js ${projectId} ${keyRingName} ${member} ${role}`
124124
);
@@ -130,7 +130,7 @@ describe('kms sample tests', () => {
130130
);
131131
});
132132

133-
it(`should create a key`, async () => {
133+
it('should create a key', async () => {
134134
const output = execSync(
135135
`node createCryptoKey.js ${projectId} ${keyRingName} ${keyNameOne}`
136136
);
@@ -139,22 +139,22 @@ describe('kms sample tests', () => {
139139
}
140140
});
141141

142-
it(`should list keys`, async () => {
142+
it('should list keys', async () => {
143143
const output = execSync(
144144
`node listCryptoKeys.js ${projectId} ${keyRingName}`
145145
);
146146
assert.match(output, new RegExp(formattedKeyName));
147147
});
148148

149-
it(`should get a key`, async () => {
149+
it('should get a key', async () => {
150150
const output = execSync(
151151
`node getCryptoKey.js ${projectId} ${keyRingName} ${keyNameOne}`
152152
);
153153
assert.match(output, new RegExp(`Name: ${formattedKeyName}`));
154-
assert.match(output, new RegExp(`Created: `));
154+
assert.match(output, new RegExp('Created: '));
155155
});
156156

157-
it(`should set a crypto key's primary version`, async () => {
157+
it("should set a crypto key's primary version", async () => {
158158
const output = execSync(
159159
`node setPrimaryCryptoKeyVersion.js ${projectId} ${keyRingName} ${keyNameOne} 1`
160160
);
@@ -164,7 +164,7 @@ describe('kms sample tests', () => {
164164
);
165165
});
166166

167-
it(`should encrypt a file`, async () => {
167+
it('should encrypt a file', async () => {
168168
const output = execSync(
169169
`node encrypt.js ${projectId} ${keyRingName} ${keyNameOne} "${plaintext}" "${ciphertext}"`
170170
);
@@ -177,7 +177,7 @@ describe('kms sample tests', () => {
177177
assert.match(output, new RegExp(`Result saved to ${ciphertext}.`));
178178
});
179179

180-
it(`should decrypt a file`, async () => {
180+
it('should decrypt a file', async () => {
181181
const output = execSync(
182182
`node decrypt.js ${projectId} "${keyRingName}" "${keyNameOne}" "${ciphertext}" "${decrypted}"`
183183
);
@@ -192,25 +192,25 @@ describe('kms sample tests', () => {
192192
);
193193
});
194194

195-
it(`should create a crypto key version`, async () => {
195+
it('should create a crypto key version', async () => {
196196
const output = execSync(
197197
`node createCryptoKeyVersion ${projectId} "${keyRingName}" "${keyNameOne}"`
198198
);
199199
assert.match(
200200
output,
201201
new RegExp(`Crypto key version ${formattedKeyName}/cryptoKeyVersions/`)
202202
);
203-
assert.match(output, new RegExp(` created.`));
203+
assert.match(output, new RegExp(' created.'));
204204
});
205205

206-
it(`should list crypto key versions`, async () => {
206+
it('should list crypto key versions', async () => {
207207
const output = execSync(
208208
`node listCryptoKeyVersions.js ${projectId} "${keyRingName}" "${keyNameOne}"`
209209
);
210210
assert.match(output, new RegExp(`${formattedKeyName}/cryptoKeyVersions/1`));
211211
});
212212

213-
it(`should destroy a crypto key version`, async () => {
213+
it('should destroy a crypto key version', async () => {
214214
const output = execSync(
215215
`node destroyCryptoKeyVersion ${projectId} "${keyRingName}" "${keyNameOne}" 2`
216216
);
@@ -222,7 +222,7 @@ describe('kms sample tests', () => {
222222
);
223223
});
224224

225-
it(`should restore a crypto key version`, async () => {
225+
it('should restore a crypto key version', async () => {
226226
const output = execSync(
227227
`node restoreCryptoKeyVersion ${projectId} "${keyRingName}" "${keyNameOne}" 2`
228228
);
@@ -234,7 +234,7 @@ describe('kms sample tests', () => {
234234
);
235235
});
236236

237-
it(`should enable a crypto key version`, async () => {
237+
it('should enable a crypto key version', async () => {
238238
const output = execSync(
239239
`node enableCryptoKeyVersion ${projectId} "${keyRingName}" "${keyNameOne}" 2`
240240
);
@@ -246,7 +246,7 @@ describe('kms sample tests', () => {
246246
);
247247
});
248248

249-
it(`should disable a crypto key version`, async () => {
249+
it('should disable a crypto key version', async () => {
250250
const output = execSync(
251251
`node disableCryptoKeyVersion ${projectId} "${keyRingName}" "${keyNameOne}" 2`
252252
);
@@ -258,7 +258,7 @@ describe('kms sample tests', () => {
258258
);
259259
});
260260

261-
it(`should get a crypto key's empty IAM policy`, async () => {
261+
it("should get a crypto key's empty IAM policy", async () => {
262262
const output = execSync(
263263
`node getCryptoKeyIamPolicy ${projectId} "${keyRingName}" "${keyNameOne}"`
264264
);
@@ -268,7 +268,7 @@ describe('kms sample tests', () => {
268268
);
269269
});
270270

271-
it(`should grant access to a crypto key`, async () => {
271+
it('should grant access to a crypto key', async () => {
272272
const output = execSync(
273273
`node addMemberToCryptoKeyPolicy ${projectId} "${keyRingName}" "${keyNameOne}" "${member}" "${role}"`
274274
);
@@ -280,15 +280,15 @@ describe('kms sample tests', () => {
280280
);
281281
});
282282

283-
it(`should get a crypto key's updated IAM policy`, async () => {
283+
it("should get a crypto key's updated IAM policy", async () => {
284284
const output = execSync(
285285
`node getCryptoKeyIamPolicy ${projectId} "${keyRingName}" "${keyNameOne}"`
286286
);
287287
assert.match(output, new RegExp(`${role}:`));
288288
assert.match(output, new RegExp(` ${member}`));
289289
});
290290

291-
it(`should revoke access to a crypto key`, async () => {
291+
it('should revoke access to a crypto key', async () => {
292292
const output = execSync(
293293
`node removeMemberCryptoKeyPolicy ${projectId} "${keyRingName}" "${keyNameOne}" ${member} ${role}`
294294
);
@@ -304,7 +304,7 @@ describe('kms sample tests', () => {
304304
const kms = require('@google-cloud/kms');
305305
const client = new kms.KeyManagementServiceClient();
306306

307-
const locationId = `global`;
307+
const locationId = 'global';
308308
const keyRingId = `test-asymmetric-ring-${v4()}`;
309309
const keyAsymmetricDecryptName = `test-asymmetric-decrypt-${v4()}`;
310310

@@ -380,7 +380,7 @@ describe('kms sample tests', () => {
380380
await client.destroyCryptoKeyVersion({name: signKeyVersionId});
381381
});
382382

383-
it(`should perform asymmetric encryption`, async function() {
383+
it('should perform asymmetric encryption', async function() {
384384
// Only run this test on Node 12+
385385
if (nodeMajorVersion < 12) {
386386
this.skip();
@@ -395,14 +395,14 @@ describe('kms sample tests', () => {
395395
"${dataToEncrypt}"
396396
`);
397397

398-
const re = new RegExp(`Encrypted ciphertext: (.+)`);
398+
const re = new RegExp('Encrypted ciphertext: (.+)');
399399
assert.match(out, re);
400400

401401
const match = re.exec(out);
402402
ciphertext = match[1];
403403
});
404404

405-
it(`should perform asymmetric decryption`, async function() {
405+
it('should perform asymmetric decryption', async function() {
406406
// Only run this test on Node 12+
407407
if (nodeMajorVersion < 12) {
408408
this.skip();
@@ -417,7 +417,7 @@ describe('kms sample tests', () => {
417417
"${ciphertext}"
418418
`);
419419

420-
const re = new RegExp(`Decrypted plaintext: (.+)`);
420+
const re = new RegExp('Decrypted plaintext: (.+)');
421421
assert.match(out, re);
422422

423423
const match = re.exec(out);
@@ -426,7 +426,7 @@ describe('kms sample tests', () => {
426426
assert.equal(dataToEncrypt, plaintext);
427427
});
428428

429-
it(`should perform asymmetric signing`, async function() {
429+
it('should perform asymmetric signing', async () => {
430430
const out = execSync(`
431431
node asymmetricSign.js \
432432
"${projectId}" \
@@ -436,14 +436,14 @@ describe('kms sample tests', () => {
436436
"${dataToSign}"
437437
`);
438438

439-
const re = new RegExp(`Signature: (.+)`);
439+
const re = new RegExp('Signature: (.+)');
440440
assert.match(out, re);
441441

442442
const match = re.exec(out);
443443
signature = match[1];
444444
});
445445

446-
it(`should perform asymmetric verification`, async function() {
446+
it('should perform asymmetric verification', async () => {
447447
const out = execSync(`
448448
node asymmetricVerify.js \
449449
"${projectId}" \
@@ -454,7 +454,7 @@ describe('kms sample tests', () => {
454454
"${signature}"
455455
`);
456456

457-
const re = new RegExp(`Signature verified: (.+)`);
457+
const re = new RegExp('Signature verified: (.+)');
458458
assert.match(out, re);
459459

460460
const match = re.exec(out);

0 commit comments

Comments
 (0)