Skip to content

Commit f8449f8

Browse files
committed
Increase severity for endpoint test NVV validation
This commit increases the validation event severity, from WARNING to DANGER, for cases where the input to an operationInputs endpoint test does not match the requirements of the input shape. There does not appear to be a use case for this behavior and it is believed that this was mistakenly lowered from ERROR to WARNING in a previous commit. It is increased only to DANGER to allow for a suppression in cases we do not foresee.
1 parent bed9664 commit f8449f8

4 files changed

Lines changed: 55 additions & 7 deletions

File tree

smithy-rules-engine/src/main/java/software/amazon/smithy/rulesengine/traits/EndpointTestsTraitValidator.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,14 @@ public List<ValidationEvent> validate(Model model) {
6161
testOperationInput);
6262

6363
// Error test cases may use invalid inputs as the mechanism to trigger their error,
64-
// so lower the severity before emitting.
65-
if (testCase.getExpect().getError().isPresent()) {
66-
for (ValidationEvent event : operationInputEvents) {
67-
events.add(event.toBuilder().severity(Severity.WARNING).build());
64+
// so lower the severity before emitting. All other events here should be raised to
65+
// DANGER level as well.
66+
for (ValidationEvent event : operationInputEvents) {
67+
if (event.getSeverity() == Severity.WARNING
68+
|| event.getSeverity() == Severity.NOTE
69+
|| testCase.getExpect().getError().isPresent()) {
70+
events.add(event.toBuilder().severity(Severity.DANGER).build());
6871
}
69-
} else {
70-
events.addAll(operationInputEvents);
7172
}
7273
}
7374
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[WARNING] smithy.example#InvalidService: This shape applies a trait that is unstable: smithy.rules#endpointTests | UnstableTrait
2+
[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
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
$version: "2.0"
2+
3+
namespace smithy.example
4+
5+
use smithy.rules#endpointTests
6+
7+
service InvalidService {
8+
version: "2022-01-01"
9+
operations: [
10+
GetThing
11+
]
12+
}
13+
14+
apply InvalidService @endpointTests({
15+
version: "1.0"
16+
testCases: [
17+
{
18+
params: { stringFoo: "c d", boolFoo: true }
19+
operationInputs: [
20+
{
21+
operationName: "GetThing"
22+
operationParams: { fizz: "something", buzz: "a buzz value" }
23+
}
24+
]
25+
expect: {
26+
endpoint: {
27+
url: "https://example.com"
28+
properties: {}
29+
headers: {
30+
single: ["foo"]
31+
multi: ["foo", "bar", "baz"]
32+
}
33+
}
34+
}
35+
}
36+
]
37+
})
38+
39+
@readonly
40+
operation GetThing {
41+
input := {
42+
buzz: String
43+
fuzz: String
44+
}
45+
}
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
[WARNING] smithy.example#InvalidService: This shape applies a trait that is unstable: smithy.rules#endpointTests | UnstableTrait
2-
[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
2+
[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

0 commit comments

Comments
 (0)