@@ -386,6 +386,7 @@ module {:options "-functionSyntax:4"} DdbEncryptionTestVectors {
386
386
BasicIoTestTransactWriteItems (c1, c2, globalRecords);
387
387
BasicIoTestExecuteStatement (c1, c2);
388
388
BasicIoTestExecuteTransaction (c1, c2);
389
+ BasicIoTestBatchExecuteStatement (c1, c2);
389
390
}
390
391
}
391
392
@@ -911,16 +912,79 @@ module {:options "-functionSyntax:4"} DdbEncryptionTestVectors {
911
912
// This error is of type DynamoDbEncryptionTransformsException
912
913
// but AWS SDK wraps it into its own type for which customers should be unwrapping.
913
914
// In test vectors, we still have to change the error from AWS SDK to dafny so it turns out to be OpaqueWithText.
914
- print (resultForWriteTransaction);
915
915
expect resultForWriteTransaction. error. OpaqueWithText?, "Error should have been of type OpaqueWithText";
916
916
917
917
// Test with read client
918
918
var resultForReadTransaction := rClient. ExecuteTransaction (inputForTransaction);
919
919
expect resultForReadTransaction. Failure?, "ExecuteTransaction should have failed";
920
- print (resultForReadTransaction);
920
+ // This error is of type DynamoDbEncryptionTransformsException
921
+ // but AWS SDK wraps it into its own type for which customers should be unwrapping.
922
+ // In test vectors, we still have to change the error from AWS SDK to dafny so it turns out to be OpaqueWithText.
921
923
expect resultForReadTransaction. error. OpaqueWithText?, "Error should have been of type OpaqueWithText";
922
924
}
923
925
926
+ method BasicIoTestBatchExecuteStatement (writeConfig : TableConfig , readConfig : TableConfig )
927
+ {
928
+ var wClient :- expect newGazelle (writeConfig);
929
+ var rClient :- expect newGazelle (readConfig);
930
+ DeleteTable (wClient);
931
+ var _ :- expect wClient. CreateTable (schemaOnEncrypt);
932
+
933
+ // Create a batch of PartiQL statements
934
+ // The dynamodb attributes are random and non-existent because BatchExecuteStatement is supposed to fail before going into dynamodb
935
+ var statements := [
936
+ DDB. BatchStatementRequest (
937
+ Statement := "INSERT INTO \"" + TableName + "\" VALUE {'partition_key': 'a', 'sort_key': 'b', 'attribute1': 'value1'}",
938
+ Parameters := None,
939
+ ConsistentRead := None
940
+ ),
941
+ DDB. BatchStatementRequest (
942
+ Statement := "INSERT INTO \"" + TableName + "\" VALUE {'partition_key': 'c', 'sort_key': 'd', 'attribute1': 'value2'}",
943
+ Parameters := None,
944
+ ConsistentRead := None
945
+ ),
946
+ DDB. BatchStatementRequest (
947
+ Statement := "SELECT * FROM " + TableName + " WHERE partition_key = 'a' AND sort_key = 'b'",
948
+ Parameters := None,
949
+ ConsistentRead := Some(true)
950
+ )
951
+ ];
952
+
953
+ // Test with write client for batch insert
954
+ var inputForBatchInsert := DDB. BatchExecuteStatementInput (
955
+ Statements := statements[..2], // Just the INSERT statements
956
+ ReturnConsumedCapacity := None
957
+ );
958
+
959
+ var resultForBatchInsert := wClient. BatchExecuteStatement (inputForBatchInsert);
960
+ expect resultForBatchInsert. Failure?, "BatchExecuteStatement for inserts should have failed";
961
+ // This error is of type DynamoDbEncryptionTransformsException
962
+ // but AWS SDK wraps it into its own type for which customers should be unwrapping.
963
+ // In test vectors, we still have to change the error from AWS SDK to dafny so it turns out to be OpaqueWithText.
964
+ expect resultForBatchInsert. error. OpaqueWithText?, "Error should have been of type OpaqueWithText";
965
+
966
+ // Test with read client for batch select
967
+ var inputForBatchSelect := DDB. BatchExecuteStatementInput (
968
+ Statements := statements[2..], // Just the SELECT statement
969
+ ReturnConsumedCapacity := None
970
+ );
971
+
972
+ var resultForBatchSelect := rClient. BatchExecuteStatement (inputForBatchSelect);
973
+ expect resultForBatchSelect. Failure?, "BatchExecuteStatement for selects should have failed";
974
+ expect resultForBatchSelect. error. OpaqueWithText?, "Error should have been of type OpaqueWithText";
975
+
976
+ // Test with mixed batch (both inserts and selects)
977
+ var inputForMixedBatch := DDB. BatchExecuteStatementInput (
978
+ Statements := statements, // All statements
979
+ ReturnConsumedCapacity := None
980
+ );
981
+
982
+ var resultForMixedBatch := wClient. BatchExecuteStatement (inputForMixedBatch);
983
+ expect resultForMixedBatch. Failure?, "BatchExecuteStatement for mixed batch should have failed";
984
+ expect resultForMixedBatch. error. OpaqueWithText?, "Error should have been of type OpaqueWithText";
985
+ }
986
+
987
+
924
988
method FindMatchingRecord (expected : DDB .AttributeMap, actual : DDB .ItemList) returns (output : bool )
925
989
{
926
990
var exp := NormalizeItem (expected);
0 commit comments