Skip to content

Latest commit

 

History

History
77 lines (62 loc) · 3.88 KB

lab_06.adoc

File metadata and controls

77 lines (62 loc) · 3.88 KB

Lab 6 - Publishing a Contract to Pact Broker

In this lab we’ll publish the “pact” we generated in Lab 4 to a running instance of Pact Broker on Pivotal Web Services.

Target

  1. If you haven’t already, download the latest release of the Cloud Foundry CLI from https://github.com/cloudfoundry/cli/releases for your operating system and install it.

  2. Set the API target for the CLI:

    $ cf api api.run.pivotal.io
  3. Login to Pivotal Web Services:

    $ cf login

    Follow the prompts.

Push Pact Broker

  1. Change to the Pact Broker example directory:

    $ cd $COURSE_HOME/labs/pact_broker
  2. Push Pact Broker to PWS:

    $ cf push pact-broker --random-route
  3. Visit Pact Broker at the random route assigned by Cloud Foundry (e.g. http://pact-broker-distortive-broadside.cfapps.io).

    You should see output similar to the following:

    pact broker 1

Publish the Pact

  1. Change to the following directory:

    $ cd $COURSE_HOME/labs/initial/fortune-teller/fortune-teller-ui/target/pacts
  2. Publish the pact using cURL (again, use the random route provided to you by Cloud Foundry):

    $ curl -i -X PUT http://pact-broker-distortive-broadside.cfapps.io/pacts/provider/FortuneService/consumer/FortuneUi/version/1.0.0 -H "Content-Type: application/json" [email protected]

    You should see output similar to the following:

    HTTP/1.1 201 Created
    Content-Type: application/json
    Content-Length: 2088
    Server: Webmachine-Ruby/1.2.0 Rack/1.3
    Connection: keep-alive
    
    {"provider":{"name":"FortuneService"},"consumer":{"name":"FortuneUi"},"interactions":[{"providerState":"FortuneState","description":"a request for a random fortune","request":{"method":"GET","path":"/random"},"response":{"status":200,"headers":{"Content-Type":"application/json;charset=UTF-8"},"body":{"id":6273300129,"text":"YQEokQivJfDaCXAEIvZH"},"responseMatchingRules":{"$.body.id":{"match":"type"},"$.body.text":{"match":"type"}}}}],"metadata":{"pact-specification":{"version":"2.0.0"},"pact-jvm":{"version":"2.1.13"}},"createdAt":"2015-05-22T06:46:46+00:00","_links":{"self":{"title":"Pact","name":"Pact between FortuneUi (v1.0.0) and FortuneService","href":"http://localhost:9292/pacts/provider/FortuneService/consumer/FortuneUi/version/1.0.0"},"pb:consumer":{"title":"Consumer","name":"FortuneUi","href":"http://localhost:9292/pacticipants/FortuneUi"},"pb:provider":{"title":"Provider","name":"FortuneService","href":"http://localhost:9292/pacticipants/FortuneService"},"pb:latest-pact-version":{"title":"Pact","name":"Latest version of this pact","href":"http://localhost:9292/pacts/provider/FortuneService/consumer/FortuneUi/latest"},"pb:previous-distinct":{"title":"Pact","name":"Previous distinct version of this pact","href":"http://localhost:9292/pacts/provider/FortuneService/consumer/FortuneUi/version/1.0.0/previous-distinct"},"pb:diff-previous-distinct":{"title":"Diff","name":"Diff with previous distinct version of this pact","href":"http://localhost:9292/pacts/provider/FortuneService/consumer/FortuneUi/version/1.0.0/diff/previous-distinct"},"pb:pact-webhooks":{"title":"Webhooks for the pact between FortuneUi and FortuneService","href":"http://localhost:9292/webhooks/provider/FortuneService/consumer/FortuneUi"},"pb:tag-prod-version":{"title":"Tag this version as 'production'","href":"http://localhost:9292/pacticipants/FortuneUi/versions/1.0.0/tags/prod"},"pb:tag-version":{"title":"Tag version","href":"http://localhost:9292/pacticipants/FortuneUi/versions/1.0.0/tags/{tag}"},"curies":[{"name":"pb","href":"http://localhost:9292/doc/{rel}","templated":true}]}}
  3. Refresh your Pact Broker browser tab. You should see your pact added:

    pact broker 2
  4. Click on the “document” icon for your Pact. You will see a nicely formatted, human readable version of your pact:

    pact broker 3