@@ -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 ( ) => {
0 commit comments