@@ -202,24 +202,24 @@ module {:options "-functionSyntax:4"} DdbEncryptionTestVectors {
202202 }
203203 expect ! bad;
204204 }
205- method DeleteTable (client : DDB .IDynamoDBClient)
205+ method DeleteTable (client : DDB .IDynamoDBClient, nameonly tableName: DDB .TableArn := TableName )
206206 requires client. ValidState ()
207207 ensures client. ValidState ()
208208 modifies client. Modifies
209209 {
210- var res := client. DeleteTable (DDB.DeleteTableInput(TableName := TableName ));
210+ var res := client. DeleteTable (DDB.DeleteTableInput(TableName := tableName ));
211211 }
212212
213- method SetupTestTable (writeConfig : TableConfig , readConfig : TableConfig )
213+ method SetupTestTable (writeConfig : TableConfig , readConfig : TableConfig , nameonly createTableInput: DDB .CreateTableInput := schemaOnEncrypt )
214214 returns (wClient : DDB. IDynamoDBClient, rClient : DDB. IDynamoDBClient)
215215 ensures wClient. ValidState () && rClient. ValidState ()
216216 ensures fresh (wClient) && fresh (wClient. Modifies)
217217 ensures fresh (rClient) && fresh (rClient. Modifies)
218218 {
219219 wClient :- expect newGazelle (writeConfig);
220220 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 );
223223 }
224224
225225 function GetUsed (q : SimpleQuery ) : (DDB. ExpressionAttributeNameMap, DDB. ExpressionAttributeValueMap)
@@ -850,14 +850,9 @@ module {:options "-functionSyntax:4"} DdbEncryptionTestVectors {
850850
851851 // Create a PartiQL INSERT statement
852852 // 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'} ";
854854 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
861856 );
862857 var resultForInsertStatement := wClient. ExecuteStatement (inputForInsertStatement);
863858 expect resultForInsertStatement. Failure?, "ExecuteStatement should have failed";
@@ -870,14 +865,9 @@ module {:options "-functionSyntax:4"} DdbEncryptionTestVectors {
870865
871866 // Create a PartiQL SELECT statement
872867 // 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'} ";
874869 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
881871 );
882872 var resultForSelectStatement := rClient. ExecuteStatement (inputForSelectStatement);
883873 expect resultForSelectStatement. Failure?, "ExecuteStatement should have failed";
@@ -887,6 +877,25 @@ module {:options "-functionSyntax:4"} DdbEncryptionTestVectors {
887877 expect resultForSelectStatement. error. OpaqueWithText?, "Error should have been of type OpaqueWithText";
888878 var hasDynamoDbEncryptionTransformsExceptionForSelectStatement? := String. HasSubString (resultForSelectStatement.error.objMessage, "ExecuteStatement not Supported on encrypted tables.");
889879 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);
890899 }
891900
892901 method BasicIoTestExecuteTransaction (writeConfig : TableConfig , readConfig : TableConfig )
@@ -1257,11 +1266,11 @@ module {:options "-functionSyntax:4"} DdbEncryptionTestVectors {
12571266 )
12581267 }
12591268
1260- function MakeCreateTableInput () : DDB. CreateTableInput
1269+ function MakeCreateTableInput (nameonly tableName: DDB .TableName := TableName ) : DDB. CreateTableInput
12611270 {
12621271 DDB. CreateTableInput (
12631272 AttributeDefinitions := [DDB.AttributeDefinition(AttributeName := HashName, AttributeType := DDB.ScalarAttributeType.N)],
1264- TableName := TableName ,
1273+ TableName := tableName ,
12651274 KeySchema := [DDB. KeySchemaElement (AttributeName := HashName, KeyType := DDB.HASH)],
12661275 LocalSecondaryIndexes := None,
12671276 GlobalSecondaryIndexes := None,
0 commit comments