Skip to content

Commit

Permalink
chore: update UUID to latest (#328)
Browse files Browse the repository at this point in the history
  • Loading branch information
bcoe authored May 4, 2020
1 parent 02c8dfe commit bb4f6b5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion kms/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@
"c8": "^7.0.0",
"chai": "^4.2.0",
"mocha": "^7.0.0",
"uuid": "^3.3.3"
"uuid": "^8.0.0"
}
}
28 changes: 14 additions & 14 deletions kms/test/kms.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,19 @@
const {describe, it, before, after, beforeEach, afterEach} = require('mocha');
const {assert} = require('chai');
const crypto = require('crypto');
const uuidv4 = require('uuid/v4');
const {v4} = require('uuid');

const {KeyManagementServiceClient} = require('@google-cloud/kms');
const client = new KeyManagementServiceClient();

const projectId = process.env.GCLOUD_PROJECT;
const locationId = 'us-east1';
const keyRingId = uuidv4();
const asymmetricDecryptKeyId = uuidv4();
const asymmetricSignEcKeyId = uuidv4();
const asymmetricSignRsaKeyId = uuidv4();
const hsmKeyId = uuidv4();
const symmetricKeyId = uuidv4();
const keyRingId = v4();
const asymmetricDecryptKeyId = v4();
const asymmetricSignEcKeyId = v4();
const asymmetricSignRsaKeyId = v4();
const hsmKeyId = v4();
const symmetricKeyId = v4();

const nodeMajorVersion = parseInt(process.version.match(/v?(\d+).*/)[1]);

Expand Down Expand Up @@ -230,47 +230,47 @@ describe('Cloud KMS samples', () => {

it('creates asymmetric decryption keys', async () => {
const sample = require('../createKeyAsymmetricDecrypt');
const key = await sample.main(projectId, locationId, keyRingId, uuidv4());
const key = await sample.main(projectId, locationId, keyRingId, v4());
assert.equal(key.purpose, 'ASYMMETRIC_DECRYPT');
assert.equal(key.versionTemplate.algorithm, 'RSA_DECRYPT_OAEP_2048_SHA256');
});

it('creates asymmetric signing keys', async () => {
const sample = require('../createKeyAsymmetricSign');
const key = await sample.main(projectId, locationId, keyRingId, uuidv4());
const key = await sample.main(projectId, locationId, keyRingId, v4());
assert.equal(key.purpose, 'ASYMMETRIC_SIGN');
assert.equal(key.versionTemplate.algorithm, 'RSA_SIGN_PKCS1_2048_SHA256');
});

it('creates hsm keys', async () => {
const sample = require('../createKeyHsm');
const key = await sample.main(projectId, locationId, keyRingId, uuidv4());
const key = await sample.main(projectId, locationId, keyRingId, v4());
assert.equal(key.versionTemplate.protectionLevel, 'HSM');
});

it('creates labeled keys', async () => {
const sample = require('../createKeyLabels');
const key = await sample.main(projectId, locationId, keyRingId, uuidv4());
const key = await sample.main(projectId, locationId, keyRingId, v4());
assert.equal(key.labels.team, 'alpha');
assert.equal(key.labels.cost_center, 'cc1234');
});

it('creates key rings', async () => {
const sample = require('../createKeyRing');
const keyRing = await sample.main(projectId, locationId, uuidv4());
const keyRing = await sample.main(projectId, locationId, v4());
assert.match(keyRing.name, new RegExp(`${locationId}`));
});

it('creates rotating keys', async () => {
const sample = require('../createKeyRotationSchedule');
const key = await sample.main(projectId, locationId, keyRingId, uuidv4());
const key = await sample.main(projectId, locationId, keyRingId, v4());
assert.exists(key.rotationPeriod);
assert.exists(key.nextRotationTime);
});

it('creates symmetric keys', async () => {
const sample = require('../createKeySymmetricEncryptDecrypt');
const key = await sample.main(projectId, locationId, keyRingId, uuidv4());
const key = await sample.main(projectId, locationId, keyRingId, v4());
assert.equal(key.purpose, 'ENCRYPT_DECRYPT');
assert.equal(key.versionTemplate.algorithm, 'GOOGLE_SYMMETRIC_ENCRYPTION');
});
Expand Down

0 comments on commit bb4f6b5

Please sign in to comment.