Skip to content

Commit ff6bdf2

Browse files
committed
Update tests
1 parent 7ec6a04 commit ff6bdf2

File tree

10 files changed

+45
-10
lines changed

10 files changed

+45
-10
lines changed

modules/example-node/src/kms-hierarchical-keyring/caching_cmm.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export async function hKeyringCachingCMMNodeSimpleTest(
3232
// This SHOULD be the same configuration that you used
3333
// to initially create and populate your KeyStore.
3434
const keyStore = new BranchKeyStoreNode({
35-
ddbTableName: keyStoreTableName,
35+
storage: {ddbTableName: keyStoreTableName},
3636
logicalKeyStoreName: logicalKeyStoreName,
3737
kmsConfiguration: new SrkCompatibilityKmsConfig(kmsKeyId),
3838
})

modules/example-node/src/kms-hierarchical-keyring/disable_commitment.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export async function hKeyringDisableCommitmentTest(
3030
// This SHOULD be the same configuration that you used
3131
// to initially create and populate your KeyStore.
3232
const keyStore = new BranchKeyStoreNode({
33-
ddbTableName: keyStoreTableName,
33+
storage: {ddbTableName: keyStoreTableName},
3434
logicalKeyStoreName: logicalKeyStoreName,
3535
kmsConfiguration: new SrkCompatibilityKmsConfig(kmsKeyId),
3636
})

modules/example-node/src/kms-hierarchical-keyring/multi_keyring.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export async function hierarchicalAesMultiKeyringTest(
3838
// This SHOULD be the same configuration that you used
3939
// to initially create and populate your KeyStore.
4040
const keyStore = new BranchKeyStoreNode({
41-
ddbTableName: keyStoreTableName,
41+
storage: {ddbTableName: keyStoreTableName},
4242
logicalKeyStoreName: logicalKeyStoreName,
4343
kmsConfiguration: new SrkCompatibilityKmsConfig(kmsKeyId),
4444
})

modules/example-node/src/kms-hierarchical-keyring/multi_tenancy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ export async function hKeyringMultiTenancy(
9898
// This SHOULD be the same configuration that you used
9999
// to initially create and populate your KeyStore.
100100
const keyStore = new BranchKeyStoreNode({
101-
ddbTableName: keyStoreTableName,
101+
storage: {ddbTableName: keyStoreTableName},
102102
logicalKeyStoreName: logicalKeyStoreName,
103103
kmsConfiguration: new SrkCompatibilityKmsConfig(kmsKeyId),
104104
})

modules/example-node/src/kms-hierarchical-keyring/simple.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export async function hKeyringSimpleTest(
6363
// This SHOULD be the same configuration that you used
6464
// to initially create and populate your KeyStore.
6565
const keyStore = new BranchKeyStoreNode({
66-
ddbTableName: keyStoreTableName,
66+
storage: {ddbTableName: keyStoreTableName},
6767
logicalKeyStoreName: logicalKeyStoreName,
6868
kmsConfiguration: new SrkCompatibilityKmsConfig(kmsKeyId),
6969
})

modules/example-node/src/kms-hierarchical-keyring/stream.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export async function hKeyringStreamTest(
3838
// This SHOULD be the same configuration that you used
3939
// to initially create and populate your KeyStore.
4040
const keyStore = new BranchKeyStoreNode({
41-
ddbTableName: keyStoreTableName,
41+
storage: {ddbTableName: keyStoreTableName},
4242
logicalKeyStoreName: logicalKeyStoreName,
4343
kmsConfiguration: new SrkCompatibilityKmsConfig(kmsKeyId),
4444
})

modules/kms-keyring-node/src/kms_hkeyring_node.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ export class KmsHierarchicalKeyRingNode
9595

9696
const partition = randomBytes(64)
9797
readOnlyProperty(this, '_partition', partition)
98-
readOnlyProperty(this, '_logicalKeyStoreName', stringToUtf8Bytes(keyStore.logicalKeyStoreName))
9998

10099
/* Precondition: The branch key id must be a string */
101100
if (branchKeyId) {
@@ -123,6 +122,8 @@ export class KmsHierarchicalKeyRingNode
123122
'The keystore must be a BranchKeyStore'
124123
)
125124

125+
readOnlyProperty(this, '_logicalKeyStoreName', stringToUtf8Bytes(keyStore.getKeyStoreInfo().logicalKeyStoreName))
126+
126127
/* Precondition: The cache limit TTL must be a number */
127128
needs(
128129
typeof cacheLimitTtl === 'number',

modules/kms-keyring-node/test/kms_hkeyring_node.edk-order.test.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ import {
3535
testOnDecryptError,
3636
testOnEncrypt,
3737
} from './kms_hkeyring_node.test'
38-
import { BranchKeyStoreNode } from '@aws-crypto/branch-keystore-node'
38+
import { BranchKeyStoreNode, KeyStoreInfoOutput } from '@aws-crypto/branch-keystore-node'
3939
chai.use(chaiAsPromised)
4040

4141
// an edk that can't even be destructured according to any alg suite
@@ -145,6 +145,17 @@ describe('KmsHierarchicalKeyRingNode: decrypt EDK order', () => {
145145
)
146146
}
147147
})
148+
149+
keyStore.getKeyStoreInfo.callsFake(function(): KeyStoreInfoOutput {
150+
return {
151+
keystoreId: "keyStoreId",
152+
keystoreTableName: "keystoreTableName",
153+
logicalKeyStoreName: "logicalKeyStoreName",
154+
grantTokens: [],
155+
// This is not used by any tests
156+
kmsConfiguration: null as any
157+
}
158+
})
148159
})
149160

150161
afterEach(() => {

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

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ import { expect } from 'chai'
3434
import Sinon from 'sinon'
3535
import { KMSClient } from '@aws-sdk/client-kms'
3636
import { DynamoDBClient } from '@aws-sdk/client-dynamodb'
37-
import { BranchKeyStoreNode } from '@aws-crypto/branch-keystore-node'
37+
import { BranchKeyStoreNode, KeyStoreInfoOutput } from '@aws-crypto/branch-keystore-node'
3838

3939
const branchKeyIdA = BRANCH_KEY_ID_A
4040
const branchKeyIdB = BRANCH_KEY_ID_B
@@ -129,6 +129,17 @@ describe('KmsHierarchicalKeyRingNode: onDecrypt', () => {
129129
)
130130
}
131131
})
132+
133+
keyStore.getKeyStoreInfo.callsFake(function(): KeyStoreInfoOutput {
134+
return {
135+
keystoreId: "keyStoreId",
136+
keystoreTableName: "keystoreTableName",
137+
logicalKeyStoreName: "logicalKeyStoreName",
138+
grantTokens: [],
139+
// This is not used by any tests
140+
kmsConfiguration: null as any
141+
}
142+
})
132143
})
133144

134145
afterEach(() => {
@@ -584,6 +595,7 @@ describe('KmsHierarchicalKeyRingNode: onDecrypt', () => {
584595

585596
it('CMC evictions occur due to capacity', async () => {
586597
const maxCacheSize = 1
598+
587599
const hkr = new KmsHierarchicalKeyRingNode({
588600
branchKeyIdSupplier,
589601
keyStore,

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

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import {
2828
testOnEncrypt,
2929
testOnEncryptError,
3030
} from './kms_hkeyring_node.test'
31-
import { BranchKeyStoreNode } from '@aws-crypto/branch-keystore-node'
31+
import { BranchKeyStoreNode, KeyStoreInfoOutput } from '@aws-crypto/branch-keystore-node'
3232
chai.use(chaiAsPromised)
3333

3434
const branchKeyIdA = BRANCH_KEY_ID_A
@@ -84,6 +84,17 @@ describe('KmsHierarchicalKeyRingNode: onEncrypt', () => {
8484
)
8585
}
8686
})
87+
88+
keyStore.getKeyStoreInfo.callsFake(function(): KeyStoreInfoOutput {
89+
return {
90+
keystoreId: "keyStoreId",
91+
keystoreTableName: "keystoreTableName",
92+
logicalKeyStoreName: "logicalKeyStoreName",
93+
grantTokens: [],
94+
// This is not used by any tests
95+
kmsConfiguration: null as any
96+
}
97+
})
8798
})
8899

89100
// what to do after each test: reset all sinons

0 commit comments

Comments
 (0)