pact_broker-client 1.75.3 → 1.75.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/lib/pact_broker/client/version.rb +1 -1
- metadata +5 -216
- data/.github/workflows/test.yml +0 -59
- data/.rspec +0 -3
- data/lib/pact_broker/client/pacts/list_latest_versions.rb +0 -66
- data/lib/pact_broker/client/webhooks/test.rb +0 -16
- data/pact-broker-client.gemspec +0 -31
- data/spec/fixtures/MyConsumer-MyProvider (1).json +0 -37
- data/spec/fixtures/MyConsumer-MyProvider.json +0 -37
- data/spec/fixtures/approvals/can_i_deploy_failure_dry_run.approved.txt +0 -7
- data/spec/fixtures/approvals/can_i_deploy_ignore.approved.txt +0 -13
- data/spec/fixtures/approvals/can_i_deploy_success_dry_run.approved.txt +0 -7
- data/spec/fixtures/approvals/describe_environment.approved.txt +0 -7
- data/spec/fixtures/approvals/describe_pacticipant.approved.txt +0 -2
- data/spec/fixtures/approvals/list_environments.approved.txt +0 -3
- data/spec/fixtures/approvals/publish_provider_contract.approved.txt +0 -2
- data/spec/fixtures/certificates/ca_cert.pem +0 -19
- data/spec/fixtures/certificates/ca_cert.srl +0 -1
- data/spec/fixtures/certificates/ca_key.pem +0 -28
- data/spec/fixtures/certificates/client_cert.pem +0 -17
- data/spec/fixtures/certificates/key.pem +0 -28
- data/spec/fixtures/certificates/server.csr +0 -15
- data/spec/fixtures/certificates/unsigned_cert.pem +0 -19
- data/spec/fixtures/certificates/unsigned_key.pem +0 -28
- data/spec/fixtures/foo-bar.json +0 -31
- data/spec/integration/can_i_deploy_spec.rb +0 -24
- data/spec/integration/can_i_merge_spec.rb +0 -44
- data/spec/integration/create_version_tag_spec.rb +0 -20
- data/spec/integration/describe_environment_spec.rb +0 -31
- data/spec/integration/publish_provider_contract_spec.rb +0 -53
- data/spec/integration/unknown_options_spec.rb +0 -39
- data/spec/lib/pact_broker/client/base_client_spec.rb +0 -182
- data/spec/lib/pact_broker/client/branches/delete_branch_spec.rb +0 -103
- data/spec/lib/pact_broker/client/can_i_deploy_spec.rb +0 -250
- data/spec/lib/pact_broker/client/cli/broker_can_i_deploy_spec.rb +0 -196
- data/spec/lib/pact_broker/client/cli/broker_create_or_update_webhook_spec.rb +0 -23
- data/spec/lib/pact_broker/client/cli/broker_create_webhook_spec.rb +0 -23
- data/spec/lib/pact_broker/client/cli/broker_publish_spec.rb +0 -327
- data/spec/lib/pact_broker/client/cli/broker_run_webhook_commands_spec.rb +0 -287
- data/spec/lib/pact_broker/client/cli/custom_thor_spec.rb +0 -174
- data/spec/lib/pact_broker/client/cli/version_selector_options_parser_spec.rb +0 -97
- data/spec/lib/pact_broker/client/deployments/record_deployment_spec.rb +0 -224
- data/spec/lib/pact_broker/client/deployments/record_support_ended_spec.rb +0 -208
- data/spec/lib/pact_broker/client/deployments/record_undeployment_spec.rb +0 -227
- data/spec/lib/pact_broker/client/environments/delete_environment_spec.rb +0 -120
- data/spec/lib/pact_broker/client/environments/describe_environment_spec.rb +0 -89
- data/spec/lib/pact_broker/client/environments/update_environment_spec.rb +0 -167
- data/spec/lib/pact_broker/client/generate_display_name_spec.rb +0 -39
- data/spec/lib/pact_broker/client/git_spec.rb +0 -159
- data/spec/lib/pact_broker/client/hal/authorization_header_redactor_spec.rb +0 -17
- data/spec/lib/pact_broker/client/hal/entity_spec.rb +0 -149
- data/spec/lib/pact_broker/client/hal/http_client_spec.rb +0 -238
- data/spec/lib/pact_broker/client/hal/link_spec.rb +0 -127
- data/spec/lib/pact_broker/client/matrix/abbreviate_version_number_spec.rb +0 -42
- data/spec/lib/pact_broker/client/matrix/resource_spec.rb +0 -70
- data/spec/lib/pact_broker/client/matrix/text_formatter_spec.rb +0 -63
- data/spec/lib/pact_broker/client/matrix_spec.rb +0 -17
- data/spec/lib/pact_broker/client/merge_pacts_spec.rb +0 -198
- data/spec/lib/pact_broker/client/pact_broker_client_spec.rb +0 -47
- data/spec/lib/pact_broker/client/pacticipants/create_spec.rb +0 -31
- data/spec/lib/pact_broker/client/pacticipants_spec.rb +0 -18
- data/spec/lib/pact_broker/client/publish_pacts_the_old_way_spec.rb +0 -272
- data/spec/lib/pact_broker/client/retry_spec.rb +0 -119
- data/spec/lib/pact_broker/client/tasks/publication_task_spec.rb +0 -231
- data/spec/lib/pact_broker/client/versions/create_spec.rb +0 -174
- data/spec/lib/pact_broker/client/versions/describe_spec.rb +0 -64
- data/spec/lib/pact_broker/client/versions_spec.rb +0 -34
- data/spec/lib/pact_broker/client/webhooks/create_spec.rb +0 -99
- data/spec/lib/pactflow/client/provider_contracts/publish_spec.rb +0 -179
- data/spec/pacts/pact_broker_client-pact_broker.json +0 -2969
- data/spec/pacts/pact_broker_client-pactflow.json +0 -288
- data/spec/readme_spec.rb +0 -16
- data/spec/service_providers/create_environment_spec.rb +0 -78
- data/spec/service_providers/delete_branch_spec.rb +0 -68
- data/spec/service_providers/extra_goodies_spec.rb +0 -108
- data/spec/service_providers/list_environments_spec.rb +0 -77
- data/spec/service_providers/list_latest_pact_versions_spec.rb.bak +0 -44
- data/spec/service_providers/pact_broker_client_matrix_ignore_spec.rb +0 -98
- data/spec/service_providers/pact_broker_client_matrix_spec.rb +0 -292
- data/spec/service_providers/pact_broker_client_pacticipant_version_spec.rb +0 -56
- data/spec/service_providers/pact_broker_client_publish_spec.rb +0 -135
- data/spec/service_providers/pact_broker_client_register_repository_spec.rb +0 -49
- data/spec/service_providers/pact_broker_client_retrieve_all_pacts_for_provider_spec.rb +0 -53
- data/spec/service_providers/pact_broker_client_retrieve_pact_spec.rb +0 -109
- data/spec/service_providers/pact_broker_client_tags_spec.rb +0 -101
- data/spec/service_providers/pact_broker_client_versions_spec.rb +0 -113
- data/spec/service_providers/pact_helper.rb +0 -136
- data/spec/service_providers/pactflow_publish_provider_contract_spec.rb +0 -137
- data/spec/service_providers/pactflow_publish_provider_contract_the_old_way_spec.rb +0 -129
- data/spec/service_providers/pactflow_webhooks_create_spec.rb +0 -86
- data/spec/service_providers/pacticipants_create_spec.rb +0 -119
- data/spec/service_providers/publish_pacts_spec.rb +0 -114
- data/spec/service_providers/record_deployment_spec.rb +0 -199
- data/spec/service_providers/record_release_spec.rb +0 -130
- data/spec/service_providers/record_undeployment_spec.rb +0 -164
- data/spec/service_providers/webhooks_create_spec.rb +0 -391
- data/spec/spec_helper.rb +0 -68
- data/spec/support/approvals.rb +0 -26
- data/spec/support/cli_test_pacts/bar.json +0 -0
- data/spec/support/cli_test_pacts/foo.json +0 -0
- data/spec/support/latest_pacts_for_provider.json +0 -15
- data/spec/support/matrix.json +0 -35
- data/spec/support/matrix.txt +0 -3
- data/spec/support/matrix_error.txt +0 -3
- data/spec/support/matrix_with_results.txt +0 -10
- data/spec/support/pacticipant_get.json +0 -18
- data/spec/support/pacticipants_list.json +0 -26
- data/spec/support/pacts_latest_list.json +0 -41
- data/spec/support/shared_context.rb +0 -25
- data/spec/support/ssl_server.rb +0 -42
@@ -1,98 +0,0 @@
|
|
1
|
-
require_relative 'pact_helper'
|
2
|
-
require 'pact_broker/client/can_i_deploy'
|
3
|
-
|
4
|
-
module PactBroker::Client
|
5
|
-
describe Matrix, :pact => true do
|
6
|
-
|
7
|
-
include_context "pact broker"
|
8
|
-
|
9
|
-
describe "can-i-deploy ignoring a pacticipant version" do
|
10
|
-
let(:matrix_response_body) { matrix }
|
11
|
-
let(:matrix) do
|
12
|
-
{
|
13
|
-
"summary" => {
|
14
|
-
"deployable" => true,
|
15
|
-
"ignored" => 1
|
16
|
-
},
|
17
|
-
"notices" => Pact.each_like("text" => "some notice", "type" => "info"),
|
18
|
-
"matrix" => [
|
19
|
-
{
|
20
|
-
"consumer" => {
|
21
|
-
"name" => "Foo",
|
22
|
-
"version" => {
|
23
|
-
"number" => "1.2.3"
|
24
|
-
}
|
25
|
-
},
|
26
|
-
"provider" => {
|
27
|
-
"name" => "Bar",
|
28
|
-
"version" => {
|
29
|
-
"number" => "4.5.6"
|
30
|
-
}
|
31
|
-
},
|
32
|
-
"verificationResult" => {
|
33
|
-
"success" => true,
|
34
|
-
"_links" => {
|
35
|
-
"self" => {
|
36
|
-
"href" => Pact.like("http://result")
|
37
|
-
}
|
38
|
-
}
|
39
|
-
}
|
40
|
-
},{
|
41
|
-
"consumer" => {
|
42
|
-
"name" => "Foo",
|
43
|
-
"version" => {
|
44
|
-
"number" => "3.4.5"
|
45
|
-
}
|
46
|
-
},
|
47
|
-
"provider" => {
|
48
|
-
"name" => "Bar",
|
49
|
-
"version" => {
|
50
|
-
"number" => "4.5.6"
|
51
|
-
}
|
52
|
-
},
|
53
|
-
"verificationResult" => {
|
54
|
-
"success" => false,
|
55
|
-
"_links" => {
|
56
|
-
"self" => {
|
57
|
-
"href" => Pact.like("http://result")
|
58
|
-
}
|
59
|
-
}
|
60
|
-
},
|
61
|
-
"ignored" => true
|
62
|
-
}
|
63
|
-
]
|
64
|
-
}
|
65
|
-
|
66
|
-
end
|
67
|
-
let(:selectors) { [{ pacticipant: "Bar", version: "4.5.6" }, { pacticipant: "Foo", tag: "prod" } ] }
|
68
|
-
let(:matrix_options) do
|
69
|
-
{
|
70
|
-
ignore_selectors: [{ pacticipant: "Foo", version: "3.4.5" }]
|
71
|
-
}
|
72
|
-
end
|
73
|
-
let(:options) { { retry_while_unknown: 0, output: 'table' } }
|
74
|
-
|
75
|
-
before do
|
76
|
-
pact_broker
|
77
|
-
.given("provider Bar version 4.5.6 has a successful verification for Foo version 1.2.3 tagged prod and a failed verification for version 3.4.5 tagged prod")
|
78
|
-
.upon_receiving("a request to determine if Bar can be deployed with all Foo tagged prod, ignoring the verification for Foo version 3.4.5")
|
79
|
-
.with(
|
80
|
-
method: :get,
|
81
|
-
path: "/matrix",
|
82
|
-
query: "q%5B%5D%5Bpacticipant%5D=Bar&q%5B%5D%5Bversion%5D=4.5.6&q%5B%5D%5Bpacticipant%5D=Foo&q%5B%5D%5Btag%5D=prod&latestby=cvpv&ignore%5B%5D%5Bpacticipant%5D=Foo&ignore%5B%5D%5Bversion%5D=3.4.5"
|
83
|
-
)
|
84
|
-
.will_respond_with(
|
85
|
-
status: 200,
|
86
|
-
headers: pact_broker_response_headers,
|
87
|
-
body: matrix_response_body
|
88
|
-
)
|
89
|
-
end
|
90
|
-
|
91
|
-
subject { PactBroker::Client::CanIDeploy.call(selectors, matrix_options, options, { pact_broker_base_url: broker_base_url })}
|
92
|
-
|
93
|
-
it 'returns the CLI output' do
|
94
|
-
Approvals.verify(subject.message, :name => "can_i_deploy_ignore", format: :txt)
|
95
|
-
end
|
96
|
-
end
|
97
|
-
end
|
98
|
-
end
|
@@ -1,292 +0,0 @@
|
|
1
|
-
require_relative 'pact_helper'
|
2
|
-
require 'pact_broker/client'
|
3
|
-
require "pact_broker/client/matrix/query"
|
4
|
-
|
5
|
-
module PactBroker::Client
|
6
|
-
describe Matrix, :pact => true do
|
7
|
-
|
8
|
-
include_context "pact broker"
|
9
|
-
|
10
|
-
describe "retriving the compatibility matrix" do
|
11
|
-
let(:matrix_response_body) { Pact.like(matrix) }
|
12
|
-
let(:matrix) { JSON.parse(File.read('spec/support/matrix.json')) }
|
13
|
-
let(:selectors) { [{ pacticipant: "Foo", version: "1.2.3" }, { pacticipant: "Bar", version: "4.5.6" }] }
|
14
|
-
let(:options) { {} }
|
15
|
-
|
16
|
-
subject { PactBroker::Client::Matrix::Query.call({ selectors: selectors, options: options }, {}, { pact_broker_base_url: pact_broker.mock_service_base_url }) }
|
17
|
-
|
18
|
-
context "when results are found" do
|
19
|
-
before do
|
20
|
-
pact_broker.
|
21
|
-
given("the pact for Foo version 1.2.3 has been verified by Bar version 4.5.6").
|
22
|
-
upon_receiving("a request for the compatibility matrix for Foo version 1.2.3 and Bar version 4.5.6").
|
23
|
-
with(
|
24
|
-
method: :get,
|
25
|
-
path: "/matrix",
|
26
|
-
query: "q%5B%5D%5Bpacticipant%5D=Foo&q%5B%5D%5Bversion%5D=1.2.3&q%5B%5D%5Bpacticipant%5D=Bar&q%5B%5D%5Bversion%5D=4.5.6&latestby=cvpv"
|
27
|
-
).
|
28
|
-
will_respond_with(
|
29
|
-
status: 200,
|
30
|
-
headers: pact_broker_response_headers,
|
31
|
-
body: matrix_response_body
|
32
|
-
)
|
33
|
-
end
|
34
|
-
|
35
|
-
it 'returns the pact matrix' do
|
36
|
-
matrix = subject
|
37
|
-
expect(matrix[:matrix].size).to eq 1
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
context "when the pacticipant name has a space in it" do
|
42
|
-
before do
|
43
|
-
pact_broker.
|
44
|
-
given("the pact for Foo Thing version 1.2.3 has been verified by Bar version 4.5.6").
|
45
|
-
upon_receiving("a request for the compatibility matrix for Foo version 1.2.3 and Bar version 4.5.6").
|
46
|
-
with(
|
47
|
-
method: :get,
|
48
|
-
path: "/matrix",
|
49
|
-
query: "q%5B%5D%5Bpacticipant%5D=Foo%20Thing&q%5B%5D%5Bversion%5D=1.2.3&q%5B%5D%5Bpacticipant%5D=Bar&q%5B%5D%5Bversion%5D=4.5.6&latestby=cvpv"
|
50
|
-
).
|
51
|
-
will_respond_with(
|
52
|
-
status: 200,
|
53
|
-
headers: pact_broker_response_headers,
|
54
|
-
body: matrix_response_body
|
55
|
-
)
|
56
|
-
end
|
57
|
-
|
58
|
-
let(:selectors) { [{ pacticipant: "Foo Thing", version: "1.2.3" }, { pacticipant: "Bar", version: "4.5.6" }] }
|
59
|
-
|
60
|
-
it 'incorrectly escapes the spaces but it still seems to work' do
|
61
|
-
matrix = subject
|
62
|
-
expect(matrix[:matrix].size).to eq 1
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
context "with only one version selector" do
|
67
|
-
before do
|
68
|
-
pact_broker.
|
69
|
-
given("the pact for Foo version 1.2.3 has been verified by Bar version 4.5.6 and version 5.6.7").
|
70
|
-
upon_receiving("a request for the compatibility matrix where only the version of Foo is specified").
|
71
|
-
with(
|
72
|
-
method: :get,
|
73
|
-
path: "/matrix",
|
74
|
-
query: "q%5B%5D%5Bpacticipant%5D=Foo&q%5B%5D%5Bversion%5D=1.2.3&latestby=cvp&latest=true"
|
75
|
-
).
|
76
|
-
will_respond_with(
|
77
|
-
status: 200,
|
78
|
-
headers: pact_broker_response_headers,
|
79
|
-
body: matrix_response_body
|
80
|
-
)
|
81
|
-
end
|
82
|
-
|
83
|
-
let(:selectors) { [{ pacticipant: "Foo", version: "1.2.3" }] }
|
84
|
-
|
85
|
-
it 'returns the row with the lastest verification for version 1.2.3' do
|
86
|
-
matrix = subject
|
87
|
-
expect(matrix[:matrix].size).to eq 1
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
context "when one or more of the versions does not exist" do
|
92
|
-
before do
|
93
|
-
pact_broker.
|
94
|
-
given("the pact for Foo version 1.2.3 has been verified by Bar version 4.5.6").
|
95
|
-
upon_receiving("a request for the compatibility matrix where one or more versions does not exist").
|
96
|
-
with(
|
97
|
-
method: :get,
|
98
|
-
path: "/matrix",
|
99
|
-
query: "q%5B%5D%5Bpacticipant%5D=Foo&q%5B%5D%5Bversion%5D=1.2.3&q%5B%5D%5Bpacticipant%5D=Bar&q%5B%5D%5Bversion%5D=9.9.9&latestby=cvpv"
|
100
|
-
).
|
101
|
-
will_respond_with(
|
102
|
-
status: 200,
|
103
|
-
headers: pact_broker_response_headers,
|
104
|
-
body: {
|
105
|
-
summary: {
|
106
|
-
reason: Pact.like("an error message")
|
107
|
-
}
|
108
|
-
}
|
109
|
-
)
|
110
|
-
end
|
111
|
-
|
112
|
-
let(:selectors) { [{ pacticipant: "Foo", version: "1.2.3" }, { pacticipant: "Bar", version: "9.9.9" }] }
|
113
|
-
|
114
|
-
it 'does not raise an error' do
|
115
|
-
subject
|
116
|
-
end
|
117
|
-
end
|
118
|
-
|
119
|
-
context "when results are not found" do
|
120
|
-
before do
|
121
|
-
pact_broker.
|
122
|
-
upon_receiving("a request for the compatibility matrix for a pacticipant that does not exist").
|
123
|
-
with(
|
124
|
-
method: :get,
|
125
|
-
path: "/matrix",
|
126
|
-
query: "q%5B%5D%5Bpacticipant%5D=Wiffle&q%5B%5D%5Bversion%5D=1.2.3&q%5B%5D%5Bpacticipant%5D=Meep&q%5B%5D%5Bversion%5D=9.9.9&latestby=cvpv"
|
127
|
-
).
|
128
|
-
will_respond_with(
|
129
|
-
status: 400,
|
130
|
-
headers: pact_broker_response_headers,
|
131
|
-
body: {
|
132
|
-
errors: Pact.each_like("an error message")
|
133
|
-
}
|
134
|
-
)
|
135
|
-
end
|
136
|
-
|
137
|
-
let(:selectors) { [{ pacticipant: "Wiffle", version: "1.2.3" }, { pacticipant: "Meep", version: "9.9.9" }] }
|
138
|
-
|
139
|
-
it 'raises an error' do
|
140
|
-
expect {
|
141
|
-
subject
|
142
|
-
}.to raise_error PactBroker::Client::Hal::ErrorResponseReturned, /an error message/
|
143
|
-
end
|
144
|
-
end
|
145
|
-
|
146
|
-
context "when no versions are specified" do
|
147
|
-
before do
|
148
|
-
pact_broker.
|
149
|
-
given("the pact for Foo version 1.2.3 and 1.2.4 has been verified by Bar version 4.5.6").
|
150
|
-
upon_receiving("a request for the compatibility matrix for all versions of Foo and Bar").
|
151
|
-
with(
|
152
|
-
method: :get,
|
153
|
-
path: "/matrix",
|
154
|
-
query: "q%5B%5D%5Bpacticipant%5D=Foo&q%5B%5D%5Bpacticipant%5D=Bar&latestby=cvpv"
|
155
|
-
).
|
156
|
-
will_respond_with(
|
157
|
-
status: 200,
|
158
|
-
headers: pact_broker_response_headers,
|
159
|
-
body: {
|
160
|
-
matrix: Pact.each_like(matrix_row, min: 2)
|
161
|
-
}
|
162
|
-
)
|
163
|
-
end
|
164
|
-
let(:matrix_row) { JSON.parse(File.read('spec/support/matrix.json'))['matrix'].first }
|
165
|
-
let(:selectors) { [{ pacticipant: "Foo" }, { pacticipant: "Bar" }] }
|
166
|
-
|
167
|
-
it "returns multiple rows" do
|
168
|
-
matrix = subject
|
169
|
-
expect(matrix[:matrix].size).to eq 2
|
170
|
-
end
|
171
|
-
end
|
172
|
-
|
173
|
-
context "when the success option is true" do
|
174
|
-
before do
|
175
|
-
pact_broker.
|
176
|
-
given("the pact for Foo version 1.2.3 has been successfully verified by Bar version 4.5.6, and 1.2.4 unsuccessfully by 9.9.9").
|
177
|
-
upon_receiving("a request for the successful rows of the compatibility matrix for all versions of Foo and Bar").
|
178
|
-
with(
|
179
|
-
method: :get,
|
180
|
-
path: "/matrix",
|
181
|
-
query: "q%5B%5D%5Bpacticipant%5D=Foo&q%5B%5D%5Bpacticipant%5D=Bar&latestby=cvpv&success%5B%5D=true"
|
182
|
-
).
|
183
|
-
will_respond_with(
|
184
|
-
status: 200,
|
185
|
-
headers: pact_broker_response_headers,
|
186
|
-
body: matrix_response_body
|
187
|
-
)
|
188
|
-
end
|
189
|
-
let(:matrix_row) { JSON.parse(File.read('spec/support/matrix.json'))['matrix'].first }
|
190
|
-
let(:selectors) { [{ pacticipant: "Foo" }, { pacticipant: "Bar" }] }
|
191
|
-
let(:options) { {success: true} }
|
192
|
-
|
193
|
-
it "returns only the successful row" do
|
194
|
-
matrix = pact_broker_client.matrix.get(selectors, options)
|
195
|
-
expect(matrix[:matrix].size).to eq 1
|
196
|
-
end
|
197
|
-
end
|
198
|
-
|
199
|
-
context "when the latest version for a given tag is specified" do
|
200
|
-
before do
|
201
|
-
pact_broker.
|
202
|
-
given("the pact for Foo version 1.2.3 has been successfully verified by Bar version 4.5.6 with tag prod, and 1.2.4 unsuccessfully by 9.9.9").
|
203
|
-
upon_receiving("a request for the compatibility matrix for Foo version 1.2.3 and the latest prod version of Bar").
|
204
|
-
with(
|
205
|
-
method: :get,
|
206
|
-
path: "/matrix",
|
207
|
-
query: "q%5B%5D%5Bpacticipant%5D=Foo&q%5B%5D%5Bversion%5D=1.2.3&q%5B%5D%5Bpacticipant%5D=Bar&q%5B%5D%5Blatest%5D=true&q%5B%5D%5Btag%5D=prod&latestby=cvpv"
|
208
|
-
).
|
209
|
-
will_respond_with(
|
210
|
-
status: 200,
|
211
|
-
headers: pact_broker_response_headers,
|
212
|
-
body: matrix_response_body
|
213
|
-
)
|
214
|
-
end
|
215
|
-
let(:matrix_row) { JSON.parse(File.read('spec/support/matrix.json'))['matrix'].first }
|
216
|
-
let(:selectors) { [{ pacticipant: "Foo", version: "1.2.3"}, { pacticipant: "Bar", latest: true, tag: 'prod' }] }
|
217
|
-
let(:options) { {} }
|
218
|
-
|
219
|
-
it "returns the matrix with the latest prod version of Bar" do
|
220
|
-
matrix = pact_broker_client.matrix.get(selectors, options)
|
221
|
-
expect(matrix[:matrix].size).to eq 1
|
222
|
-
end
|
223
|
-
end
|
224
|
-
|
225
|
-
context "when the latest version is specified" do
|
226
|
-
before do
|
227
|
-
pact_broker.
|
228
|
-
given("the pact for Foo version 1.2.3 has been successfully verified by Bar version 4.5.6, and 1.2.4 unsuccessfully by 9.9.9").
|
229
|
-
upon_receiving("a request for the compatibility matrix for Foo version 1.2.3 and the latest version of Bar").
|
230
|
-
with(
|
231
|
-
method: :get,
|
232
|
-
path: "/matrix",
|
233
|
-
query: "q%5B%5D%5Bpacticipant%5D=Foo&q%5B%5D%5Bversion%5D=1.2.4&q%5B%5D%5Bpacticipant%5D=Bar&q%5B%5D%5Blatest%5D=true&latestby=cvpv"
|
234
|
-
).
|
235
|
-
will_respond_with(
|
236
|
-
status: 200,
|
237
|
-
headers: pact_broker_response_headers,
|
238
|
-
body: matrix_response_body
|
239
|
-
)
|
240
|
-
end
|
241
|
-
let(:matrix_row) { JSON.parse(File.read('spec/support/matrix.json'))['matrix'].first }
|
242
|
-
let(:selectors) { [{ pacticipant: "Foo", version: "1.2.4"}, { pacticipant: "Bar", latest: true }] }
|
243
|
-
let(:options) { {} }
|
244
|
-
|
245
|
-
it "returns the matrix with the latest prod version of Bar" do
|
246
|
-
matrix = pact_broker_client.matrix.get(selectors, options)
|
247
|
-
expect(matrix[:matrix].size).to eq 1
|
248
|
-
end
|
249
|
-
end
|
250
|
-
|
251
|
-
context "when checking if we can deploy with the latest tagged versions of the other services" do
|
252
|
-
before do
|
253
|
-
pact_broker.
|
254
|
-
given("the pact for Foo version 1.2.3 has been successfully verified by Bar version 4.5.6 (tagged prod) and version 5.6.7").
|
255
|
-
upon_receiving("a request for the compatibility matrix for Foo version 1.2.3 and the latest prod versions of all other pacticipants").
|
256
|
-
with(
|
257
|
-
method: :get,
|
258
|
-
path: "/matrix",
|
259
|
-
query: "q%5B%5D%5Bpacticipant%5D=Foo&q%5B%5D%5Bversion%5D=1.2.3&latestby=cvp&latest=true&tag=prod"
|
260
|
-
).
|
261
|
-
will_respond_with(
|
262
|
-
status: 200,
|
263
|
-
headers: pact_broker_response_headers,
|
264
|
-
body: matrix_response_body
|
265
|
-
)
|
266
|
-
end
|
267
|
-
|
268
|
-
let(:selectors) { [{ pacticipant: "Foo", version: "1.2.3" }] }
|
269
|
-
|
270
|
-
let(:matrix_response_body) {
|
271
|
-
{
|
272
|
-
matrix: [{
|
273
|
-
consumer: { name: 'Foo', version: { number: '1.2.3' } },
|
274
|
-
provider: { name: 'Bar', version: { number: '4.5.6'} },
|
275
|
-
}]
|
276
|
-
}
|
277
|
-
}
|
278
|
-
|
279
|
-
let(:options) { { to_tag: 'prod' } }
|
280
|
-
|
281
|
-
it "returns the matrix with the latest prod version of Bar" do
|
282
|
-
matrix = pact_broker_client.matrix.get(selectors, options)
|
283
|
-
expect(matrix[:matrix].size).to eq 1
|
284
|
-
end
|
285
|
-
end
|
286
|
-
|
287
|
-
context "with an environment name" do
|
288
|
-
it "passes the environment name in the options"
|
289
|
-
end
|
290
|
-
end
|
291
|
-
end
|
292
|
-
end
|
@@ -1,56 +0,0 @@
|
|
1
|
-
require_relative 'pact_helper'
|
2
|
-
require 'pact_broker/client'
|
3
|
-
|
4
|
-
module PactBroker::Client
|
5
|
-
describe Pacts, :pact => true do
|
6
|
-
|
7
|
-
include_context "pact broker"
|
8
|
-
|
9
|
-
describe "retriving pacticipant versions" do
|
10
|
-
context "when retrieving the production details of a version" do
|
11
|
-
context "when a version is found" do
|
12
|
-
let(:repository_ref) { "package/pricing-service-1.2.3"}
|
13
|
-
let(:tags) { ['prod']}
|
14
|
-
let(:body) { { number: '1.2.3', repository_ref: repository_ref, tags: tags } }
|
15
|
-
before do
|
16
|
-
pact_broker.
|
17
|
-
given("a pacticipant version with production details exists for the Pricing Service").
|
18
|
-
upon_receiving("a request for the latest pacticpant version tagged with 'prod'").
|
19
|
-
with(
|
20
|
-
method: :get,
|
21
|
-
path: '/pacticipants/Pricing%20Service/versions/latest',
|
22
|
-
query: 'tag=prod',
|
23
|
-
headers: get_request_headers).
|
24
|
-
will_respond_with(
|
25
|
-
status: 200,
|
26
|
-
headers: pact_broker_response_headers.merge({'Content-Type' => 'application/json'}),
|
27
|
-
body: body )
|
28
|
-
end
|
29
|
-
|
30
|
-
xit 'returns the version details' do
|
31
|
-
expect( pact_broker_client.pacticipants.versions.latest pacticipant: 'Pricing Service', tag: 'prod' ).to eq body
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
context "when a version is not found" do
|
36
|
-
before do
|
37
|
-
pact_broker.
|
38
|
-
given("no pacticipant version exists for the Pricing Service").
|
39
|
-
upon_receiving("a request for the latest pacticipant version").
|
40
|
-
with(
|
41
|
-
method: :get,
|
42
|
-
path: '/pacticipants/Pricing%20Service/versions/latest',
|
43
|
-
headers: get_request_headers).
|
44
|
-
will_respond_with(
|
45
|
-
status: 404,
|
46
|
-
headers: pact_broker_response_headers )
|
47
|
-
end
|
48
|
-
|
49
|
-
xit 'returns nil' do
|
50
|
-
expect( pact_broker_client.pacticipants.versions.latest pacticipant: 'Pricing Service' ).to eq nil
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
end
|
56
|
-
end
|
@@ -1,135 +0,0 @@
|
|
1
|
-
require 'pact_broker/client/pact_broker_client'
|
2
|
-
require_relative 'pact_helper'
|
3
|
-
|
4
|
-
module PactBroker::Client
|
5
|
-
describe PactBrokerClient, :pact => true do
|
6
|
-
|
7
|
-
include_context "pact broker"
|
8
|
-
|
9
|
-
describe "publishing a pact" do
|
10
|
-
|
11
|
-
let(:options) { { pact_hash: pact_hash, consumer_version: consumer_version }}
|
12
|
-
let(:location) { 'http://example.org/pacts/provider/Pricing%20Service/consumer/Condor/latest' }
|
13
|
-
context "when the provider already exists in the pact-broker" do
|
14
|
-
|
15
|
-
before do
|
16
|
-
pact_broker.
|
17
|
-
given("the 'Pricing Service' already exists in the pact-broker").
|
18
|
-
upon_receiving("a request to publish a pact").
|
19
|
-
with(
|
20
|
-
method: :put,
|
21
|
-
path: '/pacts/provider/Pricing%20Service/consumer/Condor/version/1.3.0',
|
22
|
-
headers: default_request_headers,
|
23
|
-
body: pact_hash ).
|
24
|
-
will_respond_with(
|
25
|
-
headers: pact_broker_response_headers,
|
26
|
-
status: 201,
|
27
|
-
body: {
|
28
|
-
_links: {
|
29
|
-
:'pb:latest-pact-version' => {
|
30
|
-
href: location
|
31
|
-
}
|
32
|
-
}
|
33
|
-
}
|
34
|
-
)
|
35
|
-
end
|
36
|
-
it "returns the URL to find the newly published pact" do
|
37
|
-
expect(pact_broker_client.pacticipants.versions.pacts.publish(options)).to eq location
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
context "when the provider, consumer, pact and version already exist in the pact-broker" do
|
42
|
-
shared_examples "an already-existing pact" do |method|
|
43
|
-
before do
|
44
|
-
pact_broker.
|
45
|
-
given("the 'Pricing Service' and 'Condor' already exist in the pact-broker, and Condor already has a pact published for version 1.3.0").
|
46
|
-
upon_receiving("a request to publish a pact with method #{method}").
|
47
|
-
with(
|
48
|
-
method: method,
|
49
|
-
path: '/pacts/provider/Pricing%20Service/consumer/Condor/version/1.3.0',
|
50
|
-
headers: default_request_headers,
|
51
|
-
body: pact_hash ).
|
52
|
-
will_respond_with(
|
53
|
-
headers: pact_broker_response_headers,
|
54
|
-
status: 200,
|
55
|
-
body: {
|
56
|
-
_links: {
|
57
|
-
:'pb:latest-pact-version' => {
|
58
|
-
href: location
|
59
|
-
}
|
60
|
-
}
|
61
|
-
}
|
62
|
-
)
|
63
|
-
end
|
64
|
-
|
65
|
-
it "returns true" do
|
66
|
-
expect(pact_broker_client.pacticipants.versions.pacts.publish(options)).to be_truthy
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
context "when the write method is set to merge" do
|
71
|
-
let(:client_config) { super().merge(client_options: {write: :merge}) }
|
72
|
-
|
73
|
-
it_behaves_like "an already-existing pact", :patch
|
74
|
-
end
|
75
|
-
|
76
|
-
context "when the write method is not set" do
|
77
|
-
it_behaves_like "an already-existing pact", :put
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
context "when the provider does not exist, but the consumer, pact and version already exist in the pact-broker" do
|
82
|
-
before do
|
83
|
-
pact_broker.
|
84
|
-
given("'Condor' already exist in the pact-broker, but the 'Pricing Service' does not").
|
85
|
-
upon_receiving("a request to publish a pact").
|
86
|
-
with(
|
87
|
-
method: :put,
|
88
|
-
path: '/pacts/provider/Pricing%20Service/consumer/Condor/version/1.3.0',
|
89
|
-
headers: default_request_headers,
|
90
|
-
body: pact_hash ).
|
91
|
-
will_respond_with(
|
92
|
-
headers: pact_broker_response_headers,
|
93
|
-
status: 201,
|
94
|
-
body: {
|
95
|
-
_links: {
|
96
|
-
:'pb:latest-pact-version' => {
|
97
|
-
href: location
|
98
|
-
}
|
99
|
-
}
|
100
|
-
}
|
101
|
-
)
|
102
|
-
end
|
103
|
-
it "returns true" do
|
104
|
-
expect(pact_broker_client.pacticipants.versions.pacts.publish(options)).to be_truthy
|
105
|
-
end
|
106
|
-
end
|
107
|
-
|
108
|
-
context "when publishing is not successful" do
|
109
|
-
before do
|
110
|
-
pact_broker.
|
111
|
-
given("an error occurs while publishing a pact").
|
112
|
-
upon_receiving("a request to publish a pact").
|
113
|
-
with(
|
114
|
-
method: :put,
|
115
|
-
path: '/pacts/provider/Pricing%20Service/consumer/Condor/version/1.3.0',
|
116
|
-
headers: default_request_headers,
|
117
|
-
body: pact_hash ).
|
118
|
-
will_respond_with(
|
119
|
-
status: 500,
|
120
|
-
headers: {'Content-Type' => Pact.term(generate: 'application/hal+json', matcher: %r{application/.*json})},
|
121
|
-
body: {
|
122
|
-
error: {
|
123
|
-
message: Pact::Term.new(matcher: /.*/, generate: 'An error occurred')
|
124
|
-
}
|
125
|
-
}
|
126
|
-
)
|
127
|
-
end
|
128
|
-
it "raises an error" do
|
129
|
-
expect { pact_broker_client.pacticipants.versions.pacts.publish options }.to raise_error /An error occurred/
|
130
|
-
end
|
131
|
-
end
|
132
|
-
|
133
|
-
end
|
134
|
-
end
|
135
|
-
end
|
@@ -1,49 +0,0 @@
|
|
1
|
-
module PactBroker::Client
|
2
|
-
describe Pacticipants, :pact => true do
|
3
|
-
|
4
|
-
include_context "pact broker"
|
5
|
-
|
6
|
-
let(:repository_url ) { "git@git.realestate.com.au:business-systems/pricing-service" }
|
7
|
-
|
8
|
-
describe "registering a repository url" do
|
9
|
-
context "where the pacticipant does not already exist in the pact-broker" do
|
10
|
-
before do
|
11
|
-
pact_broker.
|
12
|
-
given("the 'Pricing Service' does not exist in the pact-broker").
|
13
|
-
upon_receiving("a request to register the repository URL of a pacticipant").
|
14
|
-
with(
|
15
|
-
method: :patch,
|
16
|
-
path: '/pacticipants/Pricing%20Service',
|
17
|
-
headers: old_patch_request_headers,
|
18
|
-
body: {repository_url: repository_url} ).
|
19
|
-
will_respond_with(
|
20
|
-
status: 201,
|
21
|
-
headers: pact_broker_response_headers
|
22
|
-
)
|
23
|
-
end
|
24
|
-
it "returns true" do
|
25
|
-
expect(pact_broker_client.pacticipants.update({:pacticipant => 'Pricing Service', :repository_url => repository_url})).to be true
|
26
|
-
end
|
27
|
-
end
|
28
|
-
context "where the 'Pricing Service' exists in the pact-broker" do
|
29
|
-
before do
|
30
|
-
pact_broker.
|
31
|
-
given("the 'Pricing Service' already exists in the pact-broker").
|
32
|
-
upon_receiving("a request to register the repository URL of a pacticipant").
|
33
|
-
with(
|
34
|
-
method: :patch,
|
35
|
-
path: '/pacticipants/Pricing%20Service',
|
36
|
-
headers: old_patch_request_headers,
|
37
|
-
body: { repository_url: repository_url }).
|
38
|
-
will_respond_with(
|
39
|
-
status: 200,
|
40
|
-
headers: pact_broker_response_headers
|
41
|
-
)
|
42
|
-
end
|
43
|
-
it "returns true" do
|
44
|
-
expect(pact_broker_client.pacticipants.update({:pacticipant => 'Pricing Service', :repository_url => repository_url})).to be true
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
@@ -1,53 +0,0 @@
|
|
1
|
-
require_relative 'pact_helper'
|
2
|
-
require 'pact_broker/client'
|
3
|
-
|
4
|
-
module PactBroker::Client
|
5
|
-
describe Pacts, :pact => true do
|
6
|
-
|
7
|
-
include_context "pact broker"
|
8
|
-
|
9
|
-
describe "retriving all pacts for provider" do
|
10
|
-
let(:response_body) { Pact.like(JSON.parse(File.read("./spec/support/latest_pacts_for_provider.json"))) }
|
11
|
-
let(:expectedPactsArray) { [{:name => "Condor", :href => "http://example.org/pacts/provider/Pricing%20Service/consumer/Condor/version/1.3.0"}] }
|
12
|
-
|
13
|
-
context "when retrieving all the latest pacts for provider with prod tag specified" do
|
14
|
-
before do
|
15
|
-
pact_broker.
|
16
|
-
given("tagged as prod pact between Condor and the Pricing Service exists").
|
17
|
-
upon_receiving("a request for the list of the latest prod pacts from all consumers for the Pricing Service'").
|
18
|
-
with(
|
19
|
-
method: :get,
|
20
|
-
path: "/pacts/provider/Pricing%20Service/latest/prod",
|
21
|
-
headers: {}).
|
22
|
-
will_respond_with(
|
23
|
-
status: 200,
|
24
|
-
body: response_body)
|
25
|
-
end
|
26
|
-
it 'returns the map of all provider latest prod pacts' do
|
27
|
-
pactsArray = pact_broker_client.pacticipants.versions.pacts.list_latest_for_provider provider: 'Pricing Service', tag: 'prod'
|
28
|
-
expect(pactsArray.length).to eq(1)
|
29
|
-
expect(pactsArray).to eq(expectedPactsArray)
|
30
|
-
end
|
31
|
-
end
|
32
|
-
context "when retrieving all the latest pacts for provider with no tag specified" do
|
33
|
-
before do
|
34
|
-
pact_broker.
|
35
|
-
given("a latest pact between Condor and the Pricing Service exists").
|
36
|
-
upon_receiving("a request for the list of the latest pacts from all consumers for the Pricing Service'").
|
37
|
-
with(
|
38
|
-
method: :get,
|
39
|
-
path: "/pacts/provider/Pricing%20Service/latest",
|
40
|
-
headers: {}).
|
41
|
-
will_respond_with(
|
42
|
-
status: 200,
|
43
|
-
body: response_body)
|
44
|
-
end
|
45
|
-
it 'returns the map of all provider latest pacts' do
|
46
|
-
pactsArray = pact_broker_client.pacticipants.versions.pacts.list_latest_for_provider provider: 'Pricing Service'
|
47
|
-
expect(pactsArray.length).to eq(1)
|
48
|
-
expect(pactsArray).to eq(expectedPactsArray)
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|