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.09k stars 480 forks source link

Authentication using bearer toker #1378

Closed naushadamin closed 3 years ago

naushadamin commented 3 years ago

Pack documentation states the following way to pass bearer token using Junit:

@PactBroker(host = "${pactbroker.url:localhost}", port = "1234", tags = {"latest", "prod", "dev"},
  authentication = @PactBrokerAuth(token = "test"))

However, the javadoc doesn't mention the token attribute nor is it available in the source. How do I pass bearer token as a provider to verify Pact?

mefellows commented 3 years ago

https://docs.pactflow.io/#java--junit-5

Note the open source pact broker doesn't support bearer tokens, only Pactflow (unless if course you've added your own security on top).

uglyog commented 3 years ago

What version are you using? Token support was added in 4.0.2.

naushadamin commented 3 years ago

Thanks! I was able to access contract using bearer token with 4.0.10. PactBroker verification failed and it was expected. I was hoping to see a track/record/audit of failed verification in Pactflow. However, the UI shows it as Never. Is that expected?

mefellows commented 3 years ago

You need to enable publishing of verification results. Please consult the docs for how to do this for your specific situation.

e.g. https://docs.pact.io/implementation_guides/jvm/provider/gradle/#3-execute-gradle-pactverify