Skip to content

Commit 6dedc67

Browse files
committedMay 6, 2024·
Assert branch key into separate method to reduce resource count
1 parent 2f4cfc9 commit 6dedc67

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed
 

‎DynamoDbEncryption/dafny/DynamoDbEncryption/test/DynamoDbGetEncryptedDataKeyDescriptionTest.dfy

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,7 @@ module DynamoDbGetEncryptedDataKeyDescriptionTest {
100100
expect actualDataKeyDescription.EncryptedDataKeyDescriptionOutput[0].keyProviderInfo.Some?;
101101
expect actualDataKeyDescription.EncryptedDataKeyDescriptionOutput[0].keyProviderInfo.value == "keyproviderInfo";
102102

103-
expect actualDataKeyDescription.EncryptedDataKeyDescriptionOutput[0].branchKeyId.Some?;
104-
expect actualDataKeyDescription.EncryptedDataKeyDescriptionOutput[0].branchKeyVersion.Some?;
105-
106-
expect actualDataKeyDescription.EncryptedDataKeyDescriptionOutput[0].branchKeyId.value == "keyproviderInfo";
107-
expect actualDataKeyDescription.EncryptedDataKeyDescriptionOutput[0].branchKeyVersion.value == "155b7a3d-7625-4826-4302-113d1179075a";
103+
assertBranchKey(actualDataKeyDescription);
108104
}
109105

110106
method {:test} TestHeaderInputRawRsaDataKeyDataKeyCase()
@@ -177,11 +173,7 @@ module DynamoDbGetEncryptedDataKeyDescriptionTest {
177173
expect actualDataKeyDescription.EncryptedDataKeyDescriptionOutput[0].keyProviderInfo.Some?;
178174
expect actualDataKeyDescription.EncryptedDataKeyDescriptionOutput[0].keyProviderInfo.value == "keyproviderInfo";
179175

180-
expect actualDataKeyDescription.EncryptedDataKeyDescriptionOutput[0].branchKeyId.Some?;
181-
expect actualDataKeyDescription.EncryptedDataKeyDescriptionOutput[0].branchKeyVersion.Some?;
182-
183-
expect actualDataKeyDescription.EncryptedDataKeyDescriptionOutput[0].branchKeyId.value == "keyproviderInfo";
184-
expect actualDataKeyDescription.EncryptedDataKeyDescriptionOutput[0].branchKeyVersion.value == "155b7a3d-7625-4826-4302-113d1179075a";
176+
assertBranchKey(actualDataKeyDescription);
185177
}
186178

187179
method {:test} TestDDBItemInputRawRsaDataKeyCase()
@@ -268,7 +260,7 @@ module DynamoDbGetEncryptedDataKeyDescriptionTest {
268260

269261
method {:test} TestNoHeaderFailureCase()
270262
{
271-
var expectedHead := CreatePartialHeader(testVersion, testFlavor1, testMsgID, testLegend, testEncContext, [testAwsKmsDataKey, testAwsKmsRsaDataKey]);
263+
var expectedHead := CreatePartialHeader(testVersion, testFlavor1, testMsgID, testLegend, testEncContext, [testAwsKmsDataKey]);
272264
var serializedHeader := expectedHead.serialize() + expectedHead.msgID;
273265
var attr := map["wrong_header_attribute" := ComAmazonawsDynamodbTypes.AttributeValue.B(serializedHeader)];
274266
var ddbEncResources :- expect DynamoDbEncryption.DynamoDbEncryption();
@@ -282,4 +274,14 @@ module DynamoDbGetEncryptedDataKeyDescriptionTest {
282274
expect actualDataKeyDescription.error.DynamoDbEncryptionException?;
283275
expect actualDataKeyDescription.error.message == "Header not found in the DynamoDB item.";
284276
}
277+
278+
method assertBranchKey(actualDataKeyDescription : Types.GetEncryptedDataKeyDescriptionOutput)
279+
{
280+
expect |actualDataKeyDescription.EncryptedDataKeyDescriptionOutput| == 1;
281+
expect actualDataKeyDescription.EncryptedDataKeyDescriptionOutput[0].branchKeyId.Some?;
282+
expect actualDataKeyDescription.EncryptedDataKeyDescriptionOutput[0].branchKeyVersion.Some?;
283+
284+
expect actualDataKeyDescription.EncryptedDataKeyDescriptionOutput[0].branchKeyId.value == "keyproviderInfo";
285+
expect actualDataKeyDescription.EncryptedDataKeyDescriptionOutput[0].branchKeyVersion.value == "155b7a3d-7625-4826-4302-113d1179075a";
286+
}
285287
}

0 commit comments

Comments
 (0)
Please sign in to comment.