pact_broker-client 1.75.3 → 1.76.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +15 -0
- data/lib/pact_broker/client/can_i_deploy.rb +1 -1
- 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,179 +0,0 @@
|
|
1
|
-
require "pactflow/client/provider_contracts/publish"
|
2
|
-
require 'ostruct'
|
3
|
-
|
4
|
-
module Pactflow
|
5
|
-
module Client
|
6
|
-
module ProviderContracts
|
7
|
-
describe Publish do
|
8
|
-
before do
|
9
|
-
allow_any_instance_of(PactBroker::Client::Hal::HttpClient).to receive(:sleep)
|
10
|
-
allow_any_instance_of(PactBroker::Client::Hal::HttpClient).to receive(:default_max_tries).and_return(1)
|
11
|
-
end
|
12
|
-
|
13
|
-
let(:command_params) do
|
14
|
-
{
|
15
|
-
provider_name: "Bar",
|
16
|
-
provider_version_number: "1",
|
17
|
-
branch_name: "main",
|
18
|
-
tags: ["dev"],
|
19
|
-
build_url: "http://build",
|
20
|
-
contract: {
|
21
|
-
content: { "some" => "contract" }.to_yaml,
|
22
|
-
content_type: "application/yaml",
|
23
|
-
specification: "oas"
|
24
|
-
},
|
25
|
-
verification_results: {
|
26
|
-
success: true,
|
27
|
-
content: "some results",
|
28
|
-
content_type: "text/plain",
|
29
|
-
format: "text",
|
30
|
-
verifier: "my custom tool",
|
31
|
-
verifier_version: "1.0"
|
32
|
-
}
|
33
|
-
}
|
34
|
-
end
|
35
|
-
|
36
|
-
let(:options) do
|
37
|
-
{
|
38
|
-
verbose: false
|
39
|
-
}
|
40
|
-
end
|
41
|
-
|
42
|
-
let(:pact_broker_client_options) do
|
43
|
-
{ pact_broker_base_url: "http://pactflow" }
|
44
|
-
end
|
45
|
-
|
46
|
-
let(:index_body_hash) do
|
47
|
-
{
|
48
|
-
_links: {
|
49
|
-
"pf:publish-provider-contract" => {
|
50
|
-
href: "http://pactflow/some-publish/{provider}"
|
51
|
-
}
|
52
|
-
}
|
53
|
-
}
|
54
|
-
end
|
55
|
-
|
56
|
-
let(:post_response_body) do
|
57
|
-
{
|
58
|
-
"notices"=>[{"text"=>"some notice", "type"=>"info"}]
|
59
|
-
}
|
60
|
-
end
|
61
|
-
|
62
|
-
let!(:index_request) do
|
63
|
-
stub_request(:get, "http://pactflow")
|
64
|
-
.to_return(
|
65
|
-
status: index_status,
|
66
|
-
body: index_body_hash.to_json,
|
67
|
-
headers: { "Content-Type" => "application/hal+json" }
|
68
|
-
)
|
69
|
-
end
|
70
|
-
let(:index_status) { 200 }
|
71
|
-
|
72
|
-
let!(:publish_request) do
|
73
|
-
stub_request(:post, "http://pactflow/some-publish/Bar")
|
74
|
-
.to_return(
|
75
|
-
status: publish_status,
|
76
|
-
body: post_response_body.to_json,
|
77
|
-
headers: { "Content-Type" => "application/hal+json" }
|
78
|
-
)
|
79
|
-
end
|
80
|
-
let(:publish_status) { 200 }
|
81
|
-
|
82
|
-
subject { Publish.call(command_params, options, pact_broker_client_options) }
|
83
|
-
|
84
|
-
context "when there is no relation pf:publish-provider-contract" do
|
85
|
-
before do
|
86
|
-
allow(PublishTheOldWay).to receive(:call).with(command_params, options, pact_broker_client_options).and_return(instance_double(PactBroker::Client::CommandResult))
|
87
|
-
end
|
88
|
-
|
89
|
-
let(:index_body_hash) do
|
90
|
-
{
|
91
|
-
_links: {}
|
92
|
-
}
|
93
|
-
end
|
94
|
-
|
95
|
-
it "publishes the provider contracts the old way" do
|
96
|
-
expect(PublishTheOldWay).to receive(:call).with(command_params, options, pact_broker_client_options)
|
97
|
-
subject
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
context "when the feature is disabled" do
|
102
|
-
before do
|
103
|
-
allow(ENV).to receive(:fetch).and_call_original
|
104
|
-
allow(ENV).to receive(:fetch).with("PACTFLOW_FEATURES", "").and_return("publish_provider_contracts_using_old_api")
|
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
|