Yousaf Nabi (pactflow.io)
Timothy Jones
04/19/2023, 12:11 AMMatt (pactflow.io / pact-js / pact-go)
Yousaf Nabi (pactflow.io)
Yousaf Nabi (pactflow.io)
Matt (pactflow.io / pact-js / pact-go)
Last login: Wed Apr 26 12:34:23 on ttys002
➜ ~ /tmp/
➜ /tmp curl -LO <https://github.com/you54f/pact-ruby-standalone/releases/download/v3.1.2.2-alpha/pact-3.1.2.2-alpha-osx-arm64.tar.gz>
tar xzf pact-3.1.2.2-alpha-osx-arm64.tar.gz
cd pact/bin
./pact-mock-service --help start
./pact-provider-verifier --help verify
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
100 19.4M 100 19.4M 0 0 2928k 0 0:00:06 0:00:06 --:--:-- 3955k
Usage:
pact-mock-service start
Options:
[--consumer=CONSUMER] # Consumer name
[--provider=PROVIDER] # Provider name
-p, [--port=PORT] # Port on which to run the service
# Default: 1234
-h, [--host=HOST] # Host on which to bind the service
# Default: localhost
-d, [--pact-dir=PACT_DIR] # Directory to which the pacts will be written
-m, [--pact-file-write-mode=PACT_FILE_WRITE_MODE] # `overwrite` or `merge`. Use `merge` when running multiple mock service instances in parallel for the same consumer/provider pair. Ensure the pact file is deleted before running tests when using this option so that interactions deleted from the code are not maintained in the file.
# Default: overwrite
[--pid-dir=PID_DIR] # PID dir
# Default: tmp/pids
-l, [--log=LOG] # File to which to log output
[--log-level=LOG_LEVEL] # Log level. Options are DEBUG INFO WARN ERROR
# Default: DEBUG
-i, [--pact-specification-version=PACT_SPECIFICATION_VERSION] # The pact specification version to use when writing the pact. Note that only versions 1 and 2 are currently supported.
# Default: 2
-o, [--cors=CORS] # Support browser security in tests by responding to OPTIONS requests and adding CORS headers to mocked responses
[--ssl], [--no-ssl] # Use a self-signed SSL cert to run the service over HTTPS
[--sslcert=SSLCERT] # Specify the path to the SSL cert to use when running the service over HTTPS
[--sslkey=SSLKEY] # Specify the path to the SSL key to use when running the service over HTTPS
Start a mock service. If the consumer, provider and pact-dir options are provided, the pact will be written automatically on shutdown (INT).
Usage:
pact-provider-verifier PACT_URL ... -h, --provider-base-url=PROVIDER_BASE_URL
Options:
-h, --provider-base-url=PROVIDER_BASE_URL # Provider host URL
-c, [--provider-states-setup-url=PROVIDER_STATES_SETUP_URL] # Base URL to setup the provider states at
[--pact-broker-base-url=PACT_BROKER_BASE_URL] # Base URL of the Pact Broker from which to retrieve the pacts. Can also be set using the environment variable PACT_BROKER_BASE_URL.
-n, [--broker-username=BROKER_USERNAME] # Pact Broker basic auth username. Can also be set using the environment variable PACT_BROKER_USERNAME.
-p, [--broker-password=BROKER_PASSWORD] # Pact Broker basic auth password. Can also be set using the environment variable PACT_BROKER_PASSWORD.
-k, [--broker-token=BROKER_TOKEN] # Pact Broker bearer token. Can also be set using the environment variable PACT_BROKER_TOKEN.
[--provider=PROVIDER]
[--consumer-version-tag=TAG] # Retrieve the latest pacts with this consumer version tag. Used in conjunction with --provider. May be specified multiple times.
[--provider-version-tag=TAG] # Tag to apply to the provider application version. May be specified multiple times.
[--provider-version-branch=BRANCH] # The name of the branch the provider version belongs to.
-g, [--tag-with-git-branch], [--no-tag-with-git-branch] # Tag provider version with the name of the current git branch. Default: false
-a, [--provider-app-version=PROVIDER_APP_VERSION] # Provider application version, required when publishing verification results
-r, [--publish-verification-results], [--no-publish-verification-results] # Publish verification results to the broker. This can also be enabled by setting the environment variable PACT_BROKER_PUBLISH_VERIFICATION_RESULTS=true
[--enable-pending], [--no-enable-pending] # Allow pacts which are in pending state to be verified without causing the overall task to fail. For more information, see <https://pact.io/pending>
[--custom-provider-header=CUSTOM_PROVIDER_HEADER] # Header to add to provider state set up and pact verification requests. eg 'Authorization: Basic cGFjdDpwYWN0'. May be specified multiple times.
[--custom-middleware=FILE] # Ruby file containing a class implementing Pact::ProviderVerifier::CustomMiddleware. This allows the response to be modified before replaying. Use with caution!
-v, [--verbose=VERBOSE] # Verbose output. Can also be set by setting the environment variable VERBOSE=true.
-f, [--format=FORMATTER] # RSpec formatter. Defaults to custom Pact formatter. Other options are json and RspecJunitFormatter (which outputs xml).
-o, [--out=FILE] # Write output to a file instead of $stdout.
[--wait=SECONDS] # The number of seconds to poll for the provider to become available before running the verification
# Default: 0
[--log-dir=LOG_DIR] # The directory for the pact.log file
[--log-level=LOG_LEVEL] # The log level
# Default: debug
[--fail-if-no-pacts-found], [--no-fail-if-no-pacts-found] # If specified, will fail when no pacts are found
Description:
The parameters used when fetching pacts dynamically from a Pact Broker are:
--pact-broker-base-url (REQUIRED)
--provider (REQUIRED)
--broker-username/--broker-password or --broker-token
--consumer-version-tag or --consumer-version-selector
--enable-pending
--include-wip-pacts-since
To verify a pact at a known URL (eg. when a verification is triggered by a 'contract content changed' webhook), pass in the pact URL(s) as the first argument(s) to the
command, and do NOT set any of the other parameters apart from the base URL and credentials.
To publish verification results for either of the above scenarios, set:
--publish-verification-results (REQUIRED)
--provider-app-version (REQUIRED)
--provider-version-tag or --tag-with-git-branch
Selectors: These are specified using JSON strings. The keys are 'tag' (the name of the consumer version tag), 'latest' (true|false), 'consumer', and 'fallbackTag'. For example '{\"tag\": \"master\", \"latest\":
true}'. For a detailed explanation of selectors, see <https://pact.io/selectors#consumer-version-selectors>
➜ bin curl -LO <https://github.com/you54f/pact-ruby-standalone/releases/download/v3.1.2.2-alpha/pact-3.1.2.2-alpha>
tar xzf pact-3.1.2.2-alpha-osx-arm64.tar.gz
cd pact/bin
./pact-mock-service --help start
./pact-provider-verifier --help verify
➜ bin
➜ bin ./pact-mock-service start
mock WARN: Please note: we are tracking events anonymously to gather important usage statistics like Pact-Ruby version and operating system. To disable tracking, set the 'PACT_DO_NOT_TRACK' environment variable to 'true'.
INFO WEBrick 1.8.1
INFO ruby 3.2.2 (2023-03-30) [arm64-darwin22]
INFO WEBrick::HTTPServer#start: pid=70249 port=1234
➜ bin I, [2023-04-26T12:40:17.080670 #70249] INFO -- : Received request GET /
D, [2023-04-26T12:40:17.107097 #70249] DEBUG -- : {
"path": "/",
"query": "",
"method": "get",
"headers": {
"Host": "localhost:1234",
"User-Agent": "curl/7.87.0",
"Accept": "*/*",
"Version": "HTTP/1.1"
}
}
E, [2023-04-26T12:40:17.108173 #70249] ERROR -- : No matching interaction found for GET /
E, [2023-04-26T12:40:17.109216 #70249] ERROR -- : Interaction diffs for that route:
E, [2023-04-26T12:40:17.110783 #70249] ERROR -- :Matt (pactflow.io / pact-js / pact-go)