diff --git a/smithy-rules-engine/src/main/java/software/amazon/smithy/rulesengine/traits/EndpointTestsTraitValidator.java b/smithy-rules-engine/src/main/java/software/amazon/smithy/rulesengine/traits/EndpointTestsTraitValidator.java index 1761769ee81..bb13da282ca 100644 --- a/smithy-rules-engine/src/main/java/software/amazon/smithy/rulesengine/traits/EndpointTestsTraitValidator.java +++ b/smithy-rules-engine/src/main/java/software/amazon/smithy/rulesengine/traits/EndpointTestsTraitValidator.java @@ -61,13 +61,14 @@ public List validate(Model model) { testOperationInput); // Error test cases may use invalid inputs as the mechanism to trigger their error, - // so lower the severity before emitting. - if (testCase.getExpect().getError().isPresent()) { - for (ValidationEvent event : operationInputEvents) { - events.add(event.toBuilder().severity(Severity.WARNING).build()); + // so lower the severity before emitting. All other events here should be raised to + // DANGER level as well. + for (ValidationEvent event : operationInputEvents) { + if (event.getSeverity() == Severity.WARNING + || event.getSeverity() == Severity.NOTE + || testCase.getExpect().getError().isPresent()) { + events.add(event.toBuilder().severity(Severity.DANGER).build()); } - } else { - events.addAll(operationInputEvents); } } } diff --git a/smithy-rules-engine/src/test/resources/software/amazon/smithy/rulesengine/traits/errorfiles/missing-input-target.errors b/smithy-rules-engine/src/test/resources/software/amazon/smithy/rulesengine/traits/errorfiles/missing-input-target.errors new file mode 100644 index 00000000000..f9e9d70d1a4 --- /dev/null +++ b/smithy-rules-engine/src/test/resources/software/amazon/smithy/rulesengine/traits/errorfiles/missing-input-target.errors @@ -0,0 +1,2 @@ +[WARNING] smithy.example#InvalidService: This shape applies a trait that is unstable: smithy.rules#endpointTests | UnstableTrait +[DANGER] smithy.example#InvalidService: The operationInput value for an endpoint test does not match the operation's input shape: Invalid structure member `fizz` found for `smithy.example#GetThingInput` | EndpointTestsTrait.smithy.example#GetThingInput.fizz diff --git a/smithy-rules-engine/src/test/resources/software/amazon/smithy/rulesengine/traits/errorfiles/missing-input-target.smithy b/smithy-rules-engine/src/test/resources/software/amazon/smithy/rulesengine/traits/errorfiles/missing-input-target.smithy new file mode 100644 index 00000000000..6e12707603d --- /dev/null +++ b/smithy-rules-engine/src/test/resources/software/amazon/smithy/rulesengine/traits/errorfiles/missing-input-target.smithy @@ -0,0 +1,45 @@ +$version: "2.0" + +namespace smithy.example + +use smithy.rules#endpointTests + +service InvalidService { + version: "2022-01-01" + operations: [ + GetThing + ] +} + +apply InvalidService @endpointTests({ + version: "1.0" + testCases: [ + { + params: { stringFoo: "c d", boolFoo: true } + operationInputs: [ + { + operationName: "GetThing" + operationParams: { fizz: "something", buzz: "a buzz value" } + } + ] + expect: { + endpoint: { + url: "https://example.com" + properties: {} + headers: { + single: ["foo"] + multi: ["foo", "bar", "baz"] + } + } + } + } + ] +}) + +@readonly +operation GetThing { + input := { + buzz: String + fuzz: String + } +} diff --git a/smithy-rules-engine/src/test/resources/software/amazon/smithy/rulesengine/traits/errorfiles/missing-required-values.errors b/smithy-rules-engine/src/test/resources/software/amazon/smithy/rulesengine/traits/errorfiles/missing-required-values.errors index 687a07963e4..dbcbbfdc7f1 100644 --- a/smithy-rules-engine/src/test/resources/software/amazon/smithy/rulesengine/traits/errorfiles/missing-required-values.errors +++ b/smithy-rules-engine/src/test/resources/software/amazon/smithy/rulesengine/traits/errorfiles/missing-required-values.errors @@ -1,2 +1,2 @@ [WARNING] smithy.example#InvalidService: This shape applies a trait that is unstable: smithy.rules#endpointTests | UnstableTrait -[WARNING] smithy.example#InvalidService: The operationInput value for an endpoint test does not match the operation's input shape: Missing required structure member `fizz` for `smithy.example#GetThingInput` | EndpointTestsTrait +[DANGER] smithy.example#InvalidService: The operationInput value for an endpoint test does not match the operation's input shape: Missing required structure member `fizz` for `smithy.example#GetThingInput` | EndpointTestsTrait