@@ -384,6 +384,7 @@ module {:options "-functionSyntax:4"} DdbEncryptionTestVectors {
384
384
BasicIoTestBatchWriteItem (c1, c2, globalRecords);
385
385
BasicIoTestPutItem (c1, c2, globalRecords);
386
386
BasicIoTestTransactWriteItems (c1, c2, globalRecords);
387
+ BasicIoTestExecuteStatement (c1, c2);
387
388
}
388
389
}
389
390
@@ -834,6 +835,50 @@ module {:options "-functionSyntax:4"} DdbEncryptionTestVectors {
834
835
BasicIoTestTransactGetItems (rClient, records);
835
836
}
836
837
838
+ method BasicIoTestExecuteStatement (writeConfig : TableConfig , readConfig : TableConfig )
839
+ {
840
+ var wClient :- expect newGazelle (writeConfig);
841
+ var rClient :- expect newGazelle (readConfig);
842
+ DeleteTable (wClient);
843
+ var _ :- expect wClient. CreateTable (schemaOnEncrypt);
844
+
845
+ // Create a PartiQL INSERT statement
846
+ // The dynamodb attributes are random and non-existent because ExecuteStatement is supposed to be failed before going into dynamodb.
847
+ var insertStatement := "INSERT INTO \"" + TableName + "\" VALUE {'partition_key': 'a', 'sort_key': 'b', 'attribute1': 'a'";
848
+ var inputForInsertStatement := DDB. ExecuteStatementInput (
849
+ Statement := insertStatement,
850
+ Parameters := None,
851
+ ConsistentRead := None,
852
+ NextToken := None,
853
+ ReturnConsumedCapacity := None,
854
+ Limit := None
855
+ );
856
+ var resultForInsertStatement := wClient. ExecuteStatement (inputForInsertStatement);
857
+ expect resultForInsertStatement. Failure?, "ExecuteStatement should have failed";
858
+ // This error is of type DynamoDbEncryptionTransformsException
859
+ // but AWS SDK wraps it into its own type for which customers should be unwrapping.
860
+ // In test vectors, we still have to change the error from AWS SDK to dafny so it turns out to be OpaqueWithText.
861
+ expect resultForInsertStatement. error. OpaqueWithText?, "Error should have been of type OpaqueWithText";
862
+
863
+ // Create a PartiQL SELECT statement
864
+ // The dynamodb attributes are random and non-existent because ExecuteStatement is supposed to be failed before going into dynamodb.
865
+ var selectStatement := "SELECT * FROM " + TableName + " WHERE partition_key = 'a' AND sort_key = 'b'";
866
+ var inputForSelectStatement := DDB. ExecuteStatementInput (
867
+ Statement := selectStatement,
868
+ Parameters := None,
869
+ ConsistentRead := Some(true),
870
+ NextToken := None,
871
+ ReturnConsumedCapacity := None,
872
+ Limit := None
873
+ );
874
+ var resultForSelectStatement := rClient. ExecuteStatement (inputForSelectStatement);
875
+ expect resultForSelectStatement. Failure?, "ExecuteStatement should have failed";
876
+ // This error is of type DynamoDbEncryptionTransformsException
877
+ // but AWS SDK wraps it into its own type for which customers should be unwrapping.
878
+ // In test vectors, we still have to change the error from AWS SDK to dafny so it turns out to be OpaqueWithText.
879
+ expect resultForSelectStatement. error. OpaqueWithText?, "Error should have been of type OpaqueWithText";
880
+ }
881
+
837
882
method FindMatchingRecord (expected : DDB .AttributeMap, actual : DDB .ItemList) returns (output : bool )
838
883
{
839
884
var exp := NormalizeItem (expected);
0 commit comments