Merge pull request #10999 from RasmusWL/inline-fail-tag

InlineExpectationsTest: Fail if missing `getARelevantTag`
This commit is contained in:
Rasmus Wriedt Larsen
2022-10-28 10:35:49 +02:00
committed by GitHub
18 changed files with 126 additions and 17 deletions

View File

@@ -137,6 +137,7 @@ abstract class InlineExpectationsTest extends string {
final predicate hasFailureMessage(FailureLocatable element, string message) {
exists(ActualResult actualResult |
actualResult.getTest() = this and
actualResult.getTag() = this.getARelevantTag() and
element = actualResult and
(
exists(FalseNegativeExpectation falseNegative |
@@ -150,9 +151,18 @@ abstract class InlineExpectationsTest extends string {
)
)
or
exists(ActualResult actualResult |
actualResult.getTest() = this and
not actualResult.getTag() = this.getARelevantTag() and
element = actualResult and
message =
"Tag mismatch: Actual result with tag '" + actualResult.getTag() +
"' that is not part of getARelevantTag()"
)
or
exists(ValidExpectation expectation |
not exists(ActualResult actualResult | expectation.matchesActualResult(actualResult)) and
expectation.getTag() = getARelevantTag() and
expectation.getTag() = this.getARelevantTag() and
element = expectation and
(
expectation instanceof GoodExpectation and

View File

@@ -41,7 +41,7 @@ public class JakartaRs1 { // $ RootResourceClass
@Produces("text/plain") // $ ProducesAnnotation=text/plain
@DELETE
double Delete() { // $ ResourceMethod=text/plain ResourceMethodOnResourceClass
return 0.0; // $ XssSink
return 0.0;
}
@Produces(MediaType.TEXT_HTML) // $ ProducesAnnotation=text/html
@@ -77,7 +77,7 @@ public class JakartaRs1 { // $ RootResourceClass
@Produces(MediaType.TEXT_PLAIN) // $ ProducesAnnotation=text/plain
@DELETE
double Delete() { // $ ResourceMethod=text/plain ResourceMethodOnResourceClass
return 0.0; // $ XssSink
return 0.0;
}
@Path("")

View File

@@ -14,7 +14,7 @@ class JaxRsTest extends InlineExpectationsTest {
"InjectionAnnotation", "ResponseDeclaration", "ResponseBuilderDeclaration",
"ClientDeclaration", "BeanParamConstructor", "MessageBodyReaderDeclaration",
"MessageBodyReaderReadFromCall", "MessageBodyReaderReadCall", "ProducesAnnotation",
"ConsumesAnnotation"
"ConsumesAnnotation", "XssSink"
]
}

View File

@@ -41,7 +41,7 @@ public class JaxRs1 { // $ RootResourceClass
@Produces("text/plain") // $ ProducesAnnotation=text/plain
@DELETE
double Delete() { // $ ResourceMethod=text/plain ResourceMethodOnResourceClass
return 0.0; // $ XssSink
return 0.0;
}
@Produces(MediaType.TEXT_HTML) // $ ProducesAnnotation=text/html
@@ -77,7 +77,7 @@ public class JaxRs1 { // $ RootResourceClass
@Produces(MediaType.TEXT_PLAIN) // $ ProducesAnnotation=text/plain
@DELETE
double Delete() { // $ ResourceMethod=text/plain ResourceMethodOnResourceClass
return 0.0; // $ XssSink
return 0.0;
}
@Path("")