pact_broker-client 1.40.0 → 1.45.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/test.yml +21 -0
- data/.gitignore +1 -0
- data/CHANGELOG.md +57 -0
- data/Gemfile +4 -0
- data/README.md +39 -22
- data/doc/pacts/markdown/Pact Broker Client - Pact Broker.md +79 -280
- data/lib/pact_broker/client/backports.rb +9 -0
- data/lib/pact_broker/client/base_command.rb +98 -0
- data/lib/pact_broker/client/can_i_deploy.rb +57 -5
- data/lib/pact_broker/client/cli/broker.rb +23 -76
- data/lib/pact_broker/client/cli/custom_thor.rb +12 -0
- data/lib/pact_broker/client/cli/deployment_commands.rb +94 -0
- data/lib/pact_broker/client/cli/environment_commands.rb +70 -0
- data/lib/pact_broker/client/cli/pacticipant_commands.rb +53 -0
- data/lib/pact_broker/client/cli/record_deployment_long_desc.txt +0 -55
- data/lib/pact_broker/client/cli/version_selector_options_parser.rb +4 -0
- data/lib/pact_broker/client/colorize_notices.rb +31 -0
- data/lib/pact_broker/client/deployments.rb +4 -0
- data/lib/pact_broker/client/deployments/record_deployment.rb +38 -0
- data/lib/pact_broker/client/deployments/record_release.rb +99 -0
- data/lib/pact_broker/client/deployments/record_support_ended.rb +103 -0
- data/lib/pact_broker/client/deployments/record_undeployment.rb +127 -0
- data/lib/pact_broker/client/describe_text_formatter.rb +23 -0
- data/lib/pact_broker/client/environments.rb +6 -0
- data/lib/pact_broker/client/environments/create_environment.rb +31 -0
- data/lib/pact_broker/client/environments/delete_environment.rb +27 -0
- data/lib/pact_broker/client/environments/describe_environment.rb +26 -0
- data/lib/pact_broker/client/environments/environment_command.rb +66 -0
- data/lib/pact_broker/client/environments/list_environments.rb +30 -0
- data/lib/pact_broker/client/environments/text_formatter.rb +30 -0
- data/lib/pact_broker/client/environments/update_environment.rb +31 -0
- data/lib/pact_broker/client/generate_display_name.rb +27 -0
- data/lib/pact_broker/client/hal/entity.rb +31 -6
- data/lib/pact_broker/client/hal/http_client.rb +8 -2
- data/lib/pact_broker/client/hal/link.rb +8 -0
- data/lib/pact_broker/client/hal_client_methods.rb +1 -3
- data/lib/pact_broker/client/matrix.rb +4 -0
- data/lib/pact_broker/client/matrix/abbreviate_version_number.rb +15 -0
- data/lib/pact_broker/client/matrix/resource.rb +26 -1
- data/lib/pact_broker/client/matrix/text_formatter.rb +28 -17
- data/lib/pact_broker/client/pacticipants.rb +6 -0
- data/lib/pact_broker/client/pacticipants/create.rb +24 -34
- data/lib/pact_broker/client/pacticipants/describe.rb +33 -0
- data/lib/pact_broker/client/pacticipants/list.rb +34 -0
- data/lib/pact_broker/client/pacticipants/text_formatter.rb +41 -0
- data/lib/pact_broker/client/publish_pacts.rb +6 -2
- data/lib/pact_broker/client/string_refinements.rb +56 -0
- data/lib/pact_broker/client/version.rb +1 -1
- data/lib/pact_broker/client/versions.rb +4 -1
- data/lib/pact_broker/client/versions/describe.rb +3 -1
- data/lib/pact_broker/client/versions/formatter.rb +3 -1
- data/lib/pact_broker/client/versions/json_formatter.rb +5 -3
- data/lib/pact_broker/client/versions/text_formatter.rb +3 -1
- data/pact-broker-client.gemspec +2 -0
- data/script/approve-all.sh +6 -0
- data/script/publish-pact.sh +12 -9
- data/script/record-deployments-and-releases.sh +18 -0
- data/spec/fixtures/approvals/can_i_deploy_failure_dry_run.approved.txt +7 -0
- data/spec/fixtures/approvals/can_i_deploy_ignore.approved.txt +13 -0
- data/spec/fixtures/approvals/can_i_deploy_success_dry_run.approved.txt +7 -0
- data/spec/fixtures/approvals/describe_environment.approved.txt +7 -0
- data/spec/fixtures/approvals/describe_pacticipant.approved.txt +2 -0
- data/spec/fixtures/approvals/list_environments.approved.txt +3 -0
- data/spec/integration/describe_environment_spec.rb +31 -0
- data/spec/lib/pact_broker/client/can_i_deploy_spec.rb +109 -7
- data/spec/lib/pact_broker/client/cli/broker_can_i_deploy_spec.rb +19 -6
- data/spec/lib/pact_broker/client/cli/broker_publish_spec.rb +1 -1
- data/spec/lib/pact_broker/client/cli/broker_run_webhook_commands_spec.rb +3 -3
- data/spec/lib/pact_broker/client/cli/version_selector_options_parser_spec.rb +21 -0
- data/spec/lib/pact_broker/client/deployments/record_deployment_spec.rb +204 -0
- data/spec/lib/pact_broker/client/deployments/record_support_ended_spec.rb +208 -0
- data/spec/lib/pact_broker/client/deployments/record_undeployment_spec.rb +219 -0
- data/spec/lib/pact_broker/client/environments/delete_environment_spec.rb +120 -0
- data/spec/lib/pact_broker/client/environments/describe_environment_spec.rb +89 -0
- data/spec/lib/pact_broker/client/environments/update_environment_spec.rb +167 -0
- data/spec/lib/pact_broker/client/generate_display_name_spec.rb +39 -0
- data/spec/lib/pact_broker/client/hal/entity_spec.rb +2 -2
- data/spec/lib/pact_broker/client/pacticipants/create_spec.rb +2 -2
- data/spec/pacts/pact_broker_client-pact_broker.json +88 -287
- data/spec/service_providers/create_environment_spec.rb +78 -0
- data/spec/service_providers/list_environments_spec.rb +77 -0
- data/spec/service_providers/pact_broker_client_matrix_ignore_spec.rb +98 -0
- data/spec/service_providers/pact_broker_client_register_repository_spec.rb +2 -2
- data/spec/service_providers/pacticipants_create_spec.rb +5 -4
- data/spec/service_providers/publish_pacts_spec.rb +5 -2
- data/spec/service_providers/record_deployment_spec.rb +17 -36
- data/spec/service_providers/record_release_spec.rb +132 -0
- data/spec/service_providers/record_undeployment_spec.rb +166 -0
- data/spec/spec_helper.rb +15 -2
- data/spec/support/approvals.rb +26 -0
- data/spec/support/shared_context.rb +8 -3
- data/tasks/pact.rake +21 -1
- metadata +104 -7
- data/lib/pact_broker/client/versions/record_deployment.rb +0 -109
- data/lib/pact_broker/client/versions/record_undeployment.rb +0 -102
- data/spec/lib/pact_broker/client/versions/record_deployment_spec.rb +0 -82
@@ -0,0 +1,132 @@
|
|
1
|
+
require 'service_providers/pact_helper'
|
2
|
+
require 'pact_broker/client/deployments/record_deployment'
|
3
|
+
|
4
|
+
deployment_feature_on = ENV.fetch('PACT_BROKER_FEATURES', '').include?("deployments")
|
5
|
+
|
6
|
+
RSpec.describe "recording a release", pact: true, skip: !deployment_feature_on do
|
7
|
+
include_context "pact broker"
|
8
|
+
include PactBrokerPactHelperMethods
|
9
|
+
|
10
|
+
let(:pacticipant_name) { "Foo" }
|
11
|
+
let(:version_number) { "5556b8149bf8bac76bc30f50a8a2dd4c22c85f30" }
|
12
|
+
let(:environment_name) { "test" }
|
13
|
+
let(:output) { "text" }
|
14
|
+
let(:target) { "blue" }
|
15
|
+
let(:params) do
|
16
|
+
{
|
17
|
+
pacticipant_name: pacticipant_name,
|
18
|
+
version_number: version_number,
|
19
|
+
environment_name: environment_name
|
20
|
+
}
|
21
|
+
end
|
22
|
+
let(:options) do
|
23
|
+
{
|
24
|
+
output: output
|
25
|
+
}
|
26
|
+
end
|
27
|
+
let(:pact_broker_client_options) { { pact_broker_base_url: broker_base_url } }
|
28
|
+
|
29
|
+
subject { PactBroker::Client::Deployments::RecordRelease.call(params, options, pact_broker_client_options) }
|
30
|
+
|
31
|
+
def mock_index
|
32
|
+
pact_broker
|
33
|
+
.given("the pb:pacticipant-version and pb:environments relations exist in the index resource")
|
34
|
+
.upon_receiving("a request for the index resource")
|
35
|
+
.with(
|
36
|
+
method: "GET",
|
37
|
+
path: '/',
|
38
|
+
headers: get_request_headers).
|
39
|
+
will_respond_with(
|
40
|
+
status: 200,
|
41
|
+
headers: pact_broker_response_headers,
|
42
|
+
body: {
|
43
|
+
_links: {
|
44
|
+
:'pb:pacticipant-version' => {
|
45
|
+
href: placeholder_url_term("pb:pacticipant-version", ["pacticipant", "version"])
|
46
|
+
},
|
47
|
+
:'pb:environments' => {
|
48
|
+
href: placeholder_url_term("pb:environments")
|
49
|
+
}
|
50
|
+
}
|
51
|
+
}
|
52
|
+
)
|
53
|
+
end
|
54
|
+
|
55
|
+
def mock_pacticipant_version_with_test_environment_available_for_release
|
56
|
+
pact_broker
|
57
|
+
.given("version 5556b8149bf8bac76bc30f50a8a2dd4c22c85f30 of pacticipant Foo exists with a test environment available for release")
|
58
|
+
.upon_receiving("a request for a pacticipant version")
|
59
|
+
.with(
|
60
|
+
method: "GET",
|
61
|
+
path: "/HAL-REL-PLACEHOLDER-PB-PACTICIPANT-VERSION-Foo-5556b8149bf8bac76bc30f50a8a2dd4c22c85f30",
|
62
|
+
headers: get_request_headers
|
63
|
+
)
|
64
|
+
.will_respond_with(
|
65
|
+
status: 200,
|
66
|
+
headers: pact_broker_response_headers,
|
67
|
+
body: {
|
68
|
+
_links: {
|
69
|
+
"pb:record-release" => [
|
70
|
+
{
|
71
|
+
name: "test",
|
72
|
+
href: placeholder_url_term("pb:record-release-#{pacticipant_name}-#{version_number}-#{environment_name}")
|
73
|
+
}
|
74
|
+
]
|
75
|
+
}
|
76
|
+
}
|
77
|
+
)
|
78
|
+
end
|
79
|
+
|
80
|
+
def mock_environments
|
81
|
+
pact_broker
|
82
|
+
.given("an environment with name test exists")
|
83
|
+
.upon_receiving("a request for the environments")
|
84
|
+
.with(
|
85
|
+
method: "GET",
|
86
|
+
path: "/HAL-REL-PLACEHOLDER-PB-ENVIRONMENTS",
|
87
|
+
headers: get_request_headers
|
88
|
+
)
|
89
|
+
.will_respond_with(
|
90
|
+
status: 200,
|
91
|
+
headers: pact_broker_response_headers,
|
92
|
+
body: {
|
93
|
+
_links: {
|
94
|
+
"pb:environments" => [
|
95
|
+
{
|
96
|
+
name: "test",
|
97
|
+
href: Pact.like("href")
|
98
|
+
}
|
99
|
+
]
|
100
|
+
}
|
101
|
+
}
|
102
|
+
)
|
103
|
+
end
|
104
|
+
|
105
|
+
def mock_record_release
|
106
|
+
pact_broker
|
107
|
+
.given("version 5556b8149bf8bac76bc30f50a8a2dd4c22c85f30 of pacticipant Foo exists with a test environment available for deployment")
|
108
|
+
.upon_receiving("a request to record a release")
|
109
|
+
.with(
|
110
|
+
method: "POST",
|
111
|
+
path: "/HAL-REL-PLACEHOLDER-PB-RECORD-RELEASE-FOO-5556B8149BF8BAC76BC30F50A8A2DD4C22C85F30-TEST",
|
112
|
+
headers: post_request_headers
|
113
|
+
)
|
114
|
+
.will_respond_with(
|
115
|
+
status: 201,
|
116
|
+
headers: pact_broker_response_headers
|
117
|
+
)
|
118
|
+
end
|
119
|
+
|
120
|
+
context "when the deployment is recorded successfully" do
|
121
|
+
before do
|
122
|
+
mock_index
|
123
|
+
mock_pacticipant_version_with_test_environment_available_for_release
|
124
|
+
mock_record_release
|
125
|
+
end
|
126
|
+
|
127
|
+
it "returns a success message" do
|
128
|
+
expect(subject.success).to be true
|
129
|
+
expect(subject.message).to include "Recorded release of Foo version 5556b8149bf8bac76bc30f50a8a2dd4c22c85f30 to test environment in the Pact Broker."
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
@@ -0,0 +1,166 @@
|
|
1
|
+
require 'service_providers/pact_helper'
|
2
|
+
require 'pact_broker/client/deployments/record_undeployment'
|
3
|
+
|
4
|
+
deployment_feature_on = ENV.fetch('PACT_BROKER_FEATURES', '').include?("deployments")
|
5
|
+
|
6
|
+
RSpec.describe "recording an undeployment", pact: true, skip: !deployment_feature_on do
|
7
|
+
include_context "pact broker"
|
8
|
+
include PactBrokerPactHelperMethods
|
9
|
+
|
10
|
+
let(:pacticipant_name) { "Foo" }
|
11
|
+
let(:environment_name) { "test" }
|
12
|
+
let(:output) { "text" }
|
13
|
+
let(:target) { "customer-1" }
|
14
|
+
let(:params) do
|
15
|
+
{
|
16
|
+
pacticipant_name: pacticipant_name,
|
17
|
+
environment_name: environment_name,
|
18
|
+
target: target
|
19
|
+
}
|
20
|
+
end
|
21
|
+
let(:options) do
|
22
|
+
{
|
23
|
+
output: output,
|
24
|
+
verbose: true
|
25
|
+
}
|
26
|
+
end
|
27
|
+
let(:webmock_base_url) { "http://broker" }
|
28
|
+
let(:pact_broker_client_options) { { pact_broker_base_url: webmock_base_url } }
|
29
|
+
let(:test_environment_placeholder_path) { "/HAL-REL-PLACEHOLDER-PB-ENVIRONMENT-16926ef3-590f-4e3f-838e-719717aa88c9" }
|
30
|
+
let(:currently_deployed_versions_placeholder_path) { "/PLACEHOLDER-ENVIRONMENT-CURRENTLY-DEPLOYED-16926ef3-590f-4e3f-838e-719717aa88c9" }
|
31
|
+
let(:deployed_version_placeholder_path) { "/PLACEHOLDER-DEPLOYED-VERSION-ff3adecf-cfc5-4653-a4e3-f1861092f8e0"}
|
32
|
+
|
33
|
+
subject { PactBroker::Client::Deployments::RecordUndeployment.call(params, options, pact_broker_client_options) }
|
34
|
+
|
35
|
+
let(:index_body_hash) do
|
36
|
+
{
|
37
|
+
_links: {
|
38
|
+
:'pb:environments' => {
|
39
|
+
href: "#{webmock_base_url}/environments"
|
40
|
+
}
|
41
|
+
}
|
42
|
+
}
|
43
|
+
end
|
44
|
+
|
45
|
+
let(:environments_hash) do
|
46
|
+
{
|
47
|
+
_links: {
|
48
|
+
:'pb:environments' => [
|
49
|
+
{
|
50
|
+
name: "test",
|
51
|
+
href: pact_broker.mock_service_base_url + test_environment_placeholder_path
|
52
|
+
}
|
53
|
+
]
|
54
|
+
}
|
55
|
+
}
|
56
|
+
end
|
57
|
+
|
58
|
+
let!(:index_request) do
|
59
|
+
stub_request(:get, "http://broker").to_return(status: 200, body: index_body_hash.to_json, headers: { "Content-Type" => "application/hal+json" } )
|
60
|
+
end
|
61
|
+
|
62
|
+
let!(:environments_request) do
|
63
|
+
stub_request(:get, "http://broker/environments").to_return(status: 200, body: environments_hash.to_json, headers: { "Content-Type" => "application/hal+json" } )
|
64
|
+
end
|
65
|
+
|
66
|
+
def mock_test_environment
|
67
|
+
pact_broker
|
68
|
+
.given("an environment with name test and UUID 16926ef3-590f-4e3f-838e-719717aa88c9 exists")
|
69
|
+
.upon_receiving("a request for an environment")
|
70
|
+
.with(
|
71
|
+
method: "GET",
|
72
|
+
path: test_environment_placeholder_path,
|
73
|
+
headers: get_request_headers
|
74
|
+
)
|
75
|
+
.will_respond_with(
|
76
|
+
status: 200,
|
77
|
+
headers: pact_broker_response_headers,
|
78
|
+
body: {
|
79
|
+
_links: {
|
80
|
+
:'pb:currently-deployed-versions' => {
|
81
|
+
href: Pact.term( pact_broker.mock_service_base_url + currently_deployed_versions_placeholder_path, /^http.*/)
|
82
|
+
}
|
83
|
+
}
|
84
|
+
}
|
85
|
+
)
|
86
|
+
end
|
87
|
+
|
88
|
+
def mock_deployed_versions_search_results
|
89
|
+
pact_broker
|
90
|
+
.given("an version is deployed to environment with UUID 16926ef3-590f-4e3f-838e-719717aa88c9 with target customer-1")
|
91
|
+
.upon_receiving("a request to list the versions deployed to an environment for a pacticipant name and target")
|
92
|
+
.with(
|
93
|
+
method: "GET",
|
94
|
+
path: currently_deployed_versions_placeholder_path,
|
95
|
+
query: { pacticipant: pacticipant_name },
|
96
|
+
headers: get_request_headers
|
97
|
+
)
|
98
|
+
.will_respond_with(
|
99
|
+
status: 200,
|
100
|
+
headers: pact_broker_response_headers,
|
101
|
+
body: {
|
102
|
+
_embedded: {
|
103
|
+
deployedVersions: [
|
104
|
+
{
|
105
|
+
target: target,
|
106
|
+
_links: {
|
107
|
+
self: {
|
108
|
+
href: Pact.term(pact_broker.mock_service_base_url + deployed_version_placeholder_path, /^http/)
|
109
|
+
}
|
110
|
+
}
|
111
|
+
}
|
112
|
+
]
|
113
|
+
}
|
114
|
+
}
|
115
|
+
)
|
116
|
+
end
|
117
|
+
|
118
|
+
def mock_mark_deployed_version_as_undeployed
|
119
|
+
pact_broker
|
120
|
+
.given("a currently deployed version exists")
|
121
|
+
.upon_receiving("a request to mark a deployed version as not currently deploye")
|
122
|
+
.with(
|
123
|
+
method: "PATCH",
|
124
|
+
path: deployed_version_placeholder_path,
|
125
|
+
body: { currentlyDeployed: false },
|
126
|
+
headers: patch_request_headers
|
127
|
+
)
|
128
|
+
.will_respond_with(
|
129
|
+
status: 200,
|
130
|
+
headers: pact_broker_response_headers,
|
131
|
+
body: deployed_version_hash
|
132
|
+
)
|
133
|
+
end
|
134
|
+
|
135
|
+
let(:deployed_version_hash) do
|
136
|
+
{
|
137
|
+
"currentlyDeployed" => false,
|
138
|
+
"_embedded" => {
|
139
|
+
"version" => {
|
140
|
+
"number" => Pact.like("2")
|
141
|
+
}
|
142
|
+
}
|
143
|
+
}
|
144
|
+
end
|
145
|
+
|
146
|
+
context "when the deployment is recorded successfully" do
|
147
|
+
before do
|
148
|
+
mock_test_environment
|
149
|
+
mock_deployed_versions_search_results
|
150
|
+
mock_mark_deployed_version_as_undeployed
|
151
|
+
end
|
152
|
+
|
153
|
+
it "returns a success message" do
|
154
|
+
expect(subject.success).to be true
|
155
|
+
expect(subject.message).to include "Recorded undeployment of Foo version 2 from test environment (target customer-1) in the Pact Broker"
|
156
|
+
end
|
157
|
+
|
158
|
+
context "when the output is json" do
|
159
|
+
let(:output) { "json" }
|
160
|
+
|
161
|
+
it "returns the JSON payload" do
|
162
|
+
expect(JSON.parse(subject.message)).to eq [Pact::Reification.from_term(deployed_version_hash)]
|
163
|
+
end
|
164
|
+
end
|
165
|
+
end
|
166
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
require 'webmock/rspec'
|
2
|
-
|
3
|
-
ENV['PACT_BROKER_FEATURES'] = 'deployments publish_contracts'
|
2
|
+
require 'rspec/its'
|
4
3
|
|
5
4
|
WebMock.disable_net_connect!(allow_localhost: true)
|
6
5
|
|
7
6
|
require "./spec/support/shared_context.rb"
|
7
|
+
require "./spec/support/approvals.rb"
|
8
8
|
|
9
9
|
is_windows = (RbConfig::CONFIG['host_os'] =~ /bccwin|cygwin|djgpp|mingw|mswin|wince/i) != nil
|
10
10
|
is_ci = ENV['CI'] == 'true'
|
@@ -23,6 +23,19 @@ RSpec.configure do | config |
|
|
23
23
|
|
24
24
|
config.filter_run_excluding skip_windows: is_windows, skip_ci: is_ci
|
25
25
|
config.example_status_persistence_file_path = "./spec/examples.txt"
|
26
|
+
|
27
|
+
def capture(stream)
|
28
|
+
begin
|
29
|
+
stream = stream.to_s
|
30
|
+
eval "$#{stream} = StringIO.new"
|
31
|
+
yield
|
32
|
+
result = eval("$#{stream}").string
|
33
|
+
ensure
|
34
|
+
eval("$#{stream} = #{stream.upcase}")
|
35
|
+
end
|
36
|
+
|
37
|
+
result
|
38
|
+
end
|
26
39
|
end
|
27
40
|
|
28
41
|
module Pact
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'approvals/rspec'
|
2
|
+
require 'pact/support'
|
3
|
+
|
4
|
+
Approvals.configure do |c|
|
5
|
+
c.approvals_path = 'spec/fixtures/approvals/'
|
6
|
+
end
|
7
|
+
|
8
|
+
def print_diff(exception)
|
9
|
+
parts = exception.message.split('"')
|
10
|
+
received_file = parts[1]
|
11
|
+
approved_file = parts[3]
|
12
|
+
if File.exist?(received_file) && File.exist?(approved_file) && received_file.end_with?(".json") && approved_file.end_with?(".json")
|
13
|
+
received_hash = JSON.parse(File.read(received_file))
|
14
|
+
approved_hash = JSON.parse(File.read(approved_file))
|
15
|
+
diff = Pact::Matchers.diff(approved_hash, received_hash)
|
16
|
+
puts Pact::Matchers::UnixDiffFormatter.call(diff)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
RSpec.configure do | config |
|
21
|
+
config.after(:each) do | example |
|
22
|
+
if example.exception.is_a?(Approvals::ApprovalError)
|
23
|
+
print_diff(example.exception)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -1,6 +1,11 @@
|
|
1
1
|
require 'pact_broker/client/pact_hash'
|
2
|
-
|
2
|
+
require 'pact_broker/client/hal/http_client'
|
3
3
|
|
4
|
+
shared_context "pact broker" do
|
5
|
+
before do
|
6
|
+
allow_any_instance_of(PactBroker::Client::Hal::HttpClient).to receive(:sleep)
|
7
|
+
allow_any_instance_of(PactBroker::Client::Hal::HttpClient).to receive(:default_max_tries).and_return(1)
|
8
|
+
end
|
4
9
|
let(:pact_hash) { PactBroker::Client::PactHash[consumer: {name: 'Condor'}, provider: {name: 'Pricing Service'}, interactions: []] }
|
5
10
|
let(:consumer_contract) { Pact::ConsumerContract.from_hash pact_hash }
|
6
11
|
let(:pact_json) { pact_hash.to_json }
|
@@ -12,9 +17,9 @@ shared_context "pact broker" do
|
|
12
17
|
let(:pact_broker_version) { Pact::Term.new(:matcher => /\d+\.\d+\.\d+/, :generate => '1.0.0') }
|
13
18
|
let(:pact_broker_response_headers) { {'Content-Type' => 'application/hal+json;charset=utf-8'} }
|
14
19
|
let(:default_request_headers) { { 'Content-Type' => 'application/json'} }
|
15
|
-
let(:
|
20
|
+
let(:old_patch_request_headers) { { 'Content-Type' => 'application/json'} }
|
21
|
+
let(:patch_request_headers) { { 'Content-Type' => 'application/merge-patch+json'} }
|
16
22
|
let(:put_request_headers) { { 'Content-Type' => 'application/json', 'Accept' => 'application/hal+json'} }
|
17
23
|
let(:post_request_headers) { { 'Content-Type' => 'application/json', 'Accept' => 'application/hal+json'} }
|
18
24
|
let(:get_request_headers) { { 'Accept' => 'application/hal+json'} }
|
19
|
-
|
20
25
|
end
|
data/tasks/pact.rake
CHANGED
@@ -14,5 +14,25 @@ PactBroker::Client::PublicationTask.new(:remote) do | task |
|
|
14
14
|
task.tag = `git rev-parse --abbrev-ref HEAD`.strip
|
15
15
|
task.consumer_version = PactBroker::Client::VERSION
|
16
16
|
task.pact_broker_base_url = "https://test.pact.dius.com.au"
|
17
|
-
task.pact_broker_basic_auth = {username: ENV.fetch('PACT_BROKER_USERNAME'), password: ENV.fetch('PACT_BROKER_PASSWORD')}
|
17
|
+
task.pact_broker_basic_auth = { username: ENV.fetch('PACT_BROKER_USERNAME'), password: ENV.fetch('PACT_BROKER_PASSWORD') }
|
18
|
+
end
|
19
|
+
|
20
|
+
PactBroker::Client::PublicationTask.new(:pactflow) do | task |
|
21
|
+
version = ENV.fetch('GITHUB_SHA')
|
22
|
+
branch = ENV.fetch('GITHUB_REF').gsub("refs/heads/", "")
|
23
|
+
feature = ENV.fetch('TEST_FEATURE', '')
|
24
|
+
tag = branch
|
25
|
+
|
26
|
+
if feature != ''
|
27
|
+
version = "#{version}+#{feature}"
|
28
|
+
tag = "#{tag}+#{feature}"
|
29
|
+
end
|
30
|
+
|
31
|
+
require 'pact_broker/client/version'
|
32
|
+
task.auto_detect_version_properties = false
|
33
|
+
task.tags = [tag]
|
34
|
+
task.branch = nil
|
35
|
+
task.consumer_version = version
|
36
|
+
task.pact_broker_base_url = "https://pact-oss.pactflow.io"
|
37
|
+
task.pact_broker_token = ENV['PACT_BROKER_TOKEN']
|
18
38
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pact_broker-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.45.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Beth Skurrie
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-06-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -170,6 +170,40 @@ dependencies:
|
|
170
170
|
- - "~>"
|
171
171
|
- !ruby/object:Gem::Version
|
172
172
|
version: '1.16'
|
173
|
+
- !ruby/object:Gem::Dependency
|
174
|
+
name: approvals
|
175
|
+
requirement: !ruby/object:Gem::Requirement
|
176
|
+
requirements:
|
177
|
+
- - ">="
|
178
|
+
- !ruby/object:Gem::Version
|
179
|
+
version: 0.0.24
|
180
|
+
- - "<"
|
181
|
+
- !ruby/object:Gem::Version
|
182
|
+
version: 1.0.0
|
183
|
+
type: :development
|
184
|
+
prerelease: false
|
185
|
+
version_requirements: !ruby/object:Gem::Requirement
|
186
|
+
requirements:
|
187
|
+
- - ">="
|
188
|
+
- !ruby/object:Gem::Version
|
189
|
+
version: 0.0.24
|
190
|
+
- - "<"
|
191
|
+
- !ruby/object:Gem::Version
|
192
|
+
version: 1.0.0
|
193
|
+
- !ruby/object:Gem::Dependency
|
194
|
+
name: rspec-its
|
195
|
+
requirement: !ruby/object:Gem::Requirement
|
196
|
+
requirements:
|
197
|
+
- - "~>"
|
198
|
+
- !ruby/object:Gem::Version
|
199
|
+
version: '1.3'
|
200
|
+
type: :development
|
201
|
+
prerelease: false
|
202
|
+
version_requirements: !ruby/object:Gem::Requirement
|
203
|
+
requirements:
|
204
|
+
- - "~>"
|
205
|
+
- !ruby/object:Gem::Version
|
206
|
+
version: '1.3'
|
173
207
|
description: Client for the Pact Broker. Publish, retrieve and query pacts and verification
|
174
208
|
results.
|
175
209
|
email:
|
@@ -206,17 +240,37 @@ files:
|
|
206
240
|
- lib/pact_broker/client.rb
|
207
241
|
- lib/pact_broker/client/backports.rb
|
208
242
|
- lib/pact_broker/client/base_client.rb
|
243
|
+
- lib/pact_broker/client/base_command.rb
|
209
244
|
- lib/pact_broker/client/can_i_deploy.rb
|
210
245
|
- lib/pact_broker/client/cli/broker.rb
|
211
246
|
- lib/pact_broker/client/cli/can_i_deploy_long_desc.txt
|
212
247
|
- lib/pact_broker/client/cli/create_or_update_webhook_long_desc.txt
|
213
248
|
- lib/pact_broker/client/cli/create_webhook_long_desc.txt
|
214
249
|
- lib/pact_broker/client/cli/custom_thor.rb
|
250
|
+
- lib/pact_broker/client/cli/deployment_commands.rb
|
251
|
+
- lib/pact_broker/client/cli/environment_commands.rb
|
252
|
+
- lib/pact_broker/client/cli/pacticipant_commands.rb
|
215
253
|
- lib/pact_broker/client/cli/record_deployment_long_desc.txt
|
216
254
|
- lib/pact_broker/client/cli/version_selector_options_parser.rb
|
255
|
+
- lib/pact_broker/client/colorize_notices.rb
|
217
256
|
- lib/pact_broker/client/command_result.rb
|
218
257
|
- lib/pact_broker/client/create_tag.rb
|
258
|
+
- lib/pact_broker/client/deployments.rb
|
259
|
+
- lib/pact_broker/client/deployments/record_deployment.rb
|
260
|
+
- lib/pact_broker/client/deployments/record_release.rb
|
261
|
+
- lib/pact_broker/client/deployments/record_support_ended.rb
|
262
|
+
- lib/pact_broker/client/deployments/record_undeployment.rb
|
263
|
+
- lib/pact_broker/client/describe_text_formatter.rb
|
264
|
+
- lib/pact_broker/client/environments.rb
|
265
|
+
- lib/pact_broker/client/environments/create_environment.rb
|
266
|
+
- lib/pact_broker/client/environments/delete_environment.rb
|
267
|
+
- lib/pact_broker/client/environments/describe_environment.rb
|
268
|
+
- lib/pact_broker/client/environments/environment_command.rb
|
269
|
+
- lib/pact_broker/client/environments/list_environments.rb
|
270
|
+
- lib/pact_broker/client/environments/text_formatter.rb
|
271
|
+
- lib/pact_broker/client/environments/update_environment.rb
|
219
272
|
- lib/pact_broker/client/error.rb
|
273
|
+
- lib/pact_broker/client/generate_display_name.rb
|
220
274
|
- lib/pact_broker/client/git.rb
|
221
275
|
- lib/pact_broker/client/hal.rb
|
222
276
|
- lib/pact_broker/client/hal/authorization_header_redactor.rb
|
@@ -228,6 +282,7 @@ files:
|
|
228
282
|
- lib/pact_broker/client/hal_client_methods.rb
|
229
283
|
- lib/pact_broker/client/hash_refinements.rb
|
230
284
|
- lib/pact_broker/client/matrix.rb
|
285
|
+
- lib/pact_broker/client/matrix/abbreviate_version_number.rb
|
231
286
|
- lib/pact_broker/client/matrix/formatter.rb
|
232
287
|
- lib/pact_broker/client/matrix/json_formatter.rb
|
233
288
|
- lib/pact_broker/client/matrix/resource.rb
|
@@ -238,11 +293,15 @@ files:
|
|
238
293
|
- lib/pact_broker/client/pact_hash.rb
|
239
294
|
- lib/pact_broker/client/pacticipants.rb
|
240
295
|
- lib/pact_broker/client/pacticipants/create.rb
|
296
|
+
- lib/pact_broker/client/pacticipants/describe.rb
|
297
|
+
- lib/pact_broker/client/pacticipants/list.rb
|
298
|
+
- lib/pact_broker/client/pacticipants/text_formatter.rb
|
241
299
|
- lib/pact_broker/client/pacts.rb
|
242
300
|
- lib/pact_broker/client/pacts/list_latest_versions.rb
|
243
301
|
- lib/pact_broker/client/publish_pacts.rb
|
244
302
|
- lib/pact_broker/client/publish_pacts_the_old_way.rb
|
245
303
|
- lib/pact_broker/client/retry.rb
|
304
|
+
- lib/pact_broker/client/string_refinements.rb
|
246
305
|
- lib/pact_broker/client/tasks.rb
|
247
306
|
- lib/pact_broker/client/tasks/publication_task.rb
|
248
307
|
- lib/pact_broker/client/version.rb
|
@@ -250,23 +309,30 @@ files:
|
|
250
309
|
- lib/pact_broker/client/versions/describe.rb
|
251
310
|
- lib/pact_broker/client/versions/formatter.rb
|
252
311
|
- lib/pact_broker/client/versions/json_formatter.rb
|
253
|
-
- lib/pact_broker/client/versions/record_deployment.rb
|
254
|
-
- lib/pact_broker/client/versions/record_undeployment.rb
|
255
312
|
- lib/pact_broker/client/versions/text_formatter.rb
|
256
313
|
- lib/pact_broker/client/webhooks/create.rb
|
257
314
|
- lib/pact_broker/client/webhooks/test.rb
|
258
315
|
- lib/pact_broker_client.rb
|
259
316
|
- pact-broker-client.gemspec
|
317
|
+
- script/approve-all.sh
|
260
318
|
- script/create-pacticipant.sh
|
261
319
|
- script/generate-cli-usage.sh
|
262
320
|
- script/publish-pact.sh
|
263
321
|
- script/record-deployment.sh
|
322
|
+
- script/record-deployments-and-releases.sh
|
264
323
|
- script/record-undeployment.sh
|
265
324
|
- script/release.sh
|
266
325
|
- script/trigger-release.sh
|
326
|
+
- spec/fixtures/approvals/can_i_deploy_failure_dry_run.approved.txt
|
327
|
+
- spec/fixtures/approvals/can_i_deploy_ignore.approved.txt
|
328
|
+
- spec/fixtures/approvals/can_i_deploy_success_dry_run.approved.txt
|
329
|
+
- spec/fixtures/approvals/describe_environment.approved.txt
|
330
|
+
- spec/fixtures/approvals/describe_pacticipant.approved.txt
|
331
|
+
- spec/fixtures/approvals/list_environments.approved.txt
|
267
332
|
- spec/fixtures/foo-bar.json
|
268
333
|
- spec/integration/can_i_deploy_spec.rb
|
269
334
|
- spec/integration/create_version_tag_spec.rb
|
335
|
+
- spec/integration/describe_environment_spec.rb
|
270
336
|
- spec/lib/pact_broker/client/base_client_spec.rb
|
271
337
|
- spec/lib/pact_broker/client/can_i_deploy_spec.rb
|
272
338
|
- spec/lib/pact_broker/client/cli/broker_can_i_deploy_spec.rb
|
@@ -276,6 +342,13 @@ files:
|
|
276
342
|
- spec/lib/pact_broker/client/cli/broker_run_webhook_commands_spec.rb
|
277
343
|
- spec/lib/pact_broker/client/cli/custom_thor_spec.rb
|
278
344
|
- spec/lib/pact_broker/client/cli/version_selector_options_parser_spec.rb
|
345
|
+
- spec/lib/pact_broker/client/deployments/record_deployment_spec.rb
|
346
|
+
- spec/lib/pact_broker/client/deployments/record_support_ended_spec.rb
|
347
|
+
- spec/lib/pact_broker/client/deployments/record_undeployment_spec.rb
|
348
|
+
- spec/lib/pact_broker/client/environments/delete_environment_spec.rb
|
349
|
+
- spec/lib/pact_broker/client/environments/describe_environment_spec.rb
|
350
|
+
- spec/lib/pact_broker/client/environments/update_environment_spec.rb
|
351
|
+
- spec/lib/pact_broker/client/generate_display_name_spec.rb
|
279
352
|
- spec/lib/pact_broker/client/git_spec.rb
|
280
353
|
- spec/lib/pact_broker/client/hal/authorization_header_redactor_spec.rb
|
281
354
|
- spec/lib/pact_broker/client/hal/entity_spec.rb
|
@@ -292,13 +365,15 @@ files:
|
|
292
365
|
- spec/lib/pact_broker/client/retry_spec.rb
|
293
366
|
- spec/lib/pact_broker/client/tasks/publication_task_spec.rb
|
294
367
|
- spec/lib/pact_broker/client/versions/describe_spec.rb
|
295
|
-
- spec/lib/pact_broker/client/versions/record_deployment_spec.rb
|
296
368
|
- spec/lib/pact_broker/client/versions_spec.rb
|
297
369
|
- spec/lib/pact_broker/client/webhooks/create_spec.rb
|
298
370
|
- spec/pacts/pact_broker_client-pact_broker.json
|
371
|
+
- spec/service_providers/create_environment_spec.rb
|
299
372
|
- spec/service_providers/extra_goodies_spec.rb
|
373
|
+
- spec/service_providers/list_environments_spec.rb
|
300
374
|
- spec/service_providers/list_latest_pact_versions_spec.rb.bak
|
301
375
|
- spec/service_providers/pact_broker_client_create_version_spec.rb
|
376
|
+
- spec/service_providers/pact_broker_client_matrix_ignore_spec.rb
|
302
377
|
- spec/service_providers/pact_broker_client_matrix_spec.rb
|
303
378
|
- spec/service_providers/pact_broker_client_pacticipant_version_spec.rb
|
304
379
|
- spec/service_providers/pact_broker_client_publish_spec.rb
|
@@ -311,8 +386,11 @@ files:
|
|
311
386
|
- spec/service_providers/pacticipants_create_spec.rb
|
312
387
|
- spec/service_providers/publish_pacts_spec.rb
|
313
388
|
- spec/service_providers/record_deployment_spec.rb
|
389
|
+
- spec/service_providers/record_release_spec.rb
|
390
|
+
- spec/service_providers/record_undeployment_spec.rb
|
314
391
|
- spec/service_providers/webhooks_create_spec.rb
|
315
392
|
- spec/spec_helper.rb
|
393
|
+
- spec/support/approvals.rb
|
316
394
|
- spec/support/cli_test_pacts/bar.json
|
317
395
|
- spec/support/cli_test_pacts/foo.json
|
318
396
|
- spec/support/latest_pacts_for_provider.json
|
@@ -344,14 +422,21 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
344
422
|
- !ruby/object:Gem::Version
|
345
423
|
version: '0'
|
346
424
|
requirements: []
|
347
|
-
rubygems_version: 3.2.
|
425
|
+
rubygems_version: 3.2.20
|
348
426
|
signing_key:
|
349
427
|
specification_version: 4
|
350
428
|
summary: See description
|
351
429
|
test_files:
|
430
|
+
- spec/fixtures/approvals/can_i_deploy_failure_dry_run.approved.txt
|
431
|
+
- spec/fixtures/approvals/can_i_deploy_ignore.approved.txt
|
432
|
+
- spec/fixtures/approvals/can_i_deploy_success_dry_run.approved.txt
|
433
|
+
- spec/fixtures/approvals/describe_environment.approved.txt
|
434
|
+
- spec/fixtures/approvals/describe_pacticipant.approved.txt
|
435
|
+
- spec/fixtures/approvals/list_environments.approved.txt
|
352
436
|
- spec/fixtures/foo-bar.json
|
353
437
|
- spec/integration/can_i_deploy_spec.rb
|
354
438
|
- spec/integration/create_version_tag_spec.rb
|
439
|
+
- spec/integration/describe_environment_spec.rb
|
355
440
|
- spec/lib/pact_broker/client/base_client_spec.rb
|
356
441
|
- spec/lib/pact_broker/client/can_i_deploy_spec.rb
|
357
442
|
- spec/lib/pact_broker/client/cli/broker_can_i_deploy_spec.rb
|
@@ -361,6 +446,13 @@ test_files:
|
|
361
446
|
- spec/lib/pact_broker/client/cli/broker_run_webhook_commands_spec.rb
|
362
447
|
- spec/lib/pact_broker/client/cli/custom_thor_spec.rb
|
363
448
|
- spec/lib/pact_broker/client/cli/version_selector_options_parser_spec.rb
|
449
|
+
- spec/lib/pact_broker/client/deployments/record_deployment_spec.rb
|
450
|
+
- spec/lib/pact_broker/client/deployments/record_support_ended_spec.rb
|
451
|
+
- spec/lib/pact_broker/client/deployments/record_undeployment_spec.rb
|
452
|
+
- spec/lib/pact_broker/client/environments/delete_environment_spec.rb
|
453
|
+
- spec/lib/pact_broker/client/environments/describe_environment_spec.rb
|
454
|
+
- spec/lib/pact_broker/client/environments/update_environment_spec.rb
|
455
|
+
- spec/lib/pact_broker/client/generate_display_name_spec.rb
|
364
456
|
- spec/lib/pact_broker/client/git_spec.rb
|
365
457
|
- spec/lib/pact_broker/client/hal/authorization_header_redactor_spec.rb
|
366
458
|
- spec/lib/pact_broker/client/hal/entity_spec.rb
|
@@ -377,13 +469,15 @@ test_files:
|
|
377
469
|
- spec/lib/pact_broker/client/retry_spec.rb
|
378
470
|
- spec/lib/pact_broker/client/tasks/publication_task_spec.rb
|
379
471
|
- spec/lib/pact_broker/client/versions/describe_spec.rb
|
380
|
-
- spec/lib/pact_broker/client/versions/record_deployment_spec.rb
|
381
472
|
- spec/lib/pact_broker/client/versions_spec.rb
|
382
473
|
- spec/lib/pact_broker/client/webhooks/create_spec.rb
|
383
474
|
- spec/pacts/pact_broker_client-pact_broker.json
|
475
|
+
- spec/service_providers/create_environment_spec.rb
|
384
476
|
- spec/service_providers/extra_goodies_spec.rb
|
477
|
+
- spec/service_providers/list_environments_spec.rb
|
385
478
|
- spec/service_providers/list_latest_pact_versions_spec.rb.bak
|
386
479
|
- spec/service_providers/pact_broker_client_create_version_spec.rb
|
480
|
+
- spec/service_providers/pact_broker_client_matrix_ignore_spec.rb
|
387
481
|
- spec/service_providers/pact_broker_client_matrix_spec.rb
|
388
482
|
- spec/service_providers/pact_broker_client_pacticipant_version_spec.rb
|
389
483
|
- spec/service_providers/pact_broker_client_publish_spec.rb
|
@@ -396,8 +490,11 @@ test_files:
|
|
396
490
|
- spec/service_providers/pacticipants_create_spec.rb
|
397
491
|
- spec/service_providers/publish_pacts_spec.rb
|
398
492
|
- spec/service_providers/record_deployment_spec.rb
|
493
|
+
- spec/service_providers/record_release_spec.rb
|
494
|
+
- spec/service_providers/record_undeployment_spec.rb
|
399
495
|
- spec/service_providers/webhooks_create_spec.rb
|
400
496
|
- spec/spec_helper.rb
|
497
|
+
- spec/support/approvals.rb
|
401
498
|
- spec/support/cli_test_pacts/bar.json
|
402
499
|
- spec/support/cli_test_pacts/foo.json
|
403
500
|
- spec/support/latest_pacts_for_provider.json
|