mirror of
https://github.com/floci-io/floci.git
synced 2026-11-23 14:10:49 -05:00
fix(dynamodb): validate query key types (#2469)
* fix(dynamodb): validate query key types Closes #2467 * fix(dynamodb): harden query validation * fix(dynamodb): validate query value payloads
This commit is contained in:
1 parent
e3df59ae1f
commit
a57c6c8112
7 files changed
+276
-27
No files matched your search
+14
@@ -84,6 +84,16 @@ class DynamoDbAccessPathValidationTest {
|
||||
":status", value("open")))));
|
||||
}
|
||||
|
||||
@Test
|
||||
void queryRejectsKeyConditionValuesWithWrongSchemaTypes() {
|
||||
assertValidationException(() -> ddb.query(request -> request
|
||||
.tableName(TABLE)
|
||||
.keyConditionExpression("pk = :pk AND sk > :sk")
|
||||
.expressionAttributeValues(Map.of(
|
||||
":pk", value("p1"),
|
||||
":sk", numberValue("1")))));
|
||||
}
|
||||
|
||||
@Test
|
||||
void acceptsTableKeyConditionsInEitherOrder() {
|
||||
var response = ddb.query(request -> request
|
||||
@@ -223,6 +233,10 @@ class DynamoDbAccessPathValidationTest {
|
||||
return AttributeValue.builder().s(value).build();
|
||||
}
|
||||
|
||||
private static AttributeValue numberValue(String value) {
|
||||
return AttributeValue.builder().n(value).build();
|
||||
}
|
||||
|
||||
private static Condition condition(ComparisonOperator operator, String attributeValue) {
|
||||
return Condition.builder()
|
||||
.comparisonOperator(operator)
|
||||
|
||||
Reference in new issue
Block a user