This setup simplifies Pact Provider verification process in any language, wrapping the Ruby implementation into a cross-platform, binary-like CLI tool.
Features:
- Verify Pacts against Pacts published to an http endpoint, such as a Pact Broker
- Verify local
*.json
Pacts on the file system - Works with Pact provider states should you need them
Download the appropriate release
for your OS and put somewhere on your PATH
.
gem install pact-provider-verifier
pact-provider-verifier <args>
Run pact-provider-verifier help
for command line options.
See the example for a demonstration with a Sinatra API:
cd examples
bundle install
./test.sh
Steps:
- Create an API and a corresponding Docker image for it
- Publish Pacts to the Pact broker (or create local ones)
- Run the CLI tool for your OS, passing the appropriate flags:
--pact_urls
- a comma delimited list of local Pact file urls or Pact Broker URLs.--provider_base_url
- the base url of the pact provider (i.e. your API)
Execute pact provider verification against a provider which implements the following:
-
an http get endpoint which returns the available Provider States by consumer
{ "SomeUI": [ "customer A is logged in", "customer A has a million dollars" ], "BackendAPI": [ "customer A is logged in", "there are no customers" ] }
-
an http post endpoint which sets the active pact consumer and provider state
consumer=web&state=customer%20is%20logged%20in
The following flags are required:
--pact-urls
- a comma delimited list of pact file urls--provider-base-url
- the base url of the pact provider--provider-states-url
- the full url of the endpoint which returns provider states by consumer--provider-states-setup-url
- the full url of the endpoint which sets the active pact consumer and provider state
The following flags are required to use basic authentication with a Pact Broker:
--broker-user
- the Username for Pact Broker basic authentication.--broker-password
- the Password for Pact Broker basic authentication.
NOTE: the http://user:password@host
format for basic HTTP auth is not supported.
See CONTRIBUTING.md