Skip to content

Commit 2a9c145

Browse files
auto commit
1 parent fa7b783 commit 2a9c145

File tree

1 file changed

+11
-14
lines changed

1 file changed

+11
-14
lines changed

TestVectors/dafny/DDBEncryption/src/TestVectors.dfy

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,8 @@ module {:options "-functionSyntax:4"} DdbEncryptionTestVectors {
399399
BasicIoTestTransactWriteItems(c1, c2, globalRecords);
400400
BasicIoTestUpdateItem(c1, c2, globalRecords, "One");
401401
BasicIoTestUpdateItem(c1, c2, globalRecords, "Two");
402-
BasicIoTestDeleteItem(c1, c2, globalRecords);
402+
BasicIoTestDeleteItem(c1, c2, globalRecords, "One", "Uno");
403+
BasicIoTestDeleteItem(c1, c2, globalRecords, "Two", "Dos");
403404
BasicIoTestExecuteStatement(c1, c2);
404405
BasicIoTestExecuteTransaction(c1, c2);
405406
BasicIoTestBatchExecuteStatement(c1, c2);
@@ -849,9 +850,7 @@ module {:options "-functionSyntax:4"} DdbEncryptionTestVectors {
849850

850851
method BasicIoTestUpdateItem(writeConfig : TableConfig, readConfig : TableConfig, records : seq<Record>, attributeToUpdate: DDB.AttributeName)
851852
{
852-
var wClient :- expect newGazelle(writeConfig);
853-
var rClient :- expect newGazelle(readConfig);
854-
DeleteTable(wClient);
853+
var wClient, rClient := SetupTestTable(writeConfig, readConfig);
855854
WriteAllRecords(wClient, records);
856855

857856
// Update each record by appending "updated" to the partition key
@@ -889,21 +888,19 @@ module {:options "-functionSyntax:4"} DdbEncryptionTestVectors {
889888
}
890889
}
891890

892-
method BasicIoTestDeleteItem(writeConfig : TableConfig, readConfig : TableConfig, records : seq<Record>)
891+
method BasicIoTestDeleteItem(writeConfig : TableConfig, readConfig : TableConfig, records : seq<Record>, attributeToDelete: DDB.AttributeName, expectedAttributeValue: string)
893892
{
894-
var wClient :- expect newGazelle(writeConfig);
895-
var rClient :- expect newGazelle(readConfig);
896-
DeleteTable(wClient);
893+
var wClient, rClient := SetupTestTable(writeConfig, readConfig);
897894
WriteAllRecords(wClient, records);
898-
var attributeToDelete := "Two";
899-
var valueToDelete := "Dos";
895+
// var attributeToDelete := "Two";
896+
// var valueToDelete := "Dos";
900897
// Try to delete records with a condition expression with condition to
901-
// delete records if the record has an attribute attributeToDelete with value valueToDelete
898+
// delete records if the record has an attribute attributeToDelete with value expectedAttributeValue
902899
for i := 0 to |records| {
903-
// Set up condition expression to only delete if Two = valueToDelete
900+
// Set up condition expression to only delete if Two = expectedAttributeValue
904901
var conditionExpr := "#attr = :val";
905902
var exprAttrNames := map["#attr" := attributeToDelete];
906-
var exprAttrValues := map[":val" := DDB.AttributeValue.S(valueToDelete)];
903+
var exprAttrValues := map[":val" := DDB.AttributeValue.S(expectedAttributeValue)];
907904
expect HashName in records[i].item, "`HashName` is not in records.";
908905
var deleteInput := DDB.DeleteItemInput(
909906
TableName := TableName,
@@ -926,7 +923,7 @@ module {:options "-functionSyntax:4"} DdbEncryptionTestVectors {
926923
expect deleteResult.error.OpaqueWithText?, "Error should have been of type OpaqueWithText";
927924
var hasDynamoDbEncryptionTransformsException? := String.HasSubString(deleteResult.error.objMessage, "Condition Expressions forbidden on encrypted attributes");
928925
expect hasDynamoDbEncryptionTransformsException?.Some?, "Error might is not be of type DynamoDbEncryptionTransformsException";
929-
} else if attributeToDelete in records[i].item && records[i].item[attributeToDelete].S? && records[i].item[attributeToDelete].S == valueToDelete {
926+
} else if attributeToDelete in records[i].item && records[i].item[attributeToDelete].S? && records[i].item[attributeToDelete].S == expectedAttributeValue {
930927
expect deleteResult.Success?, "DeleteItem should have failed.";
931928
expect deleteResult.value.Attributes.Some?, "DeleteItemOutput should have had some attribute because ReturnValues was set as `ALL_OLD` in DeleteItemInput";
932929
expect deleteResult.value.Attributes.value == records[i].item, "Wrong item was deleted.";

0 commit comments

Comments
 (0)