mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
fix(dynamodb): read a PartiQL function call statement before refusing it (#7779)
This commit is contained in:
1 parent
21b8e9346b
commit
9ba53ec87d
3 files changed
+81
-7
No files matched your search
@@ -858,6 +858,28 @@ class DynamoDbPartiQLIntegrationTest {
|
||||
+ "Number of parameters in request and statement don't match."));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(40)
|
||||
void aCallStatementIsRefusedBeforeItsParametersAreCounted() {
|
||||
String outside = "EXISTS can only be used in ExecuteTransaction write requests.";
|
||||
|
||||
statement("foo(?)")
|
||||
.statusCode(400)
|
||||
.body("__type", equalTo("ValidationException"))
|
||||
.body("message", equalTo(outside));
|
||||
request("DynamoDB_20120810.BatchExecuteStatement", """
|
||||
{"Statements":[{"Statement":"foo(1)"}]}
|
||||
""")
|
||||
.statusCode(200)
|
||||
.body("Responses[0].Error.Code", equalTo("ValidationError"))
|
||||
.body("Responses[0].Error.Message", equalTo(outside));
|
||||
request("DynamoDB_20120810.ExecuteTransaction", """
|
||||
{"TransactStatements":[{"Statement":"foo(?)"}]}
|
||||
""")
|
||||
.statusCode(400)
|
||||
.body("message", equalTo("Validation failed in TransactStatements[0]: Unsupported operation in transaction."));
|
||||
}
|
||||
|
||||
private static void putItem(String pk, String attributes) {
|
||||
request("DynamoDB_20120810.PutItem", """
|
||||
{"TableName":"%s","Item":{"pk":{"S":"%s"},%s}}
|
||||
|
||||
@@ -968,6 +968,45 @@ class DynamoDbPartiQLParserTest {
|
||||
assertEquals(expand.apply(inTransaction), statementRefusal(statement, parameters, true));
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@CsvSource(delimiter = '|', quoteCharacter = '`', textBlock = """
|
||||
foo(1) | CALL
|
||||
foo() | CALL
|
||||
"foo"(1) | CALL
|
||||
FOO (1) | CALL
|
||||
foo(?) | CALL
|
||||
foo(<<>>) | CALL
|
||||
foo(1e999999) | CALL
|
||||
foo(foo(1), a.b[0]) | CALL
|
||||
size(1) | CALL
|
||||
attribute_exists(a) | CALL
|
||||
upper('a') | CALL
|
||||
EXISTS() | CALL
|
||||
EXISTS(1, 2) | CALL
|
||||
exists(foo(1)) | CALL
|
||||
((foo(1))); | CALL
|
||||
count(1) | Unsupported operation: CallAgg
|
||||
count(*) | Unsupported operation: CallAgg
|
||||
count(DISTINCT a) | Unsupported operation: CallAgg
|
||||
foo(1).a | Unsupported operation: Path
|
||||
foo(1)[0] | Unsupported operation: Path
|
||||
foo(1) IS MISSING | Unsupported operation: IsType
|
||||
foo(1)(2) | NWF Unexpected token after expression
|
||||
foo(1 2) | NWF Expected RIGHT_PAREN
|
||||
foo(1,) | NWF Unexpected term
|
||||
foo(a, *) | NWF Unexpected term
|
||||
foo(*) | NWF foo(*) is not allowed
|
||||
count() | NWF Aggregate functions are always unary
|
||||
""")
|
||||
void refusesACallStatementOnceItParses(String statement, String message) {
|
||||
String expected = message.replace("NWF ", "Statement wasn't well formed, can't be processed: ");
|
||||
|
||||
assertEquals(expected.replace("CALL", "EXISTS can only be used in ExecuteTransaction write requests."),
|
||||
statementRefusal(statement, 0));
|
||||
assertEquals(expected.replace("CALL", "Unsupported operation in transaction."),
|
||||
statementRefusal(statement, 0, true));
|
||||
}
|
||||
|
||||
@Test
|
||||
void countsInOperandsWithTheOperandChecks() {
|
||||
String tooMany = "The IN operator is provided with too many operands; number of operands: 101";
|
||||
|
||||
Reference in new issue
Block a user