bethesque / pact-provider-verifier

Cross-platform, generic language, Pact provider verification tool

Home Page:http://pact.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Pact Provider Verification

This setup simplifies Pact Provider verification process in any language, wrapping the Ruby implementation into a cross-platform, binary-like CLI tool.

Build Status

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

Installation

Native Installation

Download the appropriate release for your OS and put somewhere on your PATH.

With Ruby on Mac OSX and Linux

gem install pact-provider-verifier
pact-provider-verifier <args>

Run pact-provider-verifier help for command line options.

Examples

See the example for a demonstration with a Sinatra API:

cd examples
bundle install
./test.sh

Simple API

Steps:

  1. Create an API and a corresponding Docker image for it
  2. Publish Pacts to the Pact broker (or create local ones)
  3. 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)

API with Provider States

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

Using the Pact Broker with Basic authentication

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.

Contributing

See CONTRIBUTING.md

About

Cross-platform, generic language, Pact provider verification tool

http://pact.io

License:MIT License


Languages

Language:Ruby 93.2%Language:Shell 4.7%Language:Batchfile 2.2%