MessageBuilderSupport should not silently pass a failing check even if isSpringInternalHeader is true
Opened this issue · 0 comments
novarx commented
Citrus Version
4.2.1
Expected behavior
The Test should fail.
- Either because the headers are obviously not the same
- Or because some headers are explicitly not allowed for testing
@Test
public class OpenApiClientIT extends TestNGCitrusSpringSupport {
private final int port = SocketUtils.findAvailableTcpPort(8080);
@BindToRegistry
private final HttpServer httpServer = new HttpServerBuilder()
.port(port)
.timeout(5000L)
.autoStart(true)
.defaultStatus(HttpStatus.NO_CONTENT)
.build();
@BindToRegistry
private final HttpClient httpClient = new HttpClientBuilder()
.requestUrl("http://localhost:%d".formatted(port))
.build();
private final OpenApiSpecification petstoreSpec = OpenApiSpecification.from(
Resources.create("classpath:org/citrusframework/openapi/petstore/petstore-v3.json"));
@CitrusTest
public void getPetById() {
variable("petId", "1001");
when(openapi(petstoreSpec)
.client(httpClient)
.send("getPetById")
.fork(true)
.message()
// ⏩ header is set here
.header("correlationId", "my-correlation-id")
);
then(http().server(httpServer)
.receive()
.get("/pet/1001")
.message()
// TODO BUG? - cannot check correlationId
// see: org/citrusframework/validation/DefaultMessageHeaderValidator.java:68
// see: org.citrusframework.message.MessageHeaderUtils.isSpringInternalHeader
// ⏩ this check should fail, but it does not 😱
.header("correlationId", "NOT-my-correlation-id")
);
then(http().server(httpServer)
.send()
.response(HttpStatus.OK)
.message()
.body(Resources.create("classpath:org/citrusframework/openapi/petstore/pet.json"))
.contentType("application/json"));
then(openapi(petstoreSpec)
.client(httpClient)
.receive("getPetById", HttpStatus.OK));
}
}
Actual behavior
The test does not fail.
Test case sample
See: Expected behaviour