I'm using spring cloud contracts to generate contract test on producer side. The producer is a resource server protected with oauth2 jwt token. When I run the test it fails with 401 http error.
In the conract I specify this
headers:
Authorization: Bearer some.jwt.token
When I generate test I have this
WebTestClientRequestSpecification request = given()
.header("Authorization", "Bearer some.jwt.token")
This is my base contract class
@BeforeEach
public void setup() {
RestAssuredWebTestClient.applicationContextSetup(applicationContext);
RestAssuredWebTestClient.webTestClient(webTestClient
.mutateWith(mockJwt().jwt(jwt -> jwt.claim("test", "prova"))));
}
If I manually remove the header from generated test it works well, but this configuration override the one specified in "mutateWith()". Is there a way to say to contract to ignore header in order do remove it in the generated code? Otherwise, can I specify a mock jwt in contracts?