Open misko321 opened 8 months ago
How are you setting the username and password?
How are you setting the username and password?
I'm running tests with Spring, so in the test I have:
@ExtendWith(SpringExtension.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT)
@Provider("some-provider-name")
@PactBroker
class ClassUnderTest {
...
}
and the properties for the @PactBroker
annotation are read from application.yaml:
pactbroker:
url: ${PACT_BROKER_URL:http://localhost:9292}
auth:
username: ${PACT_BROKER_USERNAME:pact}
password: ${PACT_BROKER_PASSWORD:pact}
Nothing more. All these properties are read fine and everything works okay when usePreemptiveAuthentication=false
.
4.6.6 has been released with a fix for this
usePreemptiveAuthentication property doesn't work as expected
Steps to reproduce:
pact.pactbroker.httpclient.usePreemptiveAuthentication="true"
Results:
I think the crucial logs are:
which confirms, that the property was read correctly and:
which tells that the underlying Apache HTTP client doesn't use the username and password set in Pact config (or it expects to find the credentials for this particular thing in other place than Pact sets).
Same thing happens if I use a remotely deployed Pact Broker and not the one running on a localhost, so that's not the reason here.
If the property is set to false, then the non-preemptive flow is executed correctly and the username and password are used just fine in the second try, so they are loaded correctly.
Dependency used:
au.com.dius.pact.provider:junit5spring:4.6.5
(the latest as of today)Excerpt from logs: