Docker container to validate Pacts in a language-agnostic manner
10K+
NOTE: If you're new to Pact and have landed here, it's probably not what you want. If you simply want a Dockerized version of the verifier, the official Docker container for all Pact libraries is: https://github.com/pact-foundation/pact-ruby-cli.
This setup simplifies Pact Provider verification process in any language, by running the Pact Rake tasks in a separate Docker container.
Features:
*.json Pacts for testing in a development environmentsrc/Rakefile keeping things DRYSteps:
docker-compose.yml file connecting your API to the Pact Verifierpact_urls - a comma delimited list of pact file urlsprovider_base_url - the base url of the pact provider (i.e. your API)docker-compose build and then docker-compose up4000:api:
build: .
command: npm start
ports:
- "4000:4000"
pactverifier:
image: dius/pact-provider-verifier-docker
links:
- api:api
volumes:
- ./pact/pacts:/tmp/pacts # If you have local Pacts
environment:
- pact_urls=http://pact-host:9292/pacts/provider/MyAPI/consumer/MyConsumer/latest
#- pact_urls=/tmp/pacts/foo-consumer.json # If you have local Pacts
- provider_base_url=http://api:4000
Execute pact provider verification against a provider which implements the following:
an http get endpoint which returns pact provider_states by consumer
{
"myConsumer": [
"customer is logged in",
"customer has a million dollars"
]
}
an http post endpoint which sets the active pact consumer and provider state
consumer=web&state=customer%20is%20logged%20in
The following environment variables required:
pact_urls - a comma delimited list of pact file urlsprovider_base_url - the base url of the pact providerprovider_states_url - the full url of the endpoint which returns provider states by consumerprovider_states_active_url - the full url of the endpoint which sets the active pact consumer and provider state$ bundle install
$ bundle exec rake verify_pacts
api:
build: .
command: npm run-script pact-provider
ports:
- "4000"
pactverifier:
image: dius/pact-provider-verifier-docker
links:
- api
environment:
- pact_urls=http://pact-host:9292/pacts/provider/MyProvider/consumer/myConsumer/latest
- provider_base_url=http://api4000:
- provider_states_url=http://api:4000/provider-states
- provider_states_active_url=http://api:4000/provider-states/active
Content type
Image
Digest
Size
27.5 MB
Last updated
almost 7 years ago
docker pull dius/pact-provider-verifier-docker