From 180d8d6e97591fe927465246cf3275205ffe95f4 Mon Sep 17 00:00:00 2001 From: Landon James Date: Mon, 26 Jan 2026 11:47:37 -0800 Subject: [PATCH 1/8] Add tree versions of coalesce, ite, and split tests --- .../resources/META-INF/smithy/coalesce.smithy | 234 +++++ .../main/resources/META-INF/smithy/ite.smithy | 80 ++ .../resources/META-INF/smithy/split.smithy | 859 ++++++++++++++++++ 3 files changed, 1173 insertions(+) create mode 100644 smithy-rules-engine-tests/src/main/resources/META-INF/smithy/coalesce.smithy create mode 100644 smithy-rules-engine-tests/src/main/resources/META-INF/smithy/ite.smithy create mode 100644 smithy-rules-engine-tests/src/main/resources/META-INF/smithy/split.smithy diff --git a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/coalesce.smithy b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/coalesce.smithy new file mode 100644 index 00000000000..fa744ca7205 --- /dev/null +++ b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/coalesce.smithy @@ -0,0 +1,234 @@ +$version: "2.0" + +namespace smithy.tests.endpointrules.coalesce + +use smithy.rules#clientContextParams +use smithy.rules#endpointRuleSet +use smithy.rules#endpointTests + +@suppress(["UnstableTrait", "RuleSetParameter.TestCase.Unused"]) +@clientContextParams( + "TestCaseId": { + "type": "string", + "required": true, + "documentation": "Test case id used to select the test case to use" + } + req1: { + type: "string", + documentation: "docs", + } + req2: { + type: "string", + documentation: "docs", + } + opt1: { + type: "string", + documentation: "always Some" + + } + opt2: { + type: "string", + documentation: "always Some" + } +) +@endpointRuleSet({ + version: "1.1", + parameters: { + "TestCaseId": { + "type": "string", + "required": true, + "documentation": "Test case id used to select the test case to use" + } + req1: { + type: "string", + documentation: "req1", + required: true, + default: "req1Value" + } + req2: { + type: "string", + documentation: "req2", + required: true, + default: "req2Value" + } + opt1: { + type: "string", + documentation: "opt1" + + } + opt2: { + type: "string", + documentation: "opt2" + } + }, + rules: [ + { + "documentation": "Two required", + "conditions": [ + { + "fn": "stringEquals", + "argv": [ + "{TestCaseId}", + "0" + ] + }, + { + "fn": "coalesce", + "argv": [ + {"ref": "req1"}, + {"ref": "req2"}, + ], + "assign": "req1req2" + }, + ], + "error": "The value is: {req1req2}", + "type": "error" + }, + { + "documentation": "Two optional", + "conditions": [ + { + "fn": "stringEquals", + "argv": [ + "{TestCaseId}", + "1" + ] + }, + { + "fn": "coalesce", + "argv": [ + {"ref": "opt1"}, + {"ref": "opt2"}, + ], + "assign": "opt1opt2" + }, + ], + "error": "The value is: {opt1opt2}", + "type": "error" + }, + { + "documentation": "Required then Optional", + "conditions": [ + { + "fn": "stringEquals", + "argv": [ + "{TestCaseId}", + "2" + ] + }, + { + "fn": "coalesce", + "argv": [ + {"ref": "req1"}, + {"ref": "opt1"}, + ], + "assign": "req1opt1" + }, + ], + "error": "The value is: {req1opt1}", + "type": "error" + }, + { + "documentation": "Optional then Required", + "conditions": [ + { + "fn": "stringEquals", + "argv": [ + "{TestCaseId}", + "3" + ] + }, + { + "fn": "coalesce", + "argv": [ + {"ref": "opt1"}, + {"ref": "req1"}, + ], + "assign": "opt1req1" + }, + ], + "error": "The value is: {opt1req1}", + "type": "error" + }, + { + "conditions": [], + "documentation": "error fallthrough", + "error": "endpoint error", + "type": "error" + } + ] +}) +@endpointTests({ + "version": "1.0", + "testCases": [ + { + "documentation": "Two required, first val returned", + "params": { + "TestCaseId": "0" + }, + "expect": { + "error": "The value is: req1Value" + } + }, + { + "documentation": "Two optional, Some(opt1Value), Some(opt2Value), opt1Value returned", + "params": { + "TestCaseId": "1", + "opt1": "opt1Value", + "opt2": "opt2Value", + }, + "expect": { + "error": "The value is: opt1Value" + } + }, + { + "documentation": "Two optional, None, Some(opt2Value), opt2Value returned", + "params": { + "TestCaseId": "1", + "opt2": "opt2Value", + }, + "expect": { + "error": "The value is: opt2Value" + } + }, + { + "documentation": "Two optional, None, None, None returned", + "params": { + "TestCaseId": "1", + }, + "expect": { + "error": "endpoint error" + } + }, + { + "documentation": "Required then Optional, required returned", + "params": { + "TestCaseId": "2", + "opt1": "opt1Value", + }, + "expect": { + "error": "The value is: req1Value" + } + }, + { + "documentation": "Optional then Required, optional value returned", + "params": { + "TestCaseId": "3", + "opt1": "opt1Value", + }, + "expect": { + "error": "The value is: opt1Value" + } + }, + { + "documentation": "Optional then Required, optional is none so required value returned", + "params": { + "TestCaseId": "3", + }, + "expect": { + "error": "The value is: req1Value" + } + }, + ] +}) +service FizzBuzz {} diff --git a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/ite.smithy b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/ite.smithy new file mode 100644 index 00000000000..75a4d4d050c --- /dev/null +++ b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/ite.smithy @@ -0,0 +1,80 @@ +$version: "2.0" + +namespace example + +use smithy.rules#clientContextParams +use smithy.rules#endpointRuleSet +use smithy.rules#endpointTests + +@clientContextParams( + useFips: {type: "boolean", documentation: "Use FIPS endpoints"} +) +@endpointRuleSet({ + version: "1.1", + parameters: { + useFips: { + type: "boolean", + documentation: "Use FIPS endpoints", + default: false, + required: true + } + }, + rules: [ + { + "documentation": "Use ite to select endpoint suffix" + "conditions": [ + { + "fn": "ite" + "argv": [{"ref": "useFips"}, "-fips", ""] + "assign": "suffix" + } + ] + "endpoint": { + "url": "https://example{suffix}.com" + } + "type": "endpoint" + } + ] +}) +@endpointTests({ + "version": "1.0", + "testCases": [ + { + "documentation": "When useFips is true, returns trueValue" + "params": { + "useFips": true + } + "operationInputs": [{ + "operationName": "GetThing" + }], + "expect": { + "endpoint": { + "url": "https://example-fips.com" + } + } + } + { + "documentation": "When useFips is false, returns falseValue" + "params": { + "useFips": false + } + "operationInputs": [{ + "operationName": "GetThing" + }], + "expect": { + "endpoint": { + "url": "https://example.com" + } + } + } + ] +}) +@suppress(["UnstableTrait.smithy"]) +service FizzBuzz { + version: "2022-01-01", + operations: [GetThing] +} + +operation GetThing { + input := {} +} diff --git a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/split.smithy b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/split.smithy new file mode 100644 index 00000000000..8e0327335c9 --- /dev/null +++ b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/split.smithy @@ -0,0 +1,859 @@ +$version: "2.0" + +namespace smithy.tests.endpointrules.split + +use smithy.rules#clientContextParams +use smithy.rules#endpointRuleSet +use smithy.rules#endpointTests + +@endpointRuleSet({ + "version": "1.3", + "parameters": { + "Input": { + "type": "string", + "required": true, + "documentation": "The input string to split" + }, + "Delimiter": { + "type": "string", + "required": true, + "documentation": "The delimiter to split by" + }, + "Limit": { + "type": "string", + "required": true, + "documentation": "The split limit as a string" + } + }, + "rules": [ + { + "documentation": "Split with limit 0 (unlimited)", + "conditions": [ + { + "fn": "stringEquals", + "argv": ["{Limit}", "0"] + }, + { + "fn": "split", + "argv": ["{Input}", "{Delimiter}", 0], + "assign": "parts" + }, + { + "fn": "coalesce", + "argv": [ + { + "fn": "getAttr", + "argv": [{"ref": "parts"}, "[0]"] + }, + "" + ], + "assign": "part1" + }, + { + "fn": "coalesce", + "argv": [ + { + "fn": "getAttr", + "argv": [{"ref": "parts"}, "[1]"] + }, + "" + ], + "assign": "part2" + }, + { + "fn": "coalesce", + "argv": [ + { + "fn": "getAttr", + "argv": [{"ref": "parts"}, "[2]"] + }, + "" + ], + "assign": "part3" + }, + { + "fn": "coalesce", + "argv": [ + { + "fn": "getAttr", + "argv": [{"ref": "parts"}, "[3]"] + }, + "" + ], + "assign": "part4" + }, + { + "fn": "coalesce", + "argv": [ + { + "fn": "getAttr", + "argv": [{"ref": "parts"}, "[4]"] + }, + "" + ], + "assign": "part5" + } + ], + "endpoint": { + "url": "https://example.com", + "properties": { + "splitResult": "p1={part1}; p2={part2}; p3={part3}; p4={part4}; p5={part5}" + } + }, + "type": "endpoint" + }, + { + "documentation": "Split with limit 1 (no split)", + "conditions": [ + { + "fn": "stringEquals", + "argv": ["{Limit}", "1"] + }, + { + "fn": "split", + "argv": ["{Input}", "{Delimiter}", 1], + "assign": "parts" + }, + { + "fn": "coalesce", + "argv": [ + { + "fn": "getAttr", + "argv": [{"ref": "parts"}, "[0]"] + }, + "" + ], + "assign": "part1" + }, + { + "fn": "coalesce", + "argv": [ + { + "fn": "getAttr", + "argv": [{"ref": "parts"}, "[1]"] + }, + "" + ], + "assign": "part2" + }, + { + "fn": "coalesce", + "argv": [ + { + "fn": "getAttr", + "argv": [{"ref": "parts"}, "[2]"] + }, + "" + ], + "assign": "part3" + }, + { + "fn": "coalesce", + "argv": [ + { + "fn": "getAttr", + "argv": [{"ref": "parts"}, "[3]"] + }, + "" + ], + "assign": "part4" + }, + { + "fn": "coalesce", + "argv": [ + { + "fn": "getAttr", + "argv": [{"ref": "parts"}, "[4]"] + }, + "" + ], + "assign": "part5" + } + ], + "endpoint": { + "url": "https://example.com", + "properties": { + "splitResult": "p1={part1}; p2={part2}; p3={part3}; p4={part4}; p5={part5}" + } + }, + "type": "endpoint" + }, + { + "documentation": "Split with limit 2", + "conditions": [ + { + "fn": "stringEquals", + "argv": ["{Limit}", "2"] + }, + { + "fn": "split", + "argv": ["{Input}", "{Delimiter}", 2], + "assign": "parts" + }, + { + "fn": "coalesce", + "argv": [ + { + "fn": "getAttr", + "argv": [{"ref": "parts"}, "[0]"] + }, + "" + ], + "assign": "part1" + }, + { + "fn": "coalesce", + "argv": [ + { + "fn": "getAttr", + "argv": [{"ref": "parts"}, "[1]"] + }, + "" + ], + "assign": "part2" + }, + { + "fn": "coalesce", + "argv": [ + { + "fn": "getAttr", + "argv": [{"ref": "parts"}, "[2]"] + }, + "" + ], + "assign": "part3" + }, + { + "fn": "coalesce", + "argv": [ + { + "fn": "getAttr", + "argv": [{"ref": "parts"}, "[3]"] + }, + "" + ], + "assign": "part4" + }, + { + "fn": "coalesce", + "argv": [ + { + "fn": "getAttr", + "argv": [{"ref": "parts"}, "[4]"] + }, + "" + ], + "assign": "part5" + } + ], + "endpoint": { + "url": "https://example.com", + "properties": { + "splitResult": "p1={part1}; p2={part2}; p3={part3}; p4={part4}; p5={part5}" + } + }, + "type": "endpoint" + }, + { + "documentation": "Split with limit 3", + "conditions": [ + { + "fn": "stringEquals", + "argv": ["{Limit}", "3"] + }, + { + "fn": "split", + "argv": ["{Input}", "{Delimiter}", 3], + "assign": "parts" + }, + { + "fn": "coalesce", + "argv": [ + { + "fn": "getAttr", + "argv": [{"ref": "parts"}, "[0]"] + }, + "" + ], + "assign": "part1" + }, + { + "fn": "coalesce", + "argv": [ + { + "fn": "getAttr", + "argv": [{"ref": "parts"}, "[1]"] + }, + "" + ], + "assign": "part2" + }, + { + "fn": "coalesce", + "argv": [ + { + "fn": "getAttr", + "argv": [{"ref": "parts"}, "[2]"] + }, + "" + ], + "assign": "part3" + }, + { + "fn": "coalesce", + "argv": [ + { + "fn": "getAttr", + "argv": [{"ref": "parts"}, "[3]"] + }, + "" + ], + "assign": "part4" + }, + { + "fn": "coalesce", + "argv": [ + { + "fn": "getAttr", + "argv": [{"ref": "parts"}, "[4]"] + }, + "" + ], + "assign": "part5" + } + ], + "endpoint": { + "url": "https://example.com", + "properties": { + "splitResult": "p1={part1}; p2={part2}; p3={part3}; p4={part4}; p5={part5}" + } + }, + "type": "endpoint" + }, + { + "documentation": "Split with limit 4", + "conditions": [ + { + "fn": "stringEquals", + "argv": ["{Limit}", "4"] + }, + { + "fn": "split", + "argv": ["{Input}", "{Delimiter}", 4], + "assign": "parts" + }, + { + "fn": "coalesce", + "argv": [ + { + "fn": "getAttr", + "argv": [{"ref": "parts"}, "[0]"] + }, + "" + ], + "assign": "part1" + }, + { + "fn": "coalesce", + "argv": [ + { + "fn": "getAttr", + "argv": [{"ref": "parts"}, "[1]"] + }, + "" + ], + "assign": "part2" + }, + { + "fn": "coalesce", + "argv": [ + { + "fn": "getAttr", + "argv": [{"ref": "parts"}, "[2]"] + }, + "" + ], + "assign": "part3" + }, + { + "fn": "coalesce", + "argv": [ + { + "fn": "getAttr", + "argv": [{"ref": "parts"}, "[3]"] + }, + "" + ], + "assign": "part4" + }, + { + "fn": "coalesce", + "argv": [ + { + "fn": "getAttr", + "argv": [{"ref": "parts"}, "[4]"] + }, + "" + ], + "assign": "part5" + } + ], + "endpoint": { + "url": "https://example.com", + "properties": { + "splitResult": "p1={part1}; p2={part2}; p3={part3}; p4={part4}; p5={part5}" + } + }, + "type": "endpoint" + }, + { + "conditions": [], + "documentation": "error fallthrough", + "error": "endpoint error", + "type": "error" + } + ] +}) +@endpointTests( + version: "1.0", + testCases: [ + // Limit 0 tests + { + "documentation": "basic three-part split", + "params": { + "Input": "a--b--c", + "Delimiter": "--", + "Limit": "0" + }, + "expect": { + "endpoint": { + "url": "https://example.com", + "properties": { + "splitResult": "p1=a; p2=b; p3=c; p4=; p5=" + } + } + } + }, + { + "documentation": "empty string returns single empty element", + "params": { + "Input": "", + "Delimiter": "--", + "Limit": "0" + }, + "expect": { + "endpoint": { + "url": "https://example.com", + "properties": { + "splitResult": "p1=; p2=; p3=; p4=; p5=" + } + } + } + }, + { + "documentation": "delimiter not found returns original string", + "params": { + "Input": "no-delimiter", + "Delimiter": "--", + "Limit": "0" + }, + "expect": { + "endpoint": { + "url": "https://example.com", + "properties": { + "splitResult": "p1=no-delimiter; p2=; p3=; p4=; p5=" + } + } + } + }, + { + "documentation": "leading delimiter creates empty first element", + "params": { + "Input": "--leading", + "Delimiter": "--", + "Limit": "0" + }, + "expect": { + "endpoint": { + "url": "https://example.com", + "properties": { + "splitResult": "p1=; p2=leading; p3=; p4=; p5=" + } + } + } + }, + { + "documentation": "trailing delimiter creates empty last element", + "params": { + "Input": "trailing--", + "Delimiter": "--", + "Limit": "0" + }, + "expect": { + "endpoint": { + "url": "https://example.com", + "properties": { + "splitResult": "p1=trailing; p2=; p3=; p4=; p5=" + } + } + } + }, + { + "documentation": "adjacent delimiters create empty element", + "params": { + "Input": "----", + "Delimiter": "--", + "Limit": "0" + }, + "expect": { + "endpoint": { + "url": "https://example.com", + "properties": { + "splitResult": "p1=; p2=; p3=; p4=; p5=" + } + } + } + }, + { + "documentation": "delimiter equals input creates two empty strings", + "params": { + "Input": "--", + "Delimiter": "--", + "Limit": "0" + }, + "expect": { + "endpoint": { + "url": "https://example.com", + "properties": { + "splitResult": "p1=; p2=; p3=; p4=; p5=" + } + } + } + }, + { + "documentation": "overlapping delimiter pattern", + "params": { + "Input": "aaaa", + "Delimiter": "aa", + "Limit": "0" + }, + "expect": { + "endpoint": { + "url": "https://example.com", + "properties": { + "splitResult": "p1=; p2=; p3=; p4=; p5=" + } + } + } + }, + { + "documentation": "overlapping delimiter with odd remainder", + "params": { + "Input": "aaa", + "Delimiter": "aa", + "Limit": "0" + }, + "expect": { + "endpoint": { + "url": "https://example.com", + "properties": { + "splitResult": "p1=; p2=a; p3=; p4=; p5=" + } + } + } + }, + { + "documentation": "multi-character delimiter", + "params": { + "Input": "foo<=>bar<=>baz", + "Delimiter": "<=>", + "Limit": "0" + }, + "expect": { + "endpoint": { + "url": "https://example.com", + "properties": { + "splitResult": "p1=foo; p2=bar; p3=baz; p4=; p5=" + } + } + } + }, + { + "documentation": "multi-character delimiter with limit", + "params": { + "Input": "foo<=>bar<=>baz", + "Delimiter": "<=>", + "Limit": "2" + }, + "expect": { + "endpoint": { + "url": "https://example.com", + "properties": { + "splitResult": "p1=foo; p2=bar<=>baz; p3=; p4=; p5=" + } + } + } + }, + { + "documentation": "both leading and trailing delimiters", + "params": { + "Input": "--both--", + "Delimiter": "--", + "Limit": "0" + }, + "expect": { + "endpoint": { + "url": "https://example.com", + "properties": { + "splitResult": "p1=; p2=both; p3=; p4=; p5=" + } + } + } + }, + { + "documentation": "both leading and trailing with limit", + "params": { + "Input": "--both--", + "Delimiter": "--", + "Limit": "2" + }, + "expect": { + "endpoint": { + "url": "https://example.com", + "properties": { + "splitResult": "p1=; p2=both--; p3=; p4=; p5=" + } + } + } + }, + + // Limit 1 tests (no split) + { + "documentation": "limit 1 returns original string", + "params": { + "Input": "a--b--c", + "Delimiter": "--", + "Limit": "1" + }, + "expect": { + "endpoint": { + "url": "https://example.com", + "properties": { + "splitResult": "p1=a--b--c; p2=; p3=; p4=; p5=" + } + } + } + }, + { + "documentation": "limit 1 with no delimiter", + "params": { + "Input": "no-delimiter", + "Delimiter": "--", + "Limit": "1" + }, + "expect": { + "endpoint": { + "url": "https://example.com", + "properties": { + "splitResult": "p1=no-delimiter; p2=; p3=; p4=; p5=" + } + } + } + }, + + // Limit 2 tests + { + "documentation": "limit 2 splits once", + "params": { + "Input": "a--b--c", + "Delimiter": "--", + "Limit": "2" + }, + "expect": { + "endpoint": { + "url": "https://example.com", + "properties": { + "splitResult": "p1=a; p2=b--c; p3=; p4=; p5=" + } + } + } + }, + { + "documentation": "limit 2 with leading delimiter", + "params": { + "Input": "--x-s3--azid", + "Delimiter": "--", + "Limit": "2" + }, + "expect": { + "endpoint": { + "url": "https://example.com", + "properties": { + "splitResult": "p1=; p2=x-s3--azid; p3=; p4=; p5=" + } + } + } + }, + + // Limit 3 tests + { + "documentation": "limit 3 exact match", + "params": { + "Input": "a--b--c", + "Delimiter": "--", + "Limit": "3" + }, + "expect": { + "endpoint": { + "url": "https://example.com", + "properties": { + "splitResult": "p1=a; p2=b; p3=c; p4=; p5=" + } + } + } + }, + { + "documentation": "limit 3 with remainder", + "params": { + "Input": "a--b--c--d", + "Delimiter": "--", + "Limit": "3" + }, + "expect": { + "endpoint": { + "url": "https://example.com", + "properties": { + "splitResult": "p1=a; p2=b; p3=c--d; p4=; p5=" + } + } + } + }, + + // Limit 4 tests + { + "documentation": "S3 Express bucket pattern", + "params": { + "Input": "--x-s3--azid--suffix", + "Delimiter": "--", + "Limit": "4" + }, + "expect": { + "endpoint": { + "url": "https://example.com", + "properties": { + "splitResult": "p1=; p2=x-s3; p3=azid; p4=suffix; p5=" + } + } + } + }, + { + "documentation": "limit 4 stops at 4 parts", + "params": { + "Input": "a--b--c--d--e", + "Delimiter": "--", + "Limit": "4" + }, + "expect": { + "endpoint": { + "url": "https://example.com", + "properties": { + "splitResult": "p1=a; p2=b; p3=c; p4=d--e; p5=" + } + } + } + }, + + // Unicode tests + { + "documentation": "unicode emoji delimiter", + "params": { + "Input": "a🌟b🌟c", + "Delimiter": "🌟", + "Limit": "0" + }, + "expect": { + "endpoint": { + "url": "https://example.com", + "properties": { + "splitResult": "p1=a; p2=b; p3=c; p4=; p5=" + } + } + } + }, + + // Regex treated literally + { + "documentation": "regex-like pattern treated literally", + "params": { + "Input": "a.*b.*c", + "Delimiter": ".*", + "Limit": "0" + }, + "expect": { + "endpoint": { + "url": "https://example.com", + "properties": { + "splitResult": "p1=a; p2=b; p3=c; p4=; p5=" + } + } + } + }, + { + "documentation": "pipe delimiter", + "params": { + "Input": "a|b|c|d|e", + "Delimiter": "|", + "Limit": "0" + }, + "expect": { + "endpoint": { + "url": "https://example.com", + "properties": { + "splitResult": "p1=a; p2=b; p3=c; p4=d; p5=e" + } + } + } + }, + + // Edge cases + { + "documentation": "delimiter longer than input", + "params": { + "Input": "ab", + "Delimiter": "abcd", + "Limit": "0" + }, + "expect": { + "endpoint": { + "url": "https://example.com", + "properties": { + "splitResult": "p1=ab; p2=; p3=; p4=; p5=" + } + } + } + }, + { + "documentation": "delimiter equals entire input", + "params": { + "Input": "abc", + "Delimiter": "abc", + "Limit": "0" + }, + "expect": { + "endpoint": { + "url": "https://example.com", + "properties": { + "splitResult": "p1=; p2=; p3=; p4=; p5=" + } + } + } + } + ] +) +@clientContextParams( + Input: {type: "string", documentation: "Input string to split"} + Delimiter: {type: "string", documentation: "Delimiter to split by"} + Limit: {type: "string", documentation: "Split limit"} +) +@suppress(["UnstableTrait.smithy"]) +service FizzBuzz {} From 8fef41a6f76771f58b05b339892a3dc3e87cd7a5 Mon Sep 17 00:00:00 2001 From: Landon James Date: Mon, 26 Jan 2026 12:52:25 -0800 Subject: [PATCH 2/8] Add bdd based rule set std lib function tests Also split tests into separate bdd-tests and tree-tests folders --- .../META-INF/smithy/bdd-tests/coalesce.smithy | 259 +++++ .../smithy/bdd-tests/default-values.smithy | 129 +++ .../smithy/bdd-tests/endpoint-bindings.smithy | 348 +++++++ .../bdd-tests/endpoints-string-array.smithy | 274 +++++ .../META-INF/smithy/bdd-tests/get-attr.smithy | 92 ++ .../META-INF/smithy/bdd-tests/headers.smithy | 92 ++ .../META-INF/smithy/bdd-tests/ite.smithy | 103 ++ .../smithy/bdd-tests/parse-url.smithy | 290 ++++++ .../META-INF/smithy/bdd-tests/split.smithy | 982 ++++++++++++++++++ .../smithy/bdd-tests/substring.smithy | 288 +++++ .../smithy/bdd-tests/url-encode.smithy | 147 +++ .../smithy/bdd-tests/valid-hostlabel.smithy | 161 +++ .../smithy/{ => tree-tests}/coalesce.smithy | 0 .../{ => tree-tests}/default-values.smithy | 0 .../{ => tree-tests}/endpoint-bindings.smithy | 0 .../endpoints-string-array.smithy | 0 .../smithy/{ => tree-tests}/get-attr.smithy | 0 .../smithy/{ => tree-tests}/headers.smithy | 0 .../smithy/{ => tree-tests}/ite.smithy | 0 .../META-INF/smithy/{ => tree-tests}/manifest | 0 .../smithy/{ => tree-tests}/parse-url.smithy | 0 .../smithy/{ => tree-tests}/split.smithy | 0 .../smithy/{ => tree-tests}/substring.smithy | 0 .../smithy/{ => tree-tests}/url-encode.smithy | 0 .../{ => tree-tests}/valid-hostlabel.smithy | 0 25 files changed, 3165 insertions(+) create mode 100644 smithy-rules-engine-tests/src/main/resources/META-INF/smithy/bdd-tests/coalesce.smithy create mode 100644 smithy-rules-engine-tests/src/main/resources/META-INF/smithy/bdd-tests/default-values.smithy create mode 100644 smithy-rules-engine-tests/src/main/resources/META-INF/smithy/bdd-tests/endpoint-bindings.smithy create mode 100644 smithy-rules-engine-tests/src/main/resources/META-INF/smithy/bdd-tests/endpoints-string-array.smithy create mode 100644 smithy-rules-engine-tests/src/main/resources/META-INF/smithy/bdd-tests/get-attr.smithy create mode 100644 smithy-rules-engine-tests/src/main/resources/META-INF/smithy/bdd-tests/headers.smithy create mode 100644 smithy-rules-engine-tests/src/main/resources/META-INF/smithy/bdd-tests/ite.smithy create mode 100644 smithy-rules-engine-tests/src/main/resources/META-INF/smithy/bdd-tests/parse-url.smithy create mode 100644 smithy-rules-engine-tests/src/main/resources/META-INF/smithy/bdd-tests/split.smithy create mode 100644 smithy-rules-engine-tests/src/main/resources/META-INF/smithy/bdd-tests/substring.smithy create mode 100644 smithy-rules-engine-tests/src/main/resources/META-INF/smithy/bdd-tests/url-encode.smithy create mode 100644 smithy-rules-engine-tests/src/main/resources/META-INF/smithy/bdd-tests/valid-hostlabel.smithy rename smithy-rules-engine-tests/src/main/resources/META-INF/smithy/{ => tree-tests}/coalesce.smithy (100%) rename smithy-rules-engine-tests/src/main/resources/META-INF/smithy/{ => tree-tests}/default-values.smithy (100%) rename smithy-rules-engine-tests/src/main/resources/META-INF/smithy/{ => tree-tests}/endpoint-bindings.smithy (100%) rename smithy-rules-engine-tests/src/main/resources/META-INF/smithy/{ => tree-tests}/endpoints-string-array.smithy (100%) rename smithy-rules-engine-tests/src/main/resources/META-INF/smithy/{ => tree-tests}/get-attr.smithy (100%) rename smithy-rules-engine-tests/src/main/resources/META-INF/smithy/{ => tree-tests}/headers.smithy (100%) rename smithy-rules-engine-tests/src/main/resources/META-INF/smithy/{ => tree-tests}/ite.smithy (100%) rename smithy-rules-engine-tests/src/main/resources/META-INF/smithy/{ => tree-tests}/manifest (100%) rename smithy-rules-engine-tests/src/main/resources/META-INF/smithy/{ => tree-tests}/parse-url.smithy (100%) rename smithy-rules-engine-tests/src/main/resources/META-INF/smithy/{ => tree-tests}/split.smithy (100%) rename smithy-rules-engine-tests/src/main/resources/META-INF/smithy/{ => tree-tests}/substring.smithy (100%) rename smithy-rules-engine-tests/src/main/resources/META-INF/smithy/{ => tree-tests}/url-encode.smithy (100%) rename smithy-rules-engine-tests/src/main/resources/META-INF/smithy/{ => tree-tests}/valid-hostlabel.smithy (100%) diff --git a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/bdd-tests/coalesce.smithy b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/bdd-tests/coalesce.smithy new file mode 100644 index 00000000000..dadb23617e9 --- /dev/null +++ b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/bdd-tests/coalesce.smithy @@ -0,0 +1,259 @@ +$version: "2.0" + +namespace smithy.tests.endpointrules.coalesce + +use smithy.rules#clientContextParams +use smithy.rules#endpointBdd +use smithy.rules#endpointTests + +@suppress([ + "UnstableTrait" + "RuleSetParameter.TestCase.Unused" +]) +@clientContextParams( + TestCaseId: { + type: "string" + required: true + documentation: "Test case id used to select the test case to use" + } + req1: { + type: "string" + documentation: "docs" + } + req2: { + type: "string" + documentation: "docs" + } + opt1: { + type: "string" + documentation: "always Some" + } + opt2: { + type: "string" + documentation: "always Some" + } +) +@endpointBdd( + version: "1.1" + parameters: { + TestCaseId: { + required: true + documentation: "Test case id used to select the test case to use" + type: "string" + } + req1: { + required: true + default: "req1Value" + documentation: "req1" + type: "string" + } + req2: { + required: true + default: "req2Value" + documentation: "req2" + type: "string" + } + opt1: { + required: false + documentation: "opt1" + type: "string" + } + opt2: { + required: false + documentation: "opt2" + type: "string" + } + } + conditions: [ + { + fn: "stringEquals" + argv: [ + { + ref: "TestCaseId" + } + "0" + ] + } + { + fn: "coalesce" + argv: [ + { + ref: "req1" + } + { + ref: "req2" + } + ] + assign: "req1req2" + } + { + fn: "stringEquals" + argv: [ + { + ref: "TestCaseId" + } + "1" + ] + } + { + fn: "coalesce" + argv: [ + { + ref: "opt1" + } + { + ref: "opt2" + } + ] + assign: "opt1opt2" + } + { + fn: "stringEquals" + argv: [ + { + ref: "TestCaseId" + } + "2" + ] + } + { + fn: "coalesce" + argv: [ + { + ref: "req1" + } + { + ref: "opt1" + } + ] + assign: "req1opt1" + } + { + fn: "stringEquals" + argv: [ + { + ref: "TestCaseId" + } + "3" + ] + } + { + fn: "coalesce" + argv: [ + { + ref: "opt1" + } + { + ref: "req1" + } + ] + assign: "opt1req1" + } + ] + results: [ + { + conditions: [] + error: "The value is: {req1req2}" + type: "error" + } + { + conditions: [] + error: "The value is: {opt1opt2}" + type: "error" + } + { + conditions: [] + error: "The value is: {req1opt1}" + type: "error" + } + { + conditions: [] + error: "The value is: {opt1req1}" + type: "error" + } + { + documentation: "error fallthrough" + conditions: [] + error: "endpoint error" + type: "error" + } + ] + root: 2 + nodeCount: 9 + nodes: "/////wAAAAH/////AAAAAAAAAAMAAAAEAAAAAQX14QEAAAAEAAAAAgAAAAUAAAAGAAAAAwX14QIAAAAGAAAABAAAAAcAAAAIAAAABQX14QMAAAAIAAAABgAAAAkF9eEFAAAABwX14QQF9eEF" +) +@endpointTests( + version: "1.0" + testCases: [ + { + documentation: "Two required, first val returned" + params: { + TestCaseId: "0" + } + expect: { + error: "The value is: req1Value" + } + } + { + documentation: "Two optional, Some(opt1Value), Some(opt2Value), opt1Value returned" + params: { + TestCaseId: "1" + opt1: "opt1Value" + opt2: "opt2Value" + } + expect: { + error: "The value is: opt1Value" + } + } + { + documentation: "Two optional, None, Some(opt2Value), opt2Value returned" + params: { + TestCaseId: "1" + opt2: "opt2Value" + } + expect: { + error: "The value is: opt2Value" + } + } + { + documentation: "Two optional, None, None, None returned" + params: { + TestCaseId: "1" + } + expect: { + error: "endpoint error" + } + } + { + documentation: "Required then Optional, required returned" + params: { + TestCaseId: "2" + opt1: "opt1Value" + } + expect: { + error: "The value is: req1Value" + } + } + { + documentation: "Optional then Required, optional value returned" + params: { + TestCaseId: "3" + opt1: "opt1Value" + } + expect: { + error: "The value is: opt1Value" + } + } + { + documentation: "Optional then Required, optional is none so required value returned" + params: { + TestCaseId: "3" + } + expect: { + error: "The value is: req1Value" + } + } + ] +) +service FizzBuzz { +} diff --git a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/bdd-tests/default-values.smithy b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/bdd-tests/default-values.smithy new file mode 100644 index 00000000000..2fc32533e07 --- /dev/null +++ b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/bdd-tests/default-values.smithy @@ -0,0 +1,129 @@ +$version: "2.0" + +namespace smithy.tests.endpointrules.defaultvalues + +use smithy.rules#clientContextParams +use smithy.rules#endpointBdd +use smithy.rules#endpointTests + +@suppress([ + "UnstableTrait" +]) +@clientContextParams( + bar: { + type: "string" + documentation: "a client string parameter" + } + baz: { + type: "string" + documentation: "another client string parameter" + } +) +@endpointBdd( + version: "1.1" + parameters: { + bar: { + required: false + documentation: "docs" + type: "string" + } + baz: { + required: true + default: "baz" + documentation: "docs" + type: "string" + } + } + conditions: [ + { + fn: "isSet" + argv: [ + { + ref: "bar" + } + ] + } + ] + results: [ + { + conditions: [] + endpoint: { + url: "https://example.com/{baz}" + properties: {} + headers: {} + } + type: "endpoint" + } + { + documentation: "error fallthrough" + conditions: [] + error: "endpoint error" + type: "error" + } + ] + root: 2 + nodeCount: 2 + nodes: "/////wAAAAH/////AAAAAAX14QEF9eEC" +) +@endpointTests( + version: "1.0" + testCases: [ + { + documentation: "Default value is used when parameter is unset" + params: { + bar: "a b" + } + operationInputs: [ + { + operationName: "GetThing" + clientParams: { + bar: "a b" + } + } + ] + expect: { + endpoint: { + url: "https://example.com/baz" + } + } + } + { + documentation: "Default value is not used when the parameter is set" + params: { + bar: "a b" + baz: "BIG" + } + operationInputs: [ + { + operationName: "GetThing" + clientParams: { + bar: "a b" + baz: "BIG" + } + } + ] + expect: { + endpoint: { + url: "https://example.com/BIG" + } + } + } + { + documentation: "a documentation string" + expect: { + error: "endpoint error" + } + } + ] +) +service FizzBuzz { + version: "2022-01-01" + operations: [ + GetThing + ] +} + +operation GetThing { + input := {} + output: Unit +} diff --git a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/bdd-tests/endpoint-bindings.smithy b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/bdd-tests/endpoint-bindings.smithy new file mode 100644 index 00000000000..2c9609c2c6e --- /dev/null +++ b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/bdd-tests/endpoint-bindings.smithy @@ -0,0 +1,348 @@ +$version: "2.0" + +namespace smithy.tests.endpointrules.endpointbindings + +use smithy.rules#clientContextParams +use smithy.rules#contextParam +use smithy.rules#endpointBdd +use smithy.rules#endpointTests +use smithy.rules#operationContextParams +use smithy.rules#staticContextParams + +@suppress([ + "UnstableTrait" +]) +@clientContextParams( + bar: { + type: "string" + documentation: "a client string parameter" + } + baz: { + type: "string" + documentation: "another client string parameter" + } + booleanParam: { + type: "boolean" + documentation: "a client boolean parameter" + } +) +@endpointBdd( + version: "1.1" + parameters: { + bar: { + required: false + documentation: "String parameter with no default value and client binding" + type: "string" + } + baz: { + required: true + default: "baz" + documentation: "String parameter with default value and client binding" + type: "string" + } + booleanParam: { + required: true + default: true + documentation: "Boolean parameter with default value and client binding" + type: "boolean" + } + Endpoint: { + builtIn: "SDK::Endpoint" + required: false + documentation: "Override the endpoint used to send this request" + type: "string" + } + } + conditions: [ + { + fn: "isSet" + argv: [ + { + ref: "Endpoint" + } + ] + } + { + fn: "booleanEquals" + argv: [ + { + ref: "booleanParam" + } + true + ] + } + { + fn: "isSet" + argv: [ + { + ref: "bar" + } + ] + } + ] + results: [ + { + conditions: [] + endpoint: { + url: { + ref: "Endpoint" + } + properties: {} + headers: {} + } + type: "endpoint" + } + { + conditions: [] + endpoint: { + url: "https://{bar}.{baz}/set" + properties: {} + headers: {} + } + type: "endpoint" + } + { + conditions: [] + endpoint: { + url: "https://{baz}/set" + properties: {} + headers: {} + } + type: "endpoint" + } + { + conditions: [] + endpoint: { + url: "https://{bar}.{baz}/unset" + properties: {} + headers: {} + } + type: "endpoint" + } + { + conditions: [] + endpoint: { + url: "https://{baz}/unset" + properties: {} + headers: {} + } + type: "endpoint" + } + ] + root: 2 + nodeCount: 5 + nodes: "/////wAAAAH/////AAAAAAX14QEAAAADAAAAAQAAAAUAAAAEAAAAAgX14QQF9eEFAAAAAgX14QIF9eED" +) +@endpointTests( + version: "1.0" + testCases: [ + { + documentation: "Custom Endpoint used" + params: { + Endpoint: "https://custom-endpoint.com" + } + expect: { + endpoint: { + url: "https://custom-endpoint.com" + } + } + operationInputs: [ + { + operationName: "NoBindingsOperation" + builtInParams: { + "SDK::Endpoint": "https://custom-endpoint.com" + } + } + ] + } + { + documentation: "Default values used" + params: {} + expect: { + endpoint: { + url: "https://baz/set" + } + } + operationInputs: [ + { + operationName: "NoBindingsOperation" + } + ] + } + { + documentation: "Client config used over default" + params: { + baz: "client-config" + } + expect: { + endpoint: { + url: "https://client-config/set" + } + } + operationInputs: [ + { + operationName: "NoBindingsOperation" + clientParams: { + baz: "client-config" + } + } + ] + } + { + documentation: "StaticContextParam values used" + params: { + bar: "static-context" + booleanParam: false + } + expect: { + endpoint: { + url: "https://static-context.baz/unset" + } + } + operationInputs: [ + { + operationName: "StaticContextOperation" + } + ] + } + { + documentation: "ContextParam values used over config and defaults" + params: { + bar: "context-bar" + baz: "context-baz" + booleanParam: false + } + expect: { + endpoint: { + url: "https://context-bar.context-baz/unset" + } + } + operationInputs: [ + { + operationName: "ContextParamsOperation" + operationParams: { + bar: "context-bar" + baz: "context-baz" + booleanParam: false + } + clientParams: { + bar: "client-config" + } + } + ] + } + { + documentation: "OperationContextParam values used over config and defaults" + params: { + bar: "operation-context-bar" + baz: "operation-context-baz" + booleanParam: false + } + expect: { + endpoint: { + url: "https://operation-context-bar.operation-context-baz/unset" + } + } + operationInputs: [ + { + operationName: "OperationContextParamsOperation" + operationParams: { + nested: { + bar: "operation-context-bar" + baz: "operation-context-baz" + } + booleanParam: false + } + clientParams: { + bar: "client-config" + } + } + ] + } + ] +) +service EndpointBindingService { + version: "2022-01-01" + operations: [ + ContextParamsOperation + NoBindingsOperation + OperationContextParamsOperation + StaticContextOperation + ] +} + +operation ContextParamsOperation { + input := { + @contextParam( + name: "bar" + ) + bar: String + @contextParam( + name: "baz" + ) + baz: String + @contextParam( + name: "booleanParam" + ) + booleanParam: Boolean + } + output: Unit +} + +operation NoBindingsOperation { + input := {} + output: Unit +} + +@operationContextParams( + bar: { + path: "nested.bar" + } + baz: { + path: "nested.baz" + } + booleanParam: { + path: "booleanParam" + } +) +operation OperationContextParamsOperation { + input := { + nested: Nested + booleanParam: Boolean + } + output: Unit +} + +@suppress([ + "UnstableTrait" +]) +@staticContextParams( + bar: { + value: "static-context" + } + booleanParam: { + value: false + } +) +operation StaticContextOperation { + input := {} + output: Unit +} + +structure Nested { + bar: String + baz: String +} + +structure ObjectMember { + key: String +} + +list ListOfObjects { + member: ObjectMember +} + +map Map { + key: String + value: String +} diff --git a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/bdd-tests/endpoints-string-array.smithy b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/bdd-tests/endpoints-string-array.smithy new file mode 100644 index 00000000000..4537cf720df --- /dev/null +++ b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/bdd-tests/endpoints-string-array.smithy @@ -0,0 +1,274 @@ +$version: "2.0" + +namespace smithy.tests.endpointrules.stringarray + +use smithy.rules#endpointBdd +use smithy.rules#endpointTests +use smithy.rules#operationContextParams +use smithy.rules#staticContextParams + +@suppress([ + "UnstableTrait" +]) +@endpointBdd( + version: "1.1" + parameters: { + stringArrayParam: { + required: true + default: [ + "defaultValue1" + "defaultValue2" + ] + documentation: "docs" + type: "stringArray" + } + } + conditions: [ + { + fn: "getAttr" + argv: [ + { + ref: "stringArrayParam" + } + "[0]" + ] + assign: "arrayValue" + } + ] + results: [ + { + conditions: [] + endpoint: { + url: "https://example.com/{arrayValue}" + properties: {} + headers: {} + } + type: "endpoint" + } + { + documentation: "error fallthrough" + conditions: [] + error: "no array values set" + type: "error" + } + ] + root: 2 + nodeCount: 2 + nodes: "/////wAAAAH/////AAAAAAX14QEF9eEC" +) +@endpointTests( + version: "1.0" + testCases: [ + { + documentation: "Default array values used" + params: {} + expect: { + endpoint: { + url: "https://example.com/defaultValue1" + } + } + operationInputs: [ + { + operationName: "NoBindingsOperation" + } + ] + } + { + documentation: "Empty array" + params: { + stringArrayParam: [] + } + expect: { + error: "no array values set" + } + operationInputs: [ + { + operationName: "EmptyStaticContextOperation" + } + ] + } + { + documentation: "Static value" + params: { + stringArrayParam: [ + "staticValue1" + ] + } + expect: { + endpoint: { + url: "https://example.com/staticValue1" + } + } + operationInputs: [ + { + operationName: "StaticContextOperation" + } + ] + } + { + documentation: "bound value from input" + params: { + stringArrayParam: [ + "key1" + ] + } + expect: { + endpoint: { + url: "https://example.com/key1" + } + } + operationInputs: [ + { + operationName: "ListOfObjectsOperation" + operationParams: { + nested: { + listOfObjects: [ + { + key: "key1" + } + ] + } + } + } + { + operationName: "MapOperation" + operationParams: { + map: { + key1: "value1" + } + } + } + { + operationName: "ListOfUnionsOperation" + operationParams: { + listOfUnions: [ + { + string: "key1" + } + { + object: { + key: "key2" + } + } + ] + } + } + ] + } + ] +) +service EndpointStringArrayService { + version: "2022-01-01" + operations: [ + EmptyStaticContextOperation + ListOfObjectsOperation + ListOfUnionsOperation + MapOperation + NoBindingsOperation + StaticContextOperation + ] +} + +@suppress([ + "UnstableTrait" +]) +@staticContextParams( + stringArrayParam: { + value: [] + } +) +operation EmptyStaticContextOperation { + input := {} + output: Unit +} + +@suppress([ + "UnstableTrait" +]) +@operationContextParams( + stringArrayParam: { + path: "nested.listOfObjects[*].key" + } +) +operation ListOfObjectsOperation { + input := { + nested: Nested + } + output: Unit +} + +@suppress([ + "UnstableTrait" +]) +@operationContextParams( + stringArrayParam: { + path: "listOfUnions[*][string, object.key][]" + } +) +operation ListOfUnionsOperation { + input := { + listOfUnions: ListOfUnions + } + output: Unit +} + +@suppress([ + "UnstableTrait" +]) +@operationContextParams( + stringArrayParam: { + path: "keys(map)" + } +) +operation MapOperation { + input := { + map: Map + } + output: Unit +} + +operation NoBindingsOperation { + input := {} + output: Unit +} + +@suppress([ + "UnstableTrait" +]) +@staticContextParams( + stringArrayParam: { + value: [ + "staticValue1" + ] + } +) +operation StaticContextOperation { + input := {} + output: Unit +} + +structure Nested { + listOfObjects: ListOfObjects +} + +structure ObjectMember { + key: String +} + +union UnionMember { + string: String + object: ObjectMember +} + +list ListOfObjects { + member: ObjectMember +} + +list ListOfUnions { + member: UnionMember +} + +map Map { + key: String + value: String +} diff --git a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/bdd-tests/get-attr.smithy b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/bdd-tests/get-attr.smithy new file mode 100644 index 00000000000..ed1823e1546 --- /dev/null +++ b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/bdd-tests/get-attr.smithy @@ -0,0 +1,92 @@ +$version: "2.0" + +namespace smithy.tests.endpointrules.getattr + +use smithy.rules#clientContextParams +use smithy.rules#endpointBdd +use smithy.rules#endpointTests + +@suppress([ + "UnstableTrait" +]) +@clientContextParams( + Bucket: { + type: "string" + documentation: "docs" + } +) +@endpointBdd( + version: "1.1" + parameters: { + Bucket: { + required: false + documentation: "docs" + type: "string" + } + } + conditions: [ + { + fn: "isSet" + argv: [ + { + ref: "Bucket" + } + ] + } + { + fn: "parseURL" + argv: [ + "{Bucket}" + ] + assign: "bucketUrl" + } + { + fn: "getAttr" + argv: [ + { + ref: "bucketUrl" + } + "path" + ] + assign: "path" + } + ] + results: [ + { + conditions: [] + endpoint: { + url: "https://{bucketUrl#authority}{path}" + properties: {} + headers: {} + } + type: "endpoint" + } + { + documentation: "fallback when no tests match" + conditions: [] + error: "No tests matched" + type: "error" + } + ] + root: 2 + nodeCount: 4 + nodes: "/////wAAAAH/////AAAAAAAAAAMF9eECAAAAAQAAAAQF9eECAAAAAgX14QEF9eEC" +) +@endpointTests( + version: "1.0" + testCases: [ + { + documentation: "getAttr on top level values in function and template" + params: { + Bucket: "http://example.com/path" + } + expect: { + endpoint: { + url: "https://example.com/path" + } + } + } + ] +) +service FizzBuzz { +} diff --git a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/bdd-tests/headers.smithy b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/bdd-tests/headers.smithy new file mode 100644 index 00000000000..8480b442435 --- /dev/null +++ b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/bdd-tests/headers.smithy @@ -0,0 +1,92 @@ +$version: "2.0" + +namespace smithy.tests.endpointrules.headers + +use smithy.rules#clientContextParams +use smithy.rules#endpointBdd +use smithy.rules#endpointTests + +@suppress([ + "UnstableTrait" +]) +@clientContextParams( + Region: { + type: "string" + documentation: "docs" + } +) +@endpointBdd( + version: "1.1" + parameters: { + Region: { + required: false + documentation: "The region to dispatch this request, eg. `us-east-1`." + type: "string" + } + } + conditions: [ + { + fn: "isSet" + argv: [ + { + ref: "Region" + } + ] + } + ] + results: [ + { + conditions: [] + endpoint: { + url: "https://{Region}.amazonaws.com" + properties: {} + headers: { + "x-amz-region": [ + "{Region}" + ] + "x-amz-multi": [ + "*" + "{Region}" + ] + } + } + type: "endpoint" + } + { + documentation: "fallback when region is unset" + conditions: [] + error: "Region must be set to resolve a valid endpoint" + type: "error" + } + ] + root: 2 + nodeCount: 2 + nodes: "/////wAAAAH/////AAAAAAX14QEF9eEC" +) +@endpointTests( + version: "1.0" + testCases: [ + { + documentation: "header set to region" + params: { + Region: "us-east-1" + } + expect: { + endpoint: { + url: "https://us-east-1.amazonaws.com" + headers: { + "x-amz-region": [ + "us-east-1" + ] + "x-amz-multi": [ + "*" + "us-east-1" + ] + } + } + } + } + ] +) +service FizzBuzz { +} diff --git a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/bdd-tests/ite.smithy b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/bdd-tests/ite.smithy new file mode 100644 index 00000000000..4ce002d53f0 --- /dev/null +++ b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/bdd-tests/ite.smithy @@ -0,0 +1,103 @@ +$version: "2.0" + +namespace example + +use smithy.rules#clientContextParams +use smithy.rules#endpointBdd +use smithy.rules#endpointTests + +@suppress([ + "UnstableTrait.smithy" +]) +@clientContextParams( + useFips: { + type: "boolean" + documentation: "Use FIPS endpoints" + } +) +@endpointBdd( + version: "1.1" + parameters: { + useFips: { + required: true + default: false + documentation: "Use FIPS endpoints" + type: "boolean" + } + } + conditions: [ + { + fn: "ite" + argv: [ + { + ref: "useFips" + } + "-fips" + "" + ] + assign: "suffix" + } + ] + results: [ + { + conditions: [] + endpoint: { + url: "https://example{suffix}.com" + properties: {} + headers: {} + } + type: "endpoint" + } + ] + root: 2 + nodeCount: 2 + nodes: "/////wAAAAH/////AAAAAAX14QEF9eEA" +) +@endpointTests( + version: "1.0" + testCases: [ + { + documentation: "When useFips is true, returns trueValue" + params: { + useFips: true + } + operationInputs: [ + { + operationName: "GetThing" + } + ] + expect: { + endpoint: { + url: "https://example-fips.com" + } + } + } + { + documentation: "When useFips is false, returns falseValue" + params: { + useFips: false + } + operationInputs: [ + { + operationName: "GetThing" + } + ] + expect: { + endpoint: { + url: "https://example.com" + } + } + } + ] +) +service FizzBuzz { + version: "2022-01-01" + operations: [ + GetThing + ] +} + +operation GetThing { + input := {} + output: Unit +} diff --git a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/bdd-tests/parse-url.smithy b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/bdd-tests/parse-url.smithy new file mode 100644 index 00000000000..0d36c941c01 --- /dev/null +++ b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/bdd-tests/parse-url.smithy @@ -0,0 +1,290 @@ +$version: "2.0" + +namespace smithy.tests.endpointrules.parseurl + +use smithy.rules#clientContextParams +use smithy.rules#endpointBdd +use smithy.rules#endpointTests + +@suppress([ + "UnstableTrait" +]) +@clientContextParams( + Endpoint: { + type: "string" + documentation: "docs" + } +) +@endpointBdd( + version: "1.1" + parameters: { + Endpoint: { + required: false + documentation: "docs" + type: "string" + } + } + conditions: [ + { + fn: "isSet" + argv: [ + { + ref: "Endpoint" + } + ] + } + { + fn: "parseURL" + argv: [ + "{Endpoint}" + ] + assign: "url" + } + { + fn: "booleanEquals" + argv: [ + true + { + fn: "getAttr" + argv: [ + { + ref: "url" + } + "isIp" + ] + } + ] + } + { + fn: "stringEquals" + argv: [ + "/port" + { + fn: "getAttr" + argv: [ + { + ref: "url" + } + "path" + ] + } + ] + } + { + fn: "stringEquals" + argv: [ + "/" + { + fn: "getAttr" + argv: [ + { + ref: "url" + } + "normalizedPath" + ] + } + ] + } + ] + results: [ + { + conditions: [] + endpoint: { + url: "{url#scheme}://{url#authority}{url#normalizedPath}is-ip-addr" + properties: {} + headers: {} + } + type: "endpoint" + } + { + conditions: [] + endpoint: { + url: "{url#scheme}://{url#authority}/uri-with-port" + properties: {} + headers: {} + } + type: "endpoint" + } + { + conditions: [] + endpoint: { + url: "https://{url#scheme}-{url#authority}-nopath.example.com" + properties: {} + headers: {} + } + type: "endpoint" + } + { + conditions: [] + endpoint: { + url: "https://{url#scheme}-{url#authority}.example.com/path-is{url#path}" + properties: {} + headers: {} + } + type: "endpoint" + } + { + conditions: [] + error: "endpoint was invalid" + type: "error" + } + ] + root: 2 + nodeCount: 6 + nodes: "/////wAAAAH/////AAAAAAAAAAMF9eEFAAAAAQAAAAQF9eEFAAAAAgX14QEAAAAFAAAAAwX14QIAAAAGAAAABAX14QMF9eEE" +) +@endpointTests( + version: "1.0" + testCases: [ + { + documentation: "simple URL parsing" + params: { + Endpoint: "https://authority.com/custom-path" + } + expect: { + endpoint: { + url: "https://https-authority.com.example.com/path-is/custom-path" + } + } + } + { + documentation: "empty path no slash" + params: { + Endpoint: "https://authority.com" + } + expect: { + endpoint: { + url: "https://https-authority.com-nopath.example.com" + } + } + } + { + documentation: "empty path with slash" + params: { + Endpoint: "https://authority.com/" + } + expect: { + endpoint: { + url: "https://https-authority.com-nopath.example.com" + } + } + } + { + documentation: "authority with port" + params: { + Endpoint: "https://authority.com:8000/port" + } + expect: { + endpoint: { + url: "https://authority.com:8000/uri-with-port" + } + } + } + { + documentation: "http schemes" + params: { + Endpoint: "http://authority.com:8000/port" + } + expect: { + endpoint: { + url: "http://authority.com:8000/uri-with-port" + } + } + } + { + documentation: "arbitrary schemes are not supported" + params: { + Endpoint: "acbd://example.com" + } + expect: { + error: "endpoint was invalid" + } + } + { + documentation: "host labels are not validated" + params: { + Endpoint: "http://99_ab.com" + } + expect: { + endpoint: { + url: "https://http-99_ab.com-nopath.example.com" + } + } + } + { + documentation: "host labels are not validated" + params: { + Endpoint: "http://99_ab-.com" + } + expect: { + endpoint: { + url: "https://http-99_ab-.com-nopath.example.com" + } + } + } + { + documentation: "invalid URL" + params: { + Endpoint: "http://abc.com:a/foo" + } + expect: { + error: "endpoint was invalid" + } + } + { + documentation: "IP Address" + params: { + Endpoint: "http://192.168.1.1/foo/" + } + expect: { + endpoint: { + url: "http://192.168.1.1/foo/is-ip-addr" + } + } + } + { + documentation: "IP Address with port" + params: { + Endpoint: "http://192.168.1.1:1234/foo/" + } + expect: { + endpoint: { + url: "http://192.168.1.1:1234/foo/is-ip-addr" + } + } + } + { + documentation: "IPv6 Address" + params: { + Endpoint: "https://[2001:db8:85a3:8d3:1319:8a2e:370:7348]:443" + } + expect: { + endpoint: { + url: "https://[2001:db8:85a3:8d3:1319:8a2e:370:7348]:443/is-ip-addr" + } + } + } + { + documentation: "weird DNS name" + params: { + Endpoint: "https://999.999.abc.blah" + } + expect: { + endpoint: { + url: "https://https-999.999.abc.blah-nopath.example.com" + } + } + } + { + documentation: "query in resolved endpoint is not supported" + params: { + Endpoint: "https://example.com/path?query1=foo" + } + expect: { + error: "endpoint was invalid" + } + } + ] +) +service FizzBuzz { +} diff --git a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/bdd-tests/split.smithy b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/bdd-tests/split.smithy new file mode 100644 index 00000000000..4ad229a6d17 --- /dev/null +++ b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/bdd-tests/split.smithy @@ -0,0 +1,982 @@ +$version: "2.0" + +namespace smithy.tests.endpointrules.split + +use smithy.rules#clientContextParams +use smithy.rules#endpointBdd +use smithy.rules#endpointTests + +@suppress([ + "UnstableTrait.smithy" +]) +@clientContextParams( + Input: { + type: "string" + documentation: "Input string to split" + } + Delimiter: { + type: "string" + documentation: "Delimiter to split by" + } + Limit: { + type: "string" + documentation: "Split limit" + } +) +@endpointBdd( + version: "1.3" + parameters: { + Input: { + required: true + documentation: "The input string to split" + type: "string" + } + Delimiter: { + required: true + documentation: "The delimiter to split by" + type: "string" + } + Limit: { + required: true + documentation: "The split limit as a string" + type: "string" + } + } + conditions: [ + { + fn: "stringEquals" + argv: [ + { + ref: "Limit" + } + "0" + ] + } + { + fn: "split" + argv: [ + "{Input}" + "{Delimiter}" + 0 + ] + assign: "parts_ssa_1" + } + { + fn: "coalesce" + argv: [ + { + fn: "getAttr" + argv: [ + { + ref: "parts_ssa_1" + } + "[0]" + ] + } + "" + ] + assign: "part1" + } + { + fn: "coalesce" + argv: [ + { + fn: "getAttr" + argv: [ + { + ref: "parts_ssa_1" + } + "[1]" + ] + } + "" + ] + assign: "part2" + } + { + fn: "coalesce" + argv: [ + { + fn: "getAttr" + argv: [ + { + ref: "parts_ssa_1" + } + "[2]" + ] + } + "" + ] + assign: "part3" + } + { + fn: "coalesce" + argv: [ + { + fn: "getAttr" + argv: [ + { + ref: "parts_ssa_1" + } + "[3]" + ] + } + "" + ] + assign: "part4" + } + { + fn: "coalesce" + argv: [ + { + fn: "getAttr" + argv: [ + { + ref: "parts_ssa_1" + } + "[4]" + ] + } + "" + ] + assign: "part5" + } + { + fn: "stringEquals" + argv: [ + { + ref: "Limit" + } + "1" + ] + } + { + fn: "split" + argv: [ + "{Input}" + "{Delimiter}" + 1 + ] + assign: "parts_ssa_2" + } + { + fn: "coalesce" + argv: [ + { + fn: "getAttr" + argv: [ + { + ref: "parts_ssa_2" + } + "[0]" + ] + } + "" + ] + assign: "part1" + } + { + fn: "coalesce" + argv: [ + { + fn: "getAttr" + argv: [ + { + ref: "parts_ssa_2" + } + "[1]" + ] + } + "" + ] + assign: "part2" + } + { + fn: "coalesce" + argv: [ + { + fn: "getAttr" + argv: [ + { + ref: "parts_ssa_2" + } + "[2]" + ] + } + "" + ] + assign: "part3" + } + { + fn: "coalesce" + argv: [ + { + fn: "getAttr" + argv: [ + { + ref: "parts_ssa_2" + } + "[3]" + ] + } + "" + ] + assign: "part4" + } + { + fn: "coalesce" + argv: [ + { + fn: "getAttr" + argv: [ + { + ref: "parts_ssa_2" + } + "[4]" + ] + } + "" + ] + assign: "part5" + } + { + fn: "stringEquals" + argv: [ + { + ref: "Limit" + } + "2" + ] + } + { + fn: "split" + argv: [ + "{Input}" + "{Delimiter}" + 2 + ] + assign: "parts_ssa_3" + } + { + fn: "coalesce" + argv: [ + { + fn: "getAttr" + argv: [ + { + ref: "parts_ssa_3" + } + "[0]" + ] + } + "" + ] + assign: "part1" + } + { + fn: "coalesce" + argv: [ + { + fn: "getAttr" + argv: [ + { + ref: "parts_ssa_3" + } + "[1]" + ] + } + "" + ] + assign: "part2" + } + { + fn: "coalesce" + argv: [ + { + fn: "getAttr" + argv: [ + { + ref: "parts_ssa_3" + } + "[2]" + ] + } + "" + ] + assign: "part3" + } + { + fn: "coalesce" + argv: [ + { + fn: "getAttr" + argv: [ + { + ref: "parts_ssa_3" + } + "[3]" + ] + } + "" + ] + assign: "part4" + } + { + fn: "coalesce" + argv: [ + { + fn: "getAttr" + argv: [ + { + ref: "parts_ssa_3" + } + "[4]" + ] + } + "" + ] + assign: "part5" + } + { + fn: "stringEquals" + argv: [ + { + ref: "Limit" + } + "3" + ] + } + { + fn: "split" + argv: [ + "{Input}" + "{Delimiter}" + 3 + ] + assign: "parts_ssa_4" + } + { + fn: "coalesce" + argv: [ + { + fn: "getAttr" + argv: [ + { + ref: "parts_ssa_4" + } + "[0]" + ] + } + "" + ] + assign: "part1" + } + { + fn: "coalesce" + argv: [ + { + fn: "getAttr" + argv: [ + { + ref: "parts_ssa_4" + } + "[1]" + ] + } + "" + ] + assign: "part2" + } + { + fn: "coalesce" + argv: [ + { + fn: "getAttr" + argv: [ + { + ref: "parts_ssa_4" + } + "[2]" + ] + } + "" + ] + assign: "part3" + } + { + fn: "coalesce" + argv: [ + { + fn: "getAttr" + argv: [ + { + ref: "parts_ssa_4" + } + "[3]" + ] + } + "" + ] + assign: "part4" + } + { + fn: "coalesce" + argv: [ + { + fn: "getAttr" + argv: [ + { + ref: "parts_ssa_4" + } + "[4]" + ] + } + "" + ] + assign: "part5" + } + { + fn: "stringEquals" + argv: [ + { + ref: "Limit" + } + "4" + ] + } + { + fn: "split" + argv: [ + "{Input}" + "{Delimiter}" + 4 + ] + assign: "parts_ssa_5" + } + { + fn: "coalesce" + argv: [ + { + fn: "getAttr" + argv: [ + { + ref: "parts_ssa_5" + } + "[0]" + ] + } + "" + ] + assign: "part1" + } + { + fn: "coalesce" + argv: [ + { + fn: "getAttr" + argv: [ + { + ref: "parts_ssa_5" + } + "[1]" + ] + } + "" + ] + assign: "part2" + } + { + fn: "coalesce" + argv: [ + { + fn: "getAttr" + argv: [ + { + ref: "parts_ssa_5" + } + "[2]" + ] + } + "" + ] + assign: "part3" + } + { + fn: "coalesce" + argv: [ + { + fn: "getAttr" + argv: [ + { + ref: "parts_ssa_5" + } + "[3]" + ] + } + "" + ] + assign: "part4" + } + { + fn: "coalesce" + argv: [ + { + fn: "getAttr" + argv: [ + { + ref: "parts_ssa_5" + } + "[4]" + ] + } + "" + ] + assign: "part5" + } + ] + results: [ + { + conditions: [] + endpoint: { + url: "https://example.com" + properties: { + splitResult: "p1={part1}; p2={part2}; p3={part3}; p4={part4}; p5={part5}" + } + headers: {} + } + type: "endpoint" + } + { + documentation: "error fallthrough" + conditions: [] + error: "endpoint error" + type: "error" + } + ] + root: 2 + nodeCount: 36 + nodes: "/////wAAAAH/////AAAAAAAAAAMAAAAJAAAAAQAAAAQAAAAJAAAAAgAAAAUAAAAJAAAAAwAAAAYAAAAJAAAABAAAAAcAAAAJAAAABQAAAAgAAAAJAAAABgX14QEAAAAJAAAABwAAAAoAAAAQAAAACAAAAAsAAAAQAAAACQAAAAwAAAAQAAAACgAAAA0AAAAQAAAACwAAAA4AAAAQAAAADAAAAA8AAAAQAAAADQX14QEAAAAQAAAADgAAABEAAAAXAAAADwAAABIAAAAXAAAAEAAAABMAAAAXAAAAEQAAABQAAAAXAAAAEgAAABUAAAAXAAAAEwAAABYAAAAXAAAAFAX14QEAAAAXAAAAFQAAABgAAAAeAAAAFgAAABkAAAAeAAAAFwAAABoAAAAeAAAAGAAAABsAAAAeAAAAGQAAABwAAAAeAAAAGgAAAB0AAAAeAAAAGwX14QEAAAAeAAAAHAAAAB8F9eECAAAAHQAAACAF9eECAAAAHgAAACEF9eECAAAAHwAAACIF9eECAAAAIAAAACMF9eECAAAAIQAAACQF9eECAAAAIgX14QEF9eEC" +) +@endpointTests( + version: "1.0" + testCases: [ + { + documentation: "basic three-part split" + params: { + Input: "a--b--c" + Delimiter: "--" + Limit: "0" + } + expect: { + endpoint: { + url: "https://example.com" + properties: { + splitResult: "p1=a; p2=b; p3=c; p4=; p5=" + } + } + } + } + { + documentation: "empty string returns single empty element" + params: { + Input: "" + Delimiter: "--" + Limit: "0" + } + expect: { + endpoint: { + url: "https://example.com" + properties: { + splitResult: "p1=; p2=; p3=; p4=; p5=" + } + } + } + } + { + documentation: "delimiter not found returns original string" + params: { + Input: "no-delimiter" + Delimiter: "--" + Limit: "0" + } + expect: { + endpoint: { + url: "https://example.com" + properties: { + splitResult: "p1=no-delimiter; p2=; p3=; p4=; p5=" + } + } + } + } + { + documentation: "leading delimiter creates empty first element" + params: { + Input: "--leading" + Delimiter: "--" + Limit: "0" + } + expect: { + endpoint: { + url: "https://example.com" + properties: { + splitResult: "p1=; p2=leading; p3=; p4=; p5=" + } + } + } + } + { + documentation: "trailing delimiter creates empty last element" + params: { + Input: "trailing--" + Delimiter: "--" + Limit: "0" + } + expect: { + endpoint: { + url: "https://example.com" + properties: { + splitResult: "p1=trailing; p2=; p3=; p4=; p5=" + } + } + } + } + { + documentation: "adjacent delimiters create empty element" + params: { + Input: "----" + Delimiter: "--" + Limit: "0" + } + expect: { + endpoint: { + url: "https://example.com" + properties: { + splitResult: "p1=; p2=; p3=; p4=; p5=" + } + } + } + } + { + documentation: "delimiter equals input creates two empty strings" + params: { + Input: "--" + Delimiter: "--" + Limit: "0" + } + expect: { + endpoint: { + url: "https://example.com" + properties: { + splitResult: "p1=; p2=; p3=; p4=; p5=" + } + } + } + } + { + documentation: "overlapping delimiter pattern" + params: { + Input: "aaaa" + Delimiter: "aa" + Limit: "0" + } + expect: { + endpoint: { + url: "https://example.com" + properties: { + splitResult: "p1=; p2=; p3=; p4=; p5=" + } + } + } + } + { + documentation: "overlapping delimiter with odd remainder" + params: { + Input: "aaa" + Delimiter: "aa" + Limit: "0" + } + expect: { + endpoint: { + url: "https://example.com" + properties: { + splitResult: "p1=; p2=a; p3=; p4=; p5=" + } + } + } + } + { + documentation: "multi-character delimiter" + params: { + Input: "foo<=>bar<=>baz" + Delimiter: "<=>" + Limit: "0" + } + expect: { + endpoint: { + url: "https://example.com" + properties: { + splitResult: "p1=foo; p2=bar; p3=baz; p4=; p5=" + } + } + } + } + { + documentation: "multi-character delimiter with limit" + params: { + Input: "foo<=>bar<=>baz" + Delimiter: "<=>" + Limit: "2" + } + expect: { + endpoint: { + url: "https://example.com" + properties: { + splitResult: "p1=foo; p2=bar<=>baz; p3=; p4=; p5=" + } + } + } + } + { + documentation: "both leading and trailing delimiters" + params: { + Input: "--both--" + Delimiter: "--" + Limit: "0" + } + expect: { + endpoint: { + url: "https://example.com" + properties: { + splitResult: "p1=; p2=both; p3=; p4=; p5=" + } + } + } + } + { + documentation: "both leading and trailing with limit" + params: { + Input: "--both--" + Delimiter: "--" + Limit: "2" + } + expect: { + endpoint: { + url: "https://example.com" + properties: { + splitResult: "p1=; p2=both--; p3=; p4=; p5=" + } + } + } + } + { + documentation: "limit 1 returns original string" + params: { + Input: "a--b--c" + Delimiter: "--" + Limit: "1" + } + expect: { + endpoint: { + url: "https://example.com" + properties: { + splitResult: "p1=a--b--c; p2=; p3=; p4=; p5=" + } + } + } + } + { + documentation: "limit 1 with no delimiter" + params: { + Input: "no-delimiter" + Delimiter: "--" + Limit: "1" + } + expect: { + endpoint: { + url: "https://example.com" + properties: { + splitResult: "p1=no-delimiter; p2=; p3=; p4=; p5=" + } + } + } + } + { + documentation: "limit 2 splits once" + params: { + Input: "a--b--c" + Delimiter: "--" + Limit: "2" + } + expect: { + endpoint: { + url: "https://example.com" + properties: { + splitResult: "p1=a; p2=b--c; p3=; p4=; p5=" + } + } + } + } + { + documentation: "limit 2 with leading delimiter" + params: { + Input: "--x-s3--azid" + Delimiter: "--" + Limit: "2" + } + expect: { + endpoint: { + url: "https://example.com" + properties: { + splitResult: "p1=; p2=x-s3--azid; p3=; p4=; p5=" + } + } + } + } + { + documentation: "limit 3 exact match" + params: { + Input: "a--b--c" + Delimiter: "--" + Limit: "3" + } + expect: { + endpoint: { + url: "https://example.com" + properties: { + splitResult: "p1=a; p2=b; p3=c; p4=; p5=" + } + } + } + } + { + documentation: "limit 3 with remainder" + params: { + Input: "a--b--c--d" + Delimiter: "--" + Limit: "3" + } + expect: { + endpoint: { + url: "https://example.com" + properties: { + splitResult: "p1=a; p2=b; p3=c--d; p4=; p5=" + } + } + } + } + { + documentation: "S3 Express bucket pattern" + params: { + Input: "--x-s3--azid--suffix" + Delimiter: "--" + Limit: "4" + } + expect: { + endpoint: { + url: "https://example.com" + properties: { + splitResult: "p1=; p2=x-s3; p3=azid; p4=suffix; p5=" + } + } + } + } + { + documentation: "limit 4 stops at 4 parts" + params: { + Input: "a--b--c--d--e" + Delimiter: "--" + Limit: "4" + } + expect: { + endpoint: { + url: "https://example.com" + properties: { + splitResult: "p1=a; p2=b; p3=c; p4=d--e; p5=" + } + } + } + } + { + documentation: "unicode emoji delimiter" + params: { + Input: "a🌟b🌟c" + Delimiter: "🌟" + Limit: "0" + } + expect: { + endpoint: { + url: "https://example.com" + properties: { + splitResult: "p1=a; p2=b; p3=c; p4=; p5=" + } + } + } + } + { + documentation: "regex-like pattern treated literally" + params: { + Input: "a.*b.*c" + Delimiter: ".*" + Limit: "0" + } + expect: { + endpoint: { + url: "https://example.com" + properties: { + splitResult: "p1=a; p2=b; p3=c; p4=; p5=" + } + } + } + } + { + documentation: "pipe delimiter" + params: { + Input: "a|b|c|d|e" + Delimiter: "|" + Limit: "0" + } + expect: { + endpoint: { + url: "https://example.com" + properties: { + splitResult: "p1=a; p2=b; p3=c; p4=d; p5=e" + } + } + } + } + { + documentation: "delimiter longer than input" + params: { + Input: "ab" + Delimiter: "abcd" + Limit: "0" + } + expect: { + endpoint: { + url: "https://example.com" + properties: { + splitResult: "p1=ab; p2=; p3=; p4=; p5=" + } + } + } + } + { + documentation: "delimiter equals entire input" + params: { + Input: "abc" + Delimiter: "abc" + Limit: "0" + } + expect: { + endpoint: { + url: "https://example.com" + properties: { + splitResult: "p1=; p2=; p3=; p4=; p5=" + } + } + } + } + ] +) +service FizzBuzz { +} diff --git a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/bdd-tests/substring.smithy b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/bdd-tests/substring.smithy new file mode 100644 index 00000000000..0b7480f9a99 --- /dev/null +++ b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/bdd-tests/substring.smithy @@ -0,0 +1,288 @@ +$version: "2.0" + +namespace smithy.tests.endpointrules.substring + +use smithy.rules#clientContextParams +use smithy.rules#endpointBdd +use smithy.rules#endpointTests + +@suppress([ + "UnstableTrait" +]) +@clientContextParams( + TestCaseId: { + type: "string" + documentation: "docs" + } + Input: { + type: "string" + documentation: "docs" + } +) +@endpointBdd( + version: "1.1" + parameters: { + TestCaseId: { + required: true + documentation: "Test case id used to select the test case to use" + type: "string" + } + Input: { + required: true + documentation: "the input used to test substring" + type: "string" + } + } + conditions: [ + { + fn: "stringEquals" + argv: [ + { + ref: "TestCaseId" + } + "1" + ] + } + { + fn: "substring" + argv: [ + "{Input}" + 0 + 4 + false + ] + assign: "output_ssa_1" + } + { + fn: "stringEquals" + argv: [ + { + ref: "TestCaseId" + } + "2" + ] + } + { + fn: "substring" + argv: [ + "{Input}" + 0 + 4 + true + ] + assign: "output_ssa_2" + } + { + fn: "stringEquals" + argv: [ + { + ref: "TestCaseId" + } + "3" + ] + } + { + fn: "substring" + argv: [ + "{Input}" + 1 + 3 + false + ] + assign: "output_ssa_3" + } + ] + results: [ + { + conditions: [] + error: "The value is: `{output_ssa_1}`" + type: "error" + } + { + conditions: [] + error: "The value is: `{output_ssa_2}`" + type: "error" + } + { + conditions: [] + error: "The value is: `{output_ssa_3}`" + type: "error" + } + { + documentation: "fallback when no tests match" + conditions: [] + error: "No tests matched" + type: "error" + } + ] + root: 2 + nodeCount: 7 + nodes: "/////wAAAAH/////AAAAAAAAAAMAAAAEAAAAAQX14QEAAAAEAAAAAgAAAAUAAAAGAAAAAwX14QIAAAAGAAAABAAAAAcF9eEEAAAABQX14QMF9eEE" +) +@endpointTests( + version: "1.0" + testCases: [ + { + documentation: "substring when string is long enough" + params: { + TestCaseId: "1" + Input: "abcdefg" + } + expect: { + error: "The value is: `abcd`" + } + } + { + documentation: "substring when string is exactly the right length" + params: { + TestCaseId: "1" + Input: "abcd" + } + expect: { + error: "The value is: `abcd`" + } + } + { + documentation: "substring when string is too short" + params: { + TestCaseId: "1" + Input: "abc" + } + expect: { + error: "No tests matched" + } + } + { + documentation: "substring when string is too short" + params: { + TestCaseId: "1" + Input: "" + } + expect: { + error: "No tests matched" + } + } + { + documentation: "substring on wide characters (ensure that unicode code points are properly counted)" + params: { + TestCaseId: "1" + Input: "﷽" + } + expect: { + error: "No tests matched" + } + } + { + documentation: "the full set of ascii is supported, including non-printable characters" + params: { + TestCaseId: "1" + Input: "\u007fabcdef" + } + expect: { + error: "The value is: `\u007fabc`" + } + } + { + documentation: "substring when string is long enough" + params: { + TestCaseId: "2" + Input: "abcdefg" + } + expect: { + error: "The value is: `defg`" + } + } + { + documentation: "substring when string is exactly the right length" + params: { + TestCaseId: "2" + Input: "defg" + } + expect: { + error: "The value is: `defg`" + } + } + { + documentation: "substring when string is too short" + params: { + TestCaseId: "2" + Input: "abc" + } + expect: { + error: "No tests matched" + } + } + { + documentation: "substring when string is too short" + params: { + TestCaseId: "2" + Input: "" + } + expect: { + error: "No tests matched" + } + } + { + documentation: "substring on wide characters (ensure that unicode code points are properly counted)" + params: { + TestCaseId: "2" + Input: "﷽" + } + expect: { + error: "No tests matched" + } + } + { + documentation: "substring when string is longer" + params: { + TestCaseId: "3" + Input: "defg" + } + expect: { + error: "The value is: `ef`" + } + } + { + documentation: "substring when string is exact length" + params: { + TestCaseId: "3" + Input: "def" + } + expect: { + error: "The value is: `ef`" + } + } + { + documentation: "substring when string is too short" + params: { + TestCaseId: "3" + Input: "ab" + } + expect: { + error: "No tests matched" + } + } + { + documentation: "substring when string is too short" + params: { + TestCaseId: "3" + Input: "" + } + expect: { + error: "No tests matched" + } + } + { + documentation: "substring on wide characters (ensure that unicode code points are properly counted)" + params: { + TestCaseId: "3" + Input: "﷽" + } + expect: { + error: "No tests matched" + } + } + ] +) +service FizzBuzz { +} diff --git a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/bdd-tests/url-encode.smithy b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/bdd-tests/url-encode.smithy new file mode 100644 index 00000000000..b6fa8f975c9 --- /dev/null +++ b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/bdd-tests/url-encode.smithy @@ -0,0 +1,147 @@ +$version: "2.0" + +namespace smithy.tests.endpointrules.urlencode + +use smithy.rules#clientContextParams +use smithy.rules#endpointBdd +use smithy.rules#endpointTests + +@suppress([ + "UnstableTrait" +]) +@clientContextParams( + TestCaseId: { + type: "string" + documentation: "Test case id used to select the test case to use" + } + Input: { + type: "string" + documentation: "The input used to test uriEncoder" + } +) +@endpointBdd( + version: "1.1" + parameters: { + TestCaseId: { + required: true + documentation: "Test case id used to select the test case to use" + type: "string" + } + Input: { + required: true + documentation: "The input used to test uriEncode" + type: "string" + } + } + conditions: [ + { + fn: "stringEquals" + argv: [ + { + ref: "TestCaseId" + } + "1" + ] + } + { + fn: "uriEncode" + argv: [ + "{Input}" + ] + assign: "output" + } + ] + results: [ + { + conditions: [] + error: "The value is: `{output}`" + type: "error" + } + { + documentation: "fallback when no tests match" + conditions: [] + error: "No tests matched" + type: "error" + } + ] + root: 2 + nodeCount: 3 + nodes: "/////wAAAAH/////AAAAAAAAAAMF9eECAAAAAQX14QEF9eEC" +) +@endpointTests( + version: "1.0" + testCases: [ + { + documentation: "uriEncode when the string has nothing to encode returns the input" + params: { + TestCaseId: "1" + Input: "abcdefg" + } + expect: { + error: "The value is: `abcdefg`" + } + } + { + documentation: "uriEncode with single character to encode encodes only that character" + params: { + TestCaseId: "1" + Input: "abc:defg" + } + expect: { + error: "The value is: `abc%3Adefg`" + } + } + { + documentation: "uriEncode with all ASCII characters to encode encodes all characters" + params: { + TestCaseId: "1" + Input: "/:,?#[]{}|@! $&'()*+;=%<>\"^`\\" + } + expect: { + error: "The value is: `%2F%3A%2C%3F%23%5B%5D%7B%7D%7C%40%21%20%24%26%27%28%29%2A%2B%3B%3D%25%3C%3E%22%5E%60%5C`" + } + } + { + documentation: "uriEncode with ASCII characters that should not be encoded returns the input" + params: { + TestCaseId: "1" + Input: "0123456789.underscore_dash-Tilda~" + } + expect: { + error: "The value is: `0123456789.underscore_dash-Tilda~`" + } + } + { + documentation: "uriEncode encodes unicode characters" + params: { + TestCaseId: "1" + Input: "😹" + } + expect: { + error: "The value is: `%F0%9F%98%B9`" + } + } + { + documentation: "uriEncode on all printable ASCII characters" + params: { + TestCaseId: "1" + Input: " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~" + } + expect: { + error: "The value is: `%20%21%22%23%24%25%26%27%28%29%2A%2B%2C-.%2F0123456789%3A%3B%3C%3D%3E%3F%40ABCDEFGHIJKLMNOPQRSTUVWXYZ%5B%5C%5D%5E_%60abcdefghijklmnopqrstuvwxyz%7B%7C%7D~`" + } + } + { + documentation: "uriEncode on an empty string" + params: { + TestCaseId: "1" + Input: "" + } + expect: { + error: "The value is: ``" + } + } + ] +) +service FizzBuzz { +} diff --git a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/bdd-tests/valid-hostlabel.smithy b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/bdd-tests/valid-hostlabel.smithy new file mode 100644 index 00000000000..3231761e116 --- /dev/null +++ b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/bdd-tests/valid-hostlabel.smithy @@ -0,0 +1,161 @@ +$version: "2.0" + +namespace smithy.tests.endpointrules.validhostlabel + +use smithy.rules#clientContextParams +use smithy.rules#endpointBdd +use smithy.rules#endpointTests + +@suppress([ + "UnstableTrait" +]) +@clientContextParams( + Region: { + type: "string" + documentation: "docs" + } +) +@endpointBdd( + version: "1.1" + parameters: { + Region: { + required: true + documentation: "The region to dispatch this request, eg. `us-east-1`." + type: "string" + } + } + conditions: [ + { + fn: "isValidHostLabel" + argv: [ + { + ref: "Region" + } + false + ] + } + { + fn: "isValidHostLabel" + argv: [ + { + ref: "Region" + } + true + ] + } + ] + results: [ + { + conditions: [] + endpoint: { + url: "https://{Region}.amazonaws.com" + properties: {} + headers: {} + } + type: "endpoint" + } + { + conditions: [] + endpoint: { + url: "https://{Region}-subdomains.amazonaws.com" + properties: {} + headers: {} + } + type: "endpoint" + } + { + documentation: "Region was not a valid host label" + conditions: [] + error: "Invalid hostlabel" + type: "error" + } + ] + root: 2 + nodeCount: 3 + nodes: "/////wAAAAH/////AAAAAAX14QEAAAADAAAAAQX14QIF9eED" +) +@endpointTests( + version: "1.0" + testCases: [ + { + documentation: "standard region is a valid hostlabel" + params: { + Region: "us-east-1" + } + expect: { + endpoint: { + url: "https://us-east-1.amazonaws.com" + } + } + } + { + documentation: "starting with a number is a valid hostlabel" + params: { + Region: "3aws4" + } + expect: { + endpoint: { + url: "https://3aws4.amazonaws.com" + } + } + } + { + documentation: "when there are dots, only match if subdomains are allowed" + params: { + Region: "part1.part2" + } + expect: { + endpoint: { + url: "https://part1.part2-subdomains.amazonaws.com" + } + } + } + { + documentation: "a space is never a valid hostlabel" + params: { + Region: "part1 part2" + } + expect: { + error: "Invalid hostlabel" + } + } + { + documentation: "an empty string is not a valid hostlabel" + params: { + Region: "" + } + expect: { + error: "Invalid hostlabel" + } + } + { + documentation: "ending with a dot is not a valid hostlabel" + params: { + Region: "part1." + } + expect: { + error: "Invalid hostlabel" + } + } + { + documentation: "multiple consecutive dots are not allowed" + params: { + Region: "part1..part2" + } + expect: { + error: "Invalid hostlabel" + } + } + { + documentation: "labels cannot start with a dash" + params: { + Region: "part1.-part2" + } + expect: { + error: "Invalid hostlabel" + } + } + ] +) +service FizzBuzz { +} diff --git a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/coalesce.smithy b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/tree-tests/coalesce.smithy similarity index 100% rename from smithy-rules-engine-tests/src/main/resources/META-INF/smithy/coalesce.smithy rename to smithy-rules-engine-tests/src/main/resources/META-INF/smithy/tree-tests/coalesce.smithy diff --git a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/default-values.smithy b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/tree-tests/default-values.smithy similarity index 100% rename from smithy-rules-engine-tests/src/main/resources/META-INF/smithy/default-values.smithy rename to smithy-rules-engine-tests/src/main/resources/META-INF/smithy/tree-tests/default-values.smithy diff --git a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/endpoint-bindings.smithy b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/tree-tests/endpoint-bindings.smithy similarity index 100% rename from smithy-rules-engine-tests/src/main/resources/META-INF/smithy/endpoint-bindings.smithy rename to smithy-rules-engine-tests/src/main/resources/META-INF/smithy/tree-tests/endpoint-bindings.smithy diff --git a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/endpoints-string-array.smithy b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/tree-tests/endpoints-string-array.smithy similarity index 100% rename from smithy-rules-engine-tests/src/main/resources/META-INF/smithy/endpoints-string-array.smithy rename to smithy-rules-engine-tests/src/main/resources/META-INF/smithy/tree-tests/endpoints-string-array.smithy diff --git a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/get-attr.smithy b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/tree-tests/get-attr.smithy similarity index 100% rename from smithy-rules-engine-tests/src/main/resources/META-INF/smithy/get-attr.smithy rename to smithy-rules-engine-tests/src/main/resources/META-INF/smithy/tree-tests/get-attr.smithy diff --git a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/headers.smithy b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/tree-tests/headers.smithy similarity index 100% rename from smithy-rules-engine-tests/src/main/resources/META-INF/smithy/headers.smithy rename to smithy-rules-engine-tests/src/main/resources/META-INF/smithy/tree-tests/headers.smithy diff --git a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/ite.smithy b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/tree-tests/ite.smithy similarity index 100% rename from smithy-rules-engine-tests/src/main/resources/META-INF/smithy/ite.smithy rename to smithy-rules-engine-tests/src/main/resources/META-INF/smithy/tree-tests/ite.smithy diff --git a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/manifest b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/tree-tests/manifest similarity index 100% rename from smithy-rules-engine-tests/src/main/resources/META-INF/smithy/manifest rename to smithy-rules-engine-tests/src/main/resources/META-INF/smithy/tree-tests/manifest diff --git a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/parse-url.smithy b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/tree-tests/parse-url.smithy similarity index 100% rename from smithy-rules-engine-tests/src/main/resources/META-INF/smithy/parse-url.smithy rename to smithy-rules-engine-tests/src/main/resources/META-INF/smithy/tree-tests/parse-url.smithy diff --git a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/split.smithy b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/tree-tests/split.smithy similarity index 100% rename from smithy-rules-engine-tests/src/main/resources/META-INF/smithy/split.smithy rename to smithy-rules-engine-tests/src/main/resources/META-INF/smithy/tree-tests/split.smithy diff --git a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/substring.smithy b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/tree-tests/substring.smithy similarity index 100% rename from smithy-rules-engine-tests/src/main/resources/META-INF/smithy/substring.smithy rename to smithy-rules-engine-tests/src/main/resources/META-INF/smithy/tree-tests/substring.smithy diff --git a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/url-encode.smithy b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/tree-tests/url-encode.smithy similarity index 100% rename from smithy-rules-engine-tests/src/main/resources/META-INF/smithy/url-encode.smithy rename to smithy-rules-engine-tests/src/main/resources/META-INF/smithy/tree-tests/url-encode.smithy diff --git a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/valid-hostlabel.smithy b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/tree-tests/valid-hostlabel.smithy similarity index 100% rename from smithy-rules-engine-tests/src/main/resources/META-INF/smithy/valid-hostlabel.smithy rename to smithy-rules-engine-tests/src/main/resources/META-INF/smithy/tree-tests/valid-hostlabel.smithy From 0050d6633b3057c6461978bf0424a2bab27a6cf7 Mon Sep 17 00:00:00 2001 From: Landon James Date: Mon, 26 Jan 2026 13:20:06 -0800 Subject: [PATCH 3/8] Add cahngelog entry --- .../feature-31e86dfd28fac45a68ff1389fe531b2416b0f660.json | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 .changes/next-release/feature-31e86dfd28fac45a68ff1389fe531b2416b0f660.json diff --git a/.changes/next-release/feature-31e86dfd28fac45a68ff1389fe531b2416b0f660.json b/.changes/next-release/feature-31e86dfd28fac45a68ff1389fe531b2416b0f660.json new file mode 100644 index 00000000000..05b664b091d --- /dev/null +++ b/.changes/next-release/feature-31e86dfd28fac45a68ff1389fe531b2416b0f660.json @@ -0,0 +1,7 @@ +{ + "type": "feature", + "description": "Update smithy-rules-engine-tests with new std lib functions and bdd-based tests", + "pull_requests": [ + "[#2945](https://github.com/smithy-lang/smithy/pull/2945)" + ] +} From 523f32ef718e7051f430f4f61588e301d1058309 Mon Sep 17 00:00:00 2001 From: Landon James Date: Tue, 27 Jan 2026 11:58:43 -0800 Subject: [PATCH 4/8] Centralize both tree rules and BDD rules in single test models Note the split model currently won't compile due to the bug fixed in https://github.com/smithy-lang/smithy/pull/2946 Commiting so I can pull that change in and regenerate --- .../META-INF/smithy/bdd-tests/coalesce.smithy | 259 ----- .../smithy/bdd-tests/default-values.smithy | 129 --- .../smithy/bdd-tests/endpoint-bindings.smithy | 348 ------- .../bdd-tests/endpoints-string-array.smithy | 274 ----- .../META-INF/smithy/bdd-tests/get-attr.smithy | 92 -- .../META-INF/smithy/bdd-tests/headers.smithy | 92 -- .../META-INF/smithy/bdd-tests/ite.smithy | 103 -- .../smithy/bdd-tests/parse-url.smithy | 290 ------ .../META-INF/smithy/bdd-tests/split.smithy | 982 ------------------ .../smithy/bdd-tests/substring.smithy | 288 ----- .../smithy/bdd-tests/url-encode.smithy | 147 --- .../smithy/bdd-tests/valid-hostlabel.smithy | 161 --- .../smithy/{tree-tests => }/coalesce.smithy | 154 ++- .../{tree-tests => }/default-values.smithy | 47 + .../{tree-tests => }/endpoint-bindings.smithy | 108 ++ .../endpoints-string-array.smithy | 47 + .../smithy/{tree-tests => }/get-attr.smithy | 59 +- .../smithy/{tree-tests => }/headers.smithy | 49 + .../smithy/{tree-tests => }/ite.smithy | 43 +- .../META-INF/smithy/{tree-tests => }/manifest | 3 + .../smithy/{tree-tests => }/parse-url.smithy | 119 +++ .../smithy/{tree-tests => }/split.smithy | 539 +++++++++- .../smithy/{tree-tests => }/substring.smithy | 101 ++ .../smithy/{tree-tests => }/url-encode.smithy | 50 + .../{tree-tests => }/valid-hostlabel.smithy | 60 ++ 25 files changed, 1372 insertions(+), 3172 deletions(-) delete mode 100644 smithy-rules-engine-tests/src/main/resources/META-INF/smithy/bdd-tests/coalesce.smithy delete mode 100644 smithy-rules-engine-tests/src/main/resources/META-INF/smithy/bdd-tests/default-values.smithy delete mode 100644 smithy-rules-engine-tests/src/main/resources/META-INF/smithy/bdd-tests/endpoint-bindings.smithy delete mode 100644 smithy-rules-engine-tests/src/main/resources/META-INF/smithy/bdd-tests/endpoints-string-array.smithy delete mode 100644 smithy-rules-engine-tests/src/main/resources/META-INF/smithy/bdd-tests/get-attr.smithy delete mode 100644 smithy-rules-engine-tests/src/main/resources/META-INF/smithy/bdd-tests/headers.smithy delete mode 100644 smithy-rules-engine-tests/src/main/resources/META-INF/smithy/bdd-tests/ite.smithy delete mode 100644 smithy-rules-engine-tests/src/main/resources/META-INF/smithy/bdd-tests/parse-url.smithy delete mode 100644 smithy-rules-engine-tests/src/main/resources/META-INF/smithy/bdd-tests/split.smithy delete mode 100644 smithy-rules-engine-tests/src/main/resources/META-INF/smithy/bdd-tests/substring.smithy delete mode 100644 smithy-rules-engine-tests/src/main/resources/META-INF/smithy/bdd-tests/url-encode.smithy delete mode 100644 smithy-rules-engine-tests/src/main/resources/META-INF/smithy/bdd-tests/valid-hostlabel.smithy rename smithy-rules-engine-tests/src/main/resources/META-INF/smithy/{tree-tests => }/coalesce.smithy (64%) rename smithy-rules-engine-tests/src/main/resources/META-INF/smithy/{tree-tests => }/default-values.smithy (74%) rename smithy-rules-engine-tests/src/main/resources/META-INF/smithy/{tree-tests => }/endpoint-bindings.smithy (80%) rename smithy-rules-engine-tests/src/main/resources/META-INF/smithy/{tree-tests => }/endpoints-string-array.smithy (84%) rename smithy-rules-engine-tests/src/main/resources/META-INF/smithy/{tree-tests => }/get-attr.smithy (59%) rename smithy-rules-engine-tests/src/main/resources/META-INF/smithy/{tree-tests => }/headers.smithy (64%) rename smithy-rules-engine-tests/src/main/resources/META-INF/smithy/{tree-tests => }/ite.smithy (68%) rename smithy-rules-engine-tests/src/main/resources/META-INF/smithy/{tree-tests => }/manifest (82%) rename smithy-rules-engine-tests/src/main/resources/META-INF/smithy/{tree-tests => }/parse-url.smithy (73%) rename smithy-rules-engine-tests/src/main/resources/META-INF/smithy/{tree-tests => }/split.smithy (67%) rename smithy-rules-engine-tests/src/main/resources/META-INF/smithy/{tree-tests => }/substring.smithy (77%) rename smithy-rules-engine-tests/src/main/resources/META-INF/smithy/{tree-tests => }/url-encode.smithy (78%) rename smithy-rules-engine-tests/src/main/resources/META-INF/smithy/{tree-tests => }/valid-hostlabel.smithy (74%) diff --git a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/bdd-tests/coalesce.smithy b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/bdd-tests/coalesce.smithy deleted file mode 100644 index dadb23617e9..00000000000 --- a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/bdd-tests/coalesce.smithy +++ /dev/null @@ -1,259 +0,0 @@ -$version: "2.0" - -namespace smithy.tests.endpointrules.coalesce - -use smithy.rules#clientContextParams -use smithy.rules#endpointBdd -use smithy.rules#endpointTests - -@suppress([ - "UnstableTrait" - "RuleSetParameter.TestCase.Unused" -]) -@clientContextParams( - TestCaseId: { - type: "string" - required: true - documentation: "Test case id used to select the test case to use" - } - req1: { - type: "string" - documentation: "docs" - } - req2: { - type: "string" - documentation: "docs" - } - opt1: { - type: "string" - documentation: "always Some" - } - opt2: { - type: "string" - documentation: "always Some" - } -) -@endpointBdd( - version: "1.1" - parameters: { - TestCaseId: { - required: true - documentation: "Test case id used to select the test case to use" - type: "string" - } - req1: { - required: true - default: "req1Value" - documentation: "req1" - type: "string" - } - req2: { - required: true - default: "req2Value" - documentation: "req2" - type: "string" - } - opt1: { - required: false - documentation: "opt1" - type: "string" - } - opt2: { - required: false - documentation: "opt2" - type: "string" - } - } - conditions: [ - { - fn: "stringEquals" - argv: [ - { - ref: "TestCaseId" - } - "0" - ] - } - { - fn: "coalesce" - argv: [ - { - ref: "req1" - } - { - ref: "req2" - } - ] - assign: "req1req2" - } - { - fn: "stringEquals" - argv: [ - { - ref: "TestCaseId" - } - "1" - ] - } - { - fn: "coalesce" - argv: [ - { - ref: "opt1" - } - { - ref: "opt2" - } - ] - assign: "opt1opt2" - } - { - fn: "stringEquals" - argv: [ - { - ref: "TestCaseId" - } - "2" - ] - } - { - fn: "coalesce" - argv: [ - { - ref: "req1" - } - { - ref: "opt1" - } - ] - assign: "req1opt1" - } - { - fn: "stringEquals" - argv: [ - { - ref: "TestCaseId" - } - "3" - ] - } - { - fn: "coalesce" - argv: [ - { - ref: "opt1" - } - { - ref: "req1" - } - ] - assign: "opt1req1" - } - ] - results: [ - { - conditions: [] - error: "The value is: {req1req2}" - type: "error" - } - { - conditions: [] - error: "The value is: {opt1opt2}" - type: "error" - } - { - conditions: [] - error: "The value is: {req1opt1}" - type: "error" - } - { - conditions: [] - error: "The value is: {opt1req1}" - type: "error" - } - { - documentation: "error fallthrough" - conditions: [] - error: "endpoint error" - type: "error" - } - ] - root: 2 - nodeCount: 9 - nodes: "/////wAAAAH/////AAAAAAAAAAMAAAAEAAAAAQX14QEAAAAEAAAAAgAAAAUAAAAGAAAAAwX14QIAAAAGAAAABAAAAAcAAAAIAAAABQX14QMAAAAIAAAABgAAAAkF9eEFAAAABwX14QQF9eEF" -) -@endpointTests( - version: "1.0" - testCases: [ - { - documentation: "Two required, first val returned" - params: { - TestCaseId: "0" - } - expect: { - error: "The value is: req1Value" - } - } - { - documentation: "Two optional, Some(opt1Value), Some(opt2Value), opt1Value returned" - params: { - TestCaseId: "1" - opt1: "opt1Value" - opt2: "opt2Value" - } - expect: { - error: "The value is: opt1Value" - } - } - { - documentation: "Two optional, None, Some(opt2Value), opt2Value returned" - params: { - TestCaseId: "1" - opt2: "opt2Value" - } - expect: { - error: "The value is: opt2Value" - } - } - { - documentation: "Two optional, None, None, None returned" - params: { - TestCaseId: "1" - } - expect: { - error: "endpoint error" - } - } - { - documentation: "Required then Optional, required returned" - params: { - TestCaseId: "2" - opt1: "opt1Value" - } - expect: { - error: "The value is: req1Value" - } - } - { - documentation: "Optional then Required, optional value returned" - params: { - TestCaseId: "3" - opt1: "opt1Value" - } - expect: { - error: "The value is: opt1Value" - } - } - { - documentation: "Optional then Required, optional is none so required value returned" - params: { - TestCaseId: "3" - } - expect: { - error: "The value is: req1Value" - } - } - ] -) -service FizzBuzz { -} diff --git a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/bdd-tests/default-values.smithy b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/bdd-tests/default-values.smithy deleted file mode 100644 index 2fc32533e07..00000000000 --- a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/bdd-tests/default-values.smithy +++ /dev/null @@ -1,129 +0,0 @@ -$version: "2.0" - -namespace smithy.tests.endpointrules.defaultvalues - -use smithy.rules#clientContextParams -use smithy.rules#endpointBdd -use smithy.rules#endpointTests - -@suppress([ - "UnstableTrait" -]) -@clientContextParams( - bar: { - type: "string" - documentation: "a client string parameter" - } - baz: { - type: "string" - documentation: "another client string parameter" - } -) -@endpointBdd( - version: "1.1" - parameters: { - bar: { - required: false - documentation: "docs" - type: "string" - } - baz: { - required: true - default: "baz" - documentation: "docs" - type: "string" - } - } - conditions: [ - { - fn: "isSet" - argv: [ - { - ref: "bar" - } - ] - } - ] - results: [ - { - conditions: [] - endpoint: { - url: "https://example.com/{baz}" - properties: {} - headers: {} - } - type: "endpoint" - } - { - documentation: "error fallthrough" - conditions: [] - error: "endpoint error" - type: "error" - } - ] - root: 2 - nodeCount: 2 - nodes: "/////wAAAAH/////AAAAAAX14QEF9eEC" -) -@endpointTests( - version: "1.0" - testCases: [ - { - documentation: "Default value is used when parameter is unset" - params: { - bar: "a b" - } - operationInputs: [ - { - operationName: "GetThing" - clientParams: { - bar: "a b" - } - } - ] - expect: { - endpoint: { - url: "https://example.com/baz" - } - } - } - { - documentation: "Default value is not used when the parameter is set" - params: { - bar: "a b" - baz: "BIG" - } - operationInputs: [ - { - operationName: "GetThing" - clientParams: { - bar: "a b" - baz: "BIG" - } - } - ] - expect: { - endpoint: { - url: "https://example.com/BIG" - } - } - } - { - documentation: "a documentation string" - expect: { - error: "endpoint error" - } - } - ] -) -service FizzBuzz { - version: "2022-01-01" - operations: [ - GetThing - ] -} - -operation GetThing { - input := {} - output: Unit -} diff --git a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/bdd-tests/endpoint-bindings.smithy b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/bdd-tests/endpoint-bindings.smithy deleted file mode 100644 index 2c9609c2c6e..00000000000 --- a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/bdd-tests/endpoint-bindings.smithy +++ /dev/null @@ -1,348 +0,0 @@ -$version: "2.0" - -namespace smithy.tests.endpointrules.endpointbindings - -use smithy.rules#clientContextParams -use smithy.rules#contextParam -use smithy.rules#endpointBdd -use smithy.rules#endpointTests -use smithy.rules#operationContextParams -use smithy.rules#staticContextParams - -@suppress([ - "UnstableTrait" -]) -@clientContextParams( - bar: { - type: "string" - documentation: "a client string parameter" - } - baz: { - type: "string" - documentation: "another client string parameter" - } - booleanParam: { - type: "boolean" - documentation: "a client boolean parameter" - } -) -@endpointBdd( - version: "1.1" - parameters: { - bar: { - required: false - documentation: "String parameter with no default value and client binding" - type: "string" - } - baz: { - required: true - default: "baz" - documentation: "String parameter with default value and client binding" - type: "string" - } - booleanParam: { - required: true - default: true - documentation: "Boolean parameter with default value and client binding" - type: "boolean" - } - Endpoint: { - builtIn: "SDK::Endpoint" - required: false - documentation: "Override the endpoint used to send this request" - type: "string" - } - } - conditions: [ - { - fn: "isSet" - argv: [ - { - ref: "Endpoint" - } - ] - } - { - fn: "booleanEquals" - argv: [ - { - ref: "booleanParam" - } - true - ] - } - { - fn: "isSet" - argv: [ - { - ref: "bar" - } - ] - } - ] - results: [ - { - conditions: [] - endpoint: { - url: { - ref: "Endpoint" - } - properties: {} - headers: {} - } - type: "endpoint" - } - { - conditions: [] - endpoint: { - url: "https://{bar}.{baz}/set" - properties: {} - headers: {} - } - type: "endpoint" - } - { - conditions: [] - endpoint: { - url: "https://{baz}/set" - properties: {} - headers: {} - } - type: "endpoint" - } - { - conditions: [] - endpoint: { - url: "https://{bar}.{baz}/unset" - properties: {} - headers: {} - } - type: "endpoint" - } - { - conditions: [] - endpoint: { - url: "https://{baz}/unset" - properties: {} - headers: {} - } - type: "endpoint" - } - ] - root: 2 - nodeCount: 5 - nodes: "/////wAAAAH/////AAAAAAX14QEAAAADAAAAAQAAAAUAAAAEAAAAAgX14QQF9eEFAAAAAgX14QIF9eED" -) -@endpointTests( - version: "1.0" - testCases: [ - { - documentation: "Custom Endpoint used" - params: { - Endpoint: "https://custom-endpoint.com" - } - expect: { - endpoint: { - url: "https://custom-endpoint.com" - } - } - operationInputs: [ - { - operationName: "NoBindingsOperation" - builtInParams: { - "SDK::Endpoint": "https://custom-endpoint.com" - } - } - ] - } - { - documentation: "Default values used" - params: {} - expect: { - endpoint: { - url: "https://baz/set" - } - } - operationInputs: [ - { - operationName: "NoBindingsOperation" - } - ] - } - { - documentation: "Client config used over default" - params: { - baz: "client-config" - } - expect: { - endpoint: { - url: "https://client-config/set" - } - } - operationInputs: [ - { - operationName: "NoBindingsOperation" - clientParams: { - baz: "client-config" - } - } - ] - } - { - documentation: "StaticContextParam values used" - params: { - bar: "static-context" - booleanParam: false - } - expect: { - endpoint: { - url: "https://static-context.baz/unset" - } - } - operationInputs: [ - { - operationName: "StaticContextOperation" - } - ] - } - { - documentation: "ContextParam values used over config and defaults" - params: { - bar: "context-bar" - baz: "context-baz" - booleanParam: false - } - expect: { - endpoint: { - url: "https://context-bar.context-baz/unset" - } - } - operationInputs: [ - { - operationName: "ContextParamsOperation" - operationParams: { - bar: "context-bar" - baz: "context-baz" - booleanParam: false - } - clientParams: { - bar: "client-config" - } - } - ] - } - { - documentation: "OperationContextParam values used over config and defaults" - params: { - bar: "operation-context-bar" - baz: "operation-context-baz" - booleanParam: false - } - expect: { - endpoint: { - url: "https://operation-context-bar.operation-context-baz/unset" - } - } - operationInputs: [ - { - operationName: "OperationContextParamsOperation" - operationParams: { - nested: { - bar: "operation-context-bar" - baz: "operation-context-baz" - } - booleanParam: false - } - clientParams: { - bar: "client-config" - } - } - ] - } - ] -) -service EndpointBindingService { - version: "2022-01-01" - operations: [ - ContextParamsOperation - NoBindingsOperation - OperationContextParamsOperation - StaticContextOperation - ] -} - -operation ContextParamsOperation { - input := { - @contextParam( - name: "bar" - ) - bar: String - @contextParam( - name: "baz" - ) - baz: String - @contextParam( - name: "booleanParam" - ) - booleanParam: Boolean - } - output: Unit -} - -operation NoBindingsOperation { - input := {} - output: Unit -} - -@operationContextParams( - bar: { - path: "nested.bar" - } - baz: { - path: "nested.baz" - } - booleanParam: { - path: "booleanParam" - } -) -operation OperationContextParamsOperation { - input := { - nested: Nested - booleanParam: Boolean - } - output: Unit -} - -@suppress([ - "UnstableTrait" -]) -@staticContextParams( - bar: { - value: "static-context" - } - booleanParam: { - value: false - } -) -operation StaticContextOperation { - input := {} - output: Unit -} - -structure Nested { - bar: String - baz: String -} - -structure ObjectMember { - key: String -} - -list ListOfObjects { - member: ObjectMember -} - -map Map { - key: String - value: String -} diff --git a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/bdd-tests/endpoints-string-array.smithy b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/bdd-tests/endpoints-string-array.smithy deleted file mode 100644 index 4537cf720df..00000000000 --- a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/bdd-tests/endpoints-string-array.smithy +++ /dev/null @@ -1,274 +0,0 @@ -$version: "2.0" - -namespace smithy.tests.endpointrules.stringarray - -use smithy.rules#endpointBdd -use smithy.rules#endpointTests -use smithy.rules#operationContextParams -use smithy.rules#staticContextParams - -@suppress([ - "UnstableTrait" -]) -@endpointBdd( - version: "1.1" - parameters: { - stringArrayParam: { - required: true - default: [ - "defaultValue1" - "defaultValue2" - ] - documentation: "docs" - type: "stringArray" - } - } - conditions: [ - { - fn: "getAttr" - argv: [ - { - ref: "stringArrayParam" - } - "[0]" - ] - assign: "arrayValue" - } - ] - results: [ - { - conditions: [] - endpoint: { - url: "https://example.com/{arrayValue}" - properties: {} - headers: {} - } - type: "endpoint" - } - { - documentation: "error fallthrough" - conditions: [] - error: "no array values set" - type: "error" - } - ] - root: 2 - nodeCount: 2 - nodes: "/////wAAAAH/////AAAAAAX14QEF9eEC" -) -@endpointTests( - version: "1.0" - testCases: [ - { - documentation: "Default array values used" - params: {} - expect: { - endpoint: { - url: "https://example.com/defaultValue1" - } - } - operationInputs: [ - { - operationName: "NoBindingsOperation" - } - ] - } - { - documentation: "Empty array" - params: { - stringArrayParam: [] - } - expect: { - error: "no array values set" - } - operationInputs: [ - { - operationName: "EmptyStaticContextOperation" - } - ] - } - { - documentation: "Static value" - params: { - stringArrayParam: [ - "staticValue1" - ] - } - expect: { - endpoint: { - url: "https://example.com/staticValue1" - } - } - operationInputs: [ - { - operationName: "StaticContextOperation" - } - ] - } - { - documentation: "bound value from input" - params: { - stringArrayParam: [ - "key1" - ] - } - expect: { - endpoint: { - url: "https://example.com/key1" - } - } - operationInputs: [ - { - operationName: "ListOfObjectsOperation" - operationParams: { - nested: { - listOfObjects: [ - { - key: "key1" - } - ] - } - } - } - { - operationName: "MapOperation" - operationParams: { - map: { - key1: "value1" - } - } - } - { - operationName: "ListOfUnionsOperation" - operationParams: { - listOfUnions: [ - { - string: "key1" - } - { - object: { - key: "key2" - } - } - ] - } - } - ] - } - ] -) -service EndpointStringArrayService { - version: "2022-01-01" - operations: [ - EmptyStaticContextOperation - ListOfObjectsOperation - ListOfUnionsOperation - MapOperation - NoBindingsOperation - StaticContextOperation - ] -} - -@suppress([ - "UnstableTrait" -]) -@staticContextParams( - stringArrayParam: { - value: [] - } -) -operation EmptyStaticContextOperation { - input := {} - output: Unit -} - -@suppress([ - "UnstableTrait" -]) -@operationContextParams( - stringArrayParam: { - path: "nested.listOfObjects[*].key" - } -) -operation ListOfObjectsOperation { - input := { - nested: Nested - } - output: Unit -} - -@suppress([ - "UnstableTrait" -]) -@operationContextParams( - stringArrayParam: { - path: "listOfUnions[*][string, object.key][]" - } -) -operation ListOfUnionsOperation { - input := { - listOfUnions: ListOfUnions - } - output: Unit -} - -@suppress([ - "UnstableTrait" -]) -@operationContextParams( - stringArrayParam: { - path: "keys(map)" - } -) -operation MapOperation { - input := { - map: Map - } - output: Unit -} - -operation NoBindingsOperation { - input := {} - output: Unit -} - -@suppress([ - "UnstableTrait" -]) -@staticContextParams( - stringArrayParam: { - value: [ - "staticValue1" - ] - } -) -operation StaticContextOperation { - input := {} - output: Unit -} - -structure Nested { - listOfObjects: ListOfObjects -} - -structure ObjectMember { - key: String -} - -union UnionMember { - string: String - object: ObjectMember -} - -list ListOfObjects { - member: ObjectMember -} - -list ListOfUnions { - member: UnionMember -} - -map Map { - key: String - value: String -} diff --git a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/bdd-tests/get-attr.smithy b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/bdd-tests/get-attr.smithy deleted file mode 100644 index ed1823e1546..00000000000 --- a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/bdd-tests/get-attr.smithy +++ /dev/null @@ -1,92 +0,0 @@ -$version: "2.0" - -namespace smithy.tests.endpointrules.getattr - -use smithy.rules#clientContextParams -use smithy.rules#endpointBdd -use smithy.rules#endpointTests - -@suppress([ - "UnstableTrait" -]) -@clientContextParams( - Bucket: { - type: "string" - documentation: "docs" - } -) -@endpointBdd( - version: "1.1" - parameters: { - Bucket: { - required: false - documentation: "docs" - type: "string" - } - } - conditions: [ - { - fn: "isSet" - argv: [ - { - ref: "Bucket" - } - ] - } - { - fn: "parseURL" - argv: [ - "{Bucket}" - ] - assign: "bucketUrl" - } - { - fn: "getAttr" - argv: [ - { - ref: "bucketUrl" - } - "path" - ] - assign: "path" - } - ] - results: [ - { - conditions: [] - endpoint: { - url: "https://{bucketUrl#authority}{path}" - properties: {} - headers: {} - } - type: "endpoint" - } - { - documentation: "fallback when no tests match" - conditions: [] - error: "No tests matched" - type: "error" - } - ] - root: 2 - nodeCount: 4 - nodes: "/////wAAAAH/////AAAAAAAAAAMF9eECAAAAAQAAAAQF9eECAAAAAgX14QEF9eEC" -) -@endpointTests( - version: "1.0" - testCases: [ - { - documentation: "getAttr on top level values in function and template" - params: { - Bucket: "http://example.com/path" - } - expect: { - endpoint: { - url: "https://example.com/path" - } - } - } - ] -) -service FizzBuzz { -} diff --git a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/bdd-tests/headers.smithy b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/bdd-tests/headers.smithy deleted file mode 100644 index 8480b442435..00000000000 --- a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/bdd-tests/headers.smithy +++ /dev/null @@ -1,92 +0,0 @@ -$version: "2.0" - -namespace smithy.tests.endpointrules.headers - -use smithy.rules#clientContextParams -use smithy.rules#endpointBdd -use smithy.rules#endpointTests - -@suppress([ - "UnstableTrait" -]) -@clientContextParams( - Region: { - type: "string" - documentation: "docs" - } -) -@endpointBdd( - version: "1.1" - parameters: { - Region: { - required: false - documentation: "The region to dispatch this request, eg. `us-east-1`." - type: "string" - } - } - conditions: [ - { - fn: "isSet" - argv: [ - { - ref: "Region" - } - ] - } - ] - results: [ - { - conditions: [] - endpoint: { - url: "https://{Region}.amazonaws.com" - properties: {} - headers: { - "x-amz-region": [ - "{Region}" - ] - "x-amz-multi": [ - "*" - "{Region}" - ] - } - } - type: "endpoint" - } - { - documentation: "fallback when region is unset" - conditions: [] - error: "Region must be set to resolve a valid endpoint" - type: "error" - } - ] - root: 2 - nodeCount: 2 - nodes: "/////wAAAAH/////AAAAAAX14QEF9eEC" -) -@endpointTests( - version: "1.0" - testCases: [ - { - documentation: "header set to region" - params: { - Region: "us-east-1" - } - expect: { - endpoint: { - url: "https://us-east-1.amazonaws.com" - headers: { - "x-amz-region": [ - "us-east-1" - ] - "x-amz-multi": [ - "*" - "us-east-1" - ] - } - } - } - } - ] -) -service FizzBuzz { -} diff --git a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/bdd-tests/ite.smithy b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/bdd-tests/ite.smithy deleted file mode 100644 index 4ce002d53f0..00000000000 --- a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/bdd-tests/ite.smithy +++ /dev/null @@ -1,103 +0,0 @@ -$version: "2.0" - -namespace example - -use smithy.rules#clientContextParams -use smithy.rules#endpointBdd -use smithy.rules#endpointTests - -@suppress([ - "UnstableTrait.smithy" -]) -@clientContextParams( - useFips: { - type: "boolean" - documentation: "Use FIPS endpoints" - } -) -@endpointBdd( - version: "1.1" - parameters: { - useFips: { - required: true - default: false - documentation: "Use FIPS endpoints" - type: "boolean" - } - } - conditions: [ - { - fn: "ite" - argv: [ - { - ref: "useFips" - } - "-fips" - "" - ] - assign: "suffix" - } - ] - results: [ - { - conditions: [] - endpoint: { - url: "https://example{suffix}.com" - properties: {} - headers: {} - } - type: "endpoint" - } - ] - root: 2 - nodeCount: 2 - nodes: "/////wAAAAH/////AAAAAAX14QEF9eEA" -) -@endpointTests( - version: "1.0" - testCases: [ - { - documentation: "When useFips is true, returns trueValue" - params: { - useFips: true - } - operationInputs: [ - { - operationName: "GetThing" - } - ] - expect: { - endpoint: { - url: "https://example-fips.com" - } - } - } - { - documentation: "When useFips is false, returns falseValue" - params: { - useFips: false - } - operationInputs: [ - { - operationName: "GetThing" - } - ] - expect: { - endpoint: { - url: "https://example.com" - } - } - } - ] -) -service FizzBuzz { - version: "2022-01-01" - operations: [ - GetThing - ] -} - -operation GetThing { - input := {} - output: Unit -} diff --git a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/bdd-tests/parse-url.smithy b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/bdd-tests/parse-url.smithy deleted file mode 100644 index 0d36c941c01..00000000000 --- a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/bdd-tests/parse-url.smithy +++ /dev/null @@ -1,290 +0,0 @@ -$version: "2.0" - -namespace smithy.tests.endpointrules.parseurl - -use smithy.rules#clientContextParams -use smithy.rules#endpointBdd -use smithy.rules#endpointTests - -@suppress([ - "UnstableTrait" -]) -@clientContextParams( - Endpoint: { - type: "string" - documentation: "docs" - } -) -@endpointBdd( - version: "1.1" - parameters: { - Endpoint: { - required: false - documentation: "docs" - type: "string" - } - } - conditions: [ - { - fn: "isSet" - argv: [ - { - ref: "Endpoint" - } - ] - } - { - fn: "parseURL" - argv: [ - "{Endpoint}" - ] - assign: "url" - } - { - fn: "booleanEquals" - argv: [ - true - { - fn: "getAttr" - argv: [ - { - ref: "url" - } - "isIp" - ] - } - ] - } - { - fn: "stringEquals" - argv: [ - "/port" - { - fn: "getAttr" - argv: [ - { - ref: "url" - } - "path" - ] - } - ] - } - { - fn: "stringEquals" - argv: [ - "/" - { - fn: "getAttr" - argv: [ - { - ref: "url" - } - "normalizedPath" - ] - } - ] - } - ] - results: [ - { - conditions: [] - endpoint: { - url: "{url#scheme}://{url#authority}{url#normalizedPath}is-ip-addr" - properties: {} - headers: {} - } - type: "endpoint" - } - { - conditions: [] - endpoint: { - url: "{url#scheme}://{url#authority}/uri-with-port" - properties: {} - headers: {} - } - type: "endpoint" - } - { - conditions: [] - endpoint: { - url: "https://{url#scheme}-{url#authority}-nopath.example.com" - properties: {} - headers: {} - } - type: "endpoint" - } - { - conditions: [] - endpoint: { - url: "https://{url#scheme}-{url#authority}.example.com/path-is{url#path}" - properties: {} - headers: {} - } - type: "endpoint" - } - { - conditions: [] - error: "endpoint was invalid" - type: "error" - } - ] - root: 2 - nodeCount: 6 - nodes: "/////wAAAAH/////AAAAAAAAAAMF9eEFAAAAAQAAAAQF9eEFAAAAAgX14QEAAAAFAAAAAwX14QIAAAAGAAAABAX14QMF9eEE" -) -@endpointTests( - version: "1.0" - testCases: [ - { - documentation: "simple URL parsing" - params: { - Endpoint: "https://authority.com/custom-path" - } - expect: { - endpoint: { - url: "https://https-authority.com.example.com/path-is/custom-path" - } - } - } - { - documentation: "empty path no slash" - params: { - Endpoint: "https://authority.com" - } - expect: { - endpoint: { - url: "https://https-authority.com-nopath.example.com" - } - } - } - { - documentation: "empty path with slash" - params: { - Endpoint: "https://authority.com/" - } - expect: { - endpoint: { - url: "https://https-authority.com-nopath.example.com" - } - } - } - { - documentation: "authority with port" - params: { - Endpoint: "https://authority.com:8000/port" - } - expect: { - endpoint: { - url: "https://authority.com:8000/uri-with-port" - } - } - } - { - documentation: "http schemes" - params: { - Endpoint: "http://authority.com:8000/port" - } - expect: { - endpoint: { - url: "http://authority.com:8000/uri-with-port" - } - } - } - { - documentation: "arbitrary schemes are not supported" - params: { - Endpoint: "acbd://example.com" - } - expect: { - error: "endpoint was invalid" - } - } - { - documentation: "host labels are not validated" - params: { - Endpoint: "http://99_ab.com" - } - expect: { - endpoint: { - url: "https://http-99_ab.com-nopath.example.com" - } - } - } - { - documentation: "host labels are not validated" - params: { - Endpoint: "http://99_ab-.com" - } - expect: { - endpoint: { - url: "https://http-99_ab-.com-nopath.example.com" - } - } - } - { - documentation: "invalid URL" - params: { - Endpoint: "http://abc.com:a/foo" - } - expect: { - error: "endpoint was invalid" - } - } - { - documentation: "IP Address" - params: { - Endpoint: "http://192.168.1.1/foo/" - } - expect: { - endpoint: { - url: "http://192.168.1.1/foo/is-ip-addr" - } - } - } - { - documentation: "IP Address with port" - params: { - Endpoint: "http://192.168.1.1:1234/foo/" - } - expect: { - endpoint: { - url: "http://192.168.1.1:1234/foo/is-ip-addr" - } - } - } - { - documentation: "IPv6 Address" - params: { - Endpoint: "https://[2001:db8:85a3:8d3:1319:8a2e:370:7348]:443" - } - expect: { - endpoint: { - url: "https://[2001:db8:85a3:8d3:1319:8a2e:370:7348]:443/is-ip-addr" - } - } - } - { - documentation: "weird DNS name" - params: { - Endpoint: "https://999.999.abc.blah" - } - expect: { - endpoint: { - url: "https://https-999.999.abc.blah-nopath.example.com" - } - } - } - { - documentation: "query in resolved endpoint is not supported" - params: { - Endpoint: "https://example.com/path?query1=foo" - } - expect: { - error: "endpoint was invalid" - } - } - ] -) -service FizzBuzz { -} diff --git a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/bdd-tests/split.smithy b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/bdd-tests/split.smithy deleted file mode 100644 index 4ad229a6d17..00000000000 --- a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/bdd-tests/split.smithy +++ /dev/null @@ -1,982 +0,0 @@ -$version: "2.0" - -namespace smithy.tests.endpointrules.split - -use smithy.rules#clientContextParams -use smithy.rules#endpointBdd -use smithy.rules#endpointTests - -@suppress([ - "UnstableTrait.smithy" -]) -@clientContextParams( - Input: { - type: "string" - documentation: "Input string to split" - } - Delimiter: { - type: "string" - documentation: "Delimiter to split by" - } - Limit: { - type: "string" - documentation: "Split limit" - } -) -@endpointBdd( - version: "1.3" - parameters: { - Input: { - required: true - documentation: "The input string to split" - type: "string" - } - Delimiter: { - required: true - documentation: "The delimiter to split by" - type: "string" - } - Limit: { - required: true - documentation: "The split limit as a string" - type: "string" - } - } - conditions: [ - { - fn: "stringEquals" - argv: [ - { - ref: "Limit" - } - "0" - ] - } - { - fn: "split" - argv: [ - "{Input}" - "{Delimiter}" - 0 - ] - assign: "parts_ssa_1" - } - { - fn: "coalesce" - argv: [ - { - fn: "getAttr" - argv: [ - { - ref: "parts_ssa_1" - } - "[0]" - ] - } - "" - ] - assign: "part1" - } - { - fn: "coalesce" - argv: [ - { - fn: "getAttr" - argv: [ - { - ref: "parts_ssa_1" - } - "[1]" - ] - } - "" - ] - assign: "part2" - } - { - fn: "coalesce" - argv: [ - { - fn: "getAttr" - argv: [ - { - ref: "parts_ssa_1" - } - "[2]" - ] - } - "" - ] - assign: "part3" - } - { - fn: "coalesce" - argv: [ - { - fn: "getAttr" - argv: [ - { - ref: "parts_ssa_1" - } - "[3]" - ] - } - "" - ] - assign: "part4" - } - { - fn: "coalesce" - argv: [ - { - fn: "getAttr" - argv: [ - { - ref: "parts_ssa_1" - } - "[4]" - ] - } - "" - ] - assign: "part5" - } - { - fn: "stringEquals" - argv: [ - { - ref: "Limit" - } - "1" - ] - } - { - fn: "split" - argv: [ - "{Input}" - "{Delimiter}" - 1 - ] - assign: "parts_ssa_2" - } - { - fn: "coalesce" - argv: [ - { - fn: "getAttr" - argv: [ - { - ref: "parts_ssa_2" - } - "[0]" - ] - } - "" - ] - assign: "part1" - } - { - fn: "coalesce" - argv: [ - { - fn: "getAttr" - argv: [ - { - ref: "parts_ssa_2" - } - "[1]" - ] - } - "" - ] - assign: "part2" - } - { - fn: "coalesce" - argv: [ - { - fn: "getAttr" - argv: [ - { - ref: "parts_ssa_2" - } - "[2]" - ] - } - "" - ] - assign: "part3" - } - { - fn: "coalesce" - argv: [ - { - fn: "getAttr" - argv: [ - { - ref: "parts_ssa_2" - } - "[3]" - ] - } - "" - ] - assign: "part4" - } - { - fn: "coalesce" - argv: [ - { - fn: "getAttr" - argv: [ - { - ref: "parts_ssa_2" - } - "[4]" - ] - } - "" - ] - assign: "part5" - } - { - fn: "stringEquals" - argv: [ - { - ref: "Limit" - } - "2" - ] - } - { - fn: "split" - argv: [ - "{Input}" - "{Delimiter}" - 2 - ] - assign: "parts_ssa_3" - } - { - fn: "coalesce" - argv: [ - { - fn: "getAttr" - argv: [ - { - ref: "parts_ssa_3" - } - "[0]" - ] - } - "" - ] - assign: "part1" - } - { - fn: "coalesce" - argv: [ - { - fn: "getAttr" - argv: [ - { - ref: "parts_ssa_3" - } - "[1]" - ] - } - "" - ] - assign: "part2" - } - { - fn: "coalesce" - argv: [ - { - fn: "getAttr" - argv: [ - { - ref: "parts_ssa_3" - } - "[2]" - ] - } - "" - ] - assign: "part3" - } - { - fn: "coalesce" - argv: [ - { - fn: "getAttr" - argv: [ - { - ref: "parts_ssa_3" - } - "[3]" - ] - } - "" - ] - assign: "part4" - } - { - fn: "coalesce" - argv: [ - { - fn: "getAttr" - argv: [ - { - ref: "parts_ssa_3" - } - "[4]" - ] - } - "" - ] - assign: "part5" - } - { - fn: "stringEquals" - argv: [ - { - ref: "Limit" - } - "3" - ] - } - { - fn: "split" - argv: [ - "{Input}" - "{Delimiter}" - 3 - ] - assign: "parts_ssa_4" - } - { - fn: "coalesce" - argv: [ - { - fn: "getAttr" - argv: [ - { - ref: "parts_ssa_4" - } - "[0]" - ] - } - "" - ] - assign: "part1" - } - { - fn: "coalesce" - argv: [ - { - fn: "getAttr" - argv: [ - { - ref: "parts_ssa_4" - } - "[1]" - ] - } - "" - ] - assign: "part2" - } - { - fn: "coalesce" - argv: [ - { - fn: "getAttr" - argv: [ - { - ref: "parts_ssa_4" - } - "[2]" - ] - } - "" - ] - assign: "part3" - } - { - fn: "coalesce" - argv: [ - { - fn: "getAttr" - argv: [ - { - ref: "parts_ssa_4" - } - "[3]" - ] - } - "" - ] - assign: "part4" - } - { - fn: "coalesce" - argv: [ - { - fn: "getAttr" - argv: [ - { - ref: "parts_ssa_4" - } - "[4]" - ] - } - "" - ] - assign: "part5" - } - { - fn: "stringEquals" - argv: [ - { - ref: "Limit" - } - "4" - ] - } - { - fn: "split" - argv: [ - "{Input}" - "{Delimiter}" - 4 - ] - assign: "parts_ssa_5" - } - { - fn: "coalesce" - argv: [ - { - fn: "getAttr" - argv: [ - { - ref: "parts_ssa_5" - } - "[0]" - ] - } - "" - ] - assign: "part1" - } - { - fn: "coalesce" - argv: [ - { - fn: "getAttr" - argv: [ - { - ref: "parts_ssa_5" - } - "[1]" - ] - } - "" - ] - assign: "part2" - } - { - fn: "coalesce" - argv: [ - { - fn: "getAttr" - argv: [ - { - ref: "parts_ssa_5" - } - "[2]" - ] - } - "" - ] - assign: "part3" - } - { - fn: "coalesce" - argv: [ - { - fn: "getAttr" - argv: [ - { - ref: "parts_ssa_5" - } - "[3]" - ] - } - "" - ] - assign: "part4" - } - { - fn: "coalesce" - argv: [ - { - fn: "getAttr" - argv: [ - { - ref: "parts_ssa_5" - } - "[4]" - ] - } - "" - ] - assign: "part5" - } - ] - results: [ - { - conditions: [] - endpoint: { - url: "https://example.com" - properties: { - splitResult: "p1={part1}; p2={part2}; p3={part3}; p4={part4}; p5={part5}" - } - headers: {} - } - type: "endpoint" - } - { - documentation: "error fallthrough" - conditions: [] - error: "endpoint error" - type: "error" - } - ] - root: 2 - nodeCount: 36 - nodes: "/////wAAAAH/////AAAAAAAAAAMAAAAJAAAAAQAAAAQAAAAJAAAAAgAAAAUAAAAJAAAAAwAAAAYAAAAJAAAABAAAAAcAAAAJAAAABQAAAAgAAAAJAAAABgX14QEAAAAJAAAABwAAAAoAAAAQAAAACAAAAAsAAAAQAAAACQAAAAwAAAAQAAAACgAAAA0AAAAQAAAACwAAAA4AAAAQAAAADAAAAA8AAAAQAAAADQX14QEAAAAQAAAADgAAABEAAAAXAAAADwAAABIAAAAXAAAAEAAAABMAAAAXAAAAEQAAABQAAAAXAAAAEgAAABUAAAAXAAAAEwAAABYAAAAXAAAAFAX14QEAAAAXAAAAFQAAABgAAAAeAAAAFgAAABkAAAAeAAAAFwAAABoAAAAeAAAAGAAAABsAAAAeAAAAGQAAABwAAAAeAAAAGgAAAB0AAAAeAAAAGwX14QEAAAAeAAAAHAAAAB8F9eECAAAAHQAAACAF9eECAAAAHgAAACEF9eECAAAAHwAAACIF9eECAAAAIAAAACMF9eECAAAAIQAAACQF9eECAAAAIgX14QEF9eEC" -) -@endpointTests( - version: "1.0" - testCases: [ - { - documentation: "basic three-part split" - params: { - Input: "a--b--c" - Delimiter: "--" - Limit: "0" - } - expect: { - endpoint: { - url: "https://example.com" - properties: { - splitResult: "p1=a; p2=b; p3=c; p4=; p5=" - } - } - } - } - { - documentation: "empty string returns single empty element" - params: { - Input: "" - Delimiter: "--" - Limit: "0" - } - expect: { - endpoint: { - url: "https://example.com" - properties: { - splitResult: "p1=; p2=; p3=; p4=; p5=" - } - } - } - } - { - documentation: "delimiter not found returns original string" - params: { - Input: "no-delimiter" - Delimiter: "--" - Limit: "0" - } - expect: { - endpoint: { - url: "https://example.com" - properties: { - splitResult: "p1=no-delimiter; p2=; p3=; p4=; p5=" - } - } - } - } - { - documentation: "leading delimiter creates empty first element" - params: { - Input: "--leading" - Delimiter: "--" - Limit: "0" - } - expect: { - endpoint: { - url: "https://example.com" - properties: { - splitResult: "p1=; p2=leading; p3=; p4=; p5=" - } - } - } - } - { - documentation: "trailing delimiter creates empty last element" - params: { - Input: "trailing--" - Delimiter: "--" - Limit: "0" - } - expect: { - endpoint: { - url: "https://example.com" - properties: { - splitResult: "p1=trailing; p2=; p3=; p4=; p5=" - } - } - } - } - { - documentation: "adjacent delimiters create empty element" - params: { - Input: "----" - Delimiter: "--" - Limit: "0" - } - expect: { - endpoint: { - url: "https://example.com" - properties: { - splitResult: "p1=; p2=; p3=; p4=; p5=" - } - } - } - } - { - documentation: "delimiter equals input creates two empty strings" - params: { - Input: "--" - Delimiter: "--" - Limit: "0" - } - expect: { - endpoint: { - url: "https://example.com" - properties: { - splitResult: "p1=; p2=; p3=; p4=; p5=" - } - } - } - } - { - documentation: "overlapping delimiter pattern" - params: { - Input: "aaaa" - Delimiter: "aa" - Limit: "0" - } - expect: { - endpoint: { - url: "https://example.com" - properties: { - splitResult: "p1=; p2=; p3=; p4=; p5=" - } - } - } - } - { - documentation: "overlapping delimiter with odd remainder" - params: { - Input: "aaa" - Delimiter: "aa" - Limit: "0" - } - expect: { - endpoint: { - url: "https://example.com" - properties: { - splitResult: "p1=; p2=a; p3=; p4=; p5=" - } - } - } - } - { - documentation: "multi-character delimiter" - params: { - Input: "foo<=>bar<=>baz" - Delimiter: "<=>" - Limit: "0" - } - expect: { - endpoint: { - url: "https://example.com" - properties: { - splitResult: "p1=foo; p2=bar; p3=baz; p4=; p5=" - } - } - } - } - { - documentation: "multi-character delimiter with limit" - params: { - Input: "foo<=>bar<=>baz" - Delimiter: "<=>" - Limit: "2" - } - expect: { - endpoint: { - url: "https://example.com" - properties: { - splitResult: "p1=foo; p2=bar<=>baz; p3=; p4=; p5=" - } - } - } - } - { - documentation: "both leading and trailing delimiters" - params: { - Input: "--both--" - Delimiter: "--" - Limit: "0" - } - expect: { - endpoint: { - url: "https://example.com" - properties: { - splitResult: "p1=; p2=both; p3=; p4=; p5=" - } - } - } - } - { - documentation: "both leading and trailing with limit" - params: { - Input: "--both--" - Delimiter: "--" - Limit: "2" - } - expect: { - endpoint: { - url: "https://example.com" - properties: { - splitResult: "p1=; p2=both--; p3=; p4=; p5=" - } - } - } - } - { - documentation: "limit 1 returns original string" - params: { - Input: "a--b--c" - Delimiter: "--" - Limit: "1" - } - expect: { - endpoint: { - url: "https://example.com" - properties: { - splitResult: "p1=a--b--c; p2=; p3=; p4=; p5=" - } - } - } - } - { - documentation: "limit 1 with no delimiter" - params: { - Input: "no-delimiter" - Delimiter: "--" - Limit: "1" - } - expect: { - endpoint: { - url: "https://example.com" - properties: { - splitResult: "p1=no-delimiter; p2=; p3=; p4=; p5=" - } - } - } - } - { - documentation: "limit 2 splits once" - params: { - Input: "a--b--c" - Delimiter: "--" - Limit: "2" - } - expect: { - endpoint: { - url: "https://example.com" - properties: { - splitResult: "p1=a; p2=b--c; p3=; p4=; p5=" - } - } - } - } - { - documentation: "limit 2 with leading delimiter" - params: { - Input: "--x-s3--azid" - Delimiter: "--" - Limit: "2" - } - expect: { - endpoint: { - url: "https://example.com" - properties: { - splitResult: "p1=; p2=x-s3--azid; p3=; p4=; p5=" - } - } - } - } - { - documentation: "limit 3 exact match" - params: { - Input: "a--b--c" - Delimiter: "--" - Limit: "3" - } - expect: { - endpoint: { - url: "https://example.com" - properties: { - splitResult: "p1=a; p2=b; p3=c; p4=; p5=" - } - } - } - } - { - documentation: "limit 3 with remainder" - params: { - Input: "a--b--c--d" - Delimiter: "--" - Limit: "3" - } - expect: { - endpoint: { - url: "https://example.com" - properties: { - splitResult: "p1=a; p2=b; p3=c--d; p4=; p5=" - } - } - } - } - { - documentation: "S3 Express bucket pattern" - params: { - Input: "--x-s3--azid--suffix" - Delimiter: "--" - Limit: "4" - } - expect: { - endpoint: { - url: "https://example.com" - properties: { - splitResult: "p1=; p2=x-s3; p3=azid; p4=suffix; p5=" - } - } - } - } - { - documentation: "limit 4 stops at 4 parts" - params: { - Input: "a--b--c--d--e" - Delimiter: "--" - Limit: "4" - } - expect: { - endpoint: { - url: "https://example.com" - properties: { - splitResult: "p1=a; p2=b; p3=c; p4=d--e; p5=" - } - } - } - } - { - documentation: "unicode emoji delimiter" - params: { - Input: "a🌟b🌟c" - Delimiter: "🌟" - Limit: "0" - } - expect: { - endpoint: { - url: "https://example.com" - properties: { - splitResult: "p1=a; p2=b; p3=c; p4=; p5=" - } - } - } - } - { - documentation: "regex-like pattern treated literally" - params: { - Input: "a.*b.*c" - Delimiter: ".*" - Limit: "0" - } - expect: { - endpoint: { - url: "https://example.com" - properties: { - splitResult: "p1=a; p2=b; p3=c; p4=; p5=" - } - } - } - } - { - documentation: "pipe delimiter" - params: { - Input: "a|b|c|d|e" - Delimiter: "|" - Limit: "0" - } - expect: { - endpoint: { - url: "https://example.com" - properties: { - splitResult: "p1=a; p2=b; p3=c; p4=d; p5=e" - } - } - } - } - { - documentation: "delimiter longer than input" - params: { - Input: "ab" - Delimiter: "abcd" - Limit: "0" - } - expect: { - endpoint: { - url: "https://example.com" - properties: { - splitResult: "p1=ab; p2=; p3=; p4=; p5=" - } - } - } - } - { - documentation: "delimiter equals entire input" - params: { - Input: "abc" - Delimiter: "abc" - Limit: "0" - } - expect: { - endpoint: { - url: "https://example.com" - properties: { - splitResult: "p1=; p2=; p3=; p4=; p5=" - } - } - } - } - ] -) -service FizzBuzz { -} diff --git a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/bdd-tests/substring.smithy b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/bdd-tests/substring.smithy deleted file mode 100644 index 0b7480f9a99..00000000000 --- a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/bdd-tests/substring.smithy +++ /dev/null @@ -1,288 +0,0 @@ -$version: "2.0" - -namespace smithy.tests.endpointrules.substring - -use smithy.rules#clientContextParams -use smithy.rules#endpointBdd -use smithy.rules#endpointTests - -@suppress([ - "UnstableTrait" -]) -@clientContextParams( - TestCaseId: { - type: "string" - documentation: "docs" - } - Input: { - type: "string" - documentation: "docs" - } -) -@endpointBdd( - version: "1.1" - parameters: { - TestCaseId: { - required: true - documentation: "Test case id used to select the test case to use" - type: "string" - } - Input: { - required: true - documentation: "the input used to test substring" - type: "string" - } - } - conditions: [ - { - fn: "stringEquals" - argv: [ - { - ref: "TestCaseId" - } - "1" - ] - } - { - fn: "substring" - argv: [ - "{Input}" - 0 - 4 - false - ] - assign: "output_ssa_1" - } - { - fn: "stringEquals" - argv: [ - { - ref: "TestCaseId" - } - "2" - ] - } - { - fn: "substring" - argv: [ - "{Input}" - 0 - 4 - true - ] - assign: "output_ssa_2" - } - { - fn: "stringEquals" - argv: [ - { - ref: "TestCaseId" - } - "3" - ] - } - { - fn: "substring" - argv: [ - "{Input}" - 1 - 3 - false - ] - assign: "output_ssa_3" - } - ] - results: [ - { - conditions: [] - error: "The value is: `{output_ssa_1}`" - type: "error" - } - { - conditions: [] - error: "The value is: `{output_ssa_2}`" - type: "error" - } - { - conditions: [] - error: "The value is: `{output_ssa_3}`" - type: "error" - } - { - documentation: "fallback when no tests match" - conditions: [] - error: "No tests matched" - type: "error" - } - ] - root: 2 - nodeCount: 7 - nodes: "/////wAAAAH/////AAAAAAAAAAMAAAAEAAAAAQX14QEAAAAEAAAAAgAAAAUAAAAGAAAAAwX14QIAAAAGAAAABAAAAAcF9eEEAAAABQX14QMF9eEE" -) -@endpointTests( - version: "1.0" - testCases: [ - { - documentation: "substring when string is long enough" - params: { - TestCaseId: "1" - Input: "abcdefg" - } - expect: { - error: "The value is: `abcd`" - } - } - { - documentation: "substring when string is exactly the right length" - params: { - TestCaseId: "1" - Input: "abcd" - } - expect: { - error: "The value is: `abcd`" - } - } - { - documentation: "substring when string is too short" - params: { - TestCaseId: "1" - Input: "abc" - } - expect: { - error: "No tests matched" - } - } - { - documentation: "substring when string is too short" - params: { - TestCaseId: "1" - Input: "" - } - expect: { - error: "No tests matched" - } - } - { - documentation: "substring on wide characters (ensure that unicode code points are properly counted)" - params: { - TestCaseId: "1" - Input: "﷽" - } - expect: { - error: "No tests matched" - } - } - { - documentation: "the full set of ascii is supported, including non-printable characters" - params: { - TestCaseId: "1" - Input: "\u007fabcdef" - } - expect: { - error: "The value is: `\u007fabc`" - } - } - { - documentation: "substring when string is long enough" - params: { - TestCaseId: "2" - Input: "abcdefg" - } - expect: { - error: "The value is: `defg`" - } - } - { - documentation: "substring when string is exactly the right length" - params: { - TestCaseId: "2" - Input: "defg" - } - expect: { - error: "The value is: `defg`" - } - } - { - documentation: "substring when string is too short" - params: { - TestCaseId: "2" - Input: "abc" - } - expect: { - error: "No tests matched" - } - } - { - documentation: "substring when string is too short" - params: { - TestCaseId: "2" - Input: "" - } - expect: { - error: "No tests matched" - } - } - { - documentation: "substring on wide characters (ensure that unicode code points are properly counted)" - params: { - TestCaseId: "2" - Input: "﷽" - } - expect: { - error: "No tests matched" - } - } - { - documentation: "substring when string is longer" - params: { - TestCaseId: "3" - Input: "defg" - } - expect: { - error: "The value is: `ef`" - } - } - { - documentation: "substring when string is exact length" - params: { - TestCaseId: "3" - Input: "def" - } - expect: { - error: "The value is: `ef`" - } - } - { - documentation: "substring when string is too short" - params: { - TestCaseId: "3" - Input: "ab" - } - expect: { - error: "No tests matched" - } - } - { - documentation: "substring when string is too short" - params: { - TestCaseId: "3" - Input: "" - } - expect: { - error: "No tests matched" - } - } - { - documentation: "substring on wide characters (ensure that unicode code points are properly counted)" - params: { - TestCaseId: "3" - Input: "﷽" - } - expect: { - error: "No tests matched" - } - } - ] -) -service FizzBuzz { -} diff --git a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/bdd-tests/url-encode.smithy b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/bdd-tests/url-encode.smithy deleted file mode 100644 index b6fa8f975c9..00000000000 --- a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/bdd-tests/url-encode.smithy +++ /dev/null @@ -1,147 +0,0 @@ -$version: "2.0" - -namespace smithy.tests.endpointrules.urlencode - -use smithy.rules#clientContextParams -use smithy.rules#endpointBdd -use smithy.rules#endpointTests - -@suppress([ - "UnstableTrait" -]) -@clientContextParams( - TestCaseId: { - type: "string" - documentation: "Test case id used to select the test case to use" - } - Input: { - type: "string" - documentation: "The input used to test uriEncoder" - } -) -@endpointBdd( - version: "1.1" - parameters: { - TestCaseId: { - required: true - documentation: "Test case id used to select the test case to use" - type: "string" - } - Input: { - required: true - documentation: "The input used to test uriEncode" - type: "string" - } - } - conditions: [ - { - fn: "stringEquals" - argv: [ - { - ref: "TestCaseId" - } - "1" - ] - } - { - fn: "uriEncode" - argv: [ - "{Input}" - ] - assign: "output" - } - ] - results: [ - { - conditions: [] - error: "The value is: `{output}`" - type: "error" - } - { - documentation: "fallback when no tests match" - conditions: [] - error: "No tests matched" - type: "error" - } - ] - root: 2 - nodeCount: 3 - nodes: "/////wAAAAH/////AAAAAAAAAAMF9eECAAAAAQX14QEF9eEC" -) -@endpointTests( - version: "1.0" - testCases: [ - { - documentation: "uriEncode when the string has nothing to encode returns the input" - params: { - TestCaseId: "1" - Input: "abcdefg" - } - expect: { - error: "The value is: `abcdefg`" - } - } - { - documentation: "uriEncode with single character to encode encodes only that character" - params: { - TestCaseId: "1" - Input: "abc:defg" - } - expect: { - error: "The value is: `abc%3Adefg`" - } - } - { - documentation: "uriEncode with all ASCII characters to encode encodes all characters" - params: { - TestCaseId: "1" - Input: "/:,?#[]{}|@! $&'()*+;=%<>\"^`\\" - } - expect: { - error: "The value is: `%2F%3A%2C%3F%23%5B%5D%7B%7D%7C%40%21%20%24%26%27%28%29%2A%2B%3B%3D%25%3C%3E%22%5E%60%5C`" - } - } - { - documentation: "uriEncode with ASCII characters that should not be encoded returns the input" - params: { - TestCaseId: "1" - Input: "0123456789.underscore_dash-Tilda~" - } - expect: { - error: "The value is: `0123456789.underscore_dash-Tilda~`" - } - } - { - documentation: "uriEncode encodes unicode characters" - params: { - TestCaseId: "1" - Input: "😹" - } - expect: { - error: "The value is: `%F0%9F%98%B9`" - } - } - { - documentation: "uriEncode on all printable ASCII characters" - params: { - TestCaseId: "1" - Input: " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~" - } - expect: { - error: "The value is: `%20%21%22%23%24%25%26%27%28%29%2A%2B%2C-.%2F0123456789%3A%3B%3C%3D%3E%3F%40ABCDEFGHIJKLMNOPQRSTUVWXYZ%5B%5C%5D%5E_%60abcdefghijklmnopqrstuvwxyz%7B%7C%7D~`" - } - } - { - documentation: "uriEncode on an empty string" - params: { - TestCaseId: "1" - Input: "" - } - expect: { - error: "The value is: ``" - } - } - ] -) -service FizzBuzz { -} diff --git a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/bdd-tests/valid-hostlabel.smithy b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/bdd-tests/valid-hostlabel.smithy deleted file mode 100644 index 3231761e116..00000000000 --- a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/bdd-tests/valid-hostlabel.smithy +++ /dev/null @@ -1,161 +0,0 @@ -$version: "2.0" - -namespace smithy.tests.endpointrules.validhostlabel - -use smithy.rules#clientContextParams -use smithy.rules#endpointBdd -use smithy.rules#endpointTests - -@suppress([ - "UnstableTrait" -]) -@clientContextParams( - Region: { - type: "string" - documentation: "docs" - } -) -@endpointBdd( - version: "1.1" - parameters: { - Region: { - required: true - documentation: "The region to dispatch this request, eg. `us-east-1`." - type: "string" - } - } - conditions: [ - { - fn: "isValidHostLabel" - argv: [ - { - ref: "Region" - } - false - ] - } - { - fn: "isValidHostLabel" - argv: [ - { - ref: "Region" - } - true - ] - } - ] - results: [ - { - conditions: [] - endpoint: { - url: "https://{Region}.amazonaws.com" - properties: {} - headers: {} - } - type: "endpoint" - } - { - conditions: [] - endpoint: { - url: "https://{Region}-subdomains.amazonaws.com" - properties: {} - headers: {} - } - type: "endpoint" - } - { - documentation: "Region was not a valid host label" - conditions: [] - error: "Invalid hostlabel" - type: "error" - } - ] - root: 2 - nodeCount: 3 - nodes: "/////wAAAAH/////AAAAAAX14QEAAAADAAAAAQX14QIF9eED" -) -@endpointTests( - version: "1.0" - testCases: [ - { - documentation: "standard region is a valid hostlabel" - params: { - Region: "us-east-1" - } - expect: { - endpoint: { - url: "https://us-east-1.amazonaws.com" - } - } - } - { - documentation: "starting with a number is a valid hostlabel" - params: { - Region: "3aws4" - } - expect: { - endpoint: { - url: "https://3aws4.amazonaws.com" - } - } - } - { - documentation: "when there are dots, only match if subdomains are allowed" - params: { - Region: "part1.part2" - } - expect: { - endpoint: { - url: "https://part1.part2-subdomains.amazonaws.com" - } - } - } - { - documentation: "a space is never a valid hostlabel" - params: { - Region: "part1 part2" - } - expect: { - error: "Invalid hostlabel" - } - } - { - documentation: "an empty string is not a valid hostlabel" - params: { - Region: "" - } - expect: { - error: "Invalid hostlabel" - } - } - { - documentation: "ending with a dot is not a valid hostlabel" - params: { - Region: "part1." - } - expect: { - error: "Invalid hostlabel" - } - } - { - documentation: "multiple consecutive dots are not allowed" - params: { - Region: "part1..part2" - } - expect: { - error: "Invalid hostlabel" - } - } - { - documentation: "labels cannot start with a dash" - params: { - Region: "part1.-part2" - } - expect: { - error: "Invalid hostlabel" - } - } - ] -) -service FizzBuzz { -} diff --git a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/tree-tests/coalesce.smithy b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/coalesce.smithy similarity index 64% rename from smithy-rules-engine-tests/src/main/resources/META-INF/smithy/tree-tests/coalesce.smithy rename to smithy-rules-engine-tests/src/main/resources/META-INF/smithy/coalesce.smithy index fa744ca7205..f25c8224949 100644 --- a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/tree-tests/coalesce.smithy +++ b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/coalesce.smithy @@ -1,8 +1,9 @@ $version: "2.0" -namespace smithy.tests.endpointrules.coalesce +namespace smithy.rules.tests use smithy.rules#clientContextParams +use smithy.rules#endpointBdd use smithy.rules#endpointRuleSet use smithy.rules#endpointTests @@ -158,6 +159,155 @@ use smithy.rules#endpointTests } ] }) +@endpointBdd( + version: "1.1" + parameters: { + TestCaseId: { + required: true + documentation: "Test case id used to select the test case to use" + type: "string" + } + req1: { + required: true + default: "req1Value" + documentation: "req1" + type: "string" + } + req2: { + required: true + default: "req2Value" + documentation: "req2" + type: "string" + } + opt1: { + required: false + documentation: "opt1" + type: "string" + } + opt2: { + required: false + documentation: "opt2" + type: "string" + } + } + conditions: [ + { + fn: "stringEquals" + argv: [ + { + ref: "TestCaseId" + } + "0" + ] + } + { + fn: "coalesce" + argv: [ + { + ref: "req1" + } + { + ref: "req2" + } + ] + assign: "req1req2" + } + { + fn: "stringEquals" + argv: [ + { + ref: "TestCaseId" + } + "1" + ] + } + { + fn: "coalesce" + argv: [ + { + ref: "opt1" + } + { + ref: "opt2" + } + ] + assign: "opt1opt2" + } + { + fn: "stringEquals" + argv: [ + { + ref: "TestCaseId" + } + "2" + ] + } + { + fn: "coalesce" + argv: [ + { + ref: "req1" + } + { + ref: "opt1" + } + ] + assign: "req1opt1" + } + { + fn: "stringEquals" + argv: [ + { + ref: "TestCaseId" + } + "3" + ] + } + { + fn: "coalesce" + argv: [ + { + ref: "opt1" + } + { + ref: "req1" + } + ] + assign: "opt1req1" + } + ] + results: [ + { + conditions: [] + error: "The value is: {req1req2}" + type: "error" + } + { + conditions: [] + error: "The value is: {opt1opt2}" + type: "error" + } + { + conditions: [] + error: "The value is: {req1opt1}" + type: "error" + } + { + conditions: [] + error: "The value is: {opt1req1}" + type: "error" + } + { + documentation: "error fallthrough" + conditions: [] + error: "endpoint error" + type: "error" + } + ] + root: 2 + nodeCount: 9 + nodes: "/////wAAAAH/////AAAAAAAAAAMAAAAEAAAAAQX14QEAAAAEAAAAAgAAAAUAAAAGAAAAAwX14QIAAAAGAAAABAAAAAcAAAAIAAAABQX14QMAAAAIAAAABgAAAAkF9eEFAAAABwX14QQF9eEF" +) @endpointTests({ "version": "1.0", "testCases": [ @@ -231,4 +381,4 @@ use smithy.rules#endpointTests }, ] }) -service FizzBuzz {} +service CoalesceTest {} diff --git a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/tree-tests/default-values.smithy b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/default-values.smithy similarity index 74% rename from smithy-rules-engine-tests/src/main/resources/META-INF/smithy/tree-tests/default-values.smithy rename to smithy-rules-engine-tests/src/main/resources/META-INF/smithy/default-values.smithy index 86235f15937..9534604065e 100644 --- a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/tree-tests/default-values.smithy +++ b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/default-values.smithy @@ -3,6 +3,7 @@ $version: "2.0" namespace smithy.rules.tests use smithy.rules#clientContextParams +use smithy.rules#endpointBdd use smithy.rules#endpointRuleSet use smithy.rules#endpointTests @@ -50,6 +51,52 @@ use smithy.rules#endpointTests } ] }) +@endpointBdd( + version: "1.1" + parameters: { + bar: { + required: false + documentation: "docs" + type: "string" + } + baz: { + required: true + default: "baz" + documentation: "docs" + type: "string" + } + } + conditions: [ + { + fn: "isSet" + argv: [ + { + ref: "bar" + } + ] + } + ] + results: [ + { + conditions: [] + endpoint: { + url: "https://example.com/{baz}" + properties: {} + headers: {} + } + type: "endpoint" + } + { + documentation: "error fallthrough" + conditions: [] + error: "endpoint error" + type: "error" + } + ] + root: 2 + nodeCount: 2 + nodes: "/////wAAAAH/////AAAAAAX14QEF9eEC" +) @endpointTests({ "version": "1.0", "testCases": [ diff --git a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/tree-tests/endpoint-bindings.smithy b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/endpoint-bindings.smithy similarity index 80% rename from smithy-rules-engine-tests/src/main/resources/META-INF/smithy/tree-tests/endpoint-bindings.smithy rename to smithy-rules-engine-tests/src/main/resources/META-INF/smithy/endpoint-bindings.smithy index 47d7d99c770..fb777c2016b 100644 --- a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/tree-tests/endpoint-bindings.smithy +++ b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/endpoint-bindings.smithy @@ -2,6 +2,7 @@ $version: "2.0" namespace smithy.rules.tests +use smithy.rules#endpointBdd use smithy.rules#endpointRuleSet use smithy.rules#endpointTests use smithy.rules#staticContextParams @@ -153,6 +154,113 @@ use smithy.rules#operationContextParams } ] }) +@endpointBdd( + version: "1.1" + parameters: { + bar: { + required: false + documentation: "String parameter with no default value and client binding" + type: "string" + } + baz: { + required: true + default: "baz" + documentation: "String parameter with default value and client binding" + type: "string" + } + booleanParam: { + required: true + default: true + documentation: "Boolean parameter with default value and client binding" + type: "boolean" + } + Endpoint: { + builtIn: "SDK::Endpoint" + required: false + documentation: "Override the endpoint used to send this request" + type: "string" + } + } + conditions: [ + { + fn: "isSet" + argv: [ + { + ref: "Endpoint" + } + ] + } + { + fn: "booleanEquals" + argv: [ + { + ref: "booleanParam" + } + true + ] + } + { + fn: "isSet" + argv: [ + { + ref: "bar" + } + ] + } + ] + results: [ + { + conditions: [] + endpoint: { + url: { + ref: "Endpoint" + } + properties: {} + headers: {} + } + type: "endpoint" + } + { + conditions: [] + endpoint: { + url: "https://{bar}.{baz}/set" + properties: {} + headers: {} + } + type: "endpoint" + } + { + conditions: [] + endpoint: { + url: "https://{baz}/set" + properties: {} + headers: {} + } + type: "endpoint" + } + { + conditions: [] + endpoint: { + url: "https://{bar}.{baz}/unset" + properties: {} + headers: {} + } + type: "endpoint" + } + { + conditions: [] + endpoint: { + url: "https://{baz}/unset" + properties: {} + headers: {} + } + type: "endpoint" + } + ] + root: 2 + nodeCount: 5 + nodes: "/////wAAAAH/////AAAAAAX14QEAAAADAAAAAQAAAAUAAAAEAAAAAgX14QQF9eEFAAAAAgX14QIF9eED" +) @endpointTests({ "version": "1.0", "testCases": [ diff --git a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/tree-tests/endpoints-string-array.smithy b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/endpoints-string-array.smithy similarity index 84% rename from smithy-rules-engine-tests/src/main/resources/META-INF/smithy/tree-tests/endpoints-string-array.smithy rename to smithy-rules-engine-tests/src/main/resources/META-INF/smithy/endpoints-string-array.smithy index 22e8b3da95f..ddfb05863c2 100644 --- a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/tree-tests/endpoints-string-array.smithy +++ b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/endpoints-string-array.smithy @@ -2,6 +2,7 @@ $version: "2.0" namespace smithy.rules.tests +use smithy.rules#endpointBdd use smithy.rules#endpointRuleSet use smithy.rules#endpointTests use smithy.rules#staticContextParams @@ -46,6 +47,52 @@ use smithy.rules#operationContextParams } ] }) +@endpointBdd( + version: "1.1" + parameters: { + stringArrayParam: { + required: true + default: [ + "defaultValue1" + "defaultValue2" + ] + documentation: "docs" + type: "stringArray" + } + } + conditions: [ + { + fn: "getAttr" + argv: [ + { + ref: "stringArrayParam" + } + "[0]" + ] + assign: "arrayValue" + } + ] + results: [ + { + conditions: [] + endpoint: { + url: "https://example.com/{arrayValue}" + properties: {} + headers: {} + } + type: "endpoint" + } + { + documentation: "error fallthrough" + conditions: [] + error: "no array values set" + type: "error" + } + ] + root: 2 + nodeCount: 2 + nodes: "/////wAAAAH/////AAAAAAX14QEF9eEC" +) @endpointTests({ "version": "1.0", "testCases": [ diff --git a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/tree-tests/get-attr.smithy b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/get-attr.smithy similarity index 59% rename from smithy-rules-engine-tests/src/main/resources/META-INF/smithy/tree-tests/get-attr.smithy rename to smithy-rules-engine-tests/src/main/resources/META-INF/smithy/get-attr.smithy index e0d29517e4d..f0d094beaa6 100644 --- a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/tree-tests/get-attr.smithy +++ b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/get-attr.smithy @@ -3,6 +3,7 @@ $version: "2.0" namespace smithy.rules.tests use smithy.rules#clientContextParams +use smithy.rules#endpointBdd use smithy.rules#endpointRuleSet use smithy.rules#endpointTests @@ -52,7 +53,63 @@ use smithy.rules#endpointTests } ] }) - +@endpointBdd( + version: "1.1" + parameters: { + Bucket: { + required: false + documentation: "docs" + type: "string" + } + } + conditions: [ + { + fn: "isSet" + argv: [ + { + ref: "Bucket" + } + ] + } + { + fn: "parseURL" + argv: [ + "{Bucket}" + ] + assign: "bucketUrl" + } + { + fn: "getAttr" + argv: [ + { + ref: "bucketUrl" + } + "path" + ] + assign: "path" + } + ] + results: [ + { + conditions: [] + endpoint: { + url: "https://{bucketUrl#authority}{path}" + properties: {} + headers: {} + } + type: "endpoint" + } + { + documentation: "fallback when no tests match" + conditions: [] + error: "No tests matched" + type: "error" + } + ] + root: 2 + nodeCount: 4 + nodes: "/////wAAAAH/////AAAAAAAAAAMF9eECAAAAAQAAAAQF9eECAAAAAgX14QEF9eEC" +) @endpointTests({ "version": "1.0", "testCases": [ diff --git a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/tree-tests/headers.smithy b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/headers.smithy similarity index 64% rename from smithy-rules-engine-tests/src/main/resources/META-INF/smithy/tree-tests/headers.smithy rename to smithy-rules-engine-tests/src/main/resources/META-INF/smithy/headers.smithy index d26842c785a..eff7492f651 100644 --- a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/tree-tests/headers.smithy +++ b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/headers.smithy @@ -3,6 +3,7 @@ $version: "2.0" namespace smithy.rules.tests use smithy.rules#clientContextParams +use smithy.rules#endpointBdd use smithy.rules#endpointRuleSet use smithy.rules#endpointTests @@ -50,6 +51,54 @@ use smithy.rules#endpointTests } ] }) +@endpointBdd( + version: "1.1" + parameters: { + Region: { + required: false + documentation: "The region to dispatch this request, eg. `us-east-1`." + type: "string" + } + } + conditions: [ + { + fn: "isSet" + argv: [ + { + ref: "Region" + } + ] + } + ] + results: [ + { + conditions: [] + endpoint: { + url: "https://{Region}.amazonaws.com" + properties: {} + headers: { + "x-amz-region": [ + "{Region}" + ] + "x-amz-multi": [ + "*" + "{Region}" + ] + } + } + type: "endpoint" + } + { + documentation: "fallback when region is unset" + conditions: [] + error: "Region must be set to resolve a valid endpoint" + type: "error" + } + ] + root: 2 + nodeCount: 2 + nodes: "/////wAAAAH/////AAAAAAX14QEF9eEC" +) @endpointTests( "version": "1.0", "testCases": [ diff --git a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/tree-tests/ite.smithy b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/ite.smithy similarity index 68% rename from smithy-rules-engine-tests/src/main/resources/META-INF/smithy/tree-tests/ite.smithy rename to smithy-rules-engine-tests/src/main/resources/META-INF/smithy/ite.smithy index 75a4d4d050c..95ca6bab64a 100644 --- a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/tree-tests/ite.smithy +++ b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/ite.smithy @@ -1,8 +1,9 @@ $version: "2.0" -namespace example +namespace smithy.rules.tests use smithy.rules#clientContextParams +use smithy.rules#endpointBdd use smithy.rules#endpointRuleSet use smithy.rules#endpointTests @@ -36,6 +37,44 @@ use smithy.rules#endpointTests } ] }) +@endpointBdd( + version: "1.1" + parameters: { + useFips: { + required: true + default: false + documentation: "Use FIPS endpoints" + type: "boolean" + } + } + conditions: [ + { + fn: "ite" + argv: [ + { + ref: "useFips" + } + "-fips" + "" + ] + assign: "suffix" + } + ] + results: [ + { + conditions: [] + endpoint: { + url: "https://example{suffix}.com" + properties: {} + headers: {} + } + type: "endpoint" + } + ] + root: 2 + nodeCount: 2 + nodes: "/////wAAAAH/////AAAAAAX14QEF9eEA" +) @endpointTests({ "version": "1.0", "testCases": [ @@ -70,7 +109,7 @@ use smithy.rules#endpointTests ] }) @suppress(["UnstableTrait.smithy"]) -service FizzBuzz { +service IteTest { version: "2022-01-01", operations: [GetThing] } diff --git a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/tree-tests/manifest b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/manifest similarity index 82% rename from smithy-rules-engine-tests/src/main/resources/META-INF/smithy/tree-tests/manifest rename to smithy-rules-engine-tests/src/main/resources/META-INF/smithy/manifest index 11d3889e933..ac85466d3b6 100644 --- a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/tree-tests/manifest +++ b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/manifest @@ -1,10 +1,13 @@ +coalesce.smithy default-values.smithy endpoint-bindings.smithy endpoints-string-array.smithy get-attr.smithy headers.smithy +ite.smithy manifest parse-url.smithy +split.smithy substring.smithy url-encode.smithy valid-hostlabel.smithy diff --git a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/tree-tests/parse-url.smithy b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/parse-url.smithy similarity index 73% rename from smithy-rules-engine-tests/src/main/resources/META-INF/smithy/tree-tests/parse-url.smithy rename to smithy-rules-engine-tests/src/main/resources/META-INF/smithy/parse-url.smithy index db15667c232..e68164c7e2a 100644 --- a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/tree-tests/parse-url.smithy +++ b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/parse-url.smithy @@ -3,6 +3,7 @@ $version: "2.0" namespace smithy.rules.tests use smithy.rules#clientContextParams +use smithy.rules#endpointBdd use smithy.rules#endpointRuleSet use smithy.rules#endpointTests @@ -106,6 +107,124 @@ use smithy.rules#endpointTests } ] }) +@endpointBdd( + version: "1.1" + parameters: { + Endpoint: { + required: false + documentation: "docs" + type: "string" + } + } + conditions: [ + { + fn: "isSet" + argv: [ + { + ref: "Endpoint" + } + ] + } + { + fn: "parseURL" + argv: [ + "{Endpoint}" + ] + assign: "url" + } + { + fn: "booleanEquals" + argv: [ + true + { + fn: "getAttr" + argv: [ + { + ref: "url" + } + "isIp" + ] + } + ] + } + { + fn: "stringEquals" + argv: [ + "/port" + { + fn: "getAttr" + argv: [ + { + ref: "url" + } + "path" + ] + } + ] + } + { + fn: "stringEquals" + argv: [ + "/" + { + fn: "getAttr" + argv: [ + { + ref: "url" + } + "normalizedPath" + ] + } + ] + } + ] + results: [ + { + conditions: [] + endpoint: { + url: "{url#scheme}://{url#authority}{url#normalizedPath}is-ip-addr" + properties: {} + headers: {} + } + type: "endpoint" + } + { + conditions: [] + endpoint: { + url: "{url#scheme}://{url#authority}/uri-with-port" + properties: {} + headers: {} + } + type: "endpoint" + } + { + conditions: [] + endpoint: { + url: "https://{url#scheme}-{url#authority}-nopath.example.com" + properties: {} + headers: {} + } + type: "endpoint" + } + { + conditions: [] + endpoint: { + url: "https://{url#scheme}-{url#authority}.example.com/path-is{url#path}" + properties: {} + headers: {} + } + type: "endpoint" + } + { + conditions: [] + error: "endpoint was invalid" + type: "error" + } + ] + root: 2 + nodeCount: 6 + nodes: "/////wAAAAH/////AAAAAAAAAAMF9eEFAAAAAQAAAAQF9eEFAAAAAgX14QEAAAAFAAAAAwX14QIAAAAGAAAABAX14QMF9eEE" +) @endpointTests( version: "1.0", testCases: [ diff --git a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/tree-tests/split.smithy b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/split.smithy similarity index 67% rename from smithy-rules-engine-tests/src/main/resources/META-INF/smithy/tree-tests/split.smithy rename to smithy-rules-engine-tests/src/main/resources/META-INF/smithy/split.smithy index 8e0327335c9..3c467bde4d3 100644 --- a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/tree-tests/split.smithy +++ b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/split.smithy @@ -1,8 +1,9 @@ $version: "2.0" -namespace smithy.tests.endpointrules.split +namespace smithy.rules.tests use smithy.rules#clientContextParams +use smithy.rules#endpointBdd use smithy.rules#endpointRuleSet use smithy.rules#endpointTests @@ -414,6 +415,540 @@ use smithy.rules#endpointTests } ] }) +@endpointBdd( + version: "1.3" + parameters: { + Input: { + required: true + documentation: "The input string to split" + type: "string" + } + Delimiter: { + required: true + documentation: "The delimiter to split by" + type: "string" + } + Limit: { + required: true + documentation: "The split limit as a string" + type: "string" + } + } + conditions: [ + { + fn: "stringEquals" + argv: [ + { + ref: "Limit" + } + "0" + ] + } + { + fn: "split" + argv: [ + "{Input}" + "{Delimiter}" + 0 + ] + assign: "parts_ssa_1" + } + { + fn: "coalesce" + argv: [ + { + fn: "getAttr" + argv: [ + { + ref: "parts_ssa_1" + } + "[0]" + ] + } + "" + ] + assign: "part1" + } + { + fn: "coalesce" + argv: [ + { + fn: "getAttr" + argv: [ + { + ref: "parts_ssa_1" + } + "[1]" + ] + } + "" + ] + assign: "part2" + } + { + fn: "coalesce" + argv: [ + { + fn: "getAttr" + argv: [ + { + ref: "parts_ssa_1" + } + "[2]" + ] + } + "" + ] + assign: "part3" + } + { + fn: "coalesce" + argv: [ + { + fn: "getAttr" + argv: [ + { + ref: "parts_ssa_1" + } + "[3]" + ] + } + "" + ] + assign: "part4" + } + { + fn: "coalesce" + argv: [ + { + fn: "getAttr" + argv: [ + { + ref: "parts_ssa_1" + } + "[4]" + ] + } + "" + ] + assign: "part5" + } + { + fn: "stringEquals" + argv: [ + { + ref: "Limit" + } + "1" + ] + } + { + fn: "split" + argv: [ + "{Input}" + "{Delimiter}" + 1 + ] + assign: "parts_ssa_2" + } + { + fn: "coalesce" + argv: [ + { + fn: "getAttr" + argv: [ + { + ref: "parts_ssa_2" + } + "[0]" + ] + } + "" + ] + assign: "part1" + } + { + fn: "coalesce" + argv: [ + { + fn: "getAttr" + argv: [ + { + ref: "parts_ssa_2" + } + "[1]" + ] + } + "" + ] + assign: "part2" + } + { + fn: "coalesce" + argv: [ + { + fn: "getAttr" + argv: [ + { + ref: "parts_ssa_2" + } + "[2]" + ] + } + "" + ] + assign: "part3" + } + { + fn: "coalesce" + argv: [ + { + fn: "getAttr" + argv: [ + { + ref: "parts_ssa_2" + } + "[3]" + ] + } + "" + ] + assign: "part4" + } + { + fn: "coalesce" + argv: [ + { + fn: "getAttr" + argv: [ + { + ref: "parts_ssa_2" + } + "[4]" + ] + } + "" + ] + assign: "part5" + } + { + fn: "stringEquals" + argv: [ + { + ref: "Limit" + } + "2" + ] + } + { + fn: "split" + argv: [ + "{Input}" + "{Delimiter}" + 2 + ] + assign: "parts_ssa_3" + } + { + fn: "coalesce" + argv: [ + { + fn: "getAttr" + argv: [ + { + ref: "parts_ssa_3" + } + "[0]" + ] + } + "" + ] + assign: "part1" + } + { + fn: "coalesce" + argv: [ + { + fn: "getAttr" + argv: [ + { + ref: "parts_ssa_3" + } + "[1]" + ] + } + "" + ] + assign: "part2" + } + { + fn: "coalesce" + argv: [ + { + fn: "getAttr" + argv: [ + { + ref: "parts_ssa_3" + } + "[2]" + ] + } + "" + ] + assign: "part3" + } + { + fn: "coalesce" + argv: [ + { + fn: "getAttr" + argv: [ + { + ref: "parts_ssa_3" + } + "[3]" + ] + } + "" + ] + assign: "part4" + } + { + fn: "coalesce" + argv: [ + { + fn: "getAttr" + argv: [ + { + ref: "parts_ssa_3" + } + "[4]" + ] + } + "" + ] + assign: "part5" + } + { + fn: "stringEquals" + argv: [ + { + ref: "Limit" + } + "3" + ] + } + { + fn: "split" + argv: [ + "{Input}" + "{Delimiter}" + 3 + ] + assign: "parts_ssa_4" + } + { + fn: "coalesce" + argv: [ + { + fn: "getAttr" + argv: [ + { + ref: "parts_ssa_4" + } + "[0]" + ] + } + "" + ] + assign: "part1" + } + { + fn: "coalesce" + argv: [ + { + fn: "getAttr" + argv: [ + { + ref: "parts_ssa_4" + } + "[1]" + ] + } + "" + ] + assign: "part2" + } + { + fn: "coalesce" + argv: [ + { + fn: "getAttr" + argv: [ + { + ref: "parts_ssa_4" + } + "[2]" + ] + } + "" + ] + assign: "part3" + } + { + fn: "coalesce" + argv: [ + { + fn: "getAttr" + argv: [ + { + ref: "parts_ssa_4" + } + "[3]" + ] + } + "" + ] + assign: "part4" + } + { + fn: "coalesce" + argv: [ + { + fn: "getAttr" + argv: [ + { + ref: "parts_ssa_4" + } + "[4]" + ] + } + "" + ] + assign: "part5" + } + { + fn: "stringEquals" + argv: [ + { + ref: "Limit" + } + "4" + ] + } + { + fn: "split" + argv: [ + "{Input}" + "{Delimiter}" + 4 + ] + assign: "parts_ssa_5" + } + { + fn: "coalesce" + argv: [ + { + fn: "getAttr" + argv: [ + { + ref: "parts_ssa_5" + } + "[0]" + ] + } + "" + ] + assign: "part1" + } + { + fn: "coalesce" + argv: [ + { + fn: "getAttr" + argv: [ + { + ref: "parts_ssa_5" + } + "[1]" + ] + } + "" + ] + assign: "part2" + } + { + fn: "coalesce" + argv: [ + { + fn: "getAttr" + argv: [ + { + ref: "parts_ssa_5" + } + "[2]" + ] + } + "" + ] + assign: "part3" + } + { + fn: "coalesce" + argv: [ + { + fn: "getAttr" + argv: [ + { + ref: "parts_ssa_5" + } + "[3]" + ] + } + "" + ] + assign: "part4" + } + { + fn: "coalesce" + argv: [ + { + fn: "getAttr" + argv: [ + { + ref: "parts_ssa_5" + } + "[4]" + ] + } + "" + ] + assign: "part5" + } + ] + results: [ + { + conditions: [] + endpoint: { + url: "https://example.com" + properties: { + splitResult: "p1={part1}; p2={part2}; p3={part3}; p4={part4}; p5={part5}" + } + headers: {} + } + type: "endpoint" + } + { + documentation: "error fallthrough" + conditions: [] + error: "endpoint error" + type: "error" + } + ] + root: 2 + nodeCount: 36 + nodes: "/////wAAAAH/////AAAAAAAAAAMAAAAJAAAAAQAAAAQAAAAJAAAAAgAAAAUAAAAJAAAAAwAAAAYAAAAJAAAABAAAAAcAAAAJAAAABQAAAAgAAAAJAAAABgX14QEAAAAJAAAABwAAAAoAAAAQAAAACAAAAAsAAAAQAAAACQAAAAwAAAAQAAAACgAAAA0AAAAQAAAACwAAAA4AAAAQAAAADAAAAA8AAAAQAAAADQX14QEAAAAQAAAADgAAABEAAAAXAAAADwAAABIAAAAXAAAAEAAAABMAAAAXAAAAEQAAABQAAAAXAAAAEgAAABUAAAAXAAAAEwAAABYAAAAXAAAAFAX14QEAAAAXAAAAFQAAABgAAAAeAAAAFgAAABkAAAAeAAAAFwAAABoAAAAeAAAAGAAAABsAAAAeAAAAGQAAABwAAAAeAAAAGgAAAB0AAAAeAAAAGwX14QEAAAAeAAAAHAAAAB8F9eECAAAAHQAAACAF9eECAAAAHgAAACEF9eECAAAAHwAAACIF9eECAAAAIAAAACMF9eECAAAAIQAAACQF9eECAAAAIgX14QEF9eEC" +) @endpointTests( version: "1.0", testCases: [ @@ -856,4 +1391,4 @@ use smithy.rules#endpointTests Limit: {type: "string", documentation: "Split limit"} ) @suppress(["UnstableTrait.smithy"]) -service FizzBuzz {} +service SplitTest {} diff --git a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/tree-tests/substring.smithy b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/substring.smithy similarity index 77% rename from smithy-rules-engine-tests/src/main/resources/META-INF/smithy/tree-tests/substring.smithy rename to smithy-rules-engine-tests/src/main/resources/META-INF/smithy/substring.smithy index ad79f4aaf7f..5e10ae87d60 100644 --- a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/tree-tests/substring.smithy +++ b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/substring.smithy @@ -3,6 +3,7 @@ $version: "2.0" namespace smithy.rules.tests use smithy.rules#clientContextParams +use smithy.rules#endpointBdd use smithy.rules#endpointRuleSet use smithy.rules#endpointTests @@ -102,6 +103,106 @@ use smithy.rules#endpointTests } ] }) +@endpointBdd( + version: "1.1" + parameters: { + TestCaseId: { + required: true + documentation: "Test case id used to select the test case to use" + type: "string" + } + Input: { + required: true + documentation: "the input used to test substring" + type: "string" + } + } + conditions: [ + { + fn: "stringEquals" + argv: [ + { + ref: "TestCaseId" + } + "1" + ] + } + { + fn: "substring" + argv: [ + "{Input}" + 0 + 4 + false + ] + assign: "output_ssa_1" + } + { + fn: "stringEquals" + argv: [ + { + ref: "TestCaseId" + } + "2" + ] + } + { + fn: "substring" + argv: [ + "{Input}" + 0 + 4 + true + ] + assign: "output_ssa_2" + } + { + fn: "stringEquals" + argv: [ + { + ref: "TestCaseId" + } + "3" + ] + } + { + fn: "substring" + argv: [ + "{Input}" + 1 + 3 + false + ] + assign: "output_ssa_3" + } + ] + results: [ + { + conditions: [] + error: "The value is: `{output_ssa_1}`" + type: "error" + } + { + conditions: [] + error: "The value is: `{output_ssa_2}`" + type: "error" + } + { + conditions: [] + error: "The value is: `{output_ssa_3}`" + type: "error" + } + { + documentation: "fallback when no tests match" + conditions: [] + error: "No tests matched" + type: "error" + } + ] + root: 2 + nodeCount: 7 + nodes: "/////wAAAAH/////AAAAAAAAAAMAAAAEAAAAAQX14QEAAAAEAAAAAgAAAAUAAAAGAAAAAwX14QIAAAAGAAAABAAAAAcF9eEEAAAABQX14QMF9eEE" +) @endpointTests( version: "1.0", testCases: [ diff --git a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/tree-tests/url-encode.smithy b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/url-encode.smithy similarity index 78% rename from smithy-rules-engine-tests/src/main/resources/META-INF/smithy/tree-tests/url-encode.smithy rename to smithy-rules-engine-tests/src/main/resources/META-INF/smithy/url-encode.smithy index 149bd1a2bc6..f99037306a0 100644 --- a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/tree-tests/url-encode.smithy +++ b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/url-encode.smithy @@ -3,6 +3,7 @@ $version: "2.0" namespace smithy.rules.tests use smithy.rules#clientContextParams +use smithy.rules#endpointBdd use smithy.rules#endpointRuleSet use smithy.rules#endpointTests @@ -51,6 +52,55 @@ use smithy.rules#endpointTests } ] }) +@endpointBdd( + version: "1.1" + parameters: { + TestCaseId: { + required: true + documentation: "Test case id used to select the test case to use" + type: "string" + } + Input: { + required: true + documentation: "The input used to test uriEncode" + type: "string" + } + } + conditions: [ + { + fn: "stringEquals" + argv: [ + { + ref: "TestCaseId" + } + "1" + ] + } + { + fn: "uriEncode" + argv: [ + "{Input}" + ] + assign: "output" + } + ] + results: [ + { + conditions: [] + error: "The value is: `{output}`" + type: "error" + } + { + documentation: "fallback when no tests match" + conditions: [] + error: "No tests matched" + type: "error" + } + ] + root: 2 + nodeCount: 3 + nodes: "/////wAAAAH/////AAAAAAAAAAMF9eECAAAAAQX14QEF9eEC" +) @endpointTests( version: "1.0", testCases: [ diff --git a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/tree-tests/valid-hostlabel.smithy b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/valid-hostlabel.smithy similarity index 74% rename from smithy-rules-engine-tests/src/main/resources/META-INF/smithy/tree-tests/valid-hostlabel.smithy rename to smithy-rules-engine-tests/src/main/resources/META-INF/smithy/valid-hostlabel.smithy index c6e8a7fe152..56e41b17f20 100644 --- a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/tree-tests/valid-hostlabel.smithy +++ b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/valid-hostlabel.smithy @@ -3,6 +3,7 @@ $version: "2.0" namespace smithy.rules.tests use smithy.rules#clientContextParams +use smithy.rules#endpointBdd use smithy.rules#endpointRuleSet use smithy.rules#endpointTests @@ -61,6 +62,65 @@ use smithy.rules#endpointTests } ] }) +@endpointBdd( + version: "1.1" + parameters: { + Region: { + required: true + documentation: "The region to dispatch this request, eg. `us-east-1`." + type: "string" + } + } + conditions: [ + { + fn: "isValidHostLabel" + argv: [ + { + ref: "Region" + } + false + ] + } + { + fn: "isValidHostLabel" + argv: [ + { + ref: "Region" + } + true + ] + } + ] + results: [ + { + conditions: [] + endpoint: { + url: "https://{Region}.amazonaws.com" + properties: {} + headers: {} + } + type: "endpoint" + } + { + conditions: [] + endpoint: { + url: "https://{Region}-subdomains.amazonaws.com" + properties: {} + headers: {} + } + type: "endpoint" + } + { + documentation: "Region was not a valid host label" + conditions: [] + error: "Invalid hostlabel" + type: "error" + } + ] + root: 2 + nodeCount: 3 + nodes: "/////wAAAAH/////AAAAAAX14QEAAAADAAAAAQX14QIF9eED" +) @endpointTests( version: "1.0", testCases: [ From 62747e60bec79f52d5383716202d9efaf50559ef Mon Sep 17 00:00:00 2001 From: Landon James Date: Tue, 27 Jan 2026 13:15:10 -0800 Subject: [PATCH 5/8] Recompiled split test BDD with changes from #2946 --- .../resources/META-INF/smithy/split.smithy | 98 ++++++++++++++----- 1 file changed, 71 insertions(+), 27 deletions(-) diff --git a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/split.smithy b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/split.smithy index 3c467bde4d3..7c90a91142a 100644 --- a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/split.smithy +++ b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/split.smithy @@ -467,7 +467,7 @@ use smithy.rules#endpointTests } "" ] - assign: "part1" + assign: "part1_ssa_1" } { fn: "coalesce" @@ -483,7 +483,7 @@ use smithy.rules#endpointTests } "" ] - assign: "part2" + assign: "part2_ssa_1" } { fn: "coalesce" @@ -499,7 +499,7 @@ use smithy.rules#endpointTests } "" ] - assign: "part3" + assign: "part3_ssa_1" } { fn: "coalesce" @@ -515,7 +515,7 @@ use smithy.rules#endpointTests } "" ] - assign: "part4" + assign: "part4_ssa_1" } { fn: "coalesce" @@ -531,7 +531,7 @@ use smithy.rules#endpointTests } "" ] - assign: "part5" + assign: "part5_ssa_1" } { fn: "stringEquals" @@ -565,7 +565,7 @@ use smithy.rules#endpointTests } "" ] - assign: "part1" + assign: "part1_ssa_2" } { fn: "coalesce" @@ -581,7 +581,7 @@ use smithy.rules#endpointTests } "" ] - assign: "part2" + assign: "part2_ssa_2" } { fn: "coalesce" @@ -597,7 +597,7 @@ use smithy.rules#endpointTests } "" ] - assign: "part3" + assign: "part3_ssa_2" } { fn: "coalesce" @@ -613,7 +613,7 @@ use smithy.rules#endpointTests } "" ] - assign: "part4" + assign: "part4_ssa_2" } { fn: "coalesce" @@ -629,7 +629,7 @@ use smithy.rules#endpointTests } "" ] - assign: "part5" + assign: "part5_ssa_2" } { fn: "stringEquals" @@ -663,7 +663,7 @@ use smithy.rules#endpointTests } "" ] - assign: "part1" + assign: "part1_ssa_3" } { fn: "coalesce" @@ -679,7 +679,7 @@ use smithy.rules#endpointTests } "" ] - assign: "part2" + assign: "part2_ssa_3" } { fn: "coalesce" @@ -695,7 +695,7 @@ use smithy.rules#endpointTests } "" ] - assign: "part3" + assign: "part3_ssa_3" } { fn: "coalesce" @@ -711,7 +711,7 @@ use smithy.rules#endpointTests } "" ] - assign: "part4" + assign: "part4_ssa_3" } { fn: "coalesce" @@ -727,7 +727,7 @@ use smithy.rules#endpointTests } "" ] - assign: "part5" + assign: "part5_ssa_3" } { fn: "stringEquals" @@ -761,7 +761,7 @@ use smithy.rules#endpointTests } "" ] - assign: "part1" + assign: "part1_ssa_4" } { fn: "coalesce" @@ -777,7 +777,7 @@ use smithy.rules#endpointTests } "" ] - assign: "part2" + assign: "part2_ssa_4" } { fn: "coalesce" @@ -793,7 +793,7 @@ use smithy.rules#endpointTests } "" ] - assign: "part3" + assign: "part3_ssa_4" } { fn: "coalesce" @@ -809,7 +809,7 @@ use smithy.rules#endpointTests } "" ] - assign: "part4" + assign: "part4_ssa_4" } { fn: "coalesce" @@ -825,7 +825,7 @@ use smithy.rules#endpointTests } "" ] - assign: "part5" + assign: "part5_ssa_4" } { fn: "stringEquals" @@ -859,7 +859,7 @@ use smithy.rules#endpointTests } "" ] - assign: "part1" + assign: "part1_ssa_5" } { fn: "coalesce" @@ -875,7 +875,7 @@ use smithy.rules#endpointTests } "" ] - assign: "part2" + assign: "part2_ssa_5" } { fn: "coalesce" @@ -891,7 +891,7 @@ use smithy.rules#endpointTests } "" ] - assign: "part3" + assign: "part3_ssa_5" } { fn: "coalesce" @@ -907,7 +907,7 @@ use smithy.rules#endpointTests } "" ] - assign: "part4" + assign: "part4_ssa_5" } { fn: "coalesce" @@ -923,7 +923,7 @@ use smithy.rules#endpointTests } "" ] - assign: "part5" + assign: "part5_ssa_5" } ] results: [ @@ -932,7 +932,51 @@ use smithy.rules#endpointTests endpoint: { url: "https://example.com" properties: { - splitResult: "p1={part1}; p2={part2}; p3={part3}; p4={part4}; p5={part5}" + splitResult: "p1={part1_ssa_1}; p2={part2_ssa_1}; p3={part3_ssa_1}; p4={part4_ssa_1}; p5={part5_ssa_1}" + } + headers: {} + } + type: "endpoint" + } + { + conditions: [] + endpoint: { + url: "https://example.com" + properties: { + splitResult: "p1={part1_ssa_2}; p2={part2_ssa_2}; p3={part3_ssa_2}; p4={part4_ssa_2}; p5={part5_ssa_2}" + } + headers: {} + } + type: "endpoint" + } + { + conditions: [] + endpoint: { + url: "https://example.com" + properties: { + splitResult: "p1={part1_ssa_3}; p2={part2_ssa_3}; p3={part3_ssa_3}; p4={part4_ssa_3}; p5={part5_ssa_3}" + } + headers: {} + } + type: "endpoint" + } + { + conditions: [] + endpoint: { + url: "https://example.com" + properties: { + splitResult: "p1={part1_ssa_4}; p2={part2_ssa_4}; p3={part3_ssa_4}; p4={part4_ssa_4}; p5={part5_ssa_4}" + } + headers: {} + } + type: "endpoint" + } + { + conditions: [] + endpoint: { + url: "https://example.com" + properties: { + splitResult: "p1={part1_ssa_5}; p2={part2_ssa_5}; p3={part3_ssa_5}; p4={part4_ssa_5}; p5={part5_ssa_5}" } headers: {} } @@ -947,7 +991,7 @@ use smithy.rules#endpointTests ] root: 2 nodeCount: 36 - nodes: "/////wAAAAH/////AAAAAAAAAAMAAAAJAAAAAQAAAAQAAAAJAAAAAgAAAAUAAAAJAAAAAwAAAAYAAAAJAAAABAAAAAcAAAAJAAAABQAAAAgAAAAJAAAABgX14QEAAAAJAAAABwAAAAoAAAAQAAAACAAAAAsAAAAQAAAACQAAAAwAAAAQAAAACgAAAA0AAAAQAAAACwAAAA4AAAAQAAAADAAAAA8AAAAQAAAADQX14QEAAAAQAAAADgAAABEAAAAXAAAADwAAABIAAAAXAAAAEAAAABMAAAAXAAAAEQAAABQAAAAXAAAAEgAAABUAAAAXAAAAEwAAABYAAAAXAAAAFAX14QEAAAAXAAAAFQAAABgAAAAeAAAAFgAAABkAAAAeAAAAFwAAABoAAAAeAAAAGAAAABsAAAAeAAAAGQAAABwAAAAeAAAAGgAAAB0AAAAeAAAAGwX14QEAAAAeAAAAHAAAAB8F9eECAAAAHQAAACAF9eECAAAAHgAAACEF9eECAAAAHwAAACIF9eECAAAAIAAAACMF9eECAAAAIQAAACQF9eECAAAAIgX14QEF9eEC" + nodes: "/////wAAAAH/////AAAAAAAAAAMAAAAJAAAAAQAAAAQAAAAJAAAAAgAAAAUAAAAJAAAAAwAAAAYAAAAJAAAABAAAAAcAAAAJAAAABQAAAAgAAAAJAAAABgX14QEAAAAJAAAABwAAAAoAAAAQAAAACAAAAAsAAAAQAAAACQAAAAwAAAAQAAAACgAAAA0AAAAQAAAACwAAAA4AAAAQAAAADAAAAA8AAAAQAAAADQX14QIAAAAQAAAADgAAABEAAAAXAAAADwAAABIAAAAXAAAAEAAAABMAAAAXAAAAEQAAABQAAAAXAAAAEgAAABUAAAAXAAAAEwAAABYAAAAXAAAAFAX14QMAAAAXAAAAFQAAABgAAAAeAAAAFgAAABkAAAAeAAAAFwAAABoAAAAeAAAAGAAAABsAAAAeAAAAGQAAABwAAAAeAAAAGgAAAB0AAAAeAAAAGwX14QQAAAAeAAAAHAAAAB8F9eEGAAAAHQAAACAF9eEGAAAAHgAAACEF9eEGAAAAHwAAACIF9eEGAAAAIAAAACMF9eEGAAAAIQAAACQF9eEGAAAAIgX14QUF9eEG" ) @endpointTests( version: "1.0", From 0702402195f3328b1de957a84f229fc529626495 Mon Sep 17 00:00:00 2001 From: Landon James Date: Wed, 28 Jan 2026 11:20:05 -0800 Subject: [PATCH 6/8] Remove endpointBDD traits from smithy-rules-engine-tests Automating adding them back is tracked in https://github.com/smithy-lang/smithy/issues/2949 --- .../resources/META-INF/smithy/coalesce.smithy | 149 ----- .../META-INF/smithy/default-values.smithy | 46 -- .../META-INF/smithy/endpoint-bindings.smithy | 107 ---- .../smithy/endpoints-string-array.smithy | 46 -- .../resources/META-INF/smithy/get-attr.smithy | 57 -- .../resources/META-INF/smithy/headers.smithy | 48 -- .../main/resources/META-INF/smithy/ite.smithy | 38 -- .../META-INF/smithy/parse-url.smithy | 118 ---- .../resources/META-INF/smithy/split.smithy | 578 ------------------ .../META-INF/smithy/substring.smithy | 100 --- .../META-INF/smithy/url-encode.smithy | 49 -- .../META-INF/smithy/valid-hostlabel.smithy | 59 -- 12 files changed, 1395 deletions(-) diff --git a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/coalesce.smithy b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/coalesce.smithy index f25c8224949..8517c43b61b 100644 --- a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/coalesce.smithy +++ b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/coalesce.smithy @@ -159,155 +159,6 @@ use smithy.rules#endpointTests } ] }) -@endpointBdd( - version: "1.1" - parameters: { - TestCaseId: { - required: true - documentation: "Test case id used to select the test case to use" - type: "string" - } - req1: { - required: true - default: "req1Value" - documentation: "req1" - type: "string" - } - req2: { - required: true - default: "req2Value" - documentation: "req2" - type: "string" - } - opt1: { - required: false - documentation: "opt1" - type: "string" - } - opt2: { - required: false - documentation: "opt2" - type: "string" - } - } - conditions: [ - { - fn: "stringEquals" - argv: [ - { - ref: "TestCaseId" - } - "0" - ] - } - { - fn: "coalesce" - argv: [ - { - ref: "req1" - } - { - ref: "req2" - } - ] - assign: "req1req2" - } - { - fn: "stringEquals" - argv: [ - { - ref: "TestCaseId" - } - "1" - ] - } - { - fn: "coalesce" - argv: [ - { - ref: "opt1" - } - { - ref: "opt2" - } - ] - assign: "opt1opt2" - } - { - fn: "stringEquals" - argv: [ - { - ref: "TestCaseId" - } - "2" - ] - } - { - fn: "coalesce" - argv: [ - { - ref: "req1" - } - { - ref: "opt1" - } - ] - assign: "req1opt1" - } - { - fn: "stringEquals" - argv: [ - { - ref: "TestCaseId" - } - "3" - ] - } - { - fn: "coalesce" - argv: [ - { - ref: "opt1" - } - { - ref: "req1" - } - ] - assign: "opt1req1" - } - ] - results: [ - { - conditions: [] - error: "The value is: {req1req2}" - type: "error" - } - { - conditions: [] - error: "The value is: {opt1opt2}" - type: "error" - } - { - conditions: [] - error: "The value is: {req1opt1}" - type: "error" - } - { - conditions: [] - error: "The value is: {opt1req1}" - type: "error" - } - { - documentation: "error fallthrough" - conditions: [] - error: "endpoint error" - type: "error" - } - ] - root: 2 - nodeCount: 9 - nodes: "/////wAAAAH/////AAAAAAAAAAMAAAAEAAAAAQX14QEAAAAEAAAAAgAAAAUAAAAGAAAAAwX14QIAAAAGAAAABAAAAAcAAAAIAAAABQX14QMAAAAIAAAABgAAAAkF9eEFAAAABwX14QQF9eEF" -) @endpointTests({ "version": "1.0", "testCases": [ diff --git a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/default-values.smithy b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/default-values.smithy index 9534604065e..02f186fd584 100644 --- a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/default-values.smithy +++ b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/default-values.smithy @@ -51,52 +51,6 @@ use smithy.rules#endpointTests } ] }) -@endpointBdd( - version: "1.1" - parameters: { - bar: { - required: false - documentation: "docs" - type: "string" - } - baz: { - required: true - default: "baz" - documentation: "docs" - type: "string" - } - } - conditions: [ - { - fn: "isSet" - argv: [ - { - ref: "bar" - } - ] - } - ] - results: [ - { - conditions: [] - endpoint: { - url: "https://example.com/{baz}" - properties: {} - headers: {} - } - type: "endpoint" - } - { - documentation: "error fallthrough" - conditions: [] - error: "endpoint error" - type: "error" - } - ] - root: 2 - nodeCount: 2 - nodes: "/////wAAAAH/////AAAAAAX14QEF9eEC" -) @endpointTests({ "version": "1.0", "testCases": [ diff --git a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/endpoint-bindings.smithy b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/endpoint-bindings.smithy index fb777c2016b..60e63a30a3d 100644 --- a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/endpoint-bindings.smithy +++ b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/endpoint-bindings.smithy @@ -154,113 +154,6 @@ use smithy.rules#operationContextParams } ] }) -@endpointBdd( - version: "1.1" - parameters: { - bar: { - required: false - documentation: "String parameter with no default value and client binding" - type: "string" - } - baz: { - required: true - default: "baz" - documentation: "String parameter with default value and client binding" - type: "string" - } - booleanParam: { - required: true - default: true - documentation: "Boolean parameter with default value and client binding" - type: "boolean" - } - Endpoint: { - builtIn: "SDK::Endpoint" - required: false - documentation: "Override the endpoint used to send this request" - type: "string" - } - } - conditions: [ - { - fn: "isSet" - argv: [ - { - ref: "Endpoint" - } - ] - } - { - fn: "booleanEquals" - argv: [ - { - ref: "booleanParam" - } - true - ] - } - { - fn: "isSet" - argv: [ - { - ref: "bar" - } - ] - } - ] - results: [ - { - conditions: [] - endpoint: { - url: { - ref: "Endpoint" - } - properties: {} - headers: {} - } - type: "endpoint" - } - { - conditions: [] - endpoint: { - url: "https://{bar}.{baz}/set" - properties: {} - headers: {} - } - type: "endpoint" - } - { - conditions: [] - endpoint: { - url: "https://{baz}/set" - properties: {} - headers: {} - } - type: "endpoint" - } - { - conditions: [] - endpoint: { - url: "https://{bar}.{baz}/unset" - properties: {} - headers: {} - } - type: "endpoint" - } - { - conditions: [] - endpoint: { - url: "https://{baz}/unset" - properties: {} - headers: {} - } - type: "endpoint" - } - ] - root: 2 - nodeCount: 5 - nodes: "/////wAAAAH/////AAAAAAX14QEAAAADAAAAAQAAAAUAAAAEAAAAAgX14QQF9eEFAAAAAgX14QIF9eED" -) @endpointTests({ "version": "1.0", "testCases": [ diff --git a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/endpoints-string-array.smithy b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/endpoints-string-array.smithy index ddfb05863c2..0ace867ae0c 100644 --- a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/endpoints-string-array.smithy +++ b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/endpoints-string-array.smithy @@ -47,52 +47,6 @@ use smithy.rules#operationContextParams } ] }) -@endpointBdd( - version: "1.1" - parameters: { - stringArrayParam: { - required: true - default: [ - "defaultValue1" - "defaultValue2" - ] - documentation: "docs" - type: "stringArray" - } - } - conditions: [ - { - fn: "getAttr" - argv: [ - { - ref: "stringArrayParam" - } - "[0]" - ] - assign: "arrayValue" - } - ] - results: [ - { - conditions: [] - endpoint: { - url: "https://example.com/{arrayValue}" - properties: {} - headers: {} - } - type: "endpoint" - } - { - documentation: "error fallthrough" - conditions: [] - error: "no array values set" - type: "error" - } - ] - root: 2 - nodeCount: 2 - nodes: "/////wAAAAH/////AAAAAAX14QEF9eEC" -) @endpointTests({ "version": "1.0", "testCases": [ diff --git a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/get-attr.smithy b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/get-attr.smithy index f0d094beaa6..d4618b64763 100644 --- a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/get-attr.smithy +++ b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/get-attr.smithy @@ -53,63 +53,6 @@ use smithy.rules#endpointTests } ] }) -@endpointBdd( - version: "1.1" - parameters: { - Bucket: { - required: false - documentation: "docs" - type: "string" - } - } - conditions: [ - { - fn: "isSet" - argv: [ - { - ref: "Bucket" - } - ] - } - { - fn: "parseURL" - argv: [ - "{Bucket}" - ] - assign: "bucketUrl" - } - { - fn: "getAttr" - argv: [ - { - ref: "bucketUrl" - } - "path" - ] - assign: "path" - } - ] - results: [ - { - conditions: [] - endpoint: { - url: "https://{bucketUrl#authority}{path}" - properties: {} - headers: {} - } - type: "endpoint" - } - { - documentation: "fallback when no tests match" - conditions: [] - error: "No tests matched" - type: "error" - } - ] - root: 2 - nodeCount: 4 - nodes: "/////wAAAAH/////AAAAAAAAAAMF9eECAAAAAQAAAAQF9eECAAAAAgX14QEF9eEC" -) @endpointTests({ "version": "1.0", "testCases": [ diff --git a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/headers.smithy b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/headers.smithy index eff7492f651..9a2583a009c 100644 --- a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/headers.smithy +++ b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/headers.smithy @@ -51,54 +51,6 @@ use smithy.rules#endpointTests } ] }) -@endpointBdd( - version: "1.1" - parameters: { - Region: { - required: false - documentation: "The region to dispatch this request, eg. `us-east-1`." - type: "string" - } - } - conditions: [ - { - fn: "isSet" - argv: [ - { - ref: "Region" - } - ] - } - ] - results: [ - { - conditions: [] - endpoint: { - url: "https://{Region}.amazonaws.com" - properties: {} - headers: { - "x-amz-region": [ - "{Region}" - ] - "x-amz-multi": [ - "*" - "{Region}" - ] - } - } - type: "endpoint" - } - { - documentation: "fallback when region is unset" - conditions: [] - error: "Region must be set to resolve a valid endpoint" - type: "error" - } - ] - root: 2 - nodeCount: 2 - nodes: "/////wAAAAH/////AAAAAAX14QEF9eEC" -) @endpointTests( "version": "1.0", "testCases": [ diff --git a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/ite.smithy b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/ite.smithy index 95ca6bab64a..b4d31c37edd 100644 --- a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/ite.smithy +++ b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/ite.smithy @@ -37,44 +37,6 @@ use smithy.rules#endpointTests } ] }) -@endpointBdd( - version: "1.1" - parameters: { - useFips: { - required: true - default: false - documentation: "Use FIPS endpoints" - type: "boolean" - } - } - conditions: [ - { - fn: "ite" - argv: [ - { - ref: "useFips" - } - "-fips" - "" - ] - assign: "suffix" - } - ] - results: [ - { - conditions: [] - endpoint: { - url: "https://example{suffix}.com" - properties: {} - headers: {} - } - type: "endpoint" - } - ] - root: 2 - nodeCount: 2 - nodes: "/////wAAAAH/////AAAAAAX14QEF9eEA" -) @endpointTests({ "version": "1.0", "testCases": [ diff --git a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/parse-url.smithy b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/parse-url.smithy index e68164c7e2a..5b30586bc7c 100644 --- a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/parse-url.smithy +++ b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/parse-url.smithy @@ -107,124 +107,6 @@ use smithy.rules#endpointTests } ] }) -@endpointBdd( - version: "1.1" - parameters: { - Endpoint: { - required: false - documentation: "docs" - type: "string" - } - } - conditions: [ - { - fn: "isSet" - argv: [ - { - ref: "Endpoint" - } - ] - } - { - fn: "parseURL" - argv: [ - "{Endpoint}" - ] - assign: "url" - } - { - fn: "booleanEquals" - argv: [ - true - { - fn: "getAttr" - argv: [ - { - ref: "url" - } - "isIp" - ] - } - ] - } - { - fn: "stringEquals" - argv: [ - "/port" - { - fn: "getAttr" - argv: [ - { - ref: "url" - } - "path" - ] - } - ] - } - { - fn: "stringEquals" - argv: [ - "/" - { - fn: "getAttr" - argv: [ - { - ref: "url" - } - "normalizedPath" - ] - } - ] - } - ] - results: [ - { - conditions: [] - endpoint: { - url: "{url#scheme}://{url#authority}{url#normalizedPath}is-ip-addr" - properties: {} - headers: {} - } - type: "endpoint" - } - { - conditions: [] - endpoint: { - url: "{url#scheme}://{url#authority}/uri-with-port" - properties: {} - headers: {} - } - type: "endpoint" - } - { - conditions: [] - endpoint: { - url: "https://{url#scheme}-{url#authority}-nopath.example.com" - properties: {} - headers: {} - } - type: "endpoint" - } - { - conditions: [] - endpoint: { - url: "https://{url#scheme}-{url#authority}.example.com/path-is{url#path}" - properties: {} - headers: {} - } - type: "endpoint" - } - { - conditions: [] - error: "endpoint was invalid" - type: "error" - } - ] - root: 2 - nodeCount: 6 - nodes: "/////wAAAAH/////AAAAAAAAAAMF9eEFAAAAAQAAAAQF9eEFAAAAAgX14QEAAAAFAAAAAwX14QIAAAAGAAAABAX14QMF9eEE" -) @endpointTests( version: "1.0", testCases: [ diff --git a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/split.smithy b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/split.smithy index 7c90a91142a..032cd48eab4 100644 --- a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/split.smithy +++ b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/split.smithy @@ -415,584 +415,6 @@ use smithy.rules#endpointTests } ] }) -@endpointBdd( - version: "1.3" - parameters: { - Input: { - required: true - documentation: "The input string to split" - type: "string" - } - Delimiter: { - required: true - documentation: "The delimiter to split by" - type: "string" - } - Limit: { - required: true - documentation: "The split limit as a string" - type: "string" - } - } - conditions: [ - { - fn: "stringEquals" - argv: [ - { - ref: "Limit" - } - "0" - ] - } - { - fn: "split" - argv: [ - "{Input}" - "{Delimiter}" - 0 - ] - assign: "parts_ssa_1" - } - { - fn: "coalesce" - argv: [ - { - fn: "getAttr" - argv: [ - { - ref: "parts_ssa_1" - } - "[0]" - ] - } - "" - ] - assign: "part1_ssa_1" - } - { - fn: "coalesce" - argv: [ - { - fn: "getAttr" - argv: [ - { - ref: "parts_ssa_1" - } - "[1]" - ] - } - "" - ] - assign: "part2_ssa_1" - } - { - fn: "coalesce" - argv: [ - { - fn: "getAttr" - argv: [ - { - ref: "parts_ssa_1" - } - "[2]" - ] - } - "" - ] - assign: "part3_ssa_1" - } - { - fn: "coalesce" - argv: [ - { - fn: "getAttr" - argv: [ - { - ref: "parts_ssa_1" - } - "[3]" - ] - } - "" - ] - assign: "part4_ssa_1" - } - { - fn: "coalesce" - argv: [ - { - fn: "getAttr" - argv: [ - { - ref: "parts_ssa_1" - } - "[4]" - ] - } - "" - ] - assign: "part5_ssa_1" - } - { - fn: "stringEquals" - argv: [ - { - ref: "Limit" - } - "1" - ] - } - { - fn: "split" - argv: [ - "{Input}" - "{Delimiter}" - 1 - ] - assign: "parts_ssa_2" - } - { - fn: "coalesce" - argv: [ - { - fn: "getAttr" - argv: [ - { - ref: "parts_ssa_2" - } - "[0]" - ] - } - "" - ] - assign: "part1_ssa_2" - } - { - fn: "coalesce" - argv: [ - { - fn: "getAttr" - argv: [ - { - ref: "parts_ssa_2" - } - "[1]" - ] - } - "" - ] - assign: "part2_ssa_2" - } - { - fn: "coalesce" - argv: [ - { - fn: "getAttr" - argv: [ - { - ref: "parts_ssa_2" - } - "[2]" - ] - } - "" - ] - assign: "part3_ssa_2" - } - { - fn: "coalesce" - argv: [ - { - fn: "getAttr" - argv: [ - { - ref: "parts_ssa_2" - } - "[3]" - ] - } - "" - ] - assign: "part4_ssa_2" - } - { - fn: "coalesce" - argv: [ - { - fn: "getAttr" - argv: [ - { - ref: "parts_ssa_2" - } - "[4]" - ] - } - "" - ] - assign: "part5_ssa_2" - } - { - fn: "stringEquals" - argv: [ - { - ref: "Limit" - } - "2" - ] - } - { - fn: "split" - argv: [ - "{Input}" - "{Delimiter}" - 2 - ] - assign: "parts_ssa_3" - } - { - fn: "coalesce" - argv: [ - { - fn: "getAttr" - argv: [ - { - ref: "parts_ssa_3" - } - "[0]" - ] - } - "" - ] - assign: "part1_ssa_3" - } - { - fn: "coalesce" - argv: [ - { - fn: "getAttr" - argv: [ - { - ref: "parts_ssa_3" - } - "[1]" - ] - } - "" - ] - assign: "part2_ssa_3" - } - { - fn: "coalesce" - argv: [ - { - fn: "getAttr" - argv: [ - { - ref: "parts_ssa_3" - } - "[2]" - ] - } - "" - ] - assign: "part3_ssa_3" - } - { - fn: "coalesce" - argv: [ - { - fn: "getAttr" - argv: [ - { - ref: "parts_ssa_3" - } - "[3]" - ] - } - "" - ] - assign: "part4_ssa_3" - } - { - fn: "coalesce" - argv: [ - { - fn: "getAttr" - argv: [ - { - ref: "parts_ssa_3" - } - "[4]" - ] - } - "" - ] - assign: "part5_ssa_3" - } - { - fn: "stringEquals" - argv: [ - { - ref: "Limit" - } - "3" - ] - } - { - fn: "split" - argv: [ - "{Input}" - "{Delimiter}" - 3 - ] - assign: "parts_ssa_4" - } - { - fn: "coalesce" - argv: [ - { - fn: "getAttr" - argv: [ - { - ref: "parts_ssa_4" - } - "[0]" - ] - } - "" - ] - assign: "part1_ssa_4" - } - { - fn: "coalesce" - argv: [ - { - fn: "getAttr" - argv: [ - { - ref: "parts_ssa_4" - } - "[1]" - ] - } - "" - ] - assign: "part2_ssa_4" - } - { - fn: "coalesce" - argv: [ - { - fn: "getAttr" - argv: [ - { - ref: "parts_ssa_4" - } - "[2]" - ] - } - "" - ] - assign: "part3_ssa_4" - } - { - fn: "coalesce" - argv: [ - { - fn: "getAttr" - argv: [ - { - ref: "parts_ssa_4" - } - "[3]" - ] - } - "" - ] - assign: "part4_ssa_4" - } - { - fn: "coalesce" - argv: [ - { - fn: "getAttr" - argv: [ - { - ref: "parts_ssa_4" - } - "[4]" - ] - } - "" - ] - assign: "part5_ssa_4" - } - { - fn: "stringEquals" - argv: [ - { - ref: "Limit" - } - "4" - ] - } - { - fn: "split" - argv: [ - "{Input}" - "{Delimiter}" - 4 - ] - assign: "parts_ssa_5" - } - { - fn: "coalesce" - argv: [ - { - fn: "getAttr" - argv: [ - { - ref: "parts_ssa_5" - } - "[0]" - ] - } - "" - ] - assign: "part1_ssa_5" - } - { - fn: "coalesce" - argv: [ - { - fn: "getAttr" - argv: [ - { - ref: "parts_ssa_5" - } - "[1]" - ] - } - "" - ] - assign: "part2_ssa_5" - } - { - fn: "coalesce" - argv: [ - { - fn: "getAttr" - argv: [ - { - ref: "parts_ssa_5" - } - "[2]" - ] - } - "" - ] - assign: "part3_ssa_5" - } - { - fn: "coalesce" - argv: [ - { - fn: "getAttr" - argv: [ - { - ref: "parts_ssa_5" - } - "[3]" - ] - } - "" - ] - assign: "part4_ssa_5" - } - { - fn: "coalesce" - argv: [ - { - fn: "getAttr" - argv: [ - { - ref: "parts_ssa_5" - } - "[4]" - ] - } - "" - ] - assign: "part5_ssa_5" - } - ] - results: [ - { - conditions: [] - endpoint: { - url: "https://example.com" - properties: { - splitResult: "p1={part1_ssa_1}; p2={part2_ssa_1}; p3={part3_ssa_1}; p4={part4_ssa_1}; p5={part5_ssa_1}" - } - headers: {} - } - type: "endpoint" - } - { - conditions: [] - endpoint: { - url: "https://example.com" - properties: { - splitResult: "p1={part1_ssa_2}; p2={part2_ssa_2}; p3={part3_ssa_2}; p4={part4_ssa_2}; p5={part5_ssa_2}" - } - headers: {} - } - type: "endpoint" - } - { - conditions: [] - endpoint: { - url: "https://example.com" - properties: { - splitResult: "p1={part1_ssa_3}; p2={part2_ssa_3}; p3={part3_ssa_3}; p4={part4_ssa_3}; p5={part5_ssa_3}" - } - headers: {} - } - type: "endpoint" - } - { - conditions: [] - endpoint: { - url: "https://example.com" - properties: { - splitResult: "p1={part1_ssa_4}; p2={part2_ssa_4}; p3={part3_ssa_4}; p4={part4_ssa_4}; p5={part5_ssa_4}" - } - headers: {} - } - type: "endpoint" - } - { - conditions: [] - endpoint: { - url: "https://example.com" - properties: { - splitResult: "p1={part1_ssa_5}; p2={part2_ssa_5}; p3={part3_ssa_5}; p4={part4_ssa_5}; p5={part5_ssa_5}" - } - headers: {} - } - type: "endpoint" - } - { - documentation: "error fallthrough" - conditions: [] - error: "endpoint error" - type: "error" - } - ] - root: 2 - nodeCount: 36 - nodes: "/////wAAAAH/////AAAAAAAAAAMAAAAJAAAAAQAAAAQAAAAJAAAAAgAAAAUAAAAJAAAAAwAAAAYAAAAJAAAABAAAAAcAAAAJAAAABQAAAAgAAAAJAAAABgX14QEAAAAJAAAABwAAAAoAAAAQAAAACAAAAAsAAAAQAAAACQAAAAwAAAAQAAAACgAAAA0AAAAQAAAACwAAAA4AAAAQAAAADAAAAA8AAAAQAAAADQX14QIAAAAQAAAADgAAABEAAAAXAAAADwAAABIAAAAXAAAAEAAAABMAAAAXAAAAEQAAABQAAAAXAAAAEgAAABUAAAAXAAAAEwAAABYAAAAXAAAAFAX14QMAAAAXAAAAFQAAABgAAAAeAAAAFgAAABkAAAAeAAAAFwAAABoAAAAeAAAAGAAAABsAAAAeAAAAGQAAABwAAAAeAAAAGgAAAB0AAAAeAAAAGwX14QQAAAAeAAAAHAAAAB8F9eEGAAAAHQAAACAF9eEGAAAAHgAAACEF9eEGAAAAHwAAACIF9eEGAAAAIAAAACMF9eEGAAAAIQAAACQF9eEGAAAAIgX14QUF9eEG" -) @endpointTests( version: "1.0", testCases: [ diff --git a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/substring.smithy b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/substring.smithy index 5e10ae87d60..081d1103f54 100644 --- a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/substring.smithy +++ b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/substring.smithy @@ -103,106 +103,6 @@ use smithy.rules#endpointTests } ] }) -@endpointBdd( - version: "1.1" - parameters: { - TestCaseId: { - required: true - documentation: "Test case id used to select the test case to use" - type: "string" - } - Input: { - required: true - documentation: "the input used to test substring" - type: "string" - } - } - conditions: [ - { - fn: "stringEquals" - argv: [ - { - ref: "TestCaseId" - } - "1" - ] - } - { - fn: "substring" - argv: [ - "{Input}" - 0 - 4 - false - ] - assign: "output_ssa_1" - } - { - fn: "stringEquals" - argv: [ - { - ref: "TestCaseId" - } - "2" - ] - } - { - fn: "substring" - argv: [ - "{Input}" - 0 - 4 - true - ] - assign: "output_ssa_2" - } - { - fn: "stringEquals" - argv: [ - { - ref: "TestCaseId" - } - "3" - ] - } - { - fn: "substring" - argv: [ - "{Input}" - 1 - 3 - false - ] - assign: "output_ssa_3" - } - ] - results: [ - { - conditions: [] - error: "The value is: `{output_ssa_1}`" - type: "error" - } - { - conditions: [] - error: "The value is: `{output_ssa_2}`" - type: "error" - } - { - conditions: [] - error: "The value is: `{output_ssa_3}`" - type: "error" - } - { - documentation: "fallback when no tests match" - conditions: [] - error: "No tests matched" - type: "error" - } - ] - root: 2 - nodeCount: 7 - nodes: "/////wAAAAH/////AAAAAAAAAAMAAAAEAAAAAQX14QEAAAAEAAAAAgAAAAUAAAAGAAAAAwX14QIAAAAGAAAABAAAAAcF9eEEAAAABQX14QMF9eEE" -) @endpointTests( version: "1.0", testCases: [ diff --git a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/url-encode.smithy b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/url-encode.smithy index f99037306a0..06664378087 100644 --- a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/url-encode.smithy +++ b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/url-encode.smithy @@ -52,55 +52,6 @@ use smithy.rules#endpointTests } ] }) -@endpointBdd( - version: "1.1" - parameters: { - TestCaseId: { - required: true - documentation: "Test case id used to select the test case to use" - type: "string" - } - Input: { - required: true - documentation: "The input used to test uriEncode" - type: "string" - } - } - conditions: [ - { - fn: "stringEquals" - argv: [ - { - ref: "TestCaseId" - } - "1" - ] - } - { - fn: "uriEncode" - argv: [ - "{Input}" - ] - assign: "output" - } - ] - results: [ - { - conditions: [] - error: "The value is: `{output}`" - type: "error" - } - { - documentation: "fallback when no tests match" - conditions: [] - error: "No tests matched" - type: "error" - } - ] - root: 2 - nodeCount: 3 - nodes: "/////wAAAAH/////AAAAAAAAAAMF9eECAAAAAQX14QEF9eEC" -) @endpointTests( version: "1.0", testCases: [ diff --git a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/valid-hostlabel.smithy b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/valid-hostlabel.smithy index 56e41b17f20..8d90e2b265e 100644 --- a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/valid-hostlabel.smithy +++ b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/valid-hostlabel.smithy @@ -62,65 +62,6 @@ use smithy.rules#endpointTests } ] }) -@endpointBdd( - version: "1.1" - parameters: { - Region: { - required: true - documentation: "The region to dispatch this request, eg. `us-east-1`." - type: "string" - } - } - conditions: [ - { - fn: "isValidHostLabel" - argv: [ - { - ref: "Region" - } - false - ] - } - { - fn: "isValidHostLabel" - argv: [ - { - ref: "Region" - } - true - ] - } - ] - results: [ - { - conditions: [] - endpoint: { - url: "https://{Region}.amazonaws.com" - properties: {} - headers: {} - } - type: "endpoint" - } - { - conditions: [] - endpoint: { - url: "https://{Region}-subdomains.amazonaws.com" - properties: {} - headers: {} - } - type: "endpoint" - } - { - documentation: "Region was not a valid host label" - conditions: [] - error: "Invalid hostlabel" - type: "error" - } - ] - root: 2 - nodeCount: 3 - nodes: "/////wAAAAH/////AAAAAAX14QEAAAADAAAAAQX14QIF9eED" -) @endpointTests( version: "1.0", testCases: [ From 2ce17c4c6893a106d334737768c0d51dbffdbb5f Mon Sep 17 00:00:00 2001 From: Landon James Date: Wed, 28 Jan 2026 14:33:38 -0800 Subject: [PATCH 7/8] Remove use statements for endpointBdd trait --- .../src/main/resources/META-INF/smithy/coalesce.smithy | 1 - .../src/main/resources/META-INF/smithy/default-values.smithy | 1 - .../src/main/resources/META-INF/smithy/endpoint-bindings.smithy | 1 - .../main/resources/META-INF/smithy/endpoints-string-array.smithy | 1 - .../src/main/resources/META-INF/smithy/get-attr.smithy | 1 - .../src/main/resources/META-INF/smithy/headers.smithy | 1 - .../src/main/resources/META-INF/smithy/ite.smithy | 1 - .../src/main/resources/META-INF/smithy/parse-url.smithy | 1 - .../src/main/resources/META-INF/smithy/split.smithy | 1 - .../src/main/resources/META-INF/smithy/substring.smithy | 1 - .../src/main/resources/META-INF/smithy/url-encode.smithy | 1 - .../src/main/resources/META-INF/smithy/valid-hostlabel.smithy | 1 - 12 files changed, 12 deletions(-) diff --git a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/coalesce.smithy b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/coalesce.smithy index 8517c43b61b..1b4aad4fce9 100644 --- a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/coalesce.smithy +++ b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/coalesce.smithy @@ -3,7 +3,6 @@ $version: "2.0" namespace smithy.rules.tests use smithy.rules#clientContextParams -use smithy.rules#endpointBdd use smithy.rules#endpointRuleSet use smithy.rules#endpointTests diff --git a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/default-values.smithy b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/default-values.smithy index 02f186fd584..86235f15937 100644 --- a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/default-values.smithy +++ b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/default-values.smithy @@ -3,7 +3,6 @@ $version: "2.0" namespace smithy.rules.tests use smithy.rules#clientContextParams -use smithy.rules#endpointBdd use smithy.rules#endpointRuleSet use smithy.rules#endpointTests diff --git a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/endpoint-bindings.smithy b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/endpoint-bindings.smithy index 60e63a30a3d..47d7d99c770 100644 --- a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/endpoint-bindings.smithy +++ b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/endpoint-bindings.smithy @@ -2,7 +2,6 @@ $version: "2.0" namespace smithy.rules.tests -use smithy.rules#endpointBdd use smithy.rules#endpointRuleSet use smithy.rules#endpointTests use smithy.rules#staticContextParams diff --git a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/endpoints-string-array.smithy b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/endpoints-string-array.smithy index 0ace867ae0c..22e8b3da95f 100644 --- a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/endpoints-string-array.smithy +++ b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/endpoints-string-array.smithy @@ -2,7 +2,6 @@ $version: "2.0" namespace smithy.rules.tests -use smithy.rules#endpointBdd use smithy.rules#endpointRuleSet use smithy.rules#endpointTests use smithy.rules#staticContextParams diff --git a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/get-attr.smithy b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/get-attr.smithy index d4618b64763..6052fe9972e 100644 --- a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/get-attr.smithy +++ b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/get-attr.smithy @@ -3,7 +3,6 @@ $version: "2.0" namespace smithy.rules.tests use smithy.rules#clientContextParams -use smithy.rules#endpointBdd use smithy.rules#endpointRuleSet use smithy.rules#endpointTests diff --git a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/headers.smithy b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/headers.smithy index 9a2583a009c..d26842c785a 100644 --- a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/headers.smithy +++ b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/headers.smithy @@ -3,7 +3,6 @@ $version: "2.0" namespace smithy.rules.tests use smithy.rules#clientContextParams -use smithy.rules#endpointBdd use smithy.rules#endpointRuleSet use smithy.rules#endpointTests diff --git a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/ite.smithy b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/ite.smithy index b4d31c37edd..77aea7ffc24 100644 --- a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/ite.smithy +++ b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/ite.smithy @@ -3,7 +3,6 @@ $version: "2.0" namespace smithy.rules.tests use smithy.rules#clientContextParams -use smithy.rules#endpointBdd use smithy.rules#endpointRuleSet use smithy.rules#endpointTests diff --git a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/parse-url.smithy b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/parse-url.smithy index 5b30586bc7c..db15667c232 100644 --- a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/parse-url.smithy +++ b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/parse-url.smithy @@ -3,7 +3,6 @@ $version: "2.0" namespace smithy.rules.tests use smithy.rules#clientContextParams -use smithy.rules#endpointBdd use smithy.rules#endpointRuleSet use smithy.rules#endpointTests diff --git a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/split.smithy b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/split.smithy index 032cd48eab4..de6359e68b7 100644 --- a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/split.smithy +++ b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/split.smithy @@ -3,7 +3,6 @@ $version: "2.0" namespace smithy.rules.tests use smithy.rules#clientContextParams -use smithy.rules#endpointBdd use smithy.rules#endpointRuleSet use smithy.rules#endpointTests diff --git a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/substring.smithy b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/substring.smithy index 081d1103f54..ad79f4aaf7f 100644 --- a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/substring.smithy +++ b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/substring.smithy @@ -3,7 +3,6 @@ $version: "2.0" namespace smithy.rules.tests use smithy.rules#clientContextParams -use smithy.rules#endpointBdd use smithy.rules#endpointRuleSet use smithy.rules#endpointTests diff --git a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/url-encode.smithy b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/url-encode.smithy index 06664378087..149bd1a2bc6 100644 --- a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/url-encode.smithy +++ b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/url-encode.smithy @@ -3,7 +3,6 @@ $version: "2.0" namespace smithy.rules.tests use smithy.rules#clientContextParams -use smithy.rules#endpointBdd use smithy.rules#endpointRuleSet use smithy.rules#endpointTests diff --git a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/valid-hostlabel.smithy b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/valid-hostlabel.smithy index 8d90e2b265e..c6e8a7fe152 100644 --- a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/valid-hostlabel.smithy +++ b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/valid-hostlabel.smithy @@ -3,7 +3,6 @@ $version: "2.0" namespace smithy.rules.tests use smithy.rules#clientContextParams -use smithy.rules#endpointBdd use smithy.rules#endpointRuleSet use smithy.rules#endpointTests From 8b29c1421cd66bb4830c86ce662cb5662d0125e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20Sugawara=20=28=E2=88=A9=EF=BD=80-=C2=B4=29?= =?UTF-8?q?=E2=8A=83=E2=94=81=E7=82=8E=E7=82=8E=E7=82=8E=E7=82=8E=E7=82=8E?= Date: Wed, 28 Jan 2026 15:24:34 -0800 Subject: [PATCH 8/8] Format tests --- .../resources/META-INF/smithy/coalesce.smithy | 319 ++-- .../META-INF/smithy/default-values.smithy | 112 +- .../META-INF/smithy/endpoint-bindings.smithy | 373 ++--- .../smithy/endpoints-string-array.smithy | 200 ++- .../resources/META-INF/smithy/get-attr.smithy | 73 +- .../resources/META-INF/smithy/headers.smithy | 83 +- .../main/resources/META-INF/smithy/ite.smithy | 81 +- .../META-INF/smithy/parse-url.smithy | 315 ++-- .../resources/META-INF/smithy/split.smithy | 1296 ++++++++--------- .../META-INF/smithy/substring.smithy | 338 ++--- .../META-INF/smithy/url-encode.smithy | 155 +- .../META-INF/smithy/valid-hostlabel.smithy | 170 +-- 12 files changed, 1501 insertions(+), 2014 deletions(-) diff --git a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/coalesce.smithy b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/coalesce.smithy index 1b4aad4fce9..fd649d9465b 100644 --- a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/coalesce.smithy +++ b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/coalesce.smithy @@ -8,227 +8,160 @@ use smithy.rules#endpointTests @suppress(["UnstableTrait", "RuleSetParameter.TestCase.Unused"]) @clientContextParams( - "TestCaseId": { - "type": "string", - "required": true, - "documentation": "Test case id used to select the test case to use" - } - req1: { - type: "string", - documentation: "docs", - } - req2: { - type: "string", - documentation: "docs", - } - opt1: { - type: "string", - documentation: "always Some" - - } - opt2: { - type: "string", - documentation: "always Some" - } + TestCaseId: { type: "string", required: true, documentation: "Test case id used to select the test case to use" } + req1: { type: "string", documentation: "docs" } + req2: { type: "string", documentation: "docs" } + opt1: { type: "string", documentation: "always Some" } + opt2: { type: "string", documentation: "always Some" } ) @endpointRuleSet({ - version: "1.1", + version: "1.1" parameters: { - "TestCaseId": { - "type": "string", - "required": true, - "documentation": "Test case id used to select the test case to use" - } - req1: { - type: "string", - documentation: "req1", - required: true, - default: "req1Value" - } - req2: { - type: "string", - documentation: "req2", - required: true, - default: "req2Value" - } - opt1: { - type: "string", - documentation: "opt1" - - } - opt2: { - type: "string", - documentation: "opt2" - } - }, + TestCaseId: { type: "string", required: true, documentation: "Test case id used to select the test case to use" } + req1: { type: "string", documentation: "req1", required: true, default: "req1Value" } + req2: { type: "string", documentation: "req2", required: true, default: "req2Value" } + opt1: { type: "string", documentation: "opt1" } + opt2: { type: "string", documentation: "opt2" } + } rules: [ { - "documentation": "Two required", - "conditions": [ + documentation: "Two required" + conditions: [ { - "fn": "stringEquals", - "argv": [ - "{TestCaseId}", - "0" - ] - }, + fn: "stringEquals" + argv: ["{TestCaseId}", "0"] + } { - "fn": "coalesce", - "argv": [ - {"ref": "req1"}, - {"ref": "req2"}, - ], - "assign": "req1req2" - }, - ], - "error": "The value is: {req1req2}", - "type": "error" - }, + fn: "coalesce" + argv: [ + { + ref: "req1" + } + { + ref: "req2" + } + ] + assign: "req1req2" + } + ] + error: "The value is: {req1req2}" + type: "error" + } { - "documentation": "Two optional", - "conditions": [ + documentation: "Two optional" + conditions: [ { - "fn": "stringEquals", - "argv": [ - "{TestCaseId}", - "1" - ] - }, + fn: "stringEquals" + argv: ["{TestCaseId}", "1"] + } { - "fn": "coalesce", - "argv": [ - {"ref": "opt1"}, - {"ref": "opt2"}, - ], - "assign": "opt1opt2" - }, - ], - "error": "The value is: {opt1opt2}", - "type": "error" - }, + fn: "coalesce" + argv: [ + { + ref: "opt1" + } + { + ref: "opt2" + } + ] + assign: "opt1opt2" + } + ] + error: "The value is: {opt1opt2}" + type: "error" + } { - "documentation": "Required then Optional", - "conditions": [ + documentation: "Required then Optional" + conditions: [ { - "fn": "stringEquals", - "argv": [ - "{TestCaseId}", - "2" - ] - }, + fn: "stringEquals" + argv: ["{TestCaseId}", "2"] + } { - "fn": "coalesce", - "argv": [ - {"ref": "req1"}, - {"ref": "opt1"}, - ], - "assign": "req1opt1" - }, - ], - "error": "The value is: {req1opt1}", - "type": "error" - }, + fn: "coalesce" + argv: [ + { + ref: "req1" + } + { + ref: "opt1" + } + ] + assign: "req1opt1" + } + ] + error: "The value is: {req1opt1}" + type: "error" + } { - "documentation": "Optional then Required", - "conditions": [ + documentation: "Optional then Required" + conditions: [ { - "fn": "stringEquals", - "argv": [ - "{TestCaseId}", - "3" - ] - }, + fn: "stringEquals" + argv: ["{TestCaseId}", "3"] + } { - "fn": "coalesce", - "argv": [ - {"ref": "opt1"}, - {"ref": "req1"}, - ], - "assign": "opt1req1" - }, - ], - "error": "The value is: {opt1req1}", - "type": "error" - }, + fn: "coalesce" + argv: [ + { + ref: "opt1" + } + { + ref: "req1" + } + ] + assign: "opt1req1" + } + ] + error: "The value is: {opt1req1}" + type: "error" + } { - "conditions": [], - "documentation": "error fallthrough", - "error": "endpoint error", - "type": "error" + conditions: [] + documentation: "error fallthrough" + error: "endpoint error" + type: "error" } ] }) @endpointTests({ - "version": "1.0", - "testCases": [ + version: "1.0" + testCases: [ { - "documentation": "Two required, first val returned", - "params": { - "TestCaseId": "0" - }, - "expect": { - "error": "The value is: req1Value" - } - }, + documentation: "Two required, first val returned" + params: { TestCaseId: "0" } + expect: { error: "The value is: req1Value" } + } { - "documentation": "Two optional, Some(opt1Value), Some(opt2Value), opt1Value returned", - "params": { - "TestCaseId": "1", - "opt1": "opt1Value", - "opt2": "opt2Value", - }, - "expect": { - "error": "The value is: opt1Value" - } - }, + documentation: "Two optional, Some(opt1Value), Some(opt2Value), opt1Value returned" + params: { TestCaseId: "1", opt1: "opt1Value", opt2: "opt2Value" } + expect: { error: "The value is: opt1Value" } + } { - "documentation": "Two optional, None, Some(opt2Value), opt2Value returned", - "params": { - "TestCaseId": "1", - "opt2": "opt2Value", - }, - "expect": { - "error": "The value is: opt2Value" - } - }, + documentation: "Two optional, None, Some(opt2Value), opt2Value returned" + params: { TestCaseId: "1", opt2: "opt2Value" } + expect: { error: "The value is: opt2Value" } + } { - "documentation": "Two optional, None, None, None returned", - "params": { - "TestCaseId": "1", - }, - "expect": { - "error": "endpoint error" - } - }, + documentation: "Two optional, None, None, None returned" + params: { TestCaseId: "1" } + expect: { error: "endpoint error" } + } { - "documentation": "Required then Optional, required returned", - "params": { - "TestCaseId": "2", - "opt1": "opt1Value", - }, - "expect": { - "error": "The value is: req1Value" - } - }, + documentation: "Required then Optional, required returned" + params: { TestCaseId: "2", opt1: "opt1Value" } + expect: { error: "The value is: req1Value" } + } { - "documentation": "Optional then Required, optional value returned", - "params": { - "TestCaseId": "3", - "opt1": "opt1Value", - }, - "expect": { - "error": "The value is: opt1Value" - } - }, + documentation: "Optional then Required, optional value returned" + params: { TestCaseId: "3", opt1: "opt1Value" } + expect: { error: "The value is: opt1Value" } + } { - "documentation": "Optional then Required, optional is none so required value returned", - "params": { - "TestCaseId": "3", - }, - "expect": { - "error": "The value is: req1Value" - } - }, + documentation: "Optional then Required, optional is none so required value returned" + params: { TestCaseId: "3" } + expect: { error: "The value is: req1Value" } + } ] }) service CoalesceTest {} diff --git a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/default-values.smithy b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/default-values.smithy index 86235f15937..7f22822cb5d 100644 --- a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/default-values.smithy +++ b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/default-values.smithy @@ -8,98 +8,78 @@ use smithy.rules#endpointTests @suppress(["UnstableTrait"]) @clientContextParams( - bar: {type: "string", documentation: "a client string parameter"} - baz: {type: "string", documentation: "another client string parameter"} + bar: { type: "string", documentation: "a client string parameter" } + baz: { type: "string", documentation: "another client string parameter" } ) @endpointRuleSet({ - version: "1.0", + version: "1.0" parameters: { - bar: { - type: "string", - documentation: "docs" - } - baz: { - type: "string", - documentation: "docs" - required: true - default: "baz" - } - }, + bar: { type: "string", documentation: "docs" } + baz: { type: "string", documentation: "docs", required: true, default: "baz" } + } rules: [ { - "conditions": [ + conditions: [ { - "fn": "isSet", - "argv": [ + fn: "isSet" + argv: [ { - "ref": "bar" + ref: "bar" } ] } - ], - "endpoint": { - "url": "https://example.com/{baz}" - }, - "type": "endpoint" - }, + ] + endpoint: { url: "https://example.com/{baz}" } + type: "endpoint" + } { - "conditions": [], - "documentation": "error fallthrough", - "error": "endpoint error", - "type": "error" + conditions: [] + documentation: "error fallthrough" + error: "endpoint error" + type: "error" } ] }) @endpointTests({ - "version": "1.0", - "testCases": [ + version: "1.0" + testCases: [ { - "documentation": "Default value is used when parameter is unset", - "params": { - "bar": "a b", - } - "operationInputs": [{ - "operationName": "GetThing", - "clientParams": { - "bar": "a b" - } - }], - "expect": { - "endpoint": { - "url": "https://example.com/baz" + documentation: "Default value is used when parameter is unset" + params: { bar: "a b" } + operationInputs: [ + { + operationName: "GetThing" + clientParams: { bar: "a b" } } + ] + expect: { + endpoint: { url: "https://example.com/baz" } } - }, + } { - "documentation": "Default value is not used when the parameter is set", - "params": { - "bar": "a b", - "baz": "BIG" - } - "operationInputs": [{ - "operationName": "GetThing", - "clientParams": { - "bar": "a b", - "baz": "BIG" - } - }], - "expect": { - "endpoint": { - "url": "https://example.com/BIG" + documentation: "Default value is not used when the parameter is set" + params: { bar: "a b", baz: "BIG" } + operationInputs: [ + { + operationName: "GetThing" + clientParams: { bar: "a b", baz: "BIG" } } + ] + expect: { + endpoint: { url: "https://example.com/BIG" } } - }, + } { - "documentation": "a documentation string", - "expect": { - "error": "endpoint error" - } + documentation: "a documentation string" + expect: { error: "endpoint error" } } ] }) service DefaultValuesService { - version: "2022-01-01", - operations: [GetThing] + version: "2022-01-01" + operations: [ + GetThing + ] } operation GetThing { diff --git a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/endpoint-bindings.smithy b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/endpoint-bindings.smithy index 47d7d99c770..fa2f9135566 100644 --- a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/endpoint-bindings.smithy +++ b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/endpoint-bindings.smithy @@ -2,303 +2,240 @@ $version: "2.0" namespace smithy.rules.tests -use smithy.rules#endpointRuleSet -use smithy.rules#endpointTests -use smithy.rules#staticContextParams use smithy.rules#clientContextParams use smithy.rules#contextParam +use smithy.rules#endpointRuleSet +use smithy.rules#endpointTests use smithy.rules#operationContextParams +use smithy.rules#staticContextParams @suppress(["UnstableTrait"]) @clientContextParams( - bar: {type: "string", documentation: "a client string parameter"} - baz: {type: "string", documentation: "another client string parameter"} - booleanParam: {type: "boolean", documentation: "a client boolean parameter"} + bar: { type: "string", documentation: "a client string parameter" } + baz: { type: "string", documentation: "another client string parameter" } + booleanParam: { type: "boolean", documentation: "a client boolean parameter" } ) @endpointRuleSet({ - "version": "1.0", - "parameters": { - "bar": { - "required": false, - "documentation": "String parameter with no default value and client binding", - "type": "String" - }, - "baz": { - "required": true, - "default": "baz", - "documentation": "String parameter with default value and client binding", - "type": "String" - }, - "booleanParam": { - "required": true, - "default": true, - "documentation": "Boolean parameter with default value and client binding", - "type": "Boolean" - }, - "Endpoint": { - "builtIn": "SDK::Endpoint", - "required": false, - "documentation": "Override the endpoint used to send this request", - "type": "String" - } - }, - "rules": [ + version: "1.0" + parameters: { + bar: { required: false, documentation: "String parameter with no default value and client binding", type: "String" } + baz: { required: true, default: "baz", documentation: "String parameter with default value and client binding", type: "String" } + booleanParam: { required: true, default: true, documentation: "Boolean parameter with default value and client binding", type: "Boolean" } + Endpoint: { builtIn: "SDK::Endpoint", required: false, documentation: "Override the endpoint used to send this request", type: "String" } + } + rules: [ { - "conditions": [], - "rules": [ + conditions: [] + rules: [ { - "conditions": [ + conditions: [ { - "fn": "isSet", - "argv": [ + fn: "isSet" + argv: [ { - "ref": "Endpoint" + ref: "Endpoint" } ] } - ], - "endpoint": { - "url": { - "ref": "Endpoint" - }, - "properties": {}, - "headers": {} - }, - "type": "endpoint" - }, + ] + endpoint: { + url: { ref: "Endpoint" } + properties: {} + headers: {} + } + type: "endpoint" + } { - "conditions": [], - "rules": [ + conditions: [] + rules: [ { - "conditions": [ + conditions: [ { - "fn": "booleanEquals", - "argv": [ + fn: "booleanEquals" + argv: [ { - "ref": "booleanParam" - }, + ref: "booleanParam" + } true ] } - ], - "rules": [ + ] + rules: [ { - "conditions": [ + conditions: [ { - "fn": "isSet", - "argv": [ + fn: "isSet" + argv: [ { - "ref": "bar" + ref: "bar" } ] } - ], - "endpoint": { - "url": "https://{bar}.{baz}/set", - "properties": {}, - "headers": {} - }, - "type": "endpoint" - }, + ] + endpoint: { + url: "https://{bar}.{baz}/set" + properties: {} + headers: {} + } + type: "endpoint" + } { - "conditions": [], - "endpoint": { - "url": "https://{baz}/set", - "properties": {}, - "headers": {} - }, - "type": "endpoint" + conditions: [] + endpoint: { + url: "https://{baz}/set" + properties: {} + headers: {} + } + type: "endpoint" } - ], - "type": "tree" - }, + ] + type: "tree" + } { - "conditions": [], - "rules": [ + conditions: [] + rules: [ { - "conditions": [ + conditions: [ { - "fn": "isSet", - "argv": [ + fn: "isSet" + argv: [ { - "ref": "bar" + ref: "bar" } ] } - ], - "endpoint": { - "url": "https://{bar}.{baz}/unset", - "properties": {}, - "headers": {} - }, - "type": "endpoint" - }, + ] + endpoint: { + url: "https://{bar}.{baz}/unset" + properties: {} + headers: {} + } + type: "endpoint" + } { - "conditions": [], - "endpoint": { - "url": "https://{baz}/unset", - "properties": {}, - "headers": {} - }, - "type": "endpoint" + conditions: [] + endpoint: { + url: "https://{baz}/unset" + properties: {} + headers: {} + } + type: "endpoint" } - ], - "type": "tree" + ] + type: "tree" } - ], - "type": "tree" + ] + type: "tree" } - ], - "type": "tree" + ] + type: "tree" } ] }) @endpointTests({ - "version": "1.0", - "testCases": [ + version: "1.0" + testCases: [ { - "documentation": "Custom Endpoint used" - "params": { - "Endpoint": "https://custom-endpoint.com" + documentation: "Custom Endpoint used" + params: { Endpoint: "https://custom-endpoint.com" } + expect: { + endpoint: { url: "https://custom-endpoint.com" } } - "expect": { - "endpoint": { - "url": "https://custom-endpoint.com" - } - }, - "operationInputs": [ + operationInputs: [ { - "operationName": "NoBindingsOperation", - "builtInParams": { - "SDK::Endpoint": "https://custom-endpoint.com" - } + operationName: "NoBindingsOperation" + builtInParams: { "SDK::Endpoint": "https://custom-endpoint.com" } } ] - }, + } { - "documentation": "Default values used" - "params": {} - "expect": { - "endpoint": { - "url": "https://baz/set" - } - }, - "operationInputs": [ + documentation: "Default values used" + params: {} + expect: { + endpoint: { url: "https://baz/set" } + } + operationInputs: [ { - "operationName": "NoBindingsOperation" + operationName: "NoBindingsOperation" } ] - }, + } { - "documentation": "Client config used over default" - "params": { - "baz": "client-config" + documentation: "Client config used over default" + params: { baz: "client-config" } + expect: { + endpoint: { url: "https://client-config/set" } } - "expect": { - "endpoint": { - "url": "https://client-config/set" - } - }, - "operationInputs": [ + operationInputs: [ { - "operationName": "NoBindingsOperation", - "clientParams": { - "baz": "client-config" - } + operationName: "NoBindingsOperation" + clientParams: { baz: "client-config" } } ] - }, + } { - "documentation": "StaticContextParam values used" - "params": { - "bar": "static-context", - "booleanParam": false + documentation: "StaticContextParam values used" + params: { bar: "static-context", booleanParam: false } + expect: { + endpoint: { url: "https://static-context.baz/unset" } } - "expect": { - "endpoint": { - "url": "https://static-context.baz/unset" - } - }, - "operationInputs": [ + operationInputs: [ { - "operationName": "BindingsStaticContextOperation", + operationName: "BindingsStaticContextOperation" } ] - }, + } { - "documentation": "ContextParam values used over config and defaults" - "params": { - "bar": "context-bar", - "baz": "context-baz", - "booleanParam": false + documentation: "ContextParam values used over config and defaults" + params: { bar: "context-bar", baz: "context-baz", booleanParam: false } + expect: { + endpoint: { url: "https://context-bar.context-baz/unset" } } - "expect": { - "endpoint": { - "url": "https://context-bar.context-baz/unset" - } - }, - "operationInputs": [ + operationInputs: [ { - "operationName": "ContextParamsOperation", - "operationParams": { - "bar": "context-bar", - "baz": "context-baz", - "booleanParam": false - }, - "clientParams": { - "bar": "client-config" - } + operationName: "ContextParamsOperation" + operationParams: { bar: "context-bar", baz: "context-baz", booleanParam: false } + clientParams: { bar: "client-config" } } ] - }, + } { - "documentation": "OperationContextParam values used over config and defaults" - "params": { - "bar": "operation-context-bar", - "baz": "operation-context-baz", - "booleanParam": false + documentation: "OperationContextParam values used over config and defaults" + params: { bar: "operation-context-bar", baz: "operation-context-baz", booleanParam: false } + expect: { + endpoint: { url: "https://operation-context-bar.operation-context-baz/unset" } } - "expect": { - "endpoint": { - "url": "https://operation-context-bar.operation-context-baz/unset" - } - }, - "operationInputs": [ + operationInputs: [ { - "operationName": "OperationContextParamsOperation", - "operationParams": { - "nested": { - "bar": "operation-context-bar", - "baz": "operation-context-baz" - } - "booleanParam": false - }, - "clientParams": { - "bar": "client-config" + operationName: "OperationContextParamsOperation" + operationParams: { + nested: { bar: "operation-context-bar", baz: "operation-context-baz" } + booleanParam: false } + clientParams: { bar: "client-config" } } ] - }, + } ] }) service EndpointBindingService { - version: "2022-01-01", + version: "2022-01-01" operations: [ - NoBindingsOperation, - BindingsStaticContextOperation, - ContextParamsOperation, + NoBindingsOperation + BindingsStaticContextOperation + ContextParamsOperation OperationContextParamsOperation ] } operation NoBindingsOperation { - input:= {} + input := {} } @suppress(["UnstableTrait"]) @staticContextParams( - "bar": {value: "static-context"}, - "booleanParam": {value: false} + bar: { value: "static-context" } + booleanParam: { value: false } ) operation BindingsStaticContextOperation { input := {} @@ -307,10 +244,10 @@ operation BindingsStaticContextOperation { operation ContextParamsOperation { input := { @contextParam(name: "bar") - bar: String, + bar: String @contextParam(name: "baz") - baz: String, + baz: String @contextParam(name: "booleanParam") booleanParam: Boolean @@ -318,19 +255,19 @@ operation ContextParamsOperation { } @operationContextParams( - "bar": { path: "nested.bar" } - "baz": { path: "nested.baz" } - "booleanParam": {path: "booleanParam"} + bar: { path: "nested.bar" } + baz: { path: "nested.baz" } + booleanParam: { path: "booleanParam" } ) operation OperationContextParamsOperation { input := { - nested: Nested, + nested: Nested booleanParam: Boolean } } structure Nested { - bar: String, + bar: String baz: String } @@ -339,10 +276,10 @@ list ListOfObjects { } structure ObjectMember { - key: String, + key: String } map Map { - key: String, + key: String value: String } diff --git a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/endpoints-string-array.smithy b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/endpoints-string-array.smithy index 22e8b3da95f..d64c297148c 100644 --- a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/endpoints-string-array.smithy +++ b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/endpoints-string-array.smithy @@ -4,133 +4,123 @@ namespace smithy.rules.tests use smithy.rules#endpointRuleSet use smithy.rules#endpointTests -use smithy.rules#staticContextParams use smithy.rules#operationContextParams +use smithy.rules#staticContextParams @suppress(["UnstableTrait"]) @endpointRuleSet({ - version: "1.0", + version: "1.0" parameters: { stringArrayParam: { - type: "stringArray", - required: true, - default: ["defaultValue1", "defaultValue2"], + type: "stringArray" + required: true + default: ["defaultValue1", "defaultValue2"] documentation: "docs" } - }, + } rules: [ { - "documentation": "Template first array value into URI if set", - "conditions": [ + documentation: "Template first array value into URI if set" + conditions: [ { - "fn": "getAttr", - "argv": [ + fn: "getAttr" + argv: [ { - "ref": "stringArrayParam" - }, + ref: "stringArrayParam" + } "[0]" - ], - "assign": "arrayValue" + ] + assign: "arrayValue" } - ], - "endpoint": { - "url": "https://example.com/{arrayValue}" - }, - "type": "endpoint" - }, + ] + endpoint: { url: "https://example.com/{arrayValue}" } + type: "endpoint" + } { - "conditions": [], - "documentation": "error fallthrough", - "error": "no array values set", - "type": "error" + conditions: [] + documentation: "error fallthrough" + error: "no array values set" + type: "error" } ] }) @endpointTests({ - "version": "1.0", - "testCases": [ + version: "1.0" + testCases: [ { - "documentation": "Default array values used" - "params": {} - "expect": { - "endpoint": { - "url": "https://example.com/defaultValue1" - } - }, - "operationInputs": [ + documentation: "Default array values used" + params: {} + expect: { + endpoint: { url: "https://example.com/defaultValue1" } + } + operationInputs: [ { - "operationName": "NoBindingsOperation", + operationName: "NoBindingsOperation" } ] - }, + } { - "documentation": "Empty array", - "params": { - "stringArrayParam": [] + documentation: "Empty array" + params: { + stringArrayParam: [] } - "expect": { - "error": "no array values set" - }, - "operationInputs": [ + expect: { error: "no array values set" } + operationInputs: [ { - "operationName": "EmptyStaticContextOperation", + operationName: "EmptyStaticContextOperation" } ] - }, + } { - "documentation": "Static value", - "params": { - "stringArrayParam": ["staticValue1"] + documentation: "Static value" + params: { + stringArrayParam: ["staticValue1"] } - "expect": { - "endpoint": { - "url": "https://example.com/staticValue1" - } - }, - "operationInputs": [ + expect: { + endpoint: { url: "https://example.com/staticValue1" } + } + operationInputs: [ { - "operationName": "StaticContextOperation", + operationName: "StaticContextOperation" } ] - }, + } { - "documentation": "bound value from input", - "params": { - "stringArrayParam": ["key1"] + documentation: "bound value from input" + params: { + stringArrayParam: ["key1"] } - "expect": { - "endpoint": { - "url": "https://example.com/key1" - } - }, - "operationInputs": [ + expect: { + endpoint: { url: "https://example.com/key1" } + } + operationInputs: [ { - "operationName": "ListOfObjectsOperation", - "operationParams": { - "nested": { - "listOfObjects": [{"key": "key1"}] + operationName: "ListOfObjectsOperation" + operationParams: { + nested: { + listOfObjects: [ + { + key: "key1" + } + ] } - }, - }, + } + } { - "operationName": "MapOperation", - "operationParams": { - "map": { - "key1": "value1" - } + operationName: "MapOperation" + operationParams: { + map: { key1: "value1" } } - }, + } { - "operationName": "ListOfUnionsOperation", - "operationParams": { - "listOfUnions": [ + operationName: "ListOfUnionsOperation" + operationParams: { + listOfUnions: [ { - "string": "key1" - }, + string: "key1" + } { - "object": { - "key": "key2" - } + object: { key: "key2" } } ] } @@ -140,24 +130,26 @@ use smithy.rules#operationContextParams ] }) service EndpointStringArrayService { - version: "2022-01-01", + version: "2022-01-01" operations: [ - NoBindingsOperation, - EmptyStaticContextOperation, - StaticContextOperation, - ListOfObjectsOperation, - ListOfUnionsOperation, + NoBindingsOperation + EmptyStaticContextOperation + StaticContextOperation + ListOfObjectsOperation + ListOfUnionsOperation MapOperation ] } operation NoBindingsOperation { - input:= {} + input := {} } @suppress(["UnstableTrait"]) @staticContextParams( - "stringArrayParam": {value: []} + stringArrayParam: { + value: [] + } ) operation EmptyStaticContextOperation { input := {} @@ -165,7 +157,9 @@ operation EmptyStaticContextOperation { @suppress(["UnstableTrait"]) @staticContextParams( - "stringArrayParam": {value: ["staticValue1"]} + stringArrayParam: { + value: ["staticValue1"] + } ) operation StaticContextOperation { input := {} @@ -173,30 +167,30 @@ operation StaticContextOperation { @suppress(["UnstableTrait"]) @operationContextParams( - "stringArrayParam": {path: "nested.listOfObjects[*].key"} + stringArrayParam: { path: "nested.listOfObjects[*].key" } ) operation ListOfObjectsOperation { - input:= { + input := { nested: NestedStructure } } @suppress(["UnstableTrait"]) @operationContextParams( - "stringArrayParam": {path: "listOfUnions[*][string, object.key][]"} + stringArrayParam: { path: "listOfUnions[*][string, object.key][]" } ) operation ListOfUnionsOperation { -input:= { + input := { listOfUnions: ListOfUnions } } @suppress(["UnstableTrait"]) @operationContextParams( - "stringArrayParam": {path: "keys(map)"} + stringArrayParam: { path: "keys(map)" } ) operation MapOperation { - input:= { + input := { map: Map } } @@ -210,7 +204,7 @@ list ListOfObjects { } structure ObjectMember { - key: String, + key: String } list ListOfUnions { @@ -218,11 +212,11 @@ list ListOfUnions { } union UnionMember { - string: String, + string: String object: ObjectMember } map Map { - key: String, + key: String value: String } diff --git a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/get-attr.smithy b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/get-attr.smithy index 6052fe9972e..e3006ae87df 100644 --- a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/get-attr.smithy +++ b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/get-attr.smithy @@ -8,67 +8,56 @@ use smithy.rules#endpointTests @suppress(["UnstableTrait"]) @endpointRuleSet({ - "version": "1.0", - "parameters": { - "Bucket": { - "type": "string", - "documentation": "docs" - } - }, - "rules": [ + version: "1.0" + parameters: { + Bucket: { type: "string", documentation: "docs" } + } + rules: [ { - "documentation": "bucket is set, handle bucket specific endpoints", - "conditions": [ + documentation: "bucket is set, handle bucket specific endpoints" + conditions: [ { - "fn": "isSet", - "argv": [ + fn: "isSet" + argv: [ { - "ref": "Bucket" + ref: "Bucket" } ] - }, + } { - "fn": "parseURL", - "argv": [ - "{Bucket}" - ], - "assign": "bucketUrl" - }, + fn: "parseURL" + argv: ["{Bucket}"] + assign: "bucketUrl" + } { - "fn": "getAttr", - "argv": [ + fn: "getAttr" + argv: [ { - "ref": "bucketUrl" - }, + ref: "bucketUrl" + } "path" - ], - "assign": "path" + ] + assign: "path" } - ], - "endpoint": { - "url": "https://{bucketUrl#authority}{path}" - }, - "type": "endpoint" + ] + endpoint: { url: "https://{bucketUrl#authority}{path}" } + type: "endpoint" } ] }) @endpointTests({ - "version": "1.0", - "testCases": [ + version: "1.0" + testCases: [ { - "documentation": "getAttr on top level values in function and template" - "params": { - "Bucket": "http://example.com/path" - } - "expect": { - "endpoint": { - "url": "https://example.com/path" - } + documentation: "getAttr on top level values in function and template" + params: { Bucket: "http://example.com/path" } + expect: { + endpoint: { url: "https://example.com/path" } } } ] }) @clientContextParams( - Bucket: {type: "string", documentation: "docs"} + Bucket: { type: "string", documentation: "docs" } ) service GetAttrService {} diff --git a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/headers.smithy b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/headers.smithy index d26842c785a..05bcf35d409 100644 --- a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/headers.smithy +++ b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/headers.smithy @@ -8,67 +8,52 @@ use smithy.rules#endpointTests @suppress(["UnstableTrait"]) @endpointRuleSet({ - "version": "1.0", - "parameters": { - "Region": { - "type": "string", - "documentation": "The region to dispatch this request, eg. `us-east-1`." - } - }, - "rules": [ + version: "1.0" + parameters: { + Region: { type: "string", documentation: "The region to dispatch this request, eg. `us-east-1`." } + } + rules: [ { - "documentation": "Template the region into the URI when region is set", - "conditions": [ + documentation: "Template the region into the URI when region is set" + conditions: [ { - "fn": "isSet", - "argv": [ + fn: "isSet" + argv: [ { - "ref": "Region" + ref: "Region" } ] } - ], - "endpoint": { - "url": "https://{Region}.amazonaws.com", - "headers": { - "x-amz-region": [ - "{Region}" - ], - "x-amz-multi": [ - "*", - "{Region}" - ] + ] + endpoint: { + url: "https://{Region}.amazonaws.com" + headers: { + "x-amz-region": ["{Region}"] + "x-amz-multi": ["*", "{Region}"] } - }, - "type": "endpoint" - }, + } + type: "endpoint" + } { - "documentation": "fallback when region is unset", - "conditions": [], - "error": "Region must be set to resolve a valid endpoint", - "type": "error" + documentation: "fallback when region is unset" + conditions: [] + error: "Region must be set to resolve a valid endpoint" + type: "error" } ] }) @endpointTests( - "version": "1.0", - "testCases": [ + version: "1.0" + testCases: [ { - "documentation": "header set to region", - "params": { - "Region": "us-east-1" - }, - "expect": { - "endpoint": { - "url": "https://us-east-1.amazonaws.com", - "headers": { - "x-amz-region": [ - "us-east-1" - ], - "x-amz-multi": [ - "*", - "us-east-1" - ] + documentation: "header set to region" + params: { Region: "us-east-1" } + expect: { + endpoint: { + url: "https://us-east-1.amazonaws.com" + headers: { + "x-amz-region": ["us-east-1"] + "x-amz-multi": ["*", "us-east-1"] } } } @@ -76,6 +61,6 @@ use smithy.rules#endpointTests ] ) @clientContextParams( - Region: {type: "string", documentation: "docs"} + Region: { type: "string", documentation: "docs" } ) service HeadersService {} diff --git a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/ite.smithy b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/ite.smithy index 77aea7ffc24..e1544e6787f 100644 --- a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/ite.smithy +++ b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/ite.smithy @@ -7,72 +7,69 @@ use smithy.rules#endpointRuleSet use smithy.rules#endpointTests @clientContextParams( - useFips: {type: "boolean", documentation: "Use FIPS endpoints"} + useFips: { type: "boolean", documentation: "Use FIPS endpoints" } ) @endpointRuleSet({ - version: "1.1", + version: "1.1" parameters: { - useFips: { - type: "boolean", - documentation: "Use FIPS endpoints", - default: false, - required: true - } - }, + useFips: { type: "boolean", documentation: "Use FIPS endpoints", default: false, required: true } + } rules: [ { - "documentation": "Use ite to select endpoint suffix" - "conditions": [ + documentation: "Use ite to select endpoint suffix" + conditions: [ { - "fn": "ite" - "argv": [{"ref": "useFips"}, "-fips", ""] - "assign": "suffix" + fn: "ite" + argv: [ + { + ref: "useFips" + } + "-fips" + "" + ] + assign: "suffix" } ] - "endpoint": { - "url": "https://example{suffix}.com" - } - "type": "endpoint" + endpoint: { url: "https://example{suffix}.com" } + type: "endpoint" } ] }) @endpointTests({ - "version": "1.0", - "testCases": [ + version: "1.0" + testCases: [ { - "documentation": "When useFips is true, returns trueValue" - "params": { - "useFips": true - } - "operationInputs": [{ - "operationName": "GetThing" - }], - "expect": { - "endpoint": { - "url": "https://example-fips.com" + documentation: "When useFips is true, returns trueValue" + params: { useFips: true } + operationInputs: [ + { + operationName: "GetThing" } + ] + expect: { + endpoint: { url: "https://example-fips.com" } } } { - "documentation": "When useFips is false, returns falseValue" - "params": { - "useFips": false - } - "operationInputs": [{ - "operationName": "GetThing" - }], - "expect": { - "endpoint": { - "url": "https://example.com" + documentation: "When useFips is false, returns falseValue" + params: { useFips: false } + operationInputs: [ + { + operationName: "GetThing" } + ] + expect: { + endpoint: { url: "https://example.com" } } } ] }) @suppress(["UnstableTrait.smithy"]) service IteTest { - version: "2022-01-01", - operations: [GetThing] + version: "2022-01-01" + operations: [ + GetThing + ] } operation GetThing { diff --git a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/parse-url.smithy b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/parse-url.smithy index db15667c232..87f65bb1471 100644 --- a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/parse-url.smithy +++ b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/parse-url.smithy @@ -8,258 +8,183 @@ use smithy.rules#endpointTests @suppress(["UnstableTrait"]) @endpointRuleSet({ - "version": "1.0", - "parameters": { - "Endpoint": { - "type": "string", - "documentation": "docs" - } - }, - "rules": [ - { - "documentation": "endpoint is set and is a valid URL", - "conditions": [ + version: "1.0" + parameters: { + Endpoint: { type: "string", documentation: "docs" } + } + rules: [ + { + documentation: "endpoint is set and is a valid URL" + conditions: [ { - "fn": "isSet", - "argv": [ + fn: "isSet" + argv: [ { - "ref": "Endpoint" + ref: "Endpoint" } ] - }, + } { - "fn": "parseURL", - "argv": [ - "{Endpoint}" - ], - "assign": "url" + fn: "parseURL" + argv: ["{Endpoint}"] + assign: "url" } - ], - "rules": [ + ] + rules: [ { - "conditions": [ + conditions: [ { - "fn": "booleanEquals", - "argv": [ + fn: "booleanEquals" + argv: [ { - "fn": "getAttr", - "argv": [ + fn: "getAttr" + argv: [ { - "ref": "url" - }, + ref: "url" + } "isIp" ] - }, + } true ] } - ], - "endpoint": { - "url": "{url#scheme}://{url#authority}{url#normalizedPath}is-ip-addr" - }, - "type": "endpoint" - }, + ] + endpoint: { url: "{url#scheme}://{url#authority}{url#normalizedPath}is-ip-addr" } + type: "endpoint" + } { - "conditions": [ + conditions: [ { - "fn": "stringEquals", - "argv": [ - "{url#path}", - "/port" - ] + fn: "stringEquals" + argv: ["{url#path}", "/port"] } - ], - "endpoint": { - "url": "{url#scheme}://{url#authority}/uri-with-port" - }, - "type": "endpoint" - }, + ] + endpoint: { url: "{url#scheme}://{url#authority}/uri-with-port" } + type: "endpoint" + } { - "conditions": [ + conditions: [ { - "fn": "stringEquals", - "argv": [ - "{url#normalizedPath}", - "/" - ] + fn: "stringEquals" + argv: ["{url#normalizedPath}", "/"] } - ], - "endpoint": { - "url": "https://{url#scheme}-{url#authority}-nopath.example.com" - }, - "type": "endpoint" - }, + ] + endpoint: { url: "https://{url#scheme}-{url#authority}-nopath.example.com" } + type: "endpoint" + } { - "conditions": [], - "endpoint": { - "url": "https://{url#scheme}-{url#authority}.example.com/path-is{url#path}" - }, - "type": "endpoint" + conditions: [] + endpoint: { url: "https://{url#scheme}-{url#authority}.example.com/path-is{url#path}" } + type: "endpoint" } - ], - "type": "tree" - }, + ] + type: "tree" + } { - "error": "endpoint was invalid", - "conditions": [], - "type": "error" + error: "endpoint was invalid" + conditions: [] + type: "error" } ] }) @endpointTests( - version: "1.0", + version: "1.0" testCases: [ { - "documentation": "simple URL parsing", - "params": { - "Endpoint": "https://authority.com/custom-path" - }, - "expect": { - "endpoint": { - "url": "https://https-authority.com.example.com/path-is/custom-path" - } + documentation: "simple URL parsing" + params: { Endpoint: "https://authority.com/custom-path" } + expect: { + endpoint: { url: "https://https-authority.com.example.com/path-is/custom-path" } } - }, + } { - "documentation": "empty path no slash", - "params": { - "Endpoint": "https://authority.com" - }, - "expect": { - "endpoint": { - "url": "https://https-authority.com-nopath.example.com" - } + documentation: "empty path no slash" + params: { Endpoint: "https://authority.com" } + expect: { + endpoint: { url: "https://https-authority.com-nopath.example.com" } } - }, + } { - "documentation": "empty path with slash", - "params": { - "Endpoint": "https://authority.com/" - }, - "expect": { - "endpoint": { - "url": "https://https-authority.com-nopath.example.com" - } + documentation: "empty path with slash" + params: { Endpoint: "https://authority.com/" } + expect: { + endpoint: { url: "https://https-authority.com-nopath.example.com" } } - }, + } { - "documentation": "authority with port", - "params": { - "Endpoint": "https://authority.com:8000/port" - }, - "expect": { - "endpoint": { - "url": "https://authority.com:8000/uri-with-port" - } + documentation: "authority with port" + params: { Endpoint: "https://authority.com:8000/port" } + expect: { + endpoint: { url: "https://authority.com:8000/uri-with-port" } } - }, + } { - "documentation": "http schemes", - "params": { - "Endpoint": "http://authority.com:8000/port" - }, - "expect": { - "endpoint": { - "url": "http://authority.com:8000/uri-with-port" - } + documentation: "http schemes" + params: { Endpoint: "http://authority.com:8000/port" } + expect: { + endpoint: { url: "http://authority.com:8000/uri-with-port" } } - }, + } { - "documentation": "arbitrary schemes are not supported", - "params": { - "Endpoint": "acbd://example.com" - }, - "expect": { - "error": "endpoint was invalid" - } - }, + documentation: "arbitrary schemes are not supported" + params: { Endpoint: "acbd://example.com" } + expect: { error: "endpoint was invalid" } + } { - "documentation": "host labels are not validated", - "params": { - "Endpoint": "http://99_ab.com" - }, - "expect": { - "endpoint": { - "url": "https://http-99_ab.com-nopath.example.com" - } + documentation: "host labels are not validated" + params: { Endpoint: "http://99_ab.com" } + expect: { + endpoint: { url: "https://http-99_ab.com-nopath.example.com" } } - }, + } { - "documentation": "host labels are not validated", - "params": { - "Endpoint": "http://99_ab-.com" - }, - "expect": { - "endpoint": { - "url": "https://http-99_ab-.com-nopath.example.com" - } + documentation: "host labels are not validated" + params: { Endpoint: "http://99_ab-.com" } + expect: { + endpoint: { url: "https://http-99_ab-.com-nopath.example.com" } } - }, + } { - "documentation": "invalid URL", - "params": { - "Endpoint": "http://abc.com:a/foo" - }, - "expect": { - "error": "endpoint was invalid" - } - }, + documentation: "invalid URL" + params: { Endpoint: "http://abc.com:a/foo" } + expect: { error: "endpoint was invalid" } + } { - "documentation": "IP Address", - "params": { - "Endpoint": "http://192.168.1.1/foo/" - }, - "expect": { - "endpoint": { - "url": "http://192.168.1.1/foo/is-ip-addr" - } + documentation: "IP Address" + params: { Endpoint: "http://192.168.1.1/foo/" } + expect: { + endpoint: { url: "http://192.168.1.1/foo/is-ip-addr" } } - }, + } { - "documentation": "IP Address with port", - "params": { - "Endpoint": "http://192.168.1.1:1234/foo/" - }, - "expect": { - "endpoint": { - "url": "http://192.168.1.1:1234/foo/is-ip-addr" - } + documentation: "IP Address with port" + params: { Endpoint: "http://192.168.1.1:1234/foo/" } + expect: { + endpoint: { url: "http://192.168.1.1:1234/foo/is-ip-addr" } } - }, + } { - "documentation": "IPv6 Address", - "params": { - "Endpoint": "https://[2001:db8:85a3:8d3:1319:8a2e:370:7348]:443" - }, - "expect": { - "endpoint": { - "url": "https://[2001:db8:85a3:8d3:1319:8a2e:370:7348]:443/is-ip-addr" - } + documentation: "IPv6 Address" + params: { Endpoint: "https://[2001:db8:85a3:8d3:1319:8a2e:370:7348]:443" } + expect: { + endpoint: { url: "https://[2001:db8:85a3:8d3:1319:8a2e:370:7348]:443/is-ip-addr" } } - }, + } { - "documentation": "weird DNS name", - "params": { - "Endpoint": "https://999.999.abc.blah" - }, - "expect": { - "endpoint": { - "url": "https://https-999.999.abc.blah-nopath.example.com" - } + documentation: "weird DNS name" + params: { Endpoint: "https://999.999.abc.blah" } + expect: { + endpoint: { url: "https://https-999.999.abc.blah-nopath.example.com" } } - }, + } { - "documentation": "query in resolved endpoint is not supported", - "params": { - "Endpoint": "https://example.com/path?query1=foo" - }, - "expect": { - "error": "endpoint was invalid" - } + documentation: "query in resolved endpoint is not supported" + params: { Endpoint: "https://example.com/path?query1=foo" } + expect: { error: "endpoint was invalid" } } ] ) @clientContextParams( - Endpoint: {type: "string", documentation: "docs"} + Endpoint: { type: "string", documentation: "docs" } ) service ParseUrlService {} diff --git a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/split.smithy b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/split.smithy index de6359e68b7..dc59e518590 100644 --- a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/split.smithy +++ b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/split.smithy @@ -7,853 +7,793 @@ use smithy.rules#endpointRuleSet use smithy.rules#endpointTests @endpointRuleSet({ - "version": "1.3", - "parameters": { - "Input": { - "type": "string", - "required": true, - "documentation": "The input string to split" - }, - "Delimiter": { - "type": "string", - "required": true, - "documentation": "The delimiter to split by" - }, - "Limit": { - "type": "string", - "required": true, - "documentation": "The split limit as a string" - } - }, - "rules": [ - { - "documentation": "Split with limit 0 (unlimited)", - "conditions": [ - { - "fn": "stringEquals", - "argv": ["{Limit}", "0"] - }, - { - "fn": "split", - "argv": ["{Input}", "{Delimiter}", 0], - "assign": "parts" - }, - { - "fn": "coalesce", - "argv": [ + version: "1.3" + parameters: { + Input: { type: "string", required: true, documentation: "The input string to split" } + Delimiter: { type: "string", required: true, documentation: "The delimiter to split by" } + Limit: { type: "string", required: true, documentation: "The split limit as a string" } + } + rules: [ + { + documentation: "Split with limit 0 (unlimited)" + conditions: [ + { + fn: "stringEquals" + argv: ["{Limit}", "0"] + } + { + fn: "split" + argv: ["{Input}", "{Delimiter}", 0] + assign: "parts" + } + { + fn: "coalesce" + argv: [ { - "fn": "getAttr", - "argv": [{"ref": "parts"}, "[0]"] - }, + fn: "getAttr" + argv: [ + { + ref: "parts" + } + "[0]" + ] + } "" - ], - "assign": "part1" - }, + ] + assign: "part1" + } { - "fn": "coalesce", - "argv": [ + fn: "coalesce" + argv: [ { - "fn": "getAttr", - "argv": [{"ref": "parts"}, "[1]"] - }, + fn: "getAttr" + argv: [ + { + ref: "parts" + } + "[1]" + ] + } "" - ], - "assign": "part2" - }, + ] + assign: "part2" + } { - "fn": "coalesce", - "argv": [ + fn: "coalesce" + argv: [ { - "fn": "getAttr", - "argv": [{"ref": "parts"}, "[2]"] - }, + fn: "getAttr" + argv: [ + { + ref: "parts" + } + "[2]" + ] + } "" - ], - "assign": "part3" - }, + ] + assign: "part3" + } { - "fn": "coalesce", - "argv": [ + fn: "coalesce" + argv: [ { - "fn": "getAttr", - "argv": [{"ref": "parts"}, "[3]"] - }, + fn: "getAttr" + argv: [ + { + ref: "parts" + } + "[3]" + ] + } "" - ], - "assign": "part4" - }, + ] + assign: "part4" + } { - "fn": "coalesce", - "argv": [ + fn: "coalesce" + argv: [ { - "fn": "getAttr", - "argv": [{"ref": "parts"}, "[4]"] - }, + fn: "getAttr" + argv: [ + { + ref: "parts" + } + "[4]" + ] + } "" - ], - "assign": "part5" + ] + assign: "part5" } - ], - "endpoint": { - "url": "https://example.com", - "properties": { - "splitResult": "p1={part1}; p2={part2}; p3={part3}; p4={part4}; p5={part5}" - } - }, - "type": "endpoint" - }, + ] + endpoint: { + url: "https://example.com" + properties: { splitResult: "p1={part1}; p2={part2}; p3={part3}; p4={part4}; p5={part5}" } + } + type: "endpoint" + } { - "documentation": "Split with limit 1 (no split)", - "conditions": [ + documentation: "Split with limit 1 (no split)" + conditions: [ { - "fn": "stringEquals", - "argv": ["{Limit}", "1"] - }, + fn: "stringEquals" + argv: ["{Limit}", "1"] + } { - "fn": "split", - "argv": ["{Input}", "{Delimiter}", 1], - "assign": "parts" - }, + fn: "split" + argv: ["{Input}", "{Delimiter}", 1] + assign: "parts" + } { - "fn": "coalesce", - "argv": [ + fn: "coalesce" + argv: [ { - "fn": "getAttr", - "argv": [{"ref": "parts"}, "[0]"] - }, + fn: "getAttr" + argv: [ + { + ref: "parts" + } + "[0]" + ] + } "" - ], - "assign": "part1" - }, + ] + assign: "part1" + } { - "fn": "coalesce", - "argv": [ + fn: "coalesce" + argv: [ { - "fn": "getAttr", - "argv": [{"ref": "parts"}, "[1]"] - }, + fn: "getAttr" + argv: [ + { + ref: "parts" + } + "[1]" + ] + } "" - ], - "assign": "part2" - }, + ] + assign: "part2" + } { - "fn": "coalesce", - "argv": [ + fn: "coalesce" + argv: [ { - "fn": "getAttr", - "argv": [{"ref": "parts"}, "[2]"] - }, + fn: "getAttr" + argv: [ + { + ref: "parts" + } + "[2]" + ] + } "" - ], - "assign": "part3" - }, + ] + assign: "part3" + } { - "fn": "coalesce", - "argv": [ + fn: "coalesce" + argv: [ { - "fn": "getAttr", - "argv": [{"ref": "parts"}, "[3]"] - }, + fn: "getAttr" + argv: [ + { + ref: "parts" + } + "[3]" + ] + } "" - ], - "assign": "part4" - }, + ] + assign: "part4" + } { - "fn": "coalesce", - "argv": [ + fn: "coalesce" + argv: [ { - "fn": "getAttr", - "argv": [{"ref": "parts"}, "[4]"] - }, + fn: "getAttr" + argv: [ + { + ref: "parts" + } + "[4]" + ] + } "" - ], - "assign": "part5" + ] + assign: "part5" } - ], - "endpoint": { - "url": "https://example.com", - "properties": { - "splitResult": "p1={part1}; p2={part2}; p3={part3}; p4={part4}; p5={part5}" - } - }, - "type": "endpoint" - }, + ] + endpoint: { + url: "https://example.com" + properties: { splitResult: "p1={part1}; p2={part2}; p3={part3}; p4={part4}; p5={part5}" } + } + type: "endpoint" + } { - "documentation": "Split with limit 2", - "conditions": [ + documentation: "Split with limit 2" + conditions: [ { - "fn": "stringEquals", - "argv": ["{Limit}", "2"] - }, + fn: "stringEquals" + argv: ["{Limit}", "2"] + } { - "fn": "split", - "argv": ["{Input}", "{Delimiter}", 2], - "assign": "parts" - }, + fn: "split" + argv: ["{Input}", "{Delimiter}", 2] + assign: "parts" + } { - "fn": "coalesce", - "argv": [ + fn: "coalesce" + argv: [ { - "fn": "getAttr", - "argv": [{"ref": "parts"}, "[0]"] - }, + fn: "getAttr" + argv: [ + { + ref: "parts" + } + "[0]" + ] + } "" - ], - "assign": "part1" - }, + ] + assign: "part1" + } { - "fn": "coalesce", - "argv": [ + fn: "coalesce" + argv: [ { - "fn": "getAttr", - "argv": [{"ref": "parts"}, "[1]"] - }, + fn: "getAttr" + argv: [ + { + ref: "parts" + } + "[1]" + ] + } "" - ], - "assign": "part2" - }, + ] + assign: "part2" + } { - "fn": "coalesce", - "argv": [ + fn: "coalesce" + argv: [ { - "fn": "getAttr", - "argv": [{"ref": "parts"}, "[2]"] - }, + fn: "getAttr" + argv: [ + { + ref: "parts" + } + "[2]" + ] + } "" - ], - "assign": "part3" - }, + ] + assign: "part3" + } { - "fn": "coalesce", - "argv": [ + fn: "coalesce" + argv: [ { - "fn": "getAttr", - "argv": [{"ref": "parts"}, "[3]"] - }, + fn: "getAttr" + argv: [ + { + ref: "parts" + } + "[3]" + ] + } "" - ], - "assign": "part4" - }, + ] + assign: "part4" + } { - "fn": "coalesce", - "argv": [ + fn: "coalesce" + argv: [ { - "fn": "getAttr", - "argv": [{"ref": "parts"}, "[4]"] - }, + fn: "getAttr" + argv: [ + { + ref: "parts" + } + "[4]" + ] + } "" - ], - "assign": "part5" - } - ], - "endpoint": { - "url": "https://example.com", - "properties": { - "splitResult": "p1={part1}; p2={part2}; p3={part3}; p4={part4}; p5={part5}" + ] + assign: "part5" } - }, - "type": "endpoint" - }, + ] + endpoint: { + url: "https://example.com" + properties: { splitResult: "p1={part1}; p2={part2}; p3={part3}; p4={part4}; p5={part5}" } + } + type: "endpoint" + } { - "documentation": "Split with limit 3", - "conditions": [ + documentation: "Split with limit 3" + conditions: [ { - "fn": "stringEquals", - "argv": ["{Limit}", "3"] - }, + fn: "stringEquals" + argv: ["{Limit}", "3"] + } { - "fn": "split", - "argv": ["{Input}", "{Delimiter}", 3], - "assign": "parts" - }, + fn: "split" + argv: ["{Input}", "{Delimiter}", 3] + assign: "parts" + } { - "fn": "coalesce", - "argv": [ + fn: "coalesce" + argv: [ { - "fn": "getAttr", - "argv": [{"ref": "parts"}, "[0]"] - }, + fn: "getAttr" + argv: [ + { + ref: "parts" + } + "[0]" + ] + } "" - ], - "assign": "part1" - }, + ] + assign: "part1" + } { - "fn": "coalesce", - "argv": [ + fn: "coalesce" + argv: [ { - "fn": "getAttr", - "argv": [{"ref": "parts"}, "[1]"] - }, + fn: "getAttr" + argv: [ + { + ref: "parts" + } + "[1]" + ] + } "" - ], - "assign": "part2" - }, + ] + assign: "part2" + } { - "fn": "coalesce", - "argv": [ + fn: "coalesce" + argv: [ { - "fn": "getAttr", - "argv": [{"ref": "parts"}, "[2]"] - }, + fn: "getAttr" + argv: [ + { + ref: "parts" + } + "[2]" + ] + } "" - ], - "assign": "part3" - }, + ] + assign: "part3" + } { - "fn": "coalesce", - "argv": [ + fn: "coalesce" + argv: [ { - "fn": "getAttr", - "argv": [{"ref": "parts"}, "[3]"] - }, + fn: "getAttr" + argv: [ + { + ref: "parts" + } + "[3]" + ] + } "" - ], - "assign": "part4" - }, + ] + assign: "part4" + } { - "fn": "coalesce", - "argv": [ + fn: "coalesce" + argv: [ { - "fn": "getAttr", - "argv": [{"ref": "parts"}, "[4]"] - }, + fn: "getAttr" + argv: [ + { + ref: "parts" + } + "[4]" + ] + } "" - ], - "assign": "part5" - } - ], - "endpoint": { - "url": "https://example.com", - "properties": { - "splitResult": "p1={part1}; p2={part2}; p3={part3}; p4={part4}; p5={part5}" + ] + assign: "part5" } - }, - "type": "endpoint" - }, + ] + endpoint: { + url: "https://example.com" + properties: { splitResult: "p1={part1}; p2={part2}; p3={part3}; p4={part4}; p5={part5}" } + } + type: "endpoint" + } { - "documentation": "Split with limit 4", - "conditions": [ + documentation: "Split with limit 4" + conditions: [ { - "fn": "stringEquals", - "argv": ["{Limit}", "4"] - }, + fn: "stringEquals" + argv: ["{Limit}", "4"] + } { - "fn": "split", - "argv": ["{Input}", "{Delimiter}", 4], - "assign": "parts" - }, + fn: "split" + argv: ["{Input}", "{Delimiter}", 4] + assign: "parts" + } { - "fn": "coalesce", - "argv": [ + fn: "coalesce" + argv: [ { - "fn": "getAttr", - "argv": [{"ref": "parts"}, "[0]"] - }, + fn: "getAttr" + argv: [ + { + ref: "parts" + } + "[0]" + ] + } "" - ], - "assign": "part1" - }, + ] + assign: "part1" + } { - "fn": "coalesce", - "argv": [ + fn: "coalesce" + argv: [ { - "fn": "getAttr", - "argv": [{"ref": "parts"}, "[1]"] - }, + fn: "getAttr" + argv: [ + { + ref: "parts" + } + "[1]" + ] + } "" - ], - "assign": "part2" - }, + ] + assign: "part2" + } { - "fn": "coalesce", - "argv": [ + fn: "coalesce" + argv: [ { - "fn": "getAttr", - "argv": [{"ref": "parts"}, "[2]"] - }, + fn: "getAttr" + argv: [ + { + ref: "parts" + } + "[2]" + ] + } "" - ], - "assign": "part3" - }, + ] + assign: "part3" + } { - "fn": "coalesce", - "argv": [ + fn: "coalesce" + argv: [ { - "fn": "getAttr", - "argv": [{"ref": "parts"}, "[3]"] - }, + fn: "getAttr" + argv: [ + { + ref: "parts" + } + "[3]" + ] + } "" - ], - "assign": "part4" - }, + ] + assign: "part4" + } { - "fn": "coalesce", - "argv": [ + fn: "coalesce" + argv: [ { - "fn": "getAttr", - "argv": [{"ref": "parts"}, "[4]"] - }, + fn: "getAttr" + argv: [ + { + ref: "parts" + } + "[4]" + ] + } "" - ], - "assign": "part5" - } - ], - "endpoint": { - "url": "https://example.com", - "properties": { - "splitResult": "p1={part1}; p2={part2}; p3={part3}; p4={part4}; p5={part5}" + ] + assign: "part5" } - }, - "type": "endpoint" - }, + ] + endpoint: { + url: "https://example.com" + properties: { splitResult: "p1={part1}; p2={part2}; p3={part3}; p4={part4}; p5={part5}" } + } + type: "endpoint" + } { - "conditions": [], - "documentation": "error fallthrough", - "error": "endpoint error", - "type": "error" + conditions: [] + documentation: "error fallthrough" + error: "endpoint error" + type: "error" } ] }) @endpointTests( - version: "1.0", + version: "1.0" testCases: [ // Limit 0 tests { - "documentation": "basic three-part split", - "params": { - "Input": "a--b--c", - "Delimiter": "--", - "Limit": "0" - }, - "expect": { - "endpoint": { - "url": "https://example.com", - "properties": { - "splitResult": "p1=a; p2=b; p3=c; p4=; p5=" - } + documentation: "basic three-part split" + params: { Input: "a--b--c", Delimiter: "--", Limit: "0" } + expect: { + endpoint: { + url: "https://example.com" + properties: { splitResult: "p1=a; p2=b; p3=c; p4=; p5=" } } } - }, - { - "documentation": "empty string returns single empty element", - "params": { - "Input": "", - "Delimiter": "--", - "Limit": "0" - }, - "expect": { - "endpoint": { - "url": "https://example.com", - "properties": { - "splitResult": "p1=; p2=; p3=; p4=; p5=" - } + } + { + documentation: "empty string returns single empty element" + params: { Input: "", Delimiter: "--", Limit: "0" } + expect: { + endpoint: { + url: "https://example.com" + properties: { splitResult: "p1=; p2=; p3=; p4=; p5=" } } } - }, - { - "documentation": "delimiter not found returns original string", - "params": { - "Input": "no-delimiter", - "Delimiter": "--", - "Limit": "0" - }, - "expect": { - "endpoint": { - "url": "https://example.com", - "properties": { - "splitResult": "p1=no-delimiter; p2=; p3=; p4=; p5=" - } + } + { + documentation: "delimiter not found returns original string" + params: { Input: "no-delimiter", Delimiter: "--", Limit: "0" } + expect: { + endpoint: { + url: "https://example.com" + properties: { splitResult: "p1=no-delimiter; p2=; p3=; p4=; p5=" } } } - }, - { - "documentation": "leading delimiter creates empty first element", - "params": { - "Input": "--leading", - "Delimiter": "--", - "Limit": "0" - }, - "expect": { - "endpoint": { - "url": "https://example.com", - "properties": { - "splitResult": "p1=; p2=leading; p3=; p4=; p5=" - } + } + { + documentation: "leading delimiter creates empty first element" + params: { Input: "--leading", Delimiter: "--", Limit: "0" } + expect: { + endpoint: { + url: "https://example.com" + properties: { splitResult: "p1=; p2=leading; p3=; p4=; p5=" } } } - }, - { - "documentation": "trailing delimiter creates empty last element", - "params": { - "Input": "trailing--", - "Delimiter": "--", - "Limit": "0" - }, - "expect": { - "endpoint": { - "url": "https://example.com", - "properties": { - "splitResult": "p1=trailing; p2=; p3=; p4=; p5=" - } + } + { + documentation: "trailing delimiter creates empty last element" + params: { Input: "trailing--", Delimiter: "--", Limit: "0" } + expect: { + endpoint: { + url: "https://example.com" + properties: { splitResult: "p1=trailing; p2=; p3=; p4=; p5=" } } } - }, - { - "documentation": "adjacent delimiters create empty element", - "params": { - "Input": "----", - "Delimiter": "--", - "Limit": "0" - }, - "expect": { - "endpoint": { - "url": "https://example.com", - "properties": { - "splitResult": "p1=; p2=; p3=; p4=; p5=" - } + } + { + documentation: "adjacent delimiters create empty element" + params: { Input: "----", Delimiter: "--", Limit: "0" } + expect: { + endpoint: { + url: "https://example.com" + properties: { splitResult: "p1=; p2=; p3=; p4=; p5=" } } } - }, - { - "documentation": "delimiter equals input creates two empty strings", - "params": { - "Input": "--", - "Delimiter": "--", - "Limit": "0" - }, - "expect": { - "endpoint": { - "url": "https://example.com", - "properties": { - "splitResult": "p1=; p2=; p3=; p4=; p5=" - } + } + { + documentation: "delimiter equals input creates two empty strings" + params: { Input: "--", Delimiter: "--", Limit: "0" } + expect: { + endpoint: { + url: "https://example.com" + properties: { splitResult: "p1=; p2=; p3=; p4=; p5=" } } } - }, - { - "documentation": "overlapping delimiter pattern", - "params": { - "Input": "aaaa", - "Delimiter": "aa", - "Limit": "0" - }, - "expect": { - "endpoint": { - "url": "https://example.com", - "properties": { - "splitResult": "p1=; p2=; p3=; p4=; p5=" - } + } + { + documentation: "overlapping delimiter pattern" + params: { Input: "aaaa", Delimiter: "aa", Limit: "0" } + expect: { + endpoint: { + url: "https://example.com" + properties: { splitResult: "p1=; p2=; p3=; p4=; p5=" } } } - }, - { - "documentation": "overlapping delimiter with odd remainder", - "params": { - "Input": "aaa", - "Delimiter": "aa", - "Limit": "0" - }, - "expect": { - "endpoint": { - "url": "https://example.com", - "properties": { - "splitResult": "p1=; p2=a; p3=; p4=; p5=" - } + } + { + documentation: "overlapping delimiter with odd remainder" + params: { Input: "aaa", Delimiter: "aa", Limit: "0" } + expect: { + endpoint: { + url: "https://example.com" + properties: { splitResult: "p1=; p2=a; p3=; p4=; p5=" } } } - }, - { - "documentation": "multi-character delimiter", - "params": { - "Input": "foo<=>bar<=>baz", - "Delimiter": "<=>", - "Limit": "0" - }, - "expect": { - "endpoint": { - "url": "https://example.com", - "properties": { - "splitResult": "p1=foo; p2=bar; p3=baz; p4=; p5=" - } + } + { + documentation: "multi-character delimiter" + params: { Input: "foo<=>bar<=>baz", Delimiter: "<=>", Limit: "0" } + expect: { + endpoint: { + url: "https://example.com" + properties: { splitResult: "p1=foo; p2=bar; p3=baz; p4=; p5=" } } } - }, - { - "documentation": "multi-character delimiter with limit", - "params": { - "Input": "foo<=>bar<=>baz", - "Delimiter": "<=>", - "Limit": "2" - }, - "expect": { - "endpoint": { - "url": "https://example.com", - "properties": { - "splitResult": "p1=foo; p2=bar<=>baz; p3=; p4=; p5=" - } + } + { + documentation: "multi-character delimiter with limit" + params: { Input: "foo<=>bar<=>baz", Delimiter: "<=>", Limit: "2" } + expect: { + endpoint: { + url: "https://example.com" + properties: { splitResult: "p1=foo; p2=bar<=>baz; p3=; p4=; p5=" } } } - }, - { - "documentation": "both leading and trailing delimiters", - "params": { - "Input": "--both--", - "Delimiter": "--", - "Limit": "0" - }, - "expect": { - "endpoint": { - "url": "https://example.com", - "properties": { - "splitResult": "p1=; p2=both; p3=; p4=; p5=" - } + } + { + documentation: "both leading and trailing delimiters" + params: { Input: "--both--", Delimiter: "--", Limit: "0" } + expect: { + endpoint: { + url: "https://example.com" + properties: { splitResult: "p1=; p2=both; p3=; p4=; p5=" } } } - }, - { - "documentation": "both leading and trailing with limit", - "params": { - "Input": "--both--", - "Delimiter": "--", - "Limit": "2" - }, - "expect": { - "endpoint": { - "url": "https://example.com", - "properties": { - "splitResult": "p1=; p2=both--; p3=; p4=; p5=" - } + } + { + documentation: "both leading and trailing with limit" + params: { Input: "--both--", Delimiter: "--", Limit: "2" } + expect: { + endpoint: { + url: "https://example.com" + properties: { splitResult: "p1=; p2=both--; p3=; p4=; p5=" } } } - }, - + } // Limit 1 tests (no split) { - "documentation": "limit 1 returns original string", - "params": { - "Input": "a--b--c", - "Delimiter": "--", - "Limit": "1" - }, - "expect": { - "endpoint": { - "url": "https://example.com", - "properties": { - "splitResult": "p1=a--b--c; p2=; p3=; p4=; p5=" - } + documentation: "limit 1 returns original string" + params: { Input: "a--b--c", Delimiter: "--", Limit: "1" } + expect: { + endpoint: { + url: "https://example.com" + properties: { splitResult: "p1=a--b--c; p2=; p3=; p4=; p5=" } } } - }, - { - "documentation": "limit 1 with no delimiter", - "params": { - "Input": "no-delimiter", - "Delimiter": "--", - "Limit": "1" - }, - "expect": { - "endpoint": { - "url": "https://example.com", - "properties": { - "splitResult": "p1=no-delimiter; p2=; p3=; p4=; p5=" - } + } + { + documentation: "limit 1 with no delimiter" + params: { Input: "no-delimiter", Delimiter: "--", Limit: "1" } + expect: { + endpoint: { + url: "https://example.com" + properties: { splitResult: "p1=no-delimiter; p2=; p3=; p4=; p5=" } } } - }, - + } // Limit 2 tests { - "documentation": "limit 2 splits once", - "params": { - "Input": "a--b--c", - "Delimiter": "--", - "Limit": "2" - }, - "expect": { - "endpoint": { - "url": "https://example.com", - "properties": { - "splitResult": "p1=a; p2=b--c; p3=; p4=; p5=" - } + documentation: "limit 2 splits once" + params: { Input: "a--b--c", Delimiter: "--", Limit: "2" } + expect: { + endpoint: { + url: "https://example.com" + properties: { splitResult: "p1=a; p2=b--c; p3=; p4=; p5=" } } } - }, - { - "documentation": "limit 2 with leading delimiter", - "params": { - "Input": "--x-s3--azid", - "Delimiter": "--", - "Limit": "2" - }, - "expect": { - "endpoint": { - "url": "https://example.com", - "properties": { - "splitResult": "p1=; p2=x-s3--azid; p3=; p4=; p5=" - } + } + { + documentation: "limit 2 with leading delimiter" + params: { Input: "--x-s3--azid", Delimiter: "--", Limit: "2" } + expect: { + endpoint: { + url: "https://example.com" + properties: { splitResult: "p1=; p2=x-s3--azid; p3=; p4=; p5=" } } } - }, - + } // Limit 3 tests { - "documentation": "limit 3 exact match", - "params": { - "Input": "a--b--c", - "Delimiter": "--", - "Limit": "3" - }, - "expect": { - "endpoint": { - "url": "https://example.com", - "properties": { - "splitResult": "p1=a; p2=b; p3=c; p4=; p5=" - } + documentation: "limit 3 exact match" + params: { Input: "a--b--c", Delimiter: "--", Limit: "3" } + expect: { + endpoint: { + url: "https://example.com" + properties: { splitResult: "p1=a; p2=b; p3=c; p4=; p5=" } } } - }, - { - "documentation": "limit 3 with remainder", - "params": { - "Input": "a--b--c--d", - "Delimiter": "--", - "Limit": "3" - }, - "expect": { - "endpoint": { - "url": "https://example.com", - "properties": { - "splitResult": "p1=a; p2=b; p3=c--d; p4=; p5=" - } + } + { + documentation: "limit 3 with remainder" + params: { Input: "a--b--c--d", Delimiter: "--", Limit: "3" } + expect: { + endpoint: { + url: "https://example.com" + properties: { splitResult: "p1=a; p2=b; p3=c--d; p4=; p5=" } } } - }, - + } // Limit 4 tests { - "documentation": "S3 Express bucket pattern", - "params": { - "Input": "--x-s3--azid--suffix", - "Delimiter": "--", - "Limit": "4" - }, - "expect": { - "endpoint": { - "url": "https://example.com", - "properties": { - "splitResult": "p1=; p2=x-s3; p3=azid; p4=suffix; p5=" - } + documentation: "S3 Express bucket pattern" + params: { Input: "--x-s3--azid--suffix", Delimiter: "--", Limit: "4" } + expect: { + endpoint: { + url: "https://example.com" + properties: { splitResult: "p1=; p2=x-s3; p3=azid; p4=suffix; p5=" } } } - }, - { - "documentation": "limit 4 stops at 4 parts", - "params": { - "Input": "a--b--c--d--e", - "Delimiter": "--", - "Limit": "4" - }, - "expect": { - "endpoint": { - "url": "https://example.com", - "properties": { - "splitResult": "p1=a; p2=b; p3=c; p4=d--e; p5=" - } + } + { + documentation: "limit 4 stops at 4 parts" + params: { Input: "a--b--c--d--e", Delimiter: "--", Limit: "4" } + expect: { + endpoint: { + url: "https://example.com" + properties: { splitResult: "p1=a; p2=b; p3=c; p4=d--e; p5=" } } } - }, - + } // Unicode tests { - "documentation": "unicode emoji delimiter", - "params": { - "Input": "a🌟b🌟c", - "Delimiter": "🌟", - "Limit": "0" - }, - "expect": { - "endpoint": { - "url": "https://example.com", - "properties": { - "splitResult": "p1=a; p2=b; p3=c; p4=; p5=" - } + documentation: "unicode emoji delimiter" + params: { Input: "a🌟b🌟c", Delimiter: "🌟", Limit: "0" } + expect: { + endpoint: { + url: "https://example.com" + properties: { splitResult: "p1=a; p2=b; p3=c; p4=; p5=" } } } - }, - + } // Regex treated literally { - "documentation": "regex-like pattern treated literally", - "params": { - "Input": "a.*b.*c", - "Delimiter": ".*", - "Limit": "0" - }, - "expect": { - "endpoint": { - "url": "https://example.com", - "properties": { - "splitResult": "p1=a; p2=b; p3=c; p4=; p5=" - } + documentation: "regex-like pattern treated literally" + params: { Input: "a.*b.*c", Delimiter: ".*", Limit: "0" } + expect: { + endpoint: { + url: "https://example.com" + properties: { splitResult: "p1=a; p2=b; p3=c; p4=; p5=" } } } - }, - { - "documentation": "pipe delimiter", - "params": { - "Input": "a|b|c|d|e", - "Delimiter": "|", - "Limit": "0" - }, - "expect": { - "endpoint": { - "url": "https://example.com", - "properties": { - "splitResult": "p1=a; p2=b; p3=c; p4=d; p5=e" - } + } + { + documentation: "pipe delimiter" + params: { Input: "a|b|c|d|e", Delimiter: "|", Limit: "0" } + expect: { + endpoint: { + url: "https://example.com" + properties: { splitResult: "p1=a; p2=b; p3=c; p4=d; p5=e" } } } - }, - + } // Edge cases { - "documentation": "delimiter longer than input", - "params": { - "Input": "ab", - "Delimiter": "abcd", - "Limit": "0" - }, - "expect": { - "endpoint": { - "url": "https://example.com", - "properties": { - "splitResult": "p1=ab; p2=; p3=; p4=; p5=" - } + documentation: "delimiter longer than input" + params: { Input: "ab", Delimiter: "abcd", Limit: "0" } + expect: { + endpoint: { + url: "https://example.com" + properties: { splitResult: "p1=ab; p2=; p3=; p4=; p5=" } } } - }, - { - "documentation": "delimiter equals entire input", - "params": { - "Input": "abc", - "Delimiter": "abc", - "Limit": "0" - }, - "expect": { - "endpoint": { - "url": "https://example.com", - "properties": { - "splitResult": "p1=; p2=; p3=; p4=; p5=" - } + } + { + documentation: "delimiter equals entire input" + params: { Input: "abc", Delimiter: "abc", Limit: "0" } + expect: { + endpoint: { + url: "https://example.com" + properties: { splitResult: "p1=; p2=; p3=; p4=; p5=" } } } } ] ) @clientContextParams( - Input: {type: "string", documentation: "Input string to split"} - Delimiter: {type: "string", documentation: "Delimiter to split by"} - Limit: {type: "string", documentation: "Split limit"} + Input: { type: "string", documentation: "Input string to split" } + Delimiter: { type: "string", documentation: "Delimiter to split by" } + Limit: { type: "string", documentation: "Split limit" } ) @suppress(["UnstableTrait.smithy"]) service SplitTest {} diff --git a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/substring.smithy b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/substring.smithy index ad79f4aaf7f..f7a2108e2ff 100644 --- a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/substring.smithy +++ b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/substring.smithy @@ -8,267 +8,155 @@ use smithy.rules#endpointTests @suppress(["UnstableTrait"]) @endpointRuleSet({ - "version": "1.0", - "parameters": { - "TestCaseId": { - "type": "string", - "required": true, - "documentation": "Test case id used to select the test case to use" - }, - "Input": { - "type": "string", - "required": true, - "documentation": "the input used to test substring" - } - }, - "rules": [ - { - "documentation": "Substring from beginning of input", - "conditions": [ + version: "1.0" + parameters: { + TestCaseId: { type: "string", required: true, documentation: "Test case id used to select the test case to use" } + Input: { type: "string", required: true, documentation: "the input used to test substring" } + } + rules: [ + { + documentation: "Substring from beginning of input" + conditions: [ { - "fn": "stringEquals", - "argv": [ - "{TestCaseId}", - "1" - ] - }, + fn: "stringEquals" + argv: ["{TestCaseId}", "1"] + } { - "fn": "substring", - "argv": [ - "{Input}", - 0, - 4, - false - ], - "assign": "output" + fn: "substring" + argv: ["{Input}", 0, 4, false] + assign: "output" } - ], - "error": "The value is: `{output}`", - "type": "error" - }, + ] + error: "The value is: `{output}`" + type: "error" + } { - "documentation": "Substring from end of input", - "conditions": [ + documentation: "Substring from end of input" + conditions: [ { - "fn": "stringEquals", - "argv": [ - "{TestCaseId}", - "2" - ] - }, + fn: "stringEquals" + argv: ["{TestCaseId}", "2"] + } { - "fn": "substring", - "argv": [ - "{Input}", - 0, - 4, - true - ], - "assign": "output" + fn: "substring" + argv: ["{Input}", 0, 4, true] + assign: "output" } - ], - "error": "The value is: `{output}`", - "type": "error" - }, + ] + error: "The value is: `{output}`" + type: "error" + } { - "documentation": "Substring the middle of the string", - "conditions": [ + documentation: "Substring the middle of the string" + conditions: [ { - "fn": "stringEquals", - "argv": [ - "{TestCaseId}", - "3" - ] - }, + fn: "stringEquals" + argv: ["{TestCaseId}", "3"] + } { - "fn": "substring", - "argv": [ - "{Input}", - 1, - 3, - false - ], - "assign": "output" + fn: "substring" + argv: ["{Input}", 1, 3, false] + assign: "output" } - ], - "error": "The value is: `{output}`", - "type": "error" - }, + ] + error: "The value is: `{output}`" + type: "error" + } { - "documentation": "fallback when no tests match", - "conditions": [], - "error": "No tests matched", - "type": "error" + documentation: "fallback when no tests match" + conditions: [] + error: "No tests matched" + type: "error" } ] }) @endpointTests( - version: "1.0", + version: "1.0" testCases: [ { - "documentation": "substring when string is long enough", - "params": { - "TestCaseId": "1", - "Input": "abcdefg" - }, - "expect": { - "error": "The value is: `abcd`" - } - }, + documentation: "substring when string is long enough" + params: { TestCaseId: "1", Input: "abcdefg" } + expect: { error: "The value is: `abcd`" } + } { - "documentation": "substring when string is exactly the right length", - "params": { - "TestCaseId": "1", - "Input": "abcd" - }, - "expect": { - "error": "The value is: `abcd`" - } - }, + documentation: "substring when string is exactly the right length" + params: { TestCaseId: "1", Input: "abcd" } + expect: { error: "The value is: `abcd`" } + } { - "documentation": "substring when string is too short", - "params": { - "TestCaseId": "1", - "Input": "abc" - }, - "expect": { - "error": "No tests matched" - } - }, + documentation: "substring when string is too short" + params: { TestCaseId: "1", Input: "abc" } + expect: { error: "No tests matched" } + } { - "documentation": "substring when string is too short", - "params": { - "TestCaseId": "1", - "Input": "" - }, - "expect": { - "error": "No tests matched" - } - }, + documentation: "substring when string is too short" + params: { TestCaseId: "1", Input: "" } + expect: { error: "No tests matched" } + } { - "documentation": "substring on wide characters (ensure that unicode code points are properly counted)", - "params": { - "TestCaseId": "1", - "Input": "\ufdfd" - }, - "expect": { - "error": "No tests matched" - } - }, + documentation: "substring on wide characters (ensure that unicode code points are properly counted)" + params: { TestCaseId: "1", Input: "\ufdfd" } + expect: { error: "No tests matched" } + } { - "documentation": "the full set of ascii is supported, including non-printable characters", - "params": { - "TestCaseId": "1", - "Input": "\u007Fabcdef" - }, - "expect": { - "error": "The value is: `\u007Fabc`" - } - }, + documentation: "the full set of ascii is supported, including non-printable characters" + params: { TestCaseId: "1", Input: "\u007Fabcdef" } + expect: { error: "The value is: `\u007Fabc`" } + } { - "documentation": "substring when string is long enough", - "params": { - "TestCaseId": "2", - "Input": "abcdefg" - }, - "expect": { - "error": "The value is: `defg`" - } - }, + documentation: "substring when string is long enough" + params: { TestCaseId: "2", Input: "abcdefg" } + expect: { error: "The value is: `defg`" } + } { - "documentation": "substring when string is exactly the right length", - "params": { - "TestCaseId": "2", - "Input": "defg" - }, - "expect": { - "error": "The value is: `defg`" - } - }, + documentation: "substring when string is exactly the right length" + params: { TestCaseId: "2", Input: "defg" } + expect: { error: "The value is: `defg`" } + } { - "documentation": "substring when string is too short", - "params": { - "TestCaseId": "2", - "Input": "abc" - }, - "expect": { - "error": "No tests matched" - } - }, + documentation: "substring when string is too short" + params: { TestCaseId: "2", Input: "abc" } + expect: { error: "No tests matched" } + } { - "documentation": "substring when string is too short", - "params": { - "TestCaseId": "2", - "Input": "" - }, - "expect": { - "error": "No tests matched" - } - }, + documentation: "substring when string is too short" + params: { TestCaseId: "2", Input: "" } + expect: { error: "No tests matched" } + } { - "documentation": "substring on wide characters (ensure that unicode code points are properly counted)", - "params": { - "TestCaseId": "2", - "Input": "\ufdfd" - }, - "expect": { - "error": "No tests matched" - } - }, + documentation: "substring on wide characters (ensure that unicode code points are properly counted)" + params: { TestCaseId: "2", Input: "\ufdfd" } + expect: { error: "No tests matched" } + } { - "documentation": "substring when string is longer", - "params": { - "TestCaseId": "3", - "Input": "defg" - }, - "expect": { - "error": "The value is: `ef`" - } - }, + documentation: "substring when string is longer" + params: { TestCaseId: "3", Input: "defg" } + expect: { error: "The value is: `ef`" } + } { - "documentation": "substring when string is exact length", - "params": { - "TestCaseId": "3", - "Input": "def" - }, - "expect": { - "error": "The value is: `ef`" - } - }, + documentation: "substring when string is exact length" + params: { TestCaseId: "3", Input: "def" } + expect: { error: "The value is: `ef`" } + } { - "documentation": "substring when string is too short", - "params": { - "TestCaseId": "3", - "Input": "ab" - }, - "expect": { - "error": "No tests matched" - } - }, + documentation: "substring when string is too short" + params: { TestCaseId: "3", Input: "ab" } + expect: { error: "No tests matched" } + } { - "documentation": "substring when string is too short", - "params": { - "TestCaseId": "3", - "Input": "" - }, - "expect": { - "error": "No tests matched" - } - }, + documentation: "substring when string is too short" + params: { TestCaseId: "3", Input: "" } + expect: { error: "No tests matched" } + } { - "documentation": "substring on wide characters (ensure that unicode code points are properly counted)", - "params": { - "TestCaseId": "3", - "Input": "\ufdfd" - }, - "expect": { - "error": "No tests matched" - } + documentation: "substring on wide characters (ensure that unicode code points are properly counted)" + params: { TestCaseId: "3", Input: "\ufdfd" } + expect: { error: "No tests matched" } } ] ) @clientContextParams( - TestCaseId: {type: "string", documentation: "docs"} - Input: {type: "string", documentation: "docs"} + TestCaseId: { type: "string", documentation: "docs" } + Input: { type: "string", documentation: "docs" } ) service SubstringService {} diff --git a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/url-encode.smithy b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/url-encode.smithy index 149bd1a2bc6..a232730a03a 100644 --- a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/url-encode.smithy +++ b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/url-encode.smithy @@ -8,126 +8,85 @@ use smithy.rules#endpointTests @suppress(["UnstableTrait"]) @endpointRuleSet({ - "version": "1.0", - "parameters": { - "TestCaseId": { - "type": "string", - "required": true, - "documentation": "Test case id used to select the test case to use" - }, - "Input": { - "type": "string", - "required": true, - "documentation": "The input used to test uriEncode" - } - }, - "rules": [ + version: "1.0" + parameters: { + TestCaseId: { type: "string", required: true, documentation: "Test case id used to select the test case to use" } + Input: { type: "string", required: true, documentation: "The input used to test uriEncode" } + } + rules: [ { - "documentation": "uriEncode on input", - "conditions": [ + documentation: "uriEncode on input" + conditions: [ { - "fn": "stringEquals", - "argv": [ - "{TestCaseId}", - "1" - ] - }, + fn: "stringEquals" + argv: ["{TestCaseId}", "1"] + } { - "fn": "uriEncode", - "argv": [ - "{Input}" - ], - "assign": "output" + fn: "uriEncode" + argv: ["{Input}"] + assign: "output" } - ], - "error": "The value is: `{output}`", - "type": "error" - }, + ] + error: "The value is: `{output}`" + type: "error" + } { - "documentation": "fallback when no tests match", - "conditions": [], - "error": "No tests matched", - "type": "error" + documentation: "fallback when no tests match" + conditions: [] + error: "No tests matched" + type: "error" } ] }) @endpointTests( - version: "1.0", + version: "1.0" testCases: [ { - "documentation": "uriEncode when the string has nothing to encode returns the input", - "params": { - "TestCaseId": "1", - "Input": "abcdefg" - }, - "expect": { - "error": "The value is: `abcdefg`" - } - }, + documentation: "uriEncode when the string has nothing to encode returns the input" + params: { TestCaseId: "1", Input: "abcdefg" } + expect: { error: "The value is: `abcdefg`" } + } { - "documentation": "uriEncode with single character to encode encodes only that character", - "params": { - "TestCaseId": "1", - "Input": "abc:defg" - }, - "expect": { - "error": "The value is: `abc%3Adefg`" - } - }, + documentation: "uriEncode with single character to encode encodes only that character" + params: { TestCaseId: "1", Input: "abc:defg" } + expect: { error: "The value is: `abc%3Adefg`" } + } { - "documentation": "uriEncode with all ASCII characters to encode encodes all characters", - "params": { - "TestCaseId": "1", - "Input": "/:,?#[]{}|@! $&'()*+;=%<>\"^`\\" - }, - "expect": { - "error": "The value is: `%2F%3A%2C%3F%23%5B%5D%7B%7D%7C%40%21%20%24%26%27%28%29%2A%2B%3B%3D%25%3C%3E%22%5E%60%5C`" + documentation: "uriEncode with all ASCII characters to encode encodes all characters" + params: { TestCaseId: "1", Input: "/:,?#[]{}|@! $&'()*+;=%<>\"^`\\" } + expect: { + error: "The value is: `%2F%3A%2C%3F%23%5B%5D%7B%7D%7C%40%21%20%24%26%27%28%29%2A%2B%3B%3D%25%3C%3E%22%5E%60%5C`" } - }, + } { - "documentation": "uriEncode with ASCII characters that should not be encoded returns the input", - "params": { - "TestCaseId": "1", - "Input": "0123456789.underscore_dash-Tilda~" - }, - "expect": { - "error": "The value is: `0123456789.underscore_dash-Tilda~`" - } - }, + documentation: "uriEncode with ASCII characters that should not be encoded returns the input" + params: { TestCaseId: "1", Input: "0123456789.underscore_dash-Tilda~" } + expect: { error: "The value is: `0123456789.underscore_dash-Tilda~`" } + } { - "documentation": "uriEncode encodes unicode characters", - "params": { - "TestCaseId": "1", - "Input": "\ud83d\ude39" - }, - "expect": { - "error": "The value is: `%F0%9F%98%B9`" - } - }, + documentation: "uriEncode encodes unicode characters" + params: { TestCaseId: "1", Input: "\ud83d\ude39" } + expect: { error: "The value is: `%F0%9F%98%B9`" } + } { - "documentation": "uriEncode on all printable ASCII characters", - "params": { - "TestCaseId": "1", - "Input": " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~" - }, - "expect": { - "error": "The value is: `%20%21%22%23%24%25%26%27%28%29%2A%2B%2C-.%2F0123456789%3A%3B%3C%3D%3E%3F%40ABCDEFGHIJKLMNOPQRSTUVWXYZ%5B%5C%5D%5E_%60abcdefghijklmnopqrstuvwxyz%7B%7C%7D~`" + documentation: "uriEncode on all printable ASCII characters" + params: { + TestCaseId: "1" + Input: " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~" } - }, - { - "documentation": "uriEncode on an empty string", - "params": { - "TestCaseId": "1", - "Input": "" - }, - "expect": { - "error": "The value is: ``" + expect: { + error: "The value is: `%20%21%22%23%24%25%26%27%28%29%2A%2B%2C-.%2F0123456789%3A%3B%3C%3D%3E%3F%40ABCDEFGHIJKLMNOPQRSTUVWXYZ%5B%5C%5D%5E_%60abcdefghijklmnopqrstuvwxyz%7B%7C%7D~`" } } + { + documentation: "uriEncode on an empty string" + params: { TestCaseId: "1", Input: "" } + expect: { error: "The value is: ``" } + } ] ) @clientContextParams( - TestCaseId: {type: "string", documentation: "Test case id used to select the test case to use"}, - Input: {type: "string", documentation: "The input used to test uriEncoder"} + TestCaseId: { type: "string", documentation: "Test case id used to select the test case to use" } + Input: { type: "string", documentation: "The input used to test uriEncoder" } ) service UrlEncodeService {} diff --git a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/valid-hostlabel.smithy b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/valid-hostlabel.smithy index c6e8a7fe152..15e1dd532d5 100644 --- a/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/valid-hostlabel.smithy +++ b/smithy-rules-engine-tests/src/main/resources/META-INF/smithy/valid-hostlabel.smithy @@ -8,143 +8,103 @@ use smithy.rules#endpointTests @suppress(["UnstableTrait"]) @endpointRuleSet({ - "version": "1.0", - "parameters": { - "Region": { - "type": "string", - "required": true, - "documentation": "The region to dispatch this request, eg. `us-east-1`." - } - }, - "rules": [ + version: "1.0" + parameters: { + Region: { type: "string", required: true, documentation: "The region to dispatch this request, eg. `us-east-1`." } + } + rules: [ { - "documentation": "Template the region into the URI when region is set", - "conditions": [ + documentation: "Template the region into the URI when region is set" + conditions: [ { - "fn": "isValidHostLabel", - "argv": [ + fn: "isValidHostLabel" + argv: [ { - "ref": "Region" - }, + ref: "Region" + } false ] } - ], - "endpoint": { - "url": "https://{Region}.amazonaws.com" - }, - "type": "endpoint" - }, + ] + endpoint: { url: "https://{Region}.amazonaws.com" } + type: "endpoint" + } { - "documentation": "Template the region into the URI when region is set", - "conditions": [ + documentation: "Template the region into the URI when region is set" + conditions: [ { - "fn": "isValidHostLabel", - "argv": [ + fn: "isValidHostLabel" + argv: [ { - "ref": "Region" - }, + ref: "Region" + } true ] } - ], - "endpoint": { - "url": "https://{Region}-subdomains.amazonaws.com" - }, - "type": "endpoint" - }, + ] + endpoint: { url: "https://{Region}-subdomains.amazonaws.com" } + type: "endpoint" + } { - "documentation": "Region was not a valid host label", - "conditions": [], - "error": "Invalid hostlabel", - "type": "error" + documentation: "Region was not a valid host label" + conditions: [] + error: "Invalid hostlabel" + type: "error" } ] }) @endpointTests( - version: "1.0", + version: "1.0" testCases: [ { - "documentation": "standard region is a valid hostlabel", - "params": { - "Region": "us-east-1" - }, - "expect": { - "endpoint": { - "url": "https://us-east-1.amazonaws.com" - } + documentation: "standard region is a valid hostlabel" + params: { Region: "us-east-1" } + expect: { + endpoint: { url: "https://us-east-1.amazonaws.com" } } - }, + } { - "documentation": "starting with a number is a valid hostlabel", - "params": { - "Region": "3aws4" - }, - "expect": { - "endpoint": { - "url": "https://3aws4.amazonaws.com" - } + documentation: "starting with a number is a valid hostlabel" + params: { Region: "3aws4" } + expect: { + endpoint: { url: "https://3aws4.amazonaws.com" } } - }, + } { - "documentation": "when there are dots, only match if subdomains are allowed", - "params": { - "Region": "part1.part2" - }, - "expect": { - "endpoint": { - "url": "https://part1.part2-subdomains.amazonaws.com" - } + documentation: "when there are dots, only match if subdomains are allowed" + params: { Region: "part1.part2" } + expect: { + endpoint: { url: "https://part1.part2-subdomains.amazonaws.com" } } - }, + } { - "documentation": "a space is never a valid hostlabel", - "params": { - "Region": "part1 part2" - }, - "expect": { - "error": "Invalid hostlabel" - } - }, + documentation: "a space is never a valid hostlabel" + params: { Region: "part1 part2" } + expect: { error: "Invalid hostlabel" } + } { - "documentation": "an empty string is not a valid hostlabel", - "params": { - "Region": "" - }, - "expect": { - "error": "Invalid hostlabel" - } - }, + documentation: "an empty string is not a valid hostlabel" + params: { Region: "" } + expect: { error: "Invalid hostlabel" } + } { - "documentation": "ending with a dot is not a valid hostlabel", - "params": { - "Region": "part1." - }, - "expect": { - "error": "Invalid hostlabel" - } - }, + documentation: "ending with a dot is not a valid hostlabel" + params: { Region: "part1." } + expect: { error: "Invalid hostlabel" } + } { - "documentation": "multiple consecutive dots are not allowed", - "params": { - "Region": "part1..part2" - }, - "expect": { - "error": "Invalid hostlabel" - } - }, + documentation: "multiple consecutive dots are not allowed" + params: { Region: "part1..part2" } + expect: { error: "Invalid hostlabel" } + } { - "documentation": "labels cannot start with a dash", - "params": { - "Region": "part1.-part2" - }, - "expect": { - "error": "Invalid hostlabel" - } + documentation: "labels cannot start with a dash" + params: { Region: "part1.-part2" } + expect: { error: "Invalid hostlabel" } } ] ) @clientContextParams( - Region: {type: "string", documentation: "docs"} + Region: { type: "string", documentation: "docs" } ) service ValidHostLabelService {}