pact_broker-client 1.70.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.
- checksums.yaml +4 -4
- data/.github/workflows/test.yml +4 -1
- data/CHANGELOG.md +7 -0
- data/README.md +64 -16
- data/doc/pacts/markdown/Pact Broker Client - Pactflow.md +98 -4
- data/doc/pacts/markdown/README.md +1 -1
- data/lib/pact_broker/client/cli/matrix_commands.rb +1 -2
- data/lib/pact_broker/client/version.rb +1 -1
- data/lib/pactflow/client/cli/provider_contract_commands.rb +2 -1
- data/lib/pactflow/client/provider_contracts/publish.rb +48 -56
- data/lib/pactflow/client/provider_contracts/publish_the_old_way.rb +104 -0
- data/script/foo-bar.json +81 -0
- data/script/publish-pact.sh +8 -10
- data/script/publish-provider-contract.sh +1 -1
- data/script/update-cli-usage-in-readme.rb +1 -1
- data/spec/fixtures/approvals/publish_provider_contract.approved.txt +2 -0
- data/spec/integration/publish_provider_contract_spec.rb +57 -0
- data/spec/lib/pactflow/client/provider_contracts/publish_spec.rb +179 -0
- data/spec/pacts/pact_broker_client-pactflow.json +105 -3
- data/spec/service_providers/pact_helper.rb +16 -2
- data/spec/service_providers/pactflow_publish_provider_contract_spec.rb +64 -52
- data/spec/service_providers/pactflow_publish_provider_contract_the_old_way_spec.rb +129 -0
- data/spec/spec_helper.rb +4 -0
- data/tasks/pact.rake +29 -8
- metadata +12 -2
data/script/foo-bar.json
ADDED
|
@@ -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
|
+
}
|
data/script/publish-pact.sh
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export PACT_BROKER_BASE_URL
|
|
2
|
-
export PACT_BROKER_TOKEN
|
|
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
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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
|
|
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
|
|
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,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
|
|
@@ -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": "
|
|
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": "
|
|
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": "
|
|
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.
|
|
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}#{
|
|
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)
|