Laith
11/15/2022, 4:17 PMLaith
11/15/2022, 4:18 PM@TestTemplate
@ExtendWith(PactVerificationInvocationContextProvider.class)
void testTemplate(PactVerificationContext context, HttpRequest request) {
String encodedUsernameAndPassword = Base64.getEncoder().encodeToString("user:password".getBytes());
request.addHeader("Authorization", "Basic " + encodedUsernameAndPassword);
context.verifyInteraction();
}
The headers that are actually sent - note the Authorization header is not present:
Content-Type: application/json
Accept: application/hal+json, application/json
Host: localhost:9292
Connection: Keep-Alive
User-Agent: Apache-HttpClient/4.5.6 (Java/11.0.16.1)
Accept-Encoding: gzip,deflate
The error I get when I run the test:
[ERROR] testTemplate{PactVerificationContext, HttpRequest} Time elapsed: 0.989 s <<< ERROR!
au.com.dius.pact.core.pactbroker.InvalidNavigationRequest: Failed to fetch the root HAL document
Caused by: au.com.dius.pact.core.pactbroker.RequestFailedException: Request to path '/' failed with response 'HTTP/1.1 401 Unauthorized'
Matt (pactflow.io / pact-js / pact-go)
I’m trying to modify the request sent to the pact brokerthis is not a thing. Do you mean request to the provider? The pact broker just hosts the pact files. No testing happens against the broker
Matt (pactflow.io / pact-js / pact-go)
Matt (pactflow.io / pact-js / pact-go)
Matt (pactflow.io / pact-js / pact-go)
Laith
11/16/2022, 9:08 AM