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.07k stars 473 forks source link

VersionedPactUrlLoader does not seem to support use of Auth #1791

Closed gleithall closed 1 month ago

gleithall commented 2 months ago

I have been trying to create tests to be run when the contract_requiring_verification_published event is published by the Pact Broker.

I believe I need to create tests that receive information about the specific Pact to be verified, probably the Pact URL.

The PactUrl annotation seems to require a hardcoded URL, which won't work for this use case, so I have been looking at the VersionedPactUrl annotation.

From my experiments, and looking at the code, it seems that the auth value provided to the VersionedPactUrl annotation gets ignored by the VersionedPactUrlLoader.

In particular I have tried debugging

I notice that this code was written nearly four years, so I wonder

rholshausen commented 1 month ago

VersionedPactUrlLoader was for a specific use, where you have a static URL and just need to replace a version in the URL each time.

The proper way to do it is add @AllowOverridePactUrl to your test, then set the pact.filter.pacturl JVM property or environment variable with the URL from the webhook call. That property will need to be set on the test JVM, not the build tool JVM.

gleithall commented 1 month ago

Thank you for answering this question, @rholshausen. This makes a lot of sense, so I think this issue can be closed.