Skip to content

Commit 1f0c6bc

Browse files
check substring
1 parent 6719ef1 commit 1f0c6bc

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

TestVectors/dafny/DDBEncryption/src/TestVectors.dfy

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ module {:options "-functionSyntax:4"} DdbEncryptionTestVectors {
1919
import opened DynamoDbEncryptionUtil
2020
import opened DdbItemJson
2121
import opened JsonConfig
22+
import StandardLibrary.String
2223

2324
import WriteManifest
2425
import EncryptManifest
@@ -864,6 +865,8 @@ module {:options "-functionSyntax:4"} DdbEncryptionTestVectors {
864865
// but AWS SDK wraps it into its own type for which customers should be unwrapping.
865866
// In test vectors, we still have to change the error from AWS SDK to dafny so it turns out to be OpaqueWithText.
866867
expect resultForInsertStatement.error.OpaqueWithText?, "Error should have been of type OpaqueWithText";
868+
var hasDynamoDbEncryptionTransformsExceptionForInsertStatement? := String.HasSubString(resultForInsertStatement.error.objMessage, "DynamoDbEncryptionTransformsException");
869+
expect hasDynamoDbEncryptionTransformsExceptionForInsertStatement?.Some?;
867870

868871
// Create a PartiQL SELECT statement
869872
// The dynamodb attributes are random and non-existent because ExecuteStatement is supposed to be failed before going into dynamodb.
@@ -882,6 +885,8 @@ module {:options "-functionSyntax:4"} DdbEncryptionTestVectors {
882885
// but AWS SDK wraps it into its own type for which customers should be unwrapping.
883886
// In test vectors, we still have to change the error from AWS SDK to dafny so it turns out to be OpaqueWithText.
884887
expect resultForSelectStatement.error.OpaqueWithText?, "Error should have been of type OpaqueWithText";
888+
var hasDynamoDbEncryptionTransformsExceptionForSelectStatement? := String.HasSubString(resultForSelectStatement.error.objMessage, "DynamoDbEncryptionTransformsException");
889+
expect hasDynamoDbEncryptionTransformsExceptionForSelectStatement?.Some?;
885890
}
886891

887892
method BasicIoTestExecuteTransaction(writeConfig : TableConfig, readConfig : TableConfig)
@@ -913,6 +918,8 @@ module {:options "-functionSyntax:4"} DdbEncryptionTestVectors {
913918
// but AWS SDK wraps it into its own type for which customers should be unwrapping.
914919
// In test vectors, we still have to change the error from AWS SDK to dafny so it turns out to be OpaqueWithText.
915920
expect resultForWriteTransaction.error.OpaqueWithText?, "Error should have been of type OpaqueWithText";
921+
var hasDynamoDbEncryptionTransformsExceptionForWriteTransaction? := String.HasSubString(resultForWriteTransaction.error.objMessage, "DynamoDbEncryptionTransformsException");
922+
expect hasDynamoDbEncryptionTransformsExceptionForWriteTransaction?.Some?;
916923

917924
// Test with read client
918925
var resultForReadTransaction := rClient.ExecuteTransaction(inputForTransaction);
@@ -921,6 +928,8 @@ module {:options "-functionSyntax:4"} DdbEncryptionTestVectors {
921928
// but AWS SDK wraps it into its own type for which customers should be unwrapping.
922929
// In test vectors, we still have to change the error from AWS SDK to dafny so it turns out to be OpaqueWithText.
923930
expect resultForReadTransaction.error.OpaqueWithText?, "Error should have been of type OpaqueWithText";
931+
var hasDynamoDbEncryptionTransformsExceptionForReadTransaction? := String.HasSubString(resultForReadTransaction.error.objMessage, "DynamoDbEncryptionTransformsException");
932+
expect hasDynamoDbEncryptionTransformsExceptionForReadTransaction?.Some?;
924933
}
925934

926935
method BasicIoTestBatchExecuteStatement(writeConfig : TableConfig, readConfig : TableConfig)
@@ -959,6 +968,8 @@ module {:options "-functionSyntax:4"} DdbEncryptionTestVectors {
959968
// but AWS SDK wraps it into its own type for which customers should be unwrapping.
960969
// In test vectors, we still have to change the error from AWS SDK to dafny so it turns out to be OpaqueWithText.
961970
expect resultForBatchInsert.error.OpaqueWithText?, "Error should have been of type OpaqueWithText";
971+
var hasDynamoDbEncryptionTransformsExceptionForBatchInsert? := String.HasSubString(resultForBatchInsert.error.objMessage, "DynamoDbEncryptionTransformsException");
972+
expect hasDynamoDbEncryptionTransformsExceptionForBatchInsert?.Some?;
962973

963974
// Test with read client for batch select
964975
var inputForBatchSelect := DDB.BatchExecuteStatementInput(
@@ -972,6 +983,8 @@ module {:options "-functionSyntax:4"} DdbEncryptionTestVectors {
972983
// but AWS SDK wraps it into its own type for which customers should be unwrapping.
973984
// In test vectors, we still have to change the error from AWS SDK to dafny so it turns out to be OpaqueWithText.
974985
expect resultForBatchSelect.error.OpaqueWithText?, "Error should have been of type OpaqueWithText";
986+
var hasDynamoDbEncryptionTransformsExceptionForBatchSelect? := String.HasSubString(resultForBatchSelect.error.objMessage, "DynamoDbEncryptionTransformsException");
987+
expect hasDynamoDbEncryptionTransformsExceptionForBatchSelect?.Some?;
975988

976989
// Test with mixed batch (both inserts and selects)
977990
var inputForMixedBatch := DDB.BatchExecuteStatementInput(
@@ -985,6 +998,8 @@ module {:options "-functionSyntax:4"} DdbEncryptionTestVectors {
985998
// but AWS SDK wraps it into its own type for which customers should be unwrapping.
986999
// In test vectors, we still have to change the error from AWS SDK to dafny so it turns out to be OpaqueWithText.
9871000
expect resultForMixedBatch.error.OpaqueWithText?, "Error should have been of type OpaqueWithText";
1001+
var hasDynamoDbEncryptionTransformsExceptionForMixedBatch? := String.HasSubString(resultForMixedBatch.error.objMessage, "DynamoDbEncryptionTransformsException");
1002+
expect hasDynamoDbEncryptionTransformsExceptionForMixedBatch?.Some?;
9881003
}
9891004

9901005

0 commit comments

Comments
 (0)