From bd64caa8c41725eea3f197245e4603af99a5fcad Mon Sep 17 00:00:00 2001 From: Beth Skurrie Date: Fri, 9 Jul 2021 09:04:23 +1000 Subject: [PATCH] feat: enabled deployment, release and environment commands without a feature toggle --- .github/workflows/test.yml | 2 +- .../Pact Broker Client - Pact Broker.md | 315 +++++++++++++++++ lib/pact_broker/client/cli/broker.rb | 8 +- script/record-deployment.sh | 2 +- script/record-deployments-and-releases.sh | 2 - script/record-undeployment.sh | 2 +- .../pacts/pact_broker_client-pact_broker.json | 317 ++++++++++++++++++ .../record_deployment_spec.rb | 4 +- spec/service_providers/record_release_spec.rb | 4 +- .../record_undeployment_spec.rb | 4 +- 10 files changed, 641 insertions(+), 19 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index bf1ed531..a62bc930 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -27,7 +27,7 @@ jobs: strategy: fail-fast: false matrix: - feature: ["", "publish_contracts", "deployments"] + feature: ["", "publish_contracts"] steps: - uses: actions/checkout@v2 - uses: ruby/setup-ruby@v1 diff --git a/doc/pacts/markdown/Pact Broker Client - Pact Broker.md b/doc/pacts/markdown/Pact Broker Client - Pact Broker.md index ab5bdf12..a365f883 100644 --- a/doc/pacts/markdown/Pact Broker Client - Pact Broker.md +++ b/doc/pacts/markdown/Pact Broker Client - Pact Broker.md @@ -2,6 +2,14 @@ #### Requests from Pact Broker Client to Pact Broker +* [A request for a pacticipant version](#a_request_for_a_pacticipant_version_given_version_5556b8149bf8bac76bc30f50a8a2dd4c22c85f30_of_pacticipant_Foo_exists_with_2_environments_that_aren't_test_available_for_deployment) given version 5556b8149bf8bac76bc30f50a8a2dd4c22c85f30 of pacticipant Foo exists with 2 environments that aren't test available for deployment + +* [A request for a pacticipant version](#a_request_for_a_pacticipant_version_given_version_5556b8149bf8bac76bc30f50a8a2dd4c22c85f30_of_pacticipant_Foo_exists_with_a_test_environment_available_for_deployment) given version 5556b8149bf8bac76bc30f50a8a2dd4c22c85f30 of pacticipant Foo exists with a test environment available for deployment + +* [A request for a pacticipant version](#a_request_for_a_pacticipant_version_given_version_5556b8149bf8bac76bc30f50a8a2dd4c22c85f30_of_pacticipant_Foo_exists_with_a_test_environment_available_for_release) given version 5556b8149bf8bac76bc30f50a8a2dd4c22c85f30 of pacticipant Foo exists with a test environment available for release + +* [A request for an environment](#a_request_for_an_environment_given_an_environment_with_name_test_and_UUID_16926ef3-590f-4e3f-838e-719717aa88c9_exists) given an environment with name test and UUID 16926ef3-590f-4e3f-838e-719717aa88c9 exists + * [A request for the compatibility matrix for a pacticipant that does not exist](#a_request_for_the_compatibility_matrix_for_a_pacticipant_that_does_not_exist) * [A request for the compatibility matrix for all versions of Foo and Bar](#a_request_for_the_compatibility_matrix_for_all_versions_of_Foo_and_Bar_given_the_pact_for_Foo_version_1.2.3_and_1.2.4_has_been_verified_by_Bar_version_4.5.6) given the pact for Foo version 1.2.3 and 1.2.4 has been verified by Bar version 4.5.6 @@ -20,6 +28,8 @@ * [A request for the compatibility matrix where only the version of Foo is specified](#a_request_for_the_compatibility_matrix_where_only_the_version_of_Foo_is_specified_given_the_pact_for_Foo_version_1.2.3_has_been_verified_by_Bar_version_4.5.6_and_version_5.6.7) given the pact for Foo version 1.2.3 has been verified by Bar version 4.5.6 and version 5.6.7 +* [A request for the environments](#a_request_for_the_environments_given_an_environment_with_name_test_exists) given an environment with name test exists + * [A request for the index resource](#a_request_for_the_index_resource) * [A request for the index resource](#a_request_for_the_index_resource_given_the_pacticipant_relations_are_present) given the pacticipant relations are present @@ -28,6 +38,8 @@ * [A request for the index resource](#a_request_for_the_index_resource_given_the_pb:latest-version_relation_exists_in_the_index_resource) given the pb:latest-version relation exists in the index resource +* [A request for the index resource](#a_request_for_the_index_resource_given_the_pb:pacticipant-version_and_pb:environments_relations_exist_in_the_index_resource) given the pb:pacticipant-version and pb:environments relations exist in the index resource + * [A request for the index resource](#a_request_for_the_index_resource_given_the_pb:pacticipant-version_relation_exists_in_the_index_resource) given the pb:pacticipant-version relation exists in the index resource * [A request for the index resource with the webhook relation](#a_request_for_the_index_resource_with_the_webhook_relation) @@ -74,6 +86,10 @@ * [A request to list the latest pacts](#a_request_to_list_the_latest_pacts_given_a_pact_between_Condor_and_the_Pricing_Service_exists) given a pact between Condor and the Pricing Service exists +* [A request to list the versions deployed to an environment for a pacticipant name and target](#a_request_to_list_the_versions_deployed_to_an_environment_for_a_pacticipant_name_and_target_given_an_version_is_deployed_to_environment_with_UUID_16926ef3-590f-4e3f-838e-719717aa88c9_with_target_customer-1) given an version is deployed to environment with UUID 16926ef3-590f-4e3f-838e-719717aa88c9 with target customer-1 + +* [A request to mark a deployed version as not currently deploye](#a_request_to_mark_a_deployed_version_as_not_currently_deploye_given_a_currently_deployed_version_exists) given a currently deployed version exists + * [A request to publish a pact](#a_request_to_publish_a_pact_given_'Condor'_already_exist_in_the_pact-broker,_but_the_'Pricing_Service'_does_not) given 'Condor' already exist in the pact-broker, but the 'Pricing Service' does not * [A request to publish a pact](#a_request_to_publish_a_pact_given_the_'Pricing_Service'_already_exists_in_the_pact-broker) given the 'Pricing Service' already exists in the pact-broker @@ -84,6 +100,10 @@ * [A request to publish a pact with method put](#a_request_to_publish_a_pact_with_method_put_given_the_'Pricing_Service'_and_'Condor'_already_exist_in_the_pact-broker,_and_Condor_already_has_a_pact_published_for_version_1.3.0) given the 'Pricing Service' and 'Condor' already exist in the pact-broker, and Condor already has a pact published for version 1.3.0 +* [A request to record a deployment](#a_request_to_record_a_deployment_given_version_5556b8149bf8bac76bc30f50a8a2dd4c22c85f30_of_pacticipant_Foo_exists_with_a_test_environment_available_for_deployment) given version 5556b8149bf8bac76bc30f50a8a2dd4c22c85f30 of pacticipant Foo exists with a test environment available for deployment + +* [A request to record a release](#a_request_to_record_a_release_given_version_5556b8149bf8bac76bc30f50a8a2dd4c22c85f30_of_pacticipant_Foo_exists_with_a_test_environment_available_for_deployment) given version 5556b8149bf8bac76bc30f50a8a2dd4c22c85f30 of pacticipant Foo exists with a test environment available for deployment + * [A request to register the repository URL of a pacticipant](#a_request_to_register_the_repository_URL_of_a_pacticipant_given_the_'Pricing_Service'_already_exists_in_the_pact-broker) given the 'Pricing Service' already exists in the pact-broker * [A request to register the repository URL of a pacticipant](#a_request_to_register_the_repository_URL_of_a_pacticipant_given_the_'Pricing_Service'_does_not_exist_in_the_pact-broker) given the 'Pricing Service' does not exist in the pact-broker @@ -116,6 +136,127 @@ #### Interactions + +Given **version 5556b8149bf8bac76bc30f50a8a2dd4c22c85f30 of pacticipant Foo exists with 2 environments that aren't test available for deployment**, upon receiving **a request for a pacticipant version** from Pact Broker Client, with +```json +{ + "method": "GET", + "path": "/HAL-REL-PLACEHOLDER-PB-PACTICIPANT-VERSION-Foo-5556b8149bf8bac76bc30f50a8a2dd4c22c85f30", + "headers": { + "Accept": "application/hal+json" + } +} +``` +Pact Broker will respond with: +```json +{ + "status": 200, + "headers": { + "Content-Type": "application/hal+json;charset=utf-8" + }, + "body": { + "_links": { + "pb:record-deployment": [ + { + "name": "prod", + "href": "href" + }, + { + "name": "dev", + "href": "href" + } + ] + } + } +} +``` + +Given **version 5556b8149bf8bac76bc30f50a8a2dd4c22c85f30 of pacticipant Foo exists with a test environment available for deployment**, upon receiving **a request for a pacticipant version** from Pact Broker Client, with +```json +{ + "method": "GET", + "path": "/HAL-REL-PLACEHOLDER-PB-PACTICIPANT-VERSION-Foo-5556b8149bf8bac76bc30f50a8a2dd4c22c85f30", + "headers": { + "Accept": "application/hal+json" + } +} +``` +Pact Broker will respond with: +```json +{ + "status": 200, + "headers": { + "Content-Type": "application/hal+json;charset=utf-8" + }, + "body": { + "_links": { + "pb:record-deployment": [ + { + "name": "test", + "href": "http://localhost:1234/HAL-REL-PLACEHOLDER-PB-RECORD-DEPLOYMENT-FOO-5556B8149BF8BAC76BC30F50A8A2DD4C22C85F30-TEST" + } + ] + } + } +} +``` + +Given **version 5556b8149bf8bac76bc30f50a8a2dd4c22c85f30 of pacticipant Foo exists with a test environment available for release**, upon receiving **a request for a pacticipant version** from Pact Broker Client, with +```json +{ + "method": "GET", + "path": "/HAL-REL-PLACEHOLDER-PB-PACTICIPANT-VERSION-Foo-5556b8149bf8bac76bc30f50a8a2dd4c22c85f30", + "headers": { + "Accept": "application/hal+json" + } +} +``` +Pact Broker will respond with: +```json +{ + "status": 200, + "headers": { + "Content-Type": "application/hal+json;charset=utf-8" + }, + "body": { + "_links": { + "pb:record-release": [ + { + "name": "test", + "href": "http://localhost:1234/HAL-REL-PLACEHOLDER-PB-RECORD-RELEASE-FOO-5556B8149BF8BAC76BC30F50A8A2DD4C22C85F30-TEST" + } + ] + } + } +} +``` + +Given **an environment with name test and UUID 16926ef3-590f-4e3f-838e-719717aa88c9 exists**, upon receiving **a request for an environment** from Pact Broker Client, with +```json +{ + "method": "GET", + "path": "/HAL-REL-PLACEHOLDER-PB-ENVIRONMENT-16926ef3-590f-4e3f-838e-719717aa88c9", + "headers": { + "Accept": "application/hal+json" + } +} +``` +Pact Broker will respond with: +```json +{ + "status": 200, + "headers": { + "Content-Type": "application/hal+json;charset=utf-8" + }, + "body": { + "_links": { + "pb:currently-deployed-deployed-versions": { + "href": "http://localhost:1234/PLACEHOLDER-ENVIRONMENT-CURRENTLY-DEPLOYED-16926ef3-590f-4e3f-838e-719717aa88c9" + } + } + } +} +``` Upon receiving **a request for the compatibility matrix for a pacticipant that does not exist** from Pact Broker Client, with ```json @@ -537,6 +678,36 @@ Pact Broker will respond with: } } ``` + +Given **an environment with name test exists**, upon receiving **a request for the environments** from Pact Broker Client, with +```json +{ + "method": "GET", + "path": "/HAL-REL-PLACEHOLDER-PB-ENVIRONMENTS", + "headers": { + "Accept": "application/hal+json" + } +} +``` +Pact Broker will respond with: +```json +{ + "status": 200, + "headers": { + "Content-Type": "application/hal+json;charset=utf-8" + }, + "body": { + "_links": { + "pb:environments": [ + { + "name": "test", + "href": "href" + } + ] + } + } +} +``` Upon receiving **a request for the index resource** from Pact Broker Client, with ```json @@ -654,6 +825,36 @@ Pact Broker will respond with: } } ``` + +Given **the pb:pacticipant-version and pb:environments relations exist in the index resource**, upon receiving **a request for the index resource** from Pact Broker Client, with +```json +{ + "method": "GET", + "path": "/", + "headers": { + "Accept": "application/hal+json" + } +} +``` +Pact Broker will respond with: +```json +{ + "status": 200, + "headers": { + "Content-Type": "application/hal+json;charset=utf-8" + }, + "body": { + "_links": { + "pb:pacticipant-version": { + "href": "http://localhost:1234/HAL-REL-PLACEHOLDER-PB-PACTICIPANT-VERSION-{pacticipant}-{version}" + }, + "pb:environments": { + "href": "http://localhost:1234/HAL-REL-PLACEHOLDER-PB-ENVIRONMENTS" + } + } + } +} +``` Given **the pb:pacticipant-version relation exists in the index resource**, upon receiving **a request for the index resource** from Pact Broker Client, with ```json @@ -1666,6 +1867,72 @@ Pact Broker will respond with: } } ``` + +Given **an version is deployed to environment with UUID 16926ef3-590f-4e3f-838e-719717aa88c9 with target customer-1**, upon receiving **a request to list the versions deployed to an environment for a pacticipant name and target** from Pact Broker Client, with +```json +{ + "method": "GET", + "path": "/PLACEHOLDER-ENVIRONMENT-CURRENTLY-DEPLOYED-16926ef3-590f-4e3f-838e-719717aa88c9", + "query": "pacticipant=Foo", + "headers": { + "Accept": "application/hal+json" + } +} +``` +Pact Broker will respond with: +```json +{ + "status": 200, + "headers": { + "Content-Type": "application/hal+json;charset=utf-8" + }, + "body": { + "_embedded": { + "deployedVersions": [ + { + "target": "customer-1", + "_links": { + "self": { + "href": "http://localhost:1234/PLACEHOLDER-DEPLOYED-VERSION-ff3adecf-cfc5-4653-a4e3-f1861092f8e0" + } + } + } + ] + } + } +} +``` + +Given **a currently deployed version exists**, upon receiving **a request to mark a deployed version as not currently deploye** from Pact Broker Client, with +```json +{ + "method": "PATCH", + "path": "/PLACEHOLDER-DEPLOYED-VERSION-ff3adecf-cfc5-4653-a4e3-f1861092f8e0", + "headers": { + "Content-Type": "application/merge-patch+json" + }, + "body": { + "currentlyDeployed": false + } +} +``` +Pact Broker will respond with: +```json +{ + "status": 200, + "headers": { + "Content-Type": "application/hal+json;charset=utf-8" + }, + "body": { + "currentlyDeployed": false, + "_embedded": { + "version": { + "number": "2" + } + } + } +} +``` Given **'Condor' already exist in the pact-broker, but the 'Pricing Service' does not**, upon receiving **a request to publish a pact** from Pact Broker Client, with ```json @@ -1854,6 +2121,54 @@ Pact Broker will respond with: } } ``` + +Given **version 5556b8149bf8bac76bc30f50a8a2dd4c22c85f30 of pacticipant Foo exists with a test environment available for deployment**, upon receiving **a request to record a deployment** from Pact Broker Client, with +```json +{ + "method": "POST", + "path": "/HAL-REL-PLACEHOLDER-PB-RECORD-DEPLOYMENT-FOO-5556B8149BF8BAC76BC30F50A8A2DD4C22C85F30-TEST", + "headers": { + "Content-Type": "application/json", + "Accept": "application/hal+json" + }, + "body": { + "target": "blue" + } +} +``` +Pact Broker will respond with: +```json +{ + "status": 201, + "headers": { + "Content-Type": "application/hal+json;charset=utf-8" + }, + "body": { + "target": "blue" + } +} +``` + +Given **version 5556b8149bf8bac76bc30f50a8a2dd4c22c85f30 of pacticipant Foo exists with a test environment available for deployment**, upon receiving **a request to record a release** from Pact Broker Client, with +```json +{ + "method": "POST", + "path": "/HAL-REL-PLACEHOLDER-PB-RECORD-RELEASE-FOO-5556B8149BF8BAC76BC30F50A8A2DD4C22C85F30-TEST", + "headers": { + "Content-Type": "application/json", + "Accept": "application/hal+json" + } +} +``` +Pact Broker will respond with: +```json +{ + "status": 201, + "headers": { + "Content-Type": "application/hal+json;charset=utf-8" + } +} +``` Given **the 'Pricing Service' already exists in the pact-broker**, upon receiving **a request to register the repository URL of a pacticipant** from Pact Broker Client, with ```json diff --git a/lib/pact_broker/client/cli/broker.rb b/lib/pact_broker/client/cli/broker.rb index 1303fa52..9ef7b692 100644 --- a/lib/pact_broker/client/cli/broker.rb +++ b/lib/pact_broker/client/cli/broker.rb @@ -16,14 +16,12 @@ class VersionCreationError < ::Thor::Error; end class Broker < CustomThor using PactBroker::Client::HashRefinements - if ENV.fetch("PACT_BROKER_FEATURES", "").include?("deployments") - include PactBroker::Client::CLI::EnvironmentCommands - include PactBroker::Client::CLI::DeploymentCommands - end + + include PactBroker::Client::CLI::EnvironmentCommands + include PactBroker::Client::CLI::DeploymentCommands include PactBroker::Client::CLI::PacticipantCommands include PactBroker::Client::CLI::WebhookCommands - desc 'can-i-deploy', '' long_desc File.read(File.join(__dir__, 'can_i_deploy_long_desc.txt')) diff --git a/script/record-deployment.sh b/script/record-deployment.sh index 2756ee8e..6152afd6 100755 --- a/script/record-deployment.sh +++ b/script/record-deployment.sh @@ -1,2 +1,2 @@ -PACT_BROKER_FEATURES=deployments bundle exec bin/pact-broker record-deployment \ +bundle exec bin/pact-broker record-deployment \ --pacticipant foo-consumer --version 1 --environment prod --broker-base-url http://localhost:9292 diff --git a/script/record-deployments-and-releases.sh b/script/record-deployments-and-releases.sh index 5bee45d0..c2d68b14 100755 --- a/script/record-deployments-and-releases.sh +++ b/script/record-deployments-and-releases.sh @@ -1,5 +1,3 @@ -export PACT_BROKER_FEATURES=deployments - bundle exec bin/pact-broker create-or-update-pacticipant --name Foo bundle exec bin/pact-broker create-version-tag --pacticipant Foo --version 2 --tag main --auto-create-version bundle exec bin/pact-broker describe-version --pacticipant Foo --version 2 diff --git a/script/record-undeployment.sh b/script/record-undeployment.sh index f1adcabc..c469079a 100755 --- a/script/record-undeployment.sh +++ b/script/record-undeployment.sh @@ -1,4 +1,4 @@ -PACT_BROKER_FEATURES=deployments bundle exec bin/pact-broker record-undeployment \ +bundle exec bin/pact-broker record-undeployment \ --pacticipant foo-consumer --version 1 --environment prod --broker-base-url http://localhost:9292 --output json --verbose diff --git a/spec/pacts/pact_broker_client-pact_broker.json b/spec/pacts/pact_broker_client-pact_broker.json index feb78dd7..edc3e3de 100644 --- a/spec/pacts/pact_broker_client-pact_broker.json +++ b/spec/pacts/pact_broker_client-pact_broker.json @@ -1638,6 +1638,323 @@ } } }, + { + "description": "a request for the index resource", + "providerState": "the pb:pacticipant-version and pb:environments relations exist in the index resource", + "request": { + "method": "GET", + "path": "/", + "headers": { + "Accept": "application/hal+json" + } + }, + "response": { + "status": 200, + "headers": { + "Content-Type": "application/hal+json;charset=utf-8" + }, + "body": { + "_links": { + "pb:pacticipant-version": { + "href": "http://localhost:1234/HAL-REL-PLACEHOLDER-PB-PACTICIPANT-VERSION-{pacticipant}-{version}" + }, + "pb:environments": { + "href": "http://localhost:1234/HAL-REL-PLACEHOLDER-PB-ENVIRONMENTS" + } + } + }, + "matchingRules": { + "$.body._links.pb:pacticipant-version.href": { + "match": "regex", + "regex": "http:\\/\\/.*{pacticipant}.*{version}" + }, + "$.body._links.pb:environments.href": { + "match": "regex", + "regex": "http:\\/\\/.*" + } + } + } + }, + { + "description": "a request for a pacticipant version", + "providerState": "version 5556b8149bf8bac76bc30f50a8a2dd4c22c85f30 of pacticipant Foo exists with a test environment available for deployment", + "request": { + "method": "GET", + "path": "/HAL-REL-PLACEHOLDER-PB-PACTICIPANT-VERSION-Foo-5556b8149bf8bac76bc30f50a8a2dd4c22c85f30", + "headers": { + "Accept": "application/hal+json" + } + }, + "response": { + "status": 200, + "headers": { + "Content-Type": "application/hal+json;charset=utf-8" + }, + "body": { + "_links": { + "pb:record-deployment": [ + { + "name": "test", + "href": "http://localhost:1234/HAL-REL-PLACEHOLDER-PB-RECORD-DEPLOYMENT-FOO-5556B8149BF8BAC76BC30F50A8A2DD4C22C85F30-TEST" + } + ] + } + }, + "matchingRules": { + "$.body._links.pb:record-deployment[0].href": { + "match": "regex", + "regex": "http:\\/\\/.*" + } + } + } + }, + { + "description": "a request to record a deployment", + "providerState": "version 5556b8149bf8bac76bc30f50a8a2dd4c22c85f30 of pacticipant Foo exists with a test environment available for deployment", + "request": { + "method": "POST", + "path": "/HAL-REL-PLACEHOLDER-PB-RECORD-DEPLOYMENT-FOO-5556B8149BF8BAC76BC30F50A8A2DD4C22C85F30-TEST", + "headers": { + "Content-Type": "application/json", + "Accept": "application/hal+json" + }, + "body": { + "target": "blue" + } + }, + "response": { + "status": 201, + "headers": { + "Content-Type": "application/hal+json;charset=utf-8" + }, + "body": { + "target": "blue" + } + } + }, + { + "description": "a request for a pacticipant version", + "providerState": "version 5556b8149bf8bac76bc30f50a8a2dd4c22c85f30 of pacticipant Foo exists with 2 environments that aren't test available for deployment", + "request": { + "method": "GET", + "path": "/HAL-REL-PLACEHOLDER-PB-PACTICIPANT-VERSION-Foo-5556b8149bf8bac76bc30f50a8a2dd4c22c85f30", + "headers": { + "Accept": "application/hal+json" + } + }, + "response": { + "status": 200, + "headers": { + "Content-Type": "application/hal+json;charset=utf-8" + }, + "body": { + "_links": { + "pb:record-deployment": [ + { + "name": "prod", + "href": "href" + }, + { + "name": "dev", + "href": "href" + } + ] + } + }, + "matchingRules": { + "$.body._links.pb:record-deployment[0]": { + "match": "type" + }, + "$.body._links.pb:record-deployment[1]": { + "match": "type" + } + } + } + }, + { + "description": "a request for the environments", + "providerState": "an environment with name test exists", + "request": { + "method": "GET", + "path": "/HAL-REL-PLACEHOLDER-PB-ENVIRONMENTS", + "headers": { + "Accept": "application/hal+json" + } + }, + "response": { + "status": 200, + "headers": { + "Content-Type": "application/hal+json;charset=utf-8" + }, + "body": { + "_links": { + "pb:environments": [ + { + "name": "test", + "href": "href" + } + ] + } + }, + "matchingRules": { + "$.body._links.pb:environments[0].href": { + "match": "type" + } + } + } + }, + { + "description": "a request for a pacticipant version", + "providerState": "version 5556b8149bf8bac76bc30f50a8a2dd4c22c85f30 of pacticipant Foo exists with a test environment available for release", + "request": { + "method": "GET", + "path": "/HAL-REL-PLACEHOLDER-PB-PACTICIPANT-VERSION-Foo-5556b8149bf8bac76bc30f50a8a2dd4c22c85f30", + "headers": { + "Accept": "application/hal+json" + } + }, + "response": { + "status": 200, + "headers": { + "Content-Type": "application/hal+json;charset=utf-8" + }, + "body": { + "_links": { + "pb:record-release": [ + { + "name": "test", + "href": "http://localhost:1234/HAL-REL-PLACEHOLDER-PB-RECORD-RELEASE-FOO-5556B8149BF8BAC76BC30F50A8A2DD4C22C85F30-TEST" + } + ] + } + }, + "matchingRules": { + "$.body._links.pb:record-release[0].href": { + "match": "regex", + "regex": "http:\\/\\/.*" + } + } + } + }, + { + "description": "a request to record a release", + "providerState": "version 5556b8149bf8bac76bc30f50a8a2dd4c22c85f30 of pacticipant Foo exists with a test environment available for deployment", + "request": { + "method": "POST", + "path": "/HAL-REL-PLACEHOLDER-PB-RECORD-RELEASE-FOO-5556B8149BF8BAC76BC30F50A8A2DD4C22C85F30-TEST", + "headers": { + "Content-Type": "application/json", + "Accept": "application/hal+json" + } + }, + "response": { + "status": 201, + "headers": { + "Content-Type": "application/hal+json;charset=utf-8" + } + } + }, + { + "description": "a request for an environment", + "providerState": "an environment with name test and UUID 16926ef3-590f-4e3f-838e-719717aa88c9 exists", + "request": { + "method": "GET", + "path": "/HAL-REL-PLACEHOLDER-PB-ENVIRONMENT-16926ef3-590f-4e3f-838e-719717aa88c9", + "headers": { + "Accept": "application/hal+json" + } + }, + "response": { + "status": 200, + "headers": { + "Content-Type": "application/hal+json;charset=utf-8" + }, + "body": { + "_links": { + "pb:currently-deployed-deployed-versions": { + "href": "http://localhost:1234/PLACEHOLDER-ENVIRONMENT-CURRENTLY-DEPLOYED-16926ef3-590f-4e3f-838e-719717aa88c9" + } + } + }, + "matchingRules": { + "$.body._links.pb:currently-deployed-deployed-versions.href": { + "match": "regex", + "regex": "^http.*" + } + } + } + }, + { + "description": "a request to list the versions deployed to an environment for a pacticipant name and target", + "providerState": "an version is deployed to environment with UUID 16926ef3-590f-4e3f-838e-719717aa88c9 with target customer-1", + "request": { + "method": "GET", + "path": "/PLACEHOLDER-ENVIRONMENT-CURRENTLY-DEPLOYED-16926ef3-590f-4e3f-838e-719717aa88c9", + "query": "pacticipant=Foo", + "headers": { + "Accept": "application/hal+json" + } + }, + "response": { + "status": 200, + "headers": { + "Content-Type": "application/hal+json;charset=utf-8" + }, + "body": { + "_embedded": { + "deployedVersions": [ + { + "target": "customer-1", + "_links": { + "self": { + "href": "http://localhost:1234/PLACEHOLDER-DEPLOYED-VERSION-ff3adecf-cfc5-4653-a4e3-f1861092f8e0" + } + } + } + ] + } + }, + "matchingRules": { + "$.body._embedded.deployedVersions[0]._links.self.href": { + "match": "regex", + "regex": "^http" + } + } + } + }, + { + "description": "a request to mark a deployed version as not currently deploye", + "providerState": "a currently deployed version exists", + "request": { + "method": "PATCH", + "path": "/PLACEHOLDER-DEPLOYED-VERSION-ff3adecf-cfc5-4653-a4e3-f1861092f8e0", + "headers": { + "Content-Type": "application/merge-patch+json" + }, + "body": { + "currentlyDeployed": false + } + }, + "response": { + "status": 200, + "headers": { + "Content-Type": "application/hal+json;charset=utf-8" + }, + "body": { + "currentlyDeployed": false, + "_embedded": { + "version": { + "number": "2" + } + } + }, + "matchingRules": { + "$.body._embedded.version.number": { + "match": "type" + } + } + } + }, { "description": "a request to create a webhook with a JSON body for a consumer and provider", "providerState": "the 'Pricing Service' and 'Condor' already exist in the pact-broker", diff --git a/spec/service_providers/record_deployment_spec.rb b/spec/service_providers/record_deployment_spec.rb index 6c3adc14..fd5378c9 100644 --- a/spec/service_providers/record_deployment_spec.rb +++ b/spec/service_providers/record_deployment_spec.rb @@ -1,9 +1,7 @@ require 'service_providers/pact_helper' require 'pact_broker/client/deployments/record_deployment' -deployment_feature_on = ENV.fetch('PACT_BROKER_FEATURES', '').include?("deployments") - -RSpec.describe "recording a deployment", pact: true, skip: !deployment_feature_on do +RSpec.describe "recording a deployment", pact: true do include_context "pact broker" include PactBrokerPactHelperMethods diff --git a/spec/service_providers/record_release_spec.rb b/spec/service_providers/record_release_spec.rb index 2895c8ac..351a7057 100644 --- a/spec/service_providers/record_release_spec.rb +++ b/spec/service_providers/record_release_spec.rb @@ -1,9 +1,7 @@ require 'service_providers/pact_helper' require 'pact_broker/client/deployments/record_deployment' -deployment_feature_on = ENV.fetch('PACT_BROKER_FEATURES', '').include?("deployments") - -RSpec.describe "recording a release", pact: true, skip: !deployment_feature_on do +RSpec.describe "recording a release", pact: true do include_context "pact broker" include PactBrokerPactHelperMethods diff --git a/spec/service_providers/record_undeployment_spec.rb b/spec/service_providers/record_undeployment_spec.rb index 74b4e5a3..c40ec2b6 100644 --- a/spec/service_providers/record_undeployment_spec.rb +++ b/spec/service_providers/record_undeployment_spec.rb @@ -1,9 +1,7 @@ require 'service_providers/pact_helper' require 'pact_broker/client/deployments/record_undeployment' -deployment_feature_on = ENV.fetch('PACT_BROKER_FEATURES', '').include?("deployments") - -RSpec.describe "recording an undeployment", pact: true, skip: !deployment_feature_on do +RSpec.describe "recording an undeployment", pact: true do include_context "pact broker" include PactBrokerPactHelperMethods