pact-foundation / pact-jvm

JVM version of Pact. Enables consumer driven contract testing, providing a mock service and DSL for the consumer project, and interaction playback and verification for the service provider project.
https://docs.pact.io
Apache License 2.0
1.08k stars 479 forks source link

Getting au.com.dius.pact.pactbroker.RequestFailedException: Request to path '/' failed with response 'HTTP/1.1 401 Unauthorized' #1418

Open jigarnprajapati opened 3 years ago

jigarnprajapati commented 3 years ago

I'm fairly new to pact and I am trying to validate a pact that was published by the consumer on our pactbroker which is hosted on dius.

I do it with the pact-jvm-provider-spring_2.12, and I was able to successfully validate the pact when I use postman or curl same basic auth cred

However, when I now try to use junit4 i get below error

au.com.dius.pact.pactbroker.RequestFailedException: Request to path '/' failed with response 'HTTP/1.1 401 Unauthorized'"

@PactBroker( host="myorg.pact.dius.com.au", port="443", scheme = "https", authentication = @PactBrokerAuth(username = "foo@bar.com", password = "foobar") )

JapuDCret commented 3 years ago

What version of the Pact provider dependency are you using?


Just a thought: You could also try setting the respective System properties to try to achieve your wanted behavior, so

FYI: I am no Pact dev or guru, just trying to help

uglyog commented 3 years ago

pact-jvm-provider-spring_2.12 is a very old version of Pact-JVM, and it does not support bearer token authentication which is required to access a Pactflow broker.

Can you upgrade to either au.com.dius.pact.provider:spring:4.1.25 or au.com.dius.pact.provider:spring:4.2.10 (JDK 11+) and use a user token instead of username/password?