mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
fix(sfn): validate Map numeric path fields (#3827)
* fix(sfn): validate Map numeric path fields * fix(sfn): enforce ItemBatcher byte limit * fix(sfn): import BigDecimal for map number validation
This commit is contained in:
1 parent
c0ed88d647
commit
76a0b865ca
2 files changed
+159
-2
No files matched your search
+82
@@ -425,6 +425,88 @@ class StepFunctionsValidateStateMachineDefinitionIntegrationTest {
|
||||
.body("diagnostics", hasSize(0));
|
||||
}
|
||||
|
||||
@Test
|
||||
void jsonataMapRejectsNestedNumberPathFields() {
|
||||
String def = """
|
||||
{"QueryLanguage":"JSONata","StartAt":"M","States":{"M":{"Type":"Map",
|
||||
"ItemBatcher":{"MaxItemsPerBatchPath":"$.batch"},
|
||||
"ToleratedFailurePercentagePath":"$.failure",
|
||||
"ItemReader":{"ReaderConfig":{"MaxItemsPath":"$.max"}},
|
||||
"ItemProcessor":{"StartAt":"P","States":{"P":{"Type":"Pass","End":true}}},
|
||||
"End":true}}}
|
||||
""";
|
||||
|
||||
validateDefinition(def)
|
||||
.then().statusCode(200)
|
||||
.body("result", equalTo("FAIL"))
|
||||
.body("diagnostics", hasSize(3))
|
||||
.body("diagnostics[0].message", containsString("MaxItemsPerBatchPath"))
|
||||
.body("diagnostics[0].location", equalTo("/States/M"))
|
||||
.body("diagnostics[1].message", containsString("ToleratedFailurePercentagePath"))
|
||||
.body("diagnostics[1].location", equalTo("/States/M"))
|
||||
.body("diagnostics[2].message", containsString("MaxItemsPath"))
|
||||
.body("diagnostics[2].location", equalTo("/States/M"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void mapNumberPathFieldsMustBeMutuallyExclusiveAndReferencePaths() {
|
||||
String def = mapDefinition("", "\"ItemBatcher\":{\"MaxItemsPerBatch\":2,"
|
||||
+ "\"MaxItemsPerBatchPath\":\"$.batch\"},"
|
||||
+ "\"ToleratedFailureCountPath\":\"$$.Execution.Input.count\",");
|
||||
|
||||
validateDefinition(def)
|
||||
.then().statusCode(200)
|
||||
.body("result", equalTo("FAIL"))
|
||||
.body("diagnostics", hasSize(2))
|
||||
.body("diagnostics[0].message", containsString("MaxItemsPerBatch"))
|
||||
.body("diagnostics[0].location", equalTo("/States/M/ItemBatcher/MaxItemsPerBatch"))
|
||||
.body("diagnostics[1].message", equalTo("Value is not a Reference Path"))
|
||||
.body("diagnostics[1].location", equalTo("/States/M/ToleratedFailureCountPath"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void mapNumberLiteralsEnforcePercentageAndReaderMaximums() {
|
||||
String def = mapDefinition("", "\"ItemBatcher\":{\"MaxInputBytesPerBatch\":262145},"
|
||||
+ "\"ToleratedFailurePercentage\":100.1,"
|
||||
+ "\"ItemReader\":{\"ReaderConfig\":{\"MaxItems\":100000001}},");
|
||||
|
||||
validateDefinition(def)
|
||||
.then().statusCode(200)
|
||||
.body("result", equalTo("FAIL"))
|
||||
.body("diagnostics", hasSize(3))
|
||||
.body("diagnostics[0].message", equalTo("Maximum value is 262144"))
|
||||
.body("diagnostics[0].location", equalTo("/States/M/ItemBatcher/MaxInputBytesPerBatch"))
|
||||
.body("diagnostics[1].message", equalTo("Maximum value is 100"))
|
||||
.body("diagnostics[1].location", equalTo("/States/M/ToleratedFailurePercentage"))
|
||||
.body("diagnostics[2].message", equalTo("Maximum value is 100000000"))
|
||||
.body("diagnostics[2].location", equalTo("/States/M/ItemReader/ReaderConfig/MaxItems"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void mapInputBytesAcceptsDocumentedMaximumAndReferencePath() {
|
||||
String maximum = mapDefinition("", "\"ItemBatcher\":{\"MaxInputBytesPerBatch\":262144},");
|
||||
validateDefinition(maximum)
|
||||
.then().statusCode(200)
|
||||
.body("result", equalTo("OK"))
|
||||
.body("diagnostics", hasSize(0));
|
||||
|
||||
String path = mapDefinition("", "\"ItemBatcher\":{\"MaxInputBytesPerBatchPath\":\"$.bytes\"},");
|
||||
validateDefinition(path)
|
||||
.then().statusCode(200)
|
||||
.body("result", equalTo("OK"))
|
||||
.body("diagnostics", hasSize(0));
|
||||
}
|
||||
|
||||
@Test
|
||||
void createStateMachineRejectsMapNumberPathInJsonata() {
|
||||
String def = mapDefinition("\"QueryLanguage\":\"JSONata\",",
|
||||
"\"ToleratedFailureCountPath\":\"$.count\",");
|
||||
|
||||
createStateMachine("map-number-validation-3733", def)
|
||||
.then().statusCode(400)
|
||||
.body("__type", containsString("InvalidDefinition"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void unsupportedItemReaderResource_returnsFailWithSchemaError() {
|
||||
given().contentType(CT).header("X-Amz-Target", TARGET)
|
||||
|
||||
Reference in new issue
Block a user