@@ -202,24 +202,24 @@ module {:options "-functionSyntax:4"} DdbEncryptionTestVectors {
202
202
}
203
203
expect ! bad;
204
204
}
205
- method DeleteTable (client : DDB .IDynamoDBClient)
205
+ method DeleteTable (client : DDB .IDynamoDBClient, nameonly tableName: DDB .TableArn := TableName )
206
206
requires client. ValidState ()
207
207
ensures client. ValidState ()
208
208
modifies client. Modifies
209
209
{
210
- var res := client. DeleteTable (DDB.DeleteTableInput(TableName := TableName ));
210
+ var res := client. DeleteTable (DDB.DeleteTableInput(TableName := tableName ));
211
211
}
212
212
213
- method SetupTestTable (writeConfig : TableConfig , readConfig : TableConfig )
213
+ method SetupTestTable (writeConfig : TableConfig , readConfig : TableConfig , nameonly createTableInput: DDB .CreateTableInput := schemaOnEncrypt )
214
214
returns (wClient : DDB. IDynamoDBClient, rClient : DDB. IDynamoDBClient)
215
215
ensures wClient. ValidState () && rClient. ValidState ()
216
216
ensures fresh (wClient) && fresh (wClient. Modifies)
217
217
ensures fresh (rClient) && fresh (rClient. Modifies)
218
218
{
219
219
wClient :- expect newGazelle (writeConfig);
220
220
rClient :- expect newGazelle (readConfig);
221
- DeleteTable (wClient);
222
- var _ :- expect wClient. CreateTable (schemaOnEncrypt );
221
+ DeleteTable (client := wClient, tableName := createTableInput.TableName );
222
+ var _ :- expect wClient. CreateTable (createTableInput );
223
223
}
224
224
225
225
function GetUsed (q : SimpleQuery ) : (DDB. ExpressionAttributeNameMap, DDB. ExpressionAttributeValueMap)
@@ -850,14 +850,9 @@ module {:options "-functionSyntax:4"} DdbEncryptionTestVectors {
850
850
851
851
// Create a PartiQL INSERT statement
852
852
// The dynamodb attributes are random and non-existent because ExecuteStatement is supposed to be failed before going into dynamodb.
853
- var insertStatement := "INSERT INTO \"" + TableName + "\" VALUE {'partition_key': 'a', 'sort_key': 'b', 'attribute1': 'a'";
853
+ var insertStatement := "INSERT INTO \"" + TableName + "\" VALUE {'partition_key': 'a', 'sort_key': 'b', 'attribute1': 'a'} ";
854
854
var inputForInsertStatement := DDB. ExecuteStatementInput (
855
- Statement := insertStatement,
856
- Parameters := None,
857
- ConsistentRead := None,
858
- NextToken := None,
859
- ReturnConsumedCapacity := None,
860
- Limit := None
855
+ Statement := insertStatement
861
856
);
862
857
var resultForInsertStatement := wClient. ExecuteStatement (inputForInsertStatement);
863
858
expect resultForInsertStatement. Failure?, "ExecuteStatement should have failed";
@@ -870,14 +865,9 @@ module {:options "-functionSyntax:4"} DdbEncryptionTestVectors {
870
865
871
866
// Create a PartiQL SELECT statement
872
867
// The dynamodb attributes are random and non-existent because ExecuteStatement is supposed to be failed before going into dynamodb.
873
- var selectStatement := "SELECT * FROM " + TableName + " WHERE partition_key = 'a' AND sort_key = 'b'";
868
+ var selectStatement := "SELECT * FROM \"" + TableName + "\" WHERE partition_key = 'a' AND sort_key = 'b'} ";
874
869
var inputForSelectStatement := DDB. ExecuteStatementInput (
875
- Statement := selectStatement,
876
- Parameters := None,
877
- ConsistentRead := Some(true),
878
- NextToken := None,
879
- ReturnConsumedCapacity := None,
880
- Limit := None
870
+ Statement := selectStatement
881
871
);
882
872
var resultForSelectStatement := rClient. ExecuteStatement (inputForSelectStatement);
883
873
expect resultForSelectStatement. Failure?, "ExecuteStatement should have failed";
@@ -887,6 +877,25 @@ module {:options "-functionSyntax:4"} DdbEncryptionTestVectors {
887
877
expect resultForSelectStatement. error. OpaqueWithText?, "Error should have been of type OpaqueWithText";
888
878
var hasDynamoDbEncryptionTransformsExceptionForSelectStatement? := String. HasSubString (resultForSelectStatement.error.objMessage, "ExecuteStatement not Supported on encrypted tables.");
889
879
expect hasDynamoDbEncryptionTransformsExceptionForSelectStatement?. Some?;
880
+
881
+ // Test for unconfigured Table
882
+ var unConfiguredTable := "unConfiguredTable";
883
+ var _, _ := SetupTestTable (writeConfig, readConfig, createTableInput := MakeCreateTableInput(tableName := unConfiguredTable));
884
+ var insertStatementForUnconfiguredTable := "INSERT INTO \"" + unConfiguredTable + "\" VALUE {'" + HashName + "': 0, 'attribute1': 'a'}";
885
+ var inputInsertStatementForUnconfiguredTable := DDB. ExecuteStatementInput (
886
+ Statement := insertStatementForUnconfiguredTable
887
+ );
888
+ var insertResultUnconfiguredTable := wClient. ExecuteStatement (inputInsertStatementForUnconfiguredTable);
889
+ expect insertResultUnconfiguredTable. Success?;
890
+
891
+ var selectStatementForUnconfiguredTable := "SELECT * FROM \"" + unConfiguredTable + "\" WHERE " + HashName + " = 0";
892
+ var inputSelectStatementForUnconfiguredTable := DDB. ExecuteStatementInput (
893
+ Statement := selectStatementForUnconfiguredTable
894
+ );
895
+ var selectResultUnconfiguredTable := rClient. ExecuteStatement (inputSelectStatementForUnconfiguredTable);
896
+ selectResultUnconfiguredTable. Success?;
897
+
898
+ DeleteTable (client := wClient, tableName := unConfiguredTable);
890
899
}
891
900
892
901
method BasicIoTestExecuteTransaction (writeConfig : TableConfig , readConfig : TableConfig )
@@ -1257,11 +1266,11 @@ module {:options "-functionSyntax:4"} DdbEncryptionTestVectors {
1257
1266
)
1258
1267
}
1259
1268
1260
- function MakeCreateTableInput () : DDB. CreateTableInput
1269
+ function MakeCreateTableInput (nameonly tableName: DDB .TableName := TableName ) : DDB. CreateTableInput
1261
1270
{
1262
1271
DDB. CreateTableInput (
1263
1272
AttributeDefinitions := [DDB.AttributeDefinition(AttributeName := HashName, AttributeType := DDB.ScalarAttributeType.N)],
1264
- TableName := TableName ,
1273
+ TableName := tableName ,
1265
1274
KeySchema := [DDB. KeySchemaElement (AttributeName := HashName, KeyType := DDB.HASH)],
1266
1275
LocalSecondaryIndexes := None,
1267
1276
GlobalSecondaryIndexes := None,
0 commit comments