0

I have a pact published on a pact broker, and I need now to verify it with the provider. I started by using the pact-cli on a docker image, and using pact-provider-verifier I can connect to the provider box but verification fails because the broker request does not carry a Bearer token. I could not find a way to include token to the request using pact-provider-verifier, so I went to using Rake. I installed Rake and gem, run rake pact:verify — and I saw the possibility to pass a token towards the provider — but test fails because in the config I should — it seems — define my ‘app’ but I have no idea why app I should define. Questions I have are:

  • is there a way to pass bearer token towards the provider using pact-provider-verifier?
  • if not, how do I exactly configure Rake to hit my provider?
  • Is there any other way of verifying a pact using a broker?

Thank you in advance!

1 Answer 1

0

It sounds like you're testing a Java app, is there a reason you're not using Pact JVM and using the CLI (or Ruby) instead?

There is an example JVM provider you can use as an example here.

With respect to authentication, there is a guide on strategies you can take to handle such things. If you're using the CLI you have two options

  1. Stub the CLI layer in your provider
  2. Use the --header option to add a valid bearer token
Sign up to request clarification or add additional context in comments.

4 Comments

Thank you for your reply. I do not use JVM directly because, to my understanding, programmatic verification bypasses the pact-broker, meaning you programmatically hit the provider and match pact with result. That is not what I want, I want the broker to hit the provider. Also, the example you posted is based on PactFlow, and not a custom broker. In this latter case, the pact-provider-verifier does not have a —header option.
No that's not how it works. In both cases contracts are fetched from the broker, the broker itself does not do any verification - it just mediates the process. The languages provide a richer way to do this than the CLI. Also the example uses PactFlow but it doesn't use any commercial features not available to the open source edition of Pact
Thank you Matthew, but where do I pass broker references with the programmatic verifier? I can't see anywhere in the examples...
There are lots of examples across languages here: docs.pactflow.io/docs/examples

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.