pact_broker-client 1.72.0 → 1.74.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/release_gem.yml +4 -4
  3. data/.github/workflows/test.yml +5 -5
  4. data/.github/workflows/trigger_pact_docs_update.yml +1 -1
  5. data/CHANGELOG.md +21 -0
  6. data/DEVELOPING.md +17 -0
  7. data/Gemfile +5 -0
  8. data/README.md +21 -9
  9. data/doc/pacts/markdown/Pact Broker Client - Pact Broker.md +1 -2
  10. data/example/scripts/publish-pact-rake.sh +10 -0
  11. data/example/scripts/publish-pact.sh +25 -1
  12. data/example/scripts/publish-provider-contract.sh +2 -1
  13. data/lib/pact_broker/client/cli/custom_thor.rb +32 -2
  14. data/lib/pact_broker/client/cli/pact_commands.rb +34 -13
  15. data/lib/pact_broker/client/cli/thor_unknown_options_monkey_patch.rb +38 -0
  16. data/lib/pact_broker/client/cli/webhook_commands.rb +1 -1
  17. data/lib/pact_broker/client/git.rb +20 -3
  18. data/lib/pact_broker/client/hal/http_client.rb +19 -0
  19. data/lib/pact_broker/client/merge_pacts.rb +5 -2
  20. data/lib/pact_broker/client/publish_pacts_the_old_way.rb +1 -1
  21. data/lib/pact_broker/client/tasks/publication_task.rb +40 -23
  22. data/lib/pact_broker/client/version.rb +1 -1
  23. data/script/ci/record-release.sh +2 -2
  24. data/script/publish-pact.sh +1 -1
  25. data/script/update-cli-usage-in-readme.rb +7 -0
  26. data/spec/fixtures/MyConsumer-MyProvider (1).json +37 -0
  27. data/spec/fixtures/MyConsumer-MyProvider.json +37 -0
  28. data/spec/fixtures/certificates/ca_cert.pem +19 -0
  29. data/spec/fixtures/certificates/ca_cert.srl +1 -0
  30. data/spec/fixtures/certificates/ca_key.pem +28 -0
  31. data/spec/fixtures/certificates/client_cert.pem +17 -0
  32. data/spec/fixtures/certificates/key.pem +28 -0
  33. data/spec/fixtures/certificates/server.csr +15 -0
  34. data/spec/fixtures/certificates/unsigned_cert.pem +19 -0
  35. data/spec/fixtures/certificates/unsigned_key.pem +28 -0
  36. data/spec/integration/can_i_deploy_spec.rb +0 -9
  37. data/spec/integration/unknown_options_spec.rb +39 -0
  38. data/spec/lib/pact_broker/client/cli/broker_publish_spec.rb +38 -21
  39. data/spec/lib/pact_broker/client/cli/custom_thor_spec.rb +27 -0
  40. data/spec/lib/pact_broker/client/hal/http_client_spec.rb +76 -0
  41. data/spec/lib/pact_broker/client/merge_pacts_spec.rb +26 -0
  42. data/spec/lib/pact_broker/client/publish_pacts_the_old_way_spec.rb +1 -3
  43. data/spec/lib/pact_broker/client/tasks/publication_task_spec.rb +54 -31
  44. data/spec/pacts/pact_broker_client-pact_broker.json +1 -2
  45. data/spec/service_providers/publish_pacts_spec.rb +1 -2
  46. data/spec/support/ssl_server.rb +42 -0
  47. data/tasks/pact.rake +79 -0
  48. metadata +30 -3
@@ -1,4 +1,6 @@
1
1
  require 'pact_broker/client/hal/http_client'
2
+ require "faraday"
3
+ require "faraday/retry"
2
4
 
3
5
  module PactBroker::Client
4
6
  module Hal
@@ -157,6 +159,80 @@ module PactBroker::Client
157
159
  end
158
160
  end
159
161
  end
162
+
163
+ describe "x509 certificate" do
164
+ FAKE_SERVER_URL = 'https://localhost:4444'
165
+ X509_CERT_FILE_PATH = './spec/fixtures/certificates/client_cert.pem'
166
+ X509_KEY_FILE_PATH = './spec/fixtures/certificates/key.pem'
167
+ UNSIGNED_X509_CERT_FILE_PATH = './spec/fixtures/certificates/unsigned_cert.pem'
168
+ UNSIGNED_X509_KEY_FILE_PATH = './spec/fixtures/certificates/unsigned_key.pem'
169
+
170
+ def wait_for_server_to_start
171
+ Faraday.new(
172
+ url: FAKE_SERVER_URL,
173
+ ssl: {
174
+ verify: false,
175
+ client_cert: OpenSSL::X509::Certificate.new(File.read(X509_CERT_FILE_PATH)),
176
+ client_key: OpenSSL::PKey::RSA.new(File.read(X509_KEY_FILE_PATH))
177
+ }
178
+ ) do |builder|
179
+ builder.request :retry, max: 20, interval: 0.5, exceptions: [StandardError]
180
+ builder.adapter :net_http
181
+ end.get
182
+ end
183
+
184
+ let(:do_get) { subject.get(FAKE_SERVER_URL) }
185
+
186
+ before(:all) do
187
+ @pipe = IO.popen("bundle exec ruby ./spec/support/ssl_server.rb")
188
+ ENV['SSL_CERT_FILE'] = "./spec/fixtures/certificates/ca_cert.pem"
189
+
190
+ wait_for_server_to_start()
191
+ end
192
+
193
+ context "with valid x509 client certificates" do
194
+ before do
195
+ ENV['X509_CLIENT_CERT_FILE'] = X509_CERT_FILE_PATH
196
+ ENV['X509_CLIENT_KEY_FILE'] = X509_KEY_FILE_PATH
197
+ end
198
+
199
+ it "succeeds" do
200
+ expect(do_get.status).to eq 200
201
+ end
202
+ end
203
+
204
+ context "when invalid x509 certificates are set" do
205
+ before do
206
+ ENV['X509_CLIENT_CERT_FILE'] = UNSIGNED_X509_CERT_FILE_PATH
207
+ ENV['X509_CLIENT_KEY_FILE'] = UNSIGNED_X509_KEY_FILE_PATH
208
+ end
209
+
210
+ it "fails raising SSL error" do
211
+ expect { do_get }
212
+ .to raise_error { |error|
213
+ expect([OpenSSL::SSL::SSLError, Errno::ECONNRESET]).to include(error.class)
214
+ }
215
+ end
216
+ end
217
+
218
+ context "when no x509 certificates are set" do
219
+ before do
220
+ ENV['X509_CLIENT_CERT_FILE'] = nil
221
+ ENV['X509_CLIENT_KEY_FILE'] = nil
222
+ end
223
+
224
+ it "fails raising SSL error" do
225
+ expect { do_get }
226
+ .to raise_error { |error|
227
+ expect([OpenSSL::SSL::SSLError, Errno::ECONNRESET]).to include(error.class)
228
+ }
229
+ end
230
+ end
231
+
232
+ after(:all) do
233
+ Process.kill "KILL", @pipe.pid
234
+ end
235
+ end
160
236
  end
161
237
  end
162
238
  end
@@ -166,6 +166,32 @@ module PactBroker
166
166
  expect(subject).to eq expected_merge
167
167
  end
168
168
  end
169
+
170
+ describe "with v3 pacts" do
171
+ let(:pact_hash_1) { JSON.parse(File.read("spec/fixtures/MyConsumer-MyProvider.json"), symbolize_names: true) }
172
+ let(:pact_hash_2) { JSON.parse(File.read("spec/fixtures/MyConsumer-MyProvider (1).json"), symbolize_names: true) }
173
+ let(:pact_hashes) { [pact_hash_1, pact_hash_2] }
174
+
175
+ subject { MergePacts.call(pact_hashes) }
176
+
177
+ context "when there are no conflicts and no duplicates" do
178
+ it "adds all the interactions to the merged file" do
179
+ expect(subject[:interactions].size).to eq 2
180
+ end
181
+ end
182
+
183
+ context "when there is a conflict" do
184
+ let(:pact_hash_2) do
185
+ hash = JSON.parse(File.read("spec/fixtures/MyConsumer-MyProvider.json"), symbolize_names: true)
186
+ hash[:interactions].first[:request][:path] = "/a-different-path"
187
+ hash
188
+ end
189
+
190
+ it "raises an error with a message that contains the provider states of the conflicting interactions" do
191
+ expect { subject }.to raise_error PactMergeError, /state 1/
192
+ end
193
+ end
194
+ end
169
195
  end
170
196
  end
171
197
  end
@@ -37,7 +37,6 @@ module PactBroker
37
37
  let(:tags) { nil }
38
38
  let(:branch) { nil }
39
39
  let(:build_url) { nil }
40
- let(:version_required) { false }
41
40
  let(:pact_hash) { { consumer: { name: 'Consumer'}, provider: { name: 'Provider' }, interactions: [] } }
42
41
  let(:pact_hash_2) { {consumer: { name: 'Foo' }, provider: { name: 'Bar' }, interactions: [] } }
43
42
  let(:pacts_client) { instance_double("PactBroker::ClientSupport::Pacts")}
@@ -48,8 +47,7 @@ module PactBroker
48
47
  number: consumer_version,
49
48
  branch: branch,
50
49
  tags: tags,
51
- build_url: build_url,
52
- version_required: version_required
50
+ build_url: build_url
53
51
  }
54
52
  end
55
53
  let(:pact_broker_client_options) do
@@ -5,7 +5,6 @@ require 'pact_broker/client/command_result'
5
5
 
6
6
  module PactBroker::Client
7
7
  describe PublicationTask do
8
-
9
8
  before do
10
9
  @consumer_version = "1.2.3"
11
10
  end
@@ -19,6 +18,8 @@ module PactBroker::Client
19
18
  allow(PactBroker::Client::PublishPacts).to receive(:new).and_return(publish_pacts)
20
19
  allow(FileList).to receive(:[]).with(pattern).and_return(pact_file_list)
21
20
  allow(PactBroker::Client::Git).to receive(:branch).and_return('foo')
21
+ allow(PactBroker::Client::Git).to receive(:commit).and_return('6.6.6')
22
+ allow(PactBroker::Client::Git).to receive(:build_url).and_return("build_url")
22
23
  allow($stdout).to receive(:puts)
23
24
  end
24
25
 
@@ -33,7 +34,7 @@ module PactBroker::Client
33
34
 
34
35
  context "when pacts are succesfully published" do
35
36
  it "invokes PublishPacts with the default values" do
36
- expect(PactBroker::Client::PublishPacts).to receive(:new).with('http://pact-broker', pact_file_list, { number: '1.2.3', branch: "foo", tags: [], version_required: false}, {}, {}).and_return(publish_pacts)
37
+ expect(PactBroker::Client::PublishPacts).to receive(:new).with('http://pact-broker', pact_file_list, { number: '1.2.3', branch: "foo", tags: [] }, {}, {}).and_return(publish_pacts)
37
38
  expect(publish_pacts).to receive(:call).and_return(result)
38
39
  Rake::Task['pact:publish'].execute
39
40
  end
@@ -57,7 +58,7 @@ module PactBroker::Client
57
58
  end
58
59
 
59
60
  it "invokes PublishPacts with the write method set" do
60
- expect(PactBroker::Client::PublishPacts).to receive(:new).with('http://pact-broker', pact_file_list, { number: "1.2.3", branch: "foo", tags: [], version_required: false }, {}, {write: :merge}).and_return(publish_pacts)
61
+ expect(PactBroker::Client::PublishPacts).to receive(:new).with('http://pact-broker', pact_file_list, { number: "1.2.3", branch: "foo", tags: [] }, {}, {write: :merge}).and_return(publish_pacts)
61
62
  expect(publish_pacts).to receive(:call).and_return(result)
62
63
  Rake::Task['pact:publish:merge'].execute
63
64
  end
@@ -87,81 +88,92 @@ module PactBroker::Client
87
88
  context "when auto_detect_version_properties is explicitly set to true" do
88
89
  before :all do
89
90
  PactBroker::Client::PublicationTask.new(:git_branch_auto_detect_true) do | task |
90
- task.consumer_version = '1.2.3'
91
91
  task.auto_detect_version_properties = true
92
92
  end
93
93
  end
94
94
 
95
- it "gets the git branch name" do
95
+ # Don't usually put 3 expects into the one it block, but if I separate them,
96
+ # only the first it block passes for some reason that I can't work out.
97
+ it "gets the commit, build_url and branch" do
98
+ expect(PactBroker::Client::Git).to receive(:commit).with(raise_error: true)
99
+ expect(PactBroker::Client::Git).to receive(:build_url)
96
100
  expect(PactBroker::Client::Git).to receive(:branch).with(raise_error: true)
97
101
  Rake::Task['pact:publish:git_branch_auto_detect_true'].execute
98
102
  end
99
103
 
100
- it "invokes PublishPacts with the branch name" do
101
- expect(PactBroker::Client::PublishPacts).to receive(:new).with(anything, anything, hash_including(branch: "foo"), anything, anything).and_return(publish_pacts)
104
+ it "invokes PublishPacts with the branch name and build URL" do
105
+ expect(PactBroker::Client::PublishPacts).to receive(:new).with(anything, anything, hash_including(number: "6.6.6", branch: "foo", build_url: "build_url"), anything, anything).and_return(publish_pacts)
102
106
  Rake::Task['pact:publish:git_branch_auto_detect_true'].execute
103
107
  end
104
108
  end
105
109
 
106
- context "when auto_detect_version_properties is explicitly set to true and the branch is specified" do
110
+ context "when auto_detect_version_properties is explicitly set to true and the auto detectable attributes are specified" do
107
111
  before :all do
108
- PactBroker::Client::PublicationTask.new(:git_branch_auto_detect_true_with_branch) do | task |
109
- task.consumer_version = '1.2.3'
112
+ PactBroker::Client::PublicationTask.new(:auto_detect_true_with_attributes_specified) do | task |
110
113
  task.auto_detect_version_properties = true
111
- task.branch = "main"
114
+ task.consumer_version = '1.2.3'
115
+ task.branch = "feat/foo"
116
+ task.consumer_version = "3"
117
+ task.build_url = "some_build"
112
118
  end
113
119
  end
114
120
 
115
- it "does not get the branch name" do
121
+ it "does not get the commit, branch or build URL from Git" do
122
+ expect(PactBroker::Client::Git).to_not receive(:commit)
123
+ expect(PactBroker::Client::Git).to_not receive(:build_url)
116
124
  expect(PactBroker::Client::Git).to_not receive(:branch)
117
- Rake::Task['pact:publish:git_branch_auto_detect_true_with_branch'].execute
125
+ Rake::Task['pact:publish:auto_detect_true_with_attributes_specified'].execute
118
126
  end
119
127
 
120
- it "invokes PublishPacts with the specified branch name" do
121
- expect(PactBroker::Client::PublishPacts).to receive(:new).with(anything, anything, hash_including(branch: "main"), anything, anything).and_return(publish_pacts)
122
- Rake::Task['pact:publish:git_branch_auto_detect_true_with_branch'].execute
128
+ it "invokes PublishPacts with the specified attributes" do
129
+ expect(PactBroker::Client::PublishPacts).to receive(:new).with(anything, anything, hash_including(number: "3", branch: "feat/foo", build_url: "some_build"), anything, anything).and_return(publish_pacts)
130
+ Rake::Task['pact:publish:auto_detect_true_with_attributes_specified'].execute
123
131
  end
124
132
  end
125
133
 
126
134
  context "when auto_detect_version_properties is explicitly set to false" do
127
135
  before :all do
128
- PactBroker::Client::PublicationTask.new(:git_branch_auto_detect_false) do | task |
129
- task.consumer_version = '1.2.3'
136
+ PactBroker::Client::PublicationTask.new(:auto_detect_false) do | task |
130
137
  task.auto_detect_version_properties = false
138
+ task.consumer_version = '1.2.3'
139
+ task.branch = "feat/foo"
140
+ task.consumer_version = "3"
141
+ task.build_url = "some_build"
131
142
  end
132
143
  end
133
144
 
134
- it "does not get the git branch name" do
145
+ it "does not get the commit, branch or build URL from Git" do
146
+ expect(PactBroker::Client::Git).to_not receive(:commit)
147
+ expect(PactBroker::Client::Git).to_not receive(:build_url)
135
148
  expect(PactBroker::Client::Git).to_not receive(:branch)
136
- Rake::Task['pact:publish:git_branch_auto_detect_false'].execute
149
+ Rake::Task['pact:publish:auto_detect_false'].execute
137
150
  end
138
151
 
139
- it "invokes PublishPacts without the branch name" do
140
- expect(PactBroker::Client::PublishPacts).to receive(:new).with(anything, anything, hash_not_including(branch: "foo"), anything, anything).and_return(publish_pacts)
141
- Rake::Task['pact:publish:git_branch_auto_detect_false'].execute
152
+ it "invokes PublishPacts with the specified attributes" do
153
+ expect(PactBroker::Client::PublishPacts).to receive(:new).with(anything, anything, hash_including(number: "3", branch: "feat/foo", build_url: "some_build"), anything, anything).and_return(publish_pacts)
154
+ Rake::Task['pact:publish:auto_detect_false'].execute
142
155
  end
143
156
  end
144
157
 
145
- context "when auto_detect_version_properties is left as its default" do
158
+ context "when auto_detect_version_properties is left as its default and the branch is not specified" do
146
159
  before :all do
147
- PactBroker::Client::PublicationTask.new(:git_branch_auto_detect_default) do | task |
160
+ PactBroker::Client::PublicationTask.new(:auto_detect_default) do | task |
148
161
  task.consumer_version = '1.2.3'
149
162
  end
150
163
  end
151
164
 
152
- it "gets the git branch name" do
165
+ it "gets the git branch name but won't raise an error if it can't be determined" do
153
166
  expect(PactBroker::Client::Git).to receive(:branch).with(raise_error: false)
154
- Rake::Task['pact:publish:git_branch_auto_detect_default'].execute
167
+ Rake::Task['pact:publish:auto_detect_default'].execute
155
168
  end
156
169
 
157
- it "invokes PublishPacts with the branch name" do
170
+ it "invokes PublishPacts with the branch name if found" do
158
171
  expect(PactBroker::Client::PublishPacts).to receive(:new).with(anything, anything, hash_including(branch: "foo"),anything, anything).and_return(publish_pacts)
159
- Rake::Task['pact:publish:git_branch_auto_detect_default'].execute
172
+ Rake::Task['pact:publish:auto_detect_default'].execute
160
173
  end
161
174
  end
162
175
 
163
176
  describe "custom task" do
164
-
165
177
  before :all do
166
178
  @pact_broker_base_url = "http://some-host"
167
179
  @pattern = "pact/*.json"
@@ -184,7 +196,7 @@ module PactBroker::Client
184
196
  expect(PactBroker::Client::PublishPacts).to receive(:new).with(
185
197
  @pact_broker_base_url,
186
198
  pact_file_list,
187
- { number: "1.2.3", tags: [@tag], branch: "foo", version_required: false},
199
+ { number: "1.2.3", tags: [@tag], branch: "foo" },
188
200
  {},
189
201
  { basic_auth: @pact_broker_basic_auth, token: @pact_broker_token }
190
202
  )
@@ -193,6 +205,17 @@ module PactBroker::Client
193
205
  end
194
206
  end
195
207
 
208
+ describe "with no consumer version" do
209
+ before :all do
210
+ PactBroker::Client::PublicationTask.new(:no_consumer_version) do
211
+ end
212
+ end
213
+
214
+ it "raises an error" do
215
+ expect { Rake::Task['pact:publish:no_consumer_version'].execute }.to raise_error PactBroker::Client::Error, /consumer version/
216
+ end
217
+ end
218
+
196
219
  describe "timing of block execution" do
197
220
  before :all do
198
221
  PactBroker::Client::PublicationTask.new(:exception) do | task |
@@ -1602,8 +1602,7 @@
1602
1602
  "name": "Foo"
1603
1603
  },
1604
1604
  "version": {
1605
- "number": "5556b8149bf8bac76bc30f50a8a2dd4c22c85f30",
1606
- "buildUrl": "http://build"
1605
+ "number": "5556b8149bf8bac76bc30f50a8a2dd4c22c85f30"
1607
1606
  }
1608
1607
  },
1609
1608
  "logs": [
@@ -88,8 +88,7 @@ RSpec.describe "publishing contracts", pact: true do
88
88
  name: pacticipant_name
89
89
  },
90
90
  version: {
91
- number: version_number,
92
- buildUrl: build_url
91
+ number: version_number
93
92
  }
94
93
  },
95
94
  logs: Pact.each_like(level: "info", message: "some message"),
@@ -0,0 +1,42 @@
1
+ if __FILE__ == $0
2
+
3
+ SSL_KEY = "spec/fixtures/certificates/key.pem"
4
+ SSL_CERT = "spec/fixtures/certificates/client_cert.pem"
5
+ SSL_CA_CERT = "spec/fixtures/certificates/ca_cert.pem"
6
+
7
+ trap(:INT) do
8
+ @server.shutdown
9
+ exit
10
+ end
11
+
12
+ def webrick_opts port
13
+ certificate = OpenSSL::X509::Certificate.new(File.read(SSL_CERT))
14
+ cert_name = certificate.subject.to_a.collect{|a| a[0..1] }
15
+ logger_stream = ENV["DEBUG"] ? $stderr : StringIO.new
16
+ {
17
+ Port: port,
18
+ Host: "0.0.0.0",
19
+ AccessLog: [],
20
+ Logger: WEBrick::Log.new(logger_stream,WEBrick::Log::INFO),
21
+ SSLVerifyClient: OpenSSL::SSL::VERIFY_FAIL_IF_NO_PEER_CERT | OpenSSL::SSL::VERIFY_PEER,
22
+ SSLCACertificateFile: SSL_CA_CERT,
23
+ SSLCertificate: certificate,
24
+ SSLPrivateKey: OpenSSL::PKey::RSA.new(File.read(SSL_KEY)),
25
+ SSLEnable: true,
26
+ SSLCertName: cert_name,
27
+ }
28
+ end
29
+
30
+ app = ->(_env) { puts "hello"; [200, {}, ["Hello world" + "\n"]] }
31
+
32
+ require "webrick"
33
+ require "webrick/https"
34
+ require "rack"
35
+ require "rack/handler/webrick"
36
+
37
+ opts = webrick_opts(4444)
38
+
39
+ Rack::Handler::WEBrick.run(app, **opts) do |server|
40
+ @server = server
41
+ end
42
+ end
data/tasks/pact.rake CHANGED
@@ -59,3 +59,82 @@ PactBroker::Client::PublicationTask.new(:pactflow_pact_foundation) do | task |
59
59
  task.pact_broker_token = ENV["PACT_BROKER_TOKEN_PACT_FOUNDATION"]
60
60
  task.build_url = PactBroker::Client::Git.build_url
61
61
  end
62
+ PactBroker::Client::PublicationTask.new(:pactflow_auto_on_nil_commit_nil_branch) do | task |
63
+ require 'pact_broker/client/version'
64
+ # publish with auto detected commit and branch
65
+ task.auto_detect_version_properties = true
66
+ task.branch = nil
67
+ task.consumer_version = nil
68
+ task.pact_broker_base_url = ENV['PACT_BROKER_BASE_URL']
69
+ task.pact_broker_token = ENV['PACT_BROKER_TOKEN']
70
+ task.build_url = PactBroker::Client::Git.build_url
71
+ end
72
+ PactBroker::Client::PublicationTask.new(:pactflow_auto_on_user_commit_user_branch) do | task |
73
+ require 'pact_broker/client/version'
74
+ # always accept user provided commit and branch
75
+ # even when auto_detect_version_properties enabled
76
+ task.auto_detect_version_properties = true
77
+ task.branch = 'user-provided-branch'
78
+ task.consumer_version = 'user-provided-version'
79
+ task.pact_broker_base_url = ENV['PACT_BROKER_BASE_URL']
80
+ task.pact_broker_token = ENV['PACT_BROKER_TOKEN']
81
+ task.build_url = PactBroker::Client::Git.build_url
82
+ end
83
+
84
+ PactBroker::Client::PublicationTask.new(:pactflow_auto_on_user_commit_nil_branch) do | task |
85
+ require 'pact_broker/client/version'
86
+ # auto detect branch, always accept user provided commit
87
+ # even where set to auto_detect_version_properties
88
+ task.auto_detect_version_properties = true
89
+ task.branch = nil
90
+ task.consumer_version = 'user-provided-version'
91
+ task.pact_broker_base_url = ENV['PACT_BROKER_BASE_URL']
92
+ task.pact_broker_token = ENV['PACT_BROKER_TOKEN']
93
+ task.build_url = PactBroker::Client::Git.build_url
94
+ end
95
+ PactBroker::Client::PublicationTask.new(:pactflow_auto_on_nil_commit_user_branch) do | task |
96
+ require 'pact_broker/client/version'
97
+ # auto detect commit, always accept user provided branch
98
+ # even where set to auto_detect_version_properties
99
+ task.auto_detect_version_properties = true
100
+ task.branch = 'user-provided-branch'
101
+ task.consumer_version = nil
102
+ task.pact_broker_base_url = ENV['PACT_BROKER_BASE_URL']
103
+ task.pact_broker_token = ENV['PACT_BROKER_TOKEN']
104
+ task.build_url = PactBroker::Client::Git.build_url
105
+ end
106
+
107
+ PactBroker::Client::PublicationTask.new(:pactflow_auto_off_user_commit_nil_branch) do | task |
108
+ require 'pact_broker/client/version'
109
+ # accept publish without branch, but has user provided commit
110
+ # auto_detect_version_properties off
111
+ task.auto_detect_version_properties = false
112
+ task.branch = nil
113
+ task.consumer_version = 'user-provided-version'
114
+ task.pact_broker_base_url = ENV['PACT_BROKER_BASE_URL']
115
+ task.pact_broker_token = ENV['PACT_BROKER_TOKEN']
116
+ task.build_url = PactBroker::Client::Git.build_url
117
+ end
118
+
119
+ PactBroker::Client::PublicationTask.new(:pactflow_auto_off_nil_commit_nil_branch) do | task |
120
+ require 'pact_broker/client/version'
121
+ # reject publish without user provided commit
122
+ # auto_detect_version_properties off
123
+ task.auto_detect_version_properties = false
124
+ task.branch = nil
125
+ task.consumer_version = nil
126
+ task.pact_broker_base_url = ENV['PACT_BROKER_BASE_URL']
127
+ task.pact_broker_token = ENV['PACT_BROKER_TOKEN']
128
+ task.build_url = PactBroker::Client::Git.build_url
129
+ end
130
+ PactBroker::Client::PublicationTask.new(:pactflow_auto_off_empty_string_commit_nil_branch) do | task |
131
+ require 'pact_broker/client/version'
132
+ # reject publish without user provided commit
133
+ # auto_detect_version_properties off
134
+ task.auto_detect_version_properties = false
135
+ task.branch = nil
136
+ task.consumer_version = ''
137
+ task.pact_broker_base_url = ENV['PACT_BROKER_BASE_URL']
138
+ task.pact_broker_token = ENV['PACT_BROKER_TOKEN']
139
+ task.build_url = PactBroker::Client::Git.build_url
140
+ 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.72.0
4
+ version: 1.74.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: 2023-09-11 00:00:00.000000000 Z
11
+ date: 2023-10-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -126,6 +126,7 @@ files:
126
126
  - ".rspec"
127
127
  - ".ruby-version"
128
128
  - CHANGELOG.md
129
+ - DEVELOPING.md
129
130
  - Dockerfile
130
131
  - Gemfile
131
132
  - LICENSE.txt
@@ -144,6 +145,7 @@ files:
144
145
  - example/scripts/deploy-consumer.sh
145
146
  - example/scripts/oas.yml
146
147
  - example/scripts/pact.json
148
+ - example/scripts/publish-pact-rake.sh
147
149
  - example/scripts/publish-pact.sh
148
150
  - example/scripts/publish-provider-contract.sh
149
151
  - example/scripts/publish-verification.sh
@@ -165,6 +167,7 @@ files:
165
167
  - lib/pact_broker/client/cli/pact_commands.rb
166
168
  - lib/pact_broker/client/cli/pacticipant_commands.rb
167
169
  - lib/pact_broker/client/cli/record_deployment_long_desc.txt
170
+ - lib/pact_broker/client/cli/thor_unknown_options_monkey_patch.rb
168
171
  - lib/pact_broker/client/cli/version_commands.rb
169
172
  - lib/pact_broker/client/cli/version_selector_options_parser.rb
170
173
  - lib/pact_broker/client/cli/webhook_commands.rb
@@ -253,6 +256,8 @@ files:
253
256
  - script/update-cli-usage-in-readme.rb
254
257
  - script/verification-results.txt
255
258
  - script/webhook-commands.sh
259
+ - spec/fixtures/MyConsumer-MyProvider (1).json
260
+ - spec/fixtures/MyConsumer-MyProvider.json
256
261
  - spec/fixtures/approvals/can_i_deploy_failure_dry_run.approved.txt
257
262
  - spec/fixtures/approvals/can_i_deploy_ignore.approved.txt
258
263
  - spec/fixtures/approvals/can_i_deploy_success_dry_run.approved.txt
@@ -260,12 +265,21 @@ files:
260
265
  - spec/fixtures/approvals/describe_pacticipant.approved.txt
261
266
  - spec/fixtures/approvals/list_environments.approved.txt
262
267
  - spec/fixtures/approvals/publish_provider_contract.approved.txt
268
+ - spec/fixtures/certificates/ca_cert.pem
269
+ - spec/fixtures/certificates/ca_cert.srl
270
+ - spec/fixtures/certificates/ca_key.pem
271
+ - spec/fixtures/certificates/client_cert.pem
272
+ - spec/fixtures/certificates/key.pem
273
+ - spec/fixtures/certificates/server.csr
274
+ - spec/fixtures/certificates/unsigned_cert.pem
275
+ - spec/fixtures/certificates/unsigned_key.pem
263
276
  - spec/fixtures/foo-bar.json
264
277
  - spec/integration/can_i_deploy_spec.rb
265
278
  - spec/integration/can_i_merge_spec.rb
266
279
  - spec/integration/create_version_tag_spec.rb
267
280
  - spec/integration/describe_environment_spec.rb
268
281
  - spec/integration/publish_provider_contract_spec.rb
282
+ - spec/integration/unknown_options_spec.rb
269
283
  - spec/lib/pact_broker/client/base_client_spec.rb
270
284
  - spec/lib/pact_broker/client/can_i_deploy_spec.rb
271
285
  - spec/lib/pact_broker/client/cli/broker_can_i_deploy_spec.rb
@@ -342,6 +356,7 @@ files:
342
356
  - spec/support/pacticipants_list.json
343
357
  - spec/support/pacts_latest_list.json
344
358
  - spec/support/shared_context.rb
359
+ - spec/support/ssl_server.rb
345
360
  - tasks/pact.rake
346
361
  homepage: https://github.com/pact-foundation/pact_broker-client.git
347
362
  licenses:
@@ -362,11 +377,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
362
377
  - !ruby/object:Gem::Version
363
378
  version: '0'
364
379
  requirements: []
365
- rubygems_version: 3.4.19
380
+ rubygems_version: 3.4.20
366
381
  signing_key:
367
382
  specification_version: 4
368
383
  summary: See description
369
384
  test_files:
385
+ - spec/fixtures/MyConsumer-MyProvider (1).json
386
+ - spec/fixtures/MyConsumer-MyProvider.json
370
387
  - spec/fixtures/approvals/can_i_deploy_failure_dry_run.approved.txt
371
388
  - spec/fixtures/approvals/can_i_deploy_ignore.approved.txt
372
389
  - spec/fixtures/approvals/can_i_deploy_success_dry_run.approved.txt
@@ -374,12 +391,21 @@ test_files:
374
391
  - spec/fixtures/approvals/describe_pacticipant.approved.txt
375
392
  - spec/fixtures/approvals/list_environments.approved.txt
376
393
  - spec/fixtures/approvals/publish_provider_contract.approved.txt
394
+ - spec/fixtures/certificates/ca_cert.pem
395
+ - spec/fixtures/certificates/ca_cert.srl
396
+ - spec/fixtures/certificates/ca_key.pem
397
+ - spec/fixtures/certificates/client_cert.pem
398
+ - spec/fixtures/certificates/key.pem
399
+ - spec/fixtures/certificates/server.csr
400
+ - spec/fixtures/certificates/unsigned_cert.pem
401
+ - spec/fixtures/certificates/unsigned_key.pem
377
402
  - spec/fixtures/foo-bar.json
378
403
  - spec/integration/can_i_deploy_spec.rb
379
404
  - spec/integration/can_i_merge_spec.rb
380
405
  - spec/integration/create_version_tag_spec.rb
381
406
  - spec/integration/describe_environment_spec.rb
382
407
  - spec/integration/publish_provider_contract_spec.rb
408
+ - spec/integration/unknown_options_spec.rb
383
409
  - spec/lib/pact_broker/client/base_client_spec.rb
384
410
  - spec/lib/pact_broker/client/can_i_deploy_spec.rb
385
411
  - spec/lib/pact_broker/client/cli/broker_can_i_deploy_spec.rb
@@ -456,3 +482,4 @@ test_files:
456
482
  - spec/support/pacticipants_list.json
457
483
  - spec/support/pacts_latest_list.json
458
484
  - spec/support/shared_context.rb
485
+ - spec/support/ssl_server.rb