pact_broker-client 1.69.0 → 1.71.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. checksums.yaml +4 -4
  2. data/.github/dependabot.yml +6 -0
  3. data/.github/workflows/release_gem.yml +1 -1
  4. data/.github/workflows/test.yml +4 -1
  5. data/CHANGELOG.md +15 -0
  6. data/README.md +64 -16
  7. data/doc/pacts/markdown/Pact Broker Client - Pactflow.md +98 -4
  8. data/doc/pacts/markdown/README.md +1 -1
  9. data/lib/pact_broker/client/cli/matrix_commands.rb +1 -2
  10. data/lib/pact_broker/client/hal/http_client.rb +1 -0
  11. data/lib/pact_broker/client/matrix/text_formatter.rb +19 -6
  12. data/lib/pact_broker/client/version.rb +1 -1
  13. data/lib/pactflow/client/cli/provider_contract_commands.rb +2 -1
  14. data/lib/pactflow/client/provider_contracts/publish.rb +48 -56
  15. data/lib/pactflow/client/provider_contracts/publish_the_old_way.rb +104 -0
  16. data/script/foo-bar.json +81 -0
  17. data/script/publish-pact.sh +8 -10
  18. data/script/publish-provider-contract.sh +1 -1
  19. data/script/update-cli-usage-in-readme.rb +1 -1
  20. data/spec/fixtures/approvals/publish_provider_contract.approved.txt +2 -0
  21. data/spec/integration/publish_provider_contract_spec.rb +57 -0
  22. data/spec/lib/pact_broker/client/matrix/text_formatter_spec.rb +10 -1
  23. data/spec/lib/pactflow/client/provider_contracts/publish_spec.rb +179 -0
  24. data/spec/pacts/pact_broker_client-pactflow.json +105 -3
  25. data/spec/service_providers/pact_helper.rb +16 -2
  26. data/spec/service_providers/pactflow_publish_provider_contract_spec.rb +64 -52
  27. data/spec/service_providers/pactflow_publish_provider_contract_the_old_way_spec.rb +129 -0
  28. data/spec/spec_helper.rb +4 -0
  29. data/spec/support/matrix_with_results.txt +2 -2
  30. data/tasks/pact.rake +29 -8
  31. metadata +13 -2
@@ -0,0 +1,104 @@
1
+ require "pact_broker/client/base_command"
2
+ require "pact_broker/client/versions/create"
3
+ require 'pact_broker/client/colorize_notices'
4
+ require "base64"
5
+
6
+ module Pactflow
7
+ module Client
8
+ module ProviderContracts
9
+ class PublishTheOldWay < PactBroker::Client::BaseCommand
10
+ attr_reader :branch_name, :tags, :provider_name, :provider_version_number, :contract, :verification_results
11
+
12
+ def initialize(params, options, pact_broker_client_options)
13
+ super
14
+ @provider_name = params[:provider_name]
15
+ @provider_version_number = params[:provider_version_number]
16
+ @branch_name = params[:branch_name]
17
+ @tags = params[:tags] || []
18
+ @contract = params[:contract]
19
+ @verification_results = params[:verification_results]
20
+ end
21
+
22
+ private
23
+
24
+ def do_call
25
+ create_branch_version_and_tags
26
+ render_response(create_contract)
27
+ end
28
+
29
+ def render_response(res)
30
+ notices = [
31
+ { type: 'success', text: "Successfully published provider contract for #{provider_name} version #{provider_version_number} to PactFlow"},
32
+ ]
33
+ if res.body && res.body['_links'] && res.body['_links']['pf:ui']['href']
34
+ notices.concat([{ text: "View the uploaded contract at #{res.body['_links']['pf:ui']['href']}" }])
35
+ end
36
+ notices.concat(next_steps)
37
+ PactBroker::Client::CommandResult.new(true, PactBroker::Client::ColorizeNotices.call(notices.collect do |n|
38
+ OpenStruct.new(n)
39
+ end).join("\n"))
40
+ end
41
+
42
+ def next_steps
43
+ [
44
+ { type: 'prompt', text: 'Next steps:' },
45
+ { type: 'prompt',
46
+ text: ' * Check your application is safe to deploy - https://docs.pact.io/can_i_deploy' },
47
+ { text: " pact-broker can-i-deploy --pacticipant #{provider_name} --version #{provider_version_number} --to-environment <your environment name>" },
48
+ { type: 'prompt',
49
+ text: ' * Record deployment or release to specified environment (choose one) - https://docs.pact.io/go/record-deployment' },
50
+ { text: " pact-broker record-deployment --pacticipant #{provider_name} --version #{provider_version_number} --environment <your environment name>" },
51
+ { text: " pact-broker record-release --pacticipant #{provider_name} --version #{provider_version_number} --environment <your environment name>" }
52
+ ]
53
+ end
54
+
55
+ def create_branch_version_and_tags
56
+ if branch_name || tags.any?
57
+ pacticipant_version_params = {
58
+ pacticipant_name: provider_name,
59
+ version_number: provider_version_number,
60
+ branch_name: branch_name,
61
+ tags: tags
62
+ }
63
+ result = PactBroker::Client::Versions::Create.call(pacticipant_version_params, options, pact_broker_client_options)
64
+ if !result.success
65
+ raise PactBroker::Client::Error.new(result.message)
66
+ end
67
+ end
68
+ end
69
+
70
+ def create_contract
71
+ contract_path = "#{pact_broker_base_url}/contracts/provider/{provider}/version/{version}"
72
+ entrypoint = create_entry_point(contract_path, pact_broker_client_options)
73
+ entrypoint.expand(provider: provider_name, version: provider_version_number).put!(contract_params).response
74
+ end
75
+
76
+ def contract_params
77
+ verification_results_params = {
78
+ success: verification_results[:success],
79
+ content: verification_results[:content] ? encode_content(verification_results[:content]) : nil,
80
+ contentType: verification_results[:content_type],
81
+ format: verification_results[:format],
82
+ verifier: verification_results[:verifier],
83
+ verifierVersion: verification_results[:verifier_version]
84
+ }.compact
85
+
86
+ body_params = {
87
+ content: encode_content(contract[:content]),
88
+ contractType: contract[:specification],
89
+ contentType: contract[:content_type],
90
+ }.compact
91
+
92
+ if verification_results_params.any?
93
+ body_params[:verificationResults] = verification_results_params
94
+ end
95
+ body_params
96
+ end
97
+
98
+ def encode_content oas
99
+ Base64.strict_encode64(oas)
100
+ end
101
+ end
102
+ end
103
+ end
104
+ end
@@ -0,0 +1,81 @@
1
+ {
2
+ "consumer": {
3
+ "name": "Foo"
4
+ },
5
+ "provider": {
6
+ "name": "Bar"
7
+ },
8
+ "interactions": [
9
+ {
10
+ "description": "a request to list the latest pacts",
11
+ "providerState": "a pact between Condor and the Pricing Service exists",
12
+ "request": {
13
+ "method": "get",
14
+ "path": "/pacts/latest",
15
+ "headers": {
16
+ }
17
+ },
18
+ "response": {
19
+ "status": 200,
20
+ "headers": {
21
+ "Content-Type": "application/hal+json"
22
+ },
23
+ "body": {
24
+ "_links": {
25
+ "self": {
26
+ "href": "http://example.org/pacts/latest"
27
+ }
28
+ },
29
+ "pacts": [
30
+ {
31
+ "_links": {
32
+ "self": [
33
+ {
34
+ "href": "http://example.org/pacts/provider/Pricing%20Service/consumer/Condor/latest"
35
+ },
36
+ {
37
+ "href": "http://example.org/pacts/provider/Pricing%20Service/consumer/Condor/version/1.3.0"
38
+ }
39
+ ]
40
+ },
41
+ "_embedded": {
42
+ "consumer": {
43
+ "name": "Condor",
44
+ "_links": {
45
+ "self": {
46
+ "href": "http://example.org/pacticipants/Condor"
47
+ }
48
+ },
49
+ "_embedded": {
50
+ "version": {
51
+ "number": "1.3.0"
52
+ }
53
+ }
54
+ },
55
+ "provider": {
56
+ "_links": {
57
+ "self": {
58
+ "href": "http://example.org/pacticipants/Pricing%20Service"
59
+ }
60
+ },
61
+ "name": "Pricing Service"
62
+ }
63
+ }
64
+ }
65
+ ]
66
+ },
67
+ "matchingRules": {
68
+ "$.headers.Content-Type": {
69
+ "match": "regex",
70
+ "regex": "application\\/hal\\+json"
71
+ }
72
+ }
73
+ }
74
+ }
75
+ ],
76
+ "metadata": {
77
+ "pactSpecification": {
78
+ "version": "2.0.0"
79
+ }
80
+ }
81
+ }
@@ -1,5 +1,5 @@
1
- export PACT_BROKER_BASE_URL="http://localhost:9292"
2
- export PACT_BROKER_TOKEN="localhost"
1
+ export PACT_BROKER_BASE_URL=${PACT_BROKER_BASE_URL:-"http://localhost:9292"}
2
+ export PACT_BROKER_TOKEN=${PACT_BROKER_TOKEN:-"localhost"}
3
3
  #export PACT_BROKER_FEATURES=publish_pacts_using_old_api
4
4
 
5
5
  # bundle exec bin/pact-broker create-or-update-webhook http://localhost:9393 \
@@ -8,11 +8,11 @@ export PACT_BROKER_TOKEN="localhost"
8
8
  # --description "foo webhook" \
9
9
  # --contract-published
10
10
 
11
- bundle exec bin/pact-broker create-or-update-webhook http://localhost:9393 \
12
- --uuid d40f38c3-aaa3-47f5-9161-95csfadfsd7 \
13
- --description "This is quite a long description for a webhook that I hope will be truncated" \
14
- --request POST \
15
- --contract-published
11
+ # bundle exec bin/pact-broker create-or-update-webhook http://localhost:9393 \
12
+ # --uuid d40f38c3-aaa3-47f5-9161-95csfadfsd7 \
13
+ # --description "This is quite a long description for a webhook that I hope will be truncated" \
14
+ # --request POST \
15
+ # --contract-published
16
16
 
17
17
  # bundle exec bin/pact-broker publish spec/pacts/pact_broker_client-pact_broker.json spec/fixtures/foo-bar.json \
18
18
  # --consumer-app-version 1.2.12 \
@@ -29,10 +29,8 @@ bundle exec bin/pact-broker create-or-update-webhook http://localhost:9393 \
29
29
  # --contract-published
30
30
 
31
31
 
32
- bundle exec bin/pact-broker publish spec/pacts/pact_broker_client-pact_broker.json \
32
+ bundle exec bin/pact-broker publish scripts/foo-bar.json \
33
33
  --consumer-app-version 1.2.26 \
34
- --broker-base-url http://localhost:9292 \
35
- --broker-token localhost \
36
34
  --auto-detect-version-properties \
37
35
  --build-url http://mybuild \
38
36
  --branch master --tag foo5 --tag foo6
@@ -1,7 +1,7 @@
1
1
  export PACT_BROKER_BASE_URL=${PACT_BROKER_BASE_URL:-"http://localhost:9292"}
2
2
  bundle exec bin/pactflow publish-provider-contract \
3
3
  script/oas.yml \
4
- --provider Foo \
4
+ --provider Bar \
5
5
  --provider-app-version 1013b5650d61214e19f10558f97fb5a3bb082d44 \
6
6
  --branch main \
7
7
  --tag dev \
@@ -13,7 +13,7 @@ PACT_BROKER_COMMAND_GROUPS = [
13
13
  [PactBroker::Client::CLI::Broker, "Environments", %w[create-environment update-environment describe-environment delete-environment list-environments]],
14
14
  [PactBroker::Client::CLI::Broker, "Deployments", %w[record-deployment record-undeployment]],
15
15
  [PactBroker::Client::CLI::Broker, "Releases", %w[record-release record-support-ended]],
16
- [PactBroker::Client::CLI::Broker, "Matrix", %w[can-i-deploy]],
16
+ [PactBroker::Client::CLI::Broker, "Matrix", %w[can-i-deploy can-i-merge]],
17
17
  [PactBroker::Client::CLI::Broker, "Pacticipants", %w[create-or-update-pacticipant describe-pacticipant list-pacticipants]],
18
18
  [PactBroker::Client::CLI::Broker, "Webhooks", %w[create-webhook create-or-update-webhook test-webhook]],
19
19
  [PactBroker::Client::CLI::Broker, "Tags", %w[create-version-tag]],
@@ -0,0 +1,2 @@
1
+ some notice
2
+ some other notice
@@ -0,0 +1,57 @@
1
+ require "pactflow/client/cli/pactflow"
2
+
3
+ RSpec.describe "publish-provider-contract" do
4
+ before do
5
+ allow(ENV).to receive(:fetch).and_call_original
6
+ allow(ENV).to receive(:fetch).with("PACT_BROKER_FEATURES", "").and_return("publish_provider_contracts_all_in_one")
7
+ end
8
+ let(:index_body_hash) do
9
+ {
10
+ _links: {
11
+ "pf:publish-provider-contract" => {
12
+ href: "http://broker/some-publish/{provider}"
13
+ }
14
+ }
15
+ }
16
+ end
17
+
18
+ let(:post_response_body) do
19
+ {
20
+ "notices"=>[{"text"=>"some notice", "type"=>"info"}, {"text"=>"some other notice", "type"=>"info"}]
21
+ }
22
+ end
23
+
24
+ let!(:index_request) do
25
+ stub_request(:get, "http://broker").to_return(status: 200, body: index_body_hash.to_json, headers: { "Content-Type" => "application/hal+json" } )
26
+ end
27
+
28
+ let!(:publish_request) do
29
+ stub_request(:post, "http://broker/some-publish/Bar").to_return(status: 200, body: post_response_body.to_json, headers: { "Content-Type" => "application/hal+json" } )
30
+ end
31
+
32
+ let(:parameters) do
33
+ %w{
34
+ publish-provider-contract
35
+ script/oas.yml
36
+ --provider Bar
37
+ --broker-base-url http://broker
38
+ --provider-app-version 1013b5650d61214e19f10558f97fb5a3bb082d44
39
+ --branch main
40
+ --tag dev
41
+ --specification oas
42
+ --content-type application/yml
43
+ --verification-exit-code 0
44
+ --verification-results script/verification-results.txt
45
+ --verification-results-content-type text/plain
46
+ --verification-results-format text
47
+ --verifier my-custom-tool
48
+ --verifier-version "1.0"
49
+ }
50
+ end
51
+
52
+ subject { capture(:stdout) { Pactflow::Client::CLI::Pactflow.start(parameters) } }
53
+
54
+ it "prints the notices" do
55
+ Approvals.verify(subject, :name => "publish_provider_contract", format: :txt)
56
+ end
57
+ end
@@ -36,9 +36,18 @@ module PactBroker
36
36
  line_1 = line_creator.call
37
37
  line_2 = line_creator.call
38
38
  line_3 = line_creator.call
39
+
40
+ # ensure the data is as expected
41
+ expect(line_1.dig(:consumer, :version, :number)).to_not be nil
42
+ expect(line_1.dig(:provider, :version, :number)).to_not be nil
43
+
44
+ line_1[:consumer][:version][:number] = "4"
45
+ line_2[:consumer][:version][:number] = "3"
46
+ line_3[:consumer][:version][:number] = "5"
47
+
39
48
  line_2[:verificationResult] = nil
40
49
  line_3[:verificationResult][:success] = false
41
- [line_1, line_2, line_3]
50
+ [line_1, line_2, line_3].shuffle
42
51
  end
43
52
 
44
53
  let(:matrix) { PactBroker::Client::Matrix::Resource.new(matrix: matrix_lines) }
@@ -0,0 +1,179 @@
1
+ require "pactflow/client/provider_contracts/publish"
2
+
3
+ module Pactflow
4
+ module Client
5
+ module ProviderContracts
6
+ describe Publish do
7
+ before do
8
+ allow_any_instance_of(PactBroker::Client::Hal::HttpClient).to receive(:sleep)
9
+ allow_any_instance_of(PactBroker::Client::Hal::HttpClient).to receive(:default_max_tries).and_return(1)
10
+ allow(ENV).to receive(:fetch).and_call_original
11
+ allow(ENV).to receive(:fetch).with("PACT_BROKER_FEATURES", "").and_return("publish_provider_contracts_all_in_one")
12
+ end
13
+
14
+ let(:command_params) do
15
+ {
16
+ provider_name: "Bar",
17
+ provider_version_number: "1",
18
+ branch_name: "main",
19
+ tags: ["dev"],
20
+ build_url: "http://build",
21
+ contract: {
22
+ content: { "some" => "contract" }.to_yaml,
23
+ content_type: "application/yaml",
24
+ specification: "oas"
25
+ },
26
+ verification_results: {
27
+ success: true,
28
+ content: "some results",
29
+ content_type: "text/plain",
30
+ format: "text",
31
+ verifier: "my custom tool",
32
+ verifier_version: "1.0"
33
+ }
34
+ }
35
+ end
36
+
37
+ let(:options) do
38
+ {
39
+ verbose: false
40
+ }
41
+ end
42
+
43
+ let(:pact_broker_client_options) do
44
+ { pact_broker_base_url: "http://pactflow" }
45
+ end
46
+
47
+ let(:index_body_hash) do
48
+ {
49
+ _links: {
50
+ "pf:publish-provider-contract" => {
51
+ href: "http://pactflow/some-publish/{provider}"
52
+ }
53
+ }
54
+ }
55
+ end
56
+
57
+ let(:post_response_body) do
58
+ {
59
+ "notices"=>[{"text"=>"some notice", "type"=>"info"}]
60
+ }
61
+ end
62
+
63
+ let!(:index_request) do
64
+ stub_request(:get, "http://pactflow")
65
+ .to_return(
66
+ status: index_status,
67
+ body: index_body_hash.to_json,
68
+ headers: { "Content-Type" => "application/hal+json" }
69
+ )
70
+ end
71
+ let(:index_status) { 200 }
72
+
73
+ let!(:publish_request) do
74
+ stub_request(:post, "http://pactflow/some-publish/Bar")
75
+ .to_return(
76
+ status: publish_status,
77
+ body: post_response_body.to_json,
78
+ headers: { "Content-Type" => "application/hal+json" }
79
+ )
80
+ end
81
+ let(:publish_status) { 200 }
82
+
83
+ subject { Publish.call(command_params, options, pact_broker_client_options) }
84
+
85
+ context "when there is no relation pf:publish-provider-contract" do
86
+ before do
87
+ allow(PublishTheOldWay).to receive(:call).with(command_params, options, pact_broker_client_options).and_return(instance_double(PactBroker::Client::CommandResult))
88
+ end
89
+
90
+ let(:index_body_hash) do
91
+ {
92
+ _links: {}
93
+ }
94
+ end
95
+
96
+ it "publishes the provider contracts the old way" do
97
+ expect(PublishTheOldWay).to receive(:call).with(command_params, options, pact_broker_client_options)
98
+ subject
99
+ end
100
+ end
101
+
102
+ context "when the feature is not enabled" do
103
+ before do
104
+ allow(ENV).to receive(:fetch).with("PACT_BROKER_FEATURES", "").and_return("")
105
+ end
106
+
107
+ it "publishes the provider contracts the old way" do
108
+ expect(PublishTheOldWay).to receive(:call).with(command_params, options, pact_broker_client_options)
109
+ subject
110
+ end
111
+ end
112
+
113
+ it "returns a result and message" do
114
+ expect(subject.success).to be true
115
+ expect(subject.message).to include("some notice")
116
+ end
117
+
118
+ it "colourises the notices" do
119
+ expect(PactBroker::Client::ColorizeNotices).to receive(:call).with([OpenStruct.new(text: "some notice", type: "info")]).and_return("coloured notices")
120
+ expect(subject.message).to eq "coloured notices"
121
+ end
122
+
123
+ context "when the output is json" do
124
+ let(:options) { { output: "json" } }
125
+
126
+ it "returns the raw response" do
127
+ expect(subject.message).to eq post_response_body.to_json
128
+ end
129
+ end
130
+
131
+ context "when there is an error retrieving the index" do
132
+ let(:index_status) { 500 }
133
+ let(:index_body_hash) { { "some" => "error" }}
134
+
135
+ it "returns an error result with the response body" do
136
+ expect(subject.success).to be false
137
+ expect(subject.message).to match(/some.*error/)
138
+ end
139
+ end
140
+
141
+ context "when there is an error response from publishing" do
142
+ let(:publish_status) { 400 }
143
+ let(:post_response_body) do
144
+ {
145
+ "some" => "error"
146
+ }
147
+ end
148
+
149
+ it "returns an error result with the response body" do
150
+ expect(subject.success).to be false
151
+ expect(subject.message).to match(/some.*error/)
152
+ end
153
+
154
+ context "when the output is json" do
155
+ let(:options) { { output: "json" } }
156
+
157
+ it "returns the raw response" do
158
+ expect(subject.message).to eq post_response_body.to_json
159
+ end
160
+ end
161
+ end
162
+
163
+ context "when there is an error response from publishing" do
164
+ let(:publish_status) { 400 }
165
+ let(:post_response_body) do
166
+ {
167
+ "some" => "error"
168
+ }
169
+ end
170
+
171
+ it "returns an error result with the response body" do
172
+ expect(subject.success).to be false
173
+ expect(subject.message).to match(/some.*error/)
174
+ end
175
+ end
176
+ end
177
+ end
178
+ end
179
+ end
@@ -6,6 +6,103 @@
6
6
  "name": "PactFlow"
7
7
  },
8
8
  "interactions": [
9
+ {
10
+ "description": "a request for the index resource",
11
+ "providerState": "the pb:publish-provider-contract relation exists in the index resource",
12
+ "request": {
13
+ "method": "GET",
14
+ "path": "/",
15
+ "headers": {
16
+ "Accept": "application/hal+json"
17
+ }
18
+ },
19
+ "response": {
20
+ "status": 200,
21
+ "headers": {
22
+ "Content-Type": "application/hal+json;charset=utf-8"
23
+ },
24
+ "body": {
25
+ "_links": {
26
+ "pf:publish-provider-contract": {
27
+ "href": "http://localhost:1235/HAL-REL-PLACEHOLDER-PF-PUBLISH-PROVIDER-CONTRACT-{provider}"
28
+ }
29
+ }
30
+ },
31
+ "matchingRules": {
32
+ "$.body._links.pf:publish-provider-contract.href": {
33
+ "match": "regex",
34
+ "regex": "http:\\/\\/.*{provider}"
35
+ }
36
+ }
37
+ }
38
+ },
39
+ {
40
+ "description": "a request to publish a provider contract",
41
+ "request": {
42
+ "method": "post",
43
+ "path": "/HAL-REL-PLACEHOLDER-PF-PUBLISH-PROVIDER-CONTRACT-Bar",
44
+ "headers": {
45
+ "Content-Type": "application/json",
46
+ "Accept": "application/hal+json"
47
+ },
48
+ "body": {
49
+ "pacticipantVersionNumber": "1",
50
+ "tags": [
51
+ "dev"
52
+ ],
53
+ "branch": "main",
54
+ "buildUrl": "http://build",
55
+ "contract": {
56
+ "content": "LS0tCnNvbWU6IGNvbnRyYWN0Cg==",
57
+ "contentType": "application/yaml",
58
+ "specification": "oas",
59
+ "selfVerificationResults": {
60
+ "success": true,
61
+ "content": "c29tZSByZXN1bHRz",
62
+ "contentType": "text/plain",
63
+ "format": "text",
64
+ "verifier": "my custom tool",
65
+ "verifierVersion": "1.0"
66
+ }
67
+ }
68
+ }
69
+ },
70
+ "response": {
71
+ "status": 200,
72
+ "headers": {
73
+ "Content-Type": "application/hal+json;charset=utf-8"
74
+ },
75
+ "body": {
76
+ "notices": [
77
+ {
78
+ "text": "some notice",
79
+ "type": "info"
80
+ }
81
+ ],
82
+ "_embedded": {
83
+ "version": {
84
+ "number": "1"
85
+ }
86
+ },
87
+ "_links": {
88
+ "pb:pacticipant-version-tags": [
89
+ {
90
+ }
91
+ ],
92
+ "pb:branch-version": {
93
+ }
94
+ }
95
+ },
96
+ "matchingRules": {
97
+ "$.body.notices": {
98
+ "min": 1
99
+ },
100
+ "$.body.notices[*].*": {
101
+ "match": "type"
102
+ }
103
+ }
104
+ }
105
+ },
9
106
  {
10
107
  "description": "a request to create a provider contract",
11
108
  "request": {
@@ -16,7 +113,7 @@
16
113
  "Accept": "application/hal+json"
17
114
  },
18
115
  "body": {
19
- "content": "LS0tCjpzb21lOiBjb250cmFjdAo=",
116
+ "content": "LS0tCnNvbWU6IGNvbnRyYWN0Cg==",
20
117
  "contractType": "oas",
21
118
  "contentType": "application/yaml",
22
119
  "verificationResults": {
@@ -47,7 +144,7 @@
47
144
  "Accept": "application/hal+json"
48
145
  },
49
146
  "body": {
50
- "content": "LS0tCjpzb21lOiBjb250cmFjdAo=",
147
+ "content": "LS0tCnNvbWU6IGNvbnRyYWN0Cg==",
51
148
  "contractType": "oas",
52
149
  "contentType": "application/yaml",
53
150
  "verificationResults": {
@@ -68,9 +165,14 @@
68
165
  "body": {
69
166
  "_links": {
70
167
  "pf:ui": {
71
- "href": "http://localhost:1235/contracts/bi-directional/provider/Bar/version/1/provider-contract"
168
+ "href": "some-url"
72
169
  }
73
170
  }
171
+ },
172
+ "matchingRules": {
173
+ "$.body._links.pf:ui.href": {
174
+ "match": "type"
175
+ }
74
176
  }
75
177
  }
76
178
  },
@@ -25,10 +25,12 @@ end
25
25
 
26
26
  module PactBrokerPactHelperMethods
27
27
 
28
+ # @param [String] relation eg "pb:pacticipant"
29
+ # @param [Array<String>] params eg ["Foo"]
28
30
  def placeholder_path(relation, params = [])
29
31
  path = "/HAL-REL-PLACEHOLDER-#{relation.gsub(':', '-').upcase}"
30
32
  if params.any?
31
- joined_params = params.collect{ |param| "{#{param}}"}.join("-")
33
+ joined_params = params.join("-")
32
34
  path = "#{path}-#{joined_params}"
33
35
  end
34
36
 
@@ -36,7 +38,19 @@ module PactBrokerPactHelperMethods
36
38
  end
37
39
 
38
40
  def placeholder_url(relation, params = [], mock_service = pact_broker)
39
- "#{mock_service.mock_service_base_url}#{placeholder_path(relation, params)}"
41
+ "#{mock_service.mock_service_base_url}#{placeholder_path_for_term(relation, params)}"
42
+ end
43
+
44
+ # @param [String] relation eg "pb:pacticipants"
45
+ # @param [Array<String>] params eg ["pacticipant"]
46
+ def placeholder_path_for_term(relation, params = [])
47
+ path = "/HAL-REL-PLACEHOLDER-#{relation.gsub(':', '-').upcase}"
48
+ if params.any?
49
+ joined_params = params.collect{ |param| "{#{param}}"}.join("-")
50
+ path = "#{path}-#{joined_params}"
51
+ end
52
+
53
+ path
40
54
  end
41
55
 
42
56
  def placeholder_url_term(relation, params = [], mock_service = pact_broker)