|
17 | 17 | const {describe, it, before, after, beforeEach, afterEach} = require('mocha'); |
18 | 18 | const {assert} = require('chai'); |
19 | 19 | const crypto = require('crypto'); |
20 | | -const uuidv4 = require('uuid/v4'); |
| 20 | +const {v4} = require('uuid'); |
21 | 21 |
|
22 | 22 | const {KeyManagementServiceClient} = require('@google-cloud/kms'); |
23 | 23 | const client = new KeyManagementServiceClient(); |
24 | 24 |
|
25 | 25 | const projectId = process.env.GCLOUD_PROJECT; |
26 | 26 | const locationId = 'us-east1'; |
27 | | -const keyRingId = uuidv4(); |
28 | | -const asymmetricDecryptKeyId = uuidv4(); |
29 | | -const asymmetricSignEcKeyId = uuidv4(); |
30 | | -const asymmetricSignRsaKeyId = uuidv4(); |
31 | | -const hsmKeyId = uuidv4(); |
32 | | -const symmetricKeyId = uuidv4(); |
| 27 | +const keyRingId = v4(); |
| 28 | +const asymmetricDecryptKeyId = v4(); |
| 29 | +const asymmetricSignEcKeyId = v4(); |
| 30 | +const asymmetricSignRsaKeyId = v4(); |
| 31 | +const hsmKeyId = v4(); |
| 32 | +const symmetricKeyId = v4(); |
33 | 33 |
|
34 | 34 | const nodeMajorVersion = parseInt(process.version.match(/v?(\d+).*/)[1]); |
35 | 35 |
|
@@ -230,47 +230,47 @@ describe('Cloud KMS samples', () => { |
230 | 230 |
|
231 | 231 | it('creates asymmetric decryption keys', async () => { |
232 | 232 | const sample = require('../createKeyAsymmetricDecrypt'); |
233 | | - const key = await sample.main(projectId, locationId, keyRingId, uuidv4()); |
| 233 | + const key = await sample.main(projectId, locationId, keyRingId, v4()); |
234 | 234 | assert.equal(key.purpose, 'ASYMMETRIC_DECRYPT'); |
235 | 235 | assert.equal(key.versionTemplate.algorithm, 'RSA_DECRYPT_OAEP_2048_SHA256'); |
236 | 236 | }); |
237 | 237 |
|
238 | 238 | it('creates asymmetric signing keys', async () => { |
239 | 239 | const sample = require('../createKeyAsymmetricSign'); |
240 | | - const key = await sample.main(projectId, locationId, keyRingId, uuidv4()); |
| 240 | + const key = await sample.main(projectId, locationId, keyRingId, v4()); |
241 | 241 | assert.equal(key.purpose, 'ASYMMETRIC_SIGN'); |
242 | 242 | assert.equal(key.versionTemplate.algorithm, 'RSA_SIGN_PKCS1_2048_SHA256'); |
243 | 243 | }); |
244 | 244 |
|
245 | 245 | it('creates hsm keys', async () => { |
246 | 246 | const sample = require('../createKeyHsm'); |
247 | | - const key = await sample.main(projectId, locationId, keyRingId, uuidv4()); |
| 247 | + const key = await sample.main(projectId, locationId, keyRingId, v4()); |
248 | 248 | assert.equal(key.versionTemplate.protectionLevel, 'HSM'); |
249 | 249 | }); |
250 | 250 |
|
251 | 251 | it('creates labeled keys', async () => { |
252 | 252 | const sample = require('../createKeyLabels'); |
253 | | - const key = await sample.main(projectId, locationId, keyRingId, uuidv4()); |
| 253 | + const key = await sample.main(projectId, locationId, keyRingId, v4()); |
254 | 254 | assert.equal(key.labels.team, 'alpha'); |
255 | 255 | assert.equal(key.labels.cost_center, 'cc1234'); |
256 | 256 | }); |
257 | 257 |
|
258 | 258 | it('creates key rings', async () => { |
259 | 259 | const sample = require('../createKeyRing'); |
260 | | - const keyRing = await sample.main(projectId, locationId, uuidv4()); |
| 260 | + const keyRing = await sample.main(projectId, locationId, v4()); |
261 | 261 | assert.match(keyRing.name, new RegExp(`${locationId}`)); |
262 | 262 | }); |
263 | 263 |
|
264 | 264 | it('creates rotating keys', async () => { |
265 | 265 | const sample = require('../createKeyRotationSchedule'); |
266 | | - const key = await sample.main(projectId, locationId, keyRingId, uuidv4()); |
| 266 | + const key = await sample.main(projectId, locationId, keyRingId, v4()); |
267 | 267 | assert.exists(key.rotationPeriod); |
268 | 268 | assert.exists(key.nextRotationTime); |
269 | 269 | }); |
270 | 270 |
|
271 | 271 | it('creates symmetric keys', async () => { |
272 | 272 | const sample = require('../createKeySymmetricEncryptDecrypt'); |
273 | | - const key = await sample.main(projectId, locationId, keyRingId, uuidv4()); |
| 273 | + const key = await sample.main(projectId, locationId, keyRingId, v4()); |
274 | 274 | assert.equal(key.purpose, 'ENCRYPT_DECRYPT'); |
275 | 275 | assert.equal(key.versionTemplate.algorithm, 'GOOGLE_SYMMETRIC_ENCRYPTION'); |
276 | 276 | }); |
|
0 commit comments