The pact server is a stand-alone interactions recorder and verifier, aimed at clients that are non-JVM or non-Ruby based.
The pact client for that platform will need to be implemented, but it only be responsible for generating the
interactions, running the tests and communicating with the server.
The server implements a
REST Admin API with the following endpoints.
Pact server takes the following parameters:
Trust store can be used. However, it is limited to a single port for the time being.
You can download a distribution from maven central. There is both a ZIP and TAR archive. Unpack it to a directory of choice and then run the script in the bin directory.
You can build an application bundle with gradle by running:
This will create an app bundle in
build/install/pact-jvm-server. You can then execute it with:
or with the generated bundle script file:
By default will run on port
29999 but a port number can be optionally supplied.
You can use a docker image to execute the mock server as a docker container.
This will run the main server on port 8080, and each created mock server on ports 20000-20010. You can map the ports to any you require.
The following actions are expected to occur
- The client calls
/createto initialise a server with the expected
JSONinteractions and state
- The admin server will start a mock server on a random port and return the port number in the response
- The client will execute its interaction tests against the mock server with the supplied port
- Once finished, the client will call `/complete' on the Admin API, posting the port number
- The pact server will verify the interactions and write the
pactfile to disk under
- The mock server running on the supplied port will be shutdown.
- The client will call
/publishto publish the created contract to the configured pact broker
The client will need
/create the generated
JSON interactions, also providing a state as a query parameter
and a path.
This will create a new running mock service provider on a randomly generated port. The port will be returned in the
But you can also reference the path from
/sub/ref/path using the server port. The service will not strip
the prefix path, but instead will use it as a differentiator. If your services do not have differences
in the prefix of their path, then you will have to use the port method.
Once the client has finished running its tests against the mock server on the supplied port (in this example port
34423) the client will need to
/complete the port number of the mock server that was used.
This will cause the Pact server to verify the interactions, shutdown the mock server running on that port and writing
JSON file to disk under the
Once all interactions have been tested the
/publish endpoint can be called to publish the created pact to the pact broker
For this it is required to run the pact-jvm-server with the -b parameter to configure the pact broker to publish the pacts to.
Optionaly an authentication token can be used for authentication against the broker.
This will cause the Pact server to check for the pact
Zoo-Animal_Service.json on disk under
target and publish it to
the configured pact broker. After a successful publish the pact will be removed from disk.
/ endpoint is for diagnostics and to check that the pact server is running. It will return all the currently
running mock servers port numbers.