From abc8ea3fd6440cd5aa62725b40cb107d08be8ca1 Mon Sep 17 00:00:00 2001 From: Beth Skurrie Date: Thu, 26 Oct 2023 09:30:10 +1100 Subject: [PATCH] fix: set correct Accept header when publishing provider contracts --- doc/pacts/markdown/Pact Broker Client - Pactflow.md | 2 +- lib/pactflow/client/provider_contracts/publish.rb | 2 +- script/publish-provider-contract.sh | 1 - spec/pacts/pact_broker_client-pactflow.json | 2 +- .../pactflow_publish_provider_contract_spec.rb | 2 +- 5 files changed, 4 insertions(+), 5 deletions(-) diff --git a/doc/pacts/markdown/Pact Broker Client - Pactflow.md b/doc/pacts/markdown/Pact Broker Client - Pactflow.md index 2aa4759..63990b2 100644 --- a/doc/pacts/markdown/Pact Broker Client - Pactflow.md +++ b/doc/pacts/markdown/Pact Broker Client - Pactflow.md @@ -210,7 +210,7 @@ Upon receiving **a request to publish a provider contract** from Pact Broker Cli "path": "/HAL-REL-PLACEHOLDER-PF-PUBLISH-PROVIDER-CONTRACT-Bar", "headers": { "Content-Type": "application/json", - "Accept": "application/hal+json" + "Accept": "application/hal+json,application/problem+json" }, "body": { "pacticipantVersionNumber": "1", diff --git a/lib/pactflow/client/provider_contracts/publish.rb b/lib/pactflow/client/provider_contracts/publish.rb index d18e127..3b34316 100644 --- a/lib/pactflow/client/provider_contracts/publish.rb +++ b/lib/pactflow/client/provider_contracts/publish.rb @@ -39,7 +39,7 @@ def disabled? end def publish_provider_contracts - @response_entity = index_resource._link(PUBLISH_RELATION).expand(provider: provider_name).post!(contract_params, headers: { "Accept" => "application/hal+json,application/problem+json" }) + @response_entity = index_resource._link(PUBLISH_RELATION).expand(provider: provider_name).post!(contract_params, { "Accept" => "application/hal+json,application/problem+json" }) end def contract_params diff --git a/script/publish-provider-contract.sh b/script/publish-provider-contract.sh index 99c4fff..3ea77e6 100755 --- a/script/publish-provider-contract.sh +++ b/script/publish-provider-contract.sh @@ -6,7 +6,6 @@ bundle exec bin/pactflow publish-provider-contract \ --branch main \ --tag dev \ --specification oas \ - --content-type application/yml \ --verification-exit-code 0 \ --verification-results script/verification-results.txt \ --verification-results-content-type text/plain \ diff --git a/spec/pacts/pact_broker_client-pactflow.json b/spec/pacts/pact_broker_client-pactflow.json index b5ef8b4..8c0d86f 100644 --- a/spec/pacts/pact_broker_client-pactflow.json +++ b/spec/pacts/pact_broker_client-pactflow.json @@ -43,7 +43,7 @@ "path": "/HAL-REL-PLACEHOLDER-PF-PUBLISH-PROVIDER-CONTRACT-Bar", "headers": { "Content-Type": "application/json", - "Accept": "application/hal+json" + "Accept": "application/hal+json,application/problem+json" }, "body": { "pacticipantVersionNumber": "1", diff --git a/spec/service_providers/pactflow_publish_provider_contract_spec.rb b/spec/service_providers/pactflow_publish_provider_contract_spec.rb index dc43764..45c59d0 100644 --- a/spec/service_providers/pactflow_publish_provider_contract_spec.rb +++ b/spec/service_providers/pactflow_publish_provider_contract_spec.rb @@ -123,7 +123,7 @@ .with( method: :post, path: placeholder_path("pf:publish-provider-contract", ["Bar"]), - headers: post_request_headers, + headers: post_request_headers.merge("Accept" => "application/hal+json,application/problem+json"), body: request_body ).will_respond_with(success_response) end