mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
fix(sfn): resolve context reference paths (#3390)
Co-authored-by: xujiantop-crypto <265865031+xujiantop-crypto@users.noreply.github.com>
This commit is contained in:
1 parent
fbe92aa411
commit
ce073930b9
5 files changed
+94
-8
No files matched your search
+48
@@ -92,6 +92,54 @@ class AslExecutorChoiceRuntimeTest {
|
||||
assertEquals("FAILED", exec.getStatus());
|
||||
}
|
||||
|
||||
@Test
|
||||
void contextObjectVariableRoutesUsingOriginalExecutionInput() {
|
||||
Execution exec = run("""
|
||||
{
|
||||
"StartAt": "Pick",
|
||||
"States": {
|
||||
"Pick": {
|
||||
"Type": "Choice",
|
||||
"InputPath": "$.scoped",
|
||||
"Choices": [{
|
||||
"Variable": "$$.Execution.Input.token",
|
||||
"StringEquals": "keep",
|
||||
"Next": "TAKEN"
|
||||
}],
|
||||
"Default": "FELL"
|
||||
},
|
||||
"TAKEN": {"Type": "Pass", "End": true},
|
||||
"FELL": {"Type": "Fail", "Error": "FELL"}
|
||||
}
|
||||
}
|
||||
""", "{\"token\":\"keep\",\"scoped\":{\"token\":\"wrong\"}}");
|
||||
assertEquals("SUCCEEDED", exec.getStatus());
|
||||
}
|
||||
|
||||
@Test
|
||||
void contextObjectPathOperandRoutesUsingOriginalExecutionInput() {
|
||||
Execution exec = run("""
|
||||
{
|
||||
"StartAt": "Pick",
|
||||
"States": {
|
||||
"Pick": {
|
||||
"Type": "Choice",
|
||||
"InputPath": "$.scoped",
|
||||
"Choices": [{
|
||||
"Variable": "$.district_id",
|
||||
"StringEqualsPath": "$$.Execution.Input.expected_district_id",
|
||||
"Next": "TAKEN"
|
||||
}],
|
||||
"Default": "FELL"
|
||||
},
|
||||
"TAKEN": {"Type": "Pass", "End": true},
|
||||
"FELL": {"Type": "Fail", "Error": "FELL"}
|
||||
}
|
||||
}
|
||||
""", "{\"expected_district_id\":\"42\",\"scoped\":{\"district_id\":\"42\"}}");
|
||||
assertEquals("SUCCEEDED", exec.getStatus());
|
||||
}
|
||||
|
||||
@Test
|
||||
void unknownComparatorFailsExecutionWithStatesRuntime() {
|
||||
// executeSync bypasses create-time validation, so the runtime backstop must fire loudly.
|
||||
|
||||
+15
@@ -165,6 +165,21 @@ class AslExecutorStatePathTest {
|
||||
"[{},{}]");
|
||||
}
|
||||
|
||||
@Test
|
||||
void mapItemsPathCanReadOriginalExecutionInputFromContext() throws Exception {
|
||||
assertOutput("""
|
||||
{"StartAt":"Each","States":{
|
||||
"Each":{"Type":"Map","InputPath":"$.scoped",
|
||||
"ItemsPath":"$$.Execution.Input.ids","MaxConcurrency":1,
|
||||
"ItemSelector":{"id.$":"$$.Map.Item.Value"},
|
||||
"Iterator":{"StartAt":"Pass","States":{
|
||||
"Pass":{"Type":"Pass","End":true}}},
|
||||
"End":true}}}
|
||||
""",
|
||||
"{\"ids\":[1,2],\"scoped\":{\"ignored\":true}}",
|
||||
"[{\"id\":1},{\"id\":2}]");
|
||||
}
|
||||
|
||||
@Test
|
||||
void parallelInputPathFeedsBranchesAndResultPathStillMergesIntoOriginalInput() throws Exception {
|
||||
assertOutput("""
|
||||
|
||||
+8
@@ -418,10 +418,18 @@ class ChoiceOperatorsTest {
|
||||
"Assign must be an object");
|
||||
assertTrue(validate(j("{'Variable':'$.a[0].b','NumericEquals':1,'Next':'X'}")).isEmpty(),
|
||||
"valid indexed reference path accepted");
|
||||
assertTrue(validate(j("{'Variable':'$$.Execution.Input.token',"
|
||||
+ "'StringEqualsPath':'$$.Execution.Input.expected','Next':'X'}")).isEmpty(),
|
||||
"context reference paths are valid for variables and path operands");
|
||||
assertTrue(ChoiceOperators.isReferencePath("$"));
|
||||
assertTrue(ChoiceOperators.isReferencePath("$.a.b"));
|
||||
assertTrue(ChoiceOperators.isReferencePath("$[0]"));
|
||||
assertTrue(ChoiceOperators.isReferencePath("$$"));
|
||||
assertTrue(ChoiceOperators.isReferencePath("$$.Execution.Input.token"));
|
||||
assertTrue(ChoiceOperators.isReferencePath("$$[0]"));
|
||||
assertFalse(ChoiceOperators.isReferencePath("$."));
|
||||
assertFalse(ChoiceOperators.isReferencePath("$$."));
|
||||
assertFalse(ChoiceOperators.isReferencePath("$$foo"));
|
||||
assertFalse(ChoiceOperators.isReferencePath("$["));
|
||||
assertFalse(ChoiceOperators.isReferencePath("nope"));
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user