Skip to content

Commit 2c0dc18

Browse files
committed
Update tests
1 parent e925ca1 commit 2c0dc18

File tree

2 files changed

+46
-2
lines changed

2 files changed

+46
-2
lines changed

modules/branch-keystore-node/test/branch_keystore.test.ts

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,17 @@ describe('Test Branch keystore', () => {
291291
}
292292
})
293293

294-
it('Postcondition: If unprovided, the DDB client is configured', async () => {
294+
//= aws-encryption-sdk-specification/framework/branch-key-store.md#initialization
295+
//= type=test
296+
//# If a DDB client needs to be constructed and the AWS KMS Configuration is KMS Key ARN or KMS MRKey ARN,
297+
//# a new DynamoDb client MUST be created with the region of the supplied KMS ARN.
298+
//#
299+
//# If a DDB client needs to be constructed and the AWS KMS Configuration is Discovery,
300+
//# a new DynamoDb client MUST be created with the default configuration.
301+
//#
302+
//# If a DDB client needs to be constructed and the AWS KMS Configuration is MRDiscovery,
303+
//# a new DynamoDb client MUST be created with the region configured in the MRDiscovery.
304+
it('If unprovided, the DDB client is configured', async () => {
295305
for (const ddbClient of falseyValues) {
296306
const { storage } = new BranchKeyStoreNode({
297307
storage: {
@@ -307,6 +317,40 @@ describe('Test Branch keystore', () => {
307317
await (storage as DynamoDBKeyStorage).ddbClient.config.region()
308318
).to.equal(getRegionFromIdentifier(KEY_ARN))
309319
}
320+
321+
const mrkDiscovery = new BranchKeyStoreNode({
322+
storage: {
323+
ddbTableName: DDB_TABLE_NAME
324+
},
325+
logicalKeyStoreName: LOGICAL_KEYSTORE_NAME,
326+
kmsConfiguration: { region: 'foo' },
327+
})
328+
329+
expect(
330+
await (mrkDiscovery.storage as DynamoDBKeyStorage).ddbClient.config.region()
331+
).to.equal('foo')
332+
333+
const discovery = new BranchKeyStoreNode({
334+
storage: {
335+
ddbTableName: DDB_TABLE_NAME
336+
},
337+
logicalKeyStoreName: LOGICAL_KEYSTORE_NAME,
338+
kmsConfiguration: 'discovery',
339+
})
340+
341+
expect(
342+
await (discovery.storage as DynamoDBKeyStorage).ddbClient.config.region()
343+
).to.equal('foo')
344+
})
345+
346+
it('Precondition: Only `discovery` is a valid string value', async () => {
347+
expect(() => new BranchKeyStoreNode({
348+
storage: {
349+
ddbTableName: DDB_TABLE_NAME
350+
},
351+
logicalKeyStoreName: LOGICAL_KEYSTORE_NAME,
352+
kmsConfiguration: 'not discovery' as any,
353+
})).to.throw('Unexpected config shape')
310354
})
311355

312356
it('Postcondition: If unprovided, the KMS client is configured', async () => {

modules/kms-keyring-node/test/kms_hkeyring_node.constructor.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ describe('KmsHierarchicalKeyRingNode: constructor', () => {
266266
//= type=test
267267
//# If no max cache size is provided, the cryptographic materials cache MUST be configured to a
268268
//# max cache size of 1000.
269-
it('Postcondition: The max cache size is initialized', () => {
269+
it('The max cache size is initialized', () => {
270270
expect(
271271
new KmsHierarchicalKeyRingNode({
272272
branchKeyId,

0 commit comments

Comments
 (0)