pact_broker-client 1.72.0 → 1.74.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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,6 +1,8 @@
1
1
  require 'rake/tasklib'
2
2
  require 'pact_broker/client/git'
3
3
  require 'pact_broker/client/hash_refinements'
4
+ require 'pact_broker/client/string_refinements'
5
+ require "pact_broker/client/error"
4
6
 
5
7
  =begin
6
8
  require pact_broker/client/tasks
@@ -19,57 +21,52 @@ module PactBroker
19
21
  module Client
20
22
  class PublicationTask < ::Rake::TaskLib
21
23
  using PactBroker::Client::HashRefinements
24
+ using PactBroker::Client::StringRefinements
22
25
 
23
- attr_accessor :pattern, :pact_broker_base_url, :consumer_version, :tag, :write_method, :tag_with_git_branch, :pact_broker_basic_auth, :pact_broker_token
24
- attr_reader :auto_detect_version_properties, :branch, :build_url
26
+ attr_accessor :pattern, :pact_broker_base_url, :tag, :build_url, :write_method, :tag_with_git_branch, :pact_broker_basic_auth, :pact_broker_token
27
+ attr_reader :auto_detect_version_properties, :build_url
28
+ attr_writer :consumer_version, :branch
25
29
  alias_method :tags=, :tag=
26
30
  alias_method :tags, :tag
27
31
 
28
32
  def initialize name = nil, &block
29
33
  @name = name
30
34
  @auto_detect_version_properties = nil
31
- @version_required = false
32
35
  @pattern = 'spec/pacts/*.json'
33
36
  @pact_broker_base_url = 'http://pact-broker'
34
37
  rake_task &block
35
38
  end
36
39
 
37
40
  def auto_detect_version_properties= auto_detect_version_properties
38
- @version_required = version_required || auto_detect_version_properties
39
41
  @auto_detect_version_properties = auto_detect_version_properties
40
42
  end
41
-
42
- def branch= branch
43
- @version_required = version_required || !!branch
44
- @branch = branch
45
- end
46
-
47
- def build_url= build_url
48
- @version_required = version_required || !!build_url
49
- @build_url = build_url
50
- end
51
-
43
+
52
44
  private
53
45
 
54
- attr_reader :version_required
55
-
56
46
  def rake_task &block
57
47
  namespace :pact do
58
48
  desc "Publish pacts to pact broker"
59
49
  task task_name do
60
50
  block.call(self)
51
+ validate!
61
52
  require 'pact_broker/client/publish_pacts'
62
53
  pact_broker_client_options = { write: write_method, token: pact_broker_token }
63
54
  pact_broker_client_options[:basic_auth] = pact_broker_basic_auth if pact_broker_basic_auth && pact_broker_basic_auth.any?
64
55
  pact_broker_client_options.compact!
65
- consumer_version_params = { number: consumer_version, branch: the_branch, build_url: build_url, tags: all_tags, version_required: version_required }.compact
56
+ consumer_version_params = { number: consumer_version, branch: branch, build_url: build_url, tags: all_tags }.compact
66
57
  result = PactBroker::Client::PublishPacts.new(pact_broker_base_url, FileList[pattern], consumer_version_params, {}, pact_broker_client_options).call
67
58
  $stdout.puts result.message
68
- raise "One or more pacts failed to be published" unless result.success
59
+ raise PactBroker::Client::Error.new("One or more pacts failed to be published") unless result.success
69
60
  end
70
61
  end
71
62
  end
72
63
 
64
+ def validate!
65
+ if consumer_version.blank?
66
+ raise PactBroker::Client::Error.new("A consumer version must be provided")
67
+ end
68
+ end
69
+
73
70
  def task_name
74
71
  @name ? "publish:#{@name}" : "publish"
75
72
  end
@@ -80,11 +77,31 @@ module PactBroker
80
77
  t.compact.uniq
81
78
  end
82
79
 
83
- def the_branch
84
- if branch.nil? && auto_detect_version_properties != false
85
- PactBroker::Client::Git.branch(raise_error: auto_detect_version_properties == true)
80
+ # Attempt to detect the branch automatically, but don't raise an error if the branch can't be found
81
+ # unless the user has explicitly enabled auto_detect_version_properties.
82
+ # This approach is an attempt to include the branch without the user having to explicitly
83
+ # set it, because people tend to not update things.
84
+ def branch
85
+ if @branch.nil? && auto_detect_version_properties != false
86
+ @branch = PactBroker::Client::Git.branch(raise_error: auto_detect_version_properties == true)
87
+ else
88
+ @branch
89
+ end
90
+ end
91
+
92
+ def consumer_version
93
+ if @consumer_version.nil? && @auto_detect_version_properties
94
+ @consumer_version = PactBroker::Client::Git.commit(raise_error: true)
95
+ else
96
+ @consumer_version
97
+ end
98
+ end
99
+
100
+ def build_url
101
+ if @build_url.nil? && @auto_detect_version_properties
102
+ @build_url = PactBroker::Client::Git.build_url
86
103
  else
87
- branch
104
+ @build_url
88
105
  end
89
106
  end
90
107
  end
@@ -1,5 +1,5 @@
1
1
  module PactBroker
2
2
  module Client
3
- VERSION = '1.72.0'
3
+ VERSION = '1.74.0'
4
4
  end
5
5
  end
@@ -1,7 +1,7 @@
1
1
  #!/bin/sh
2
2
 
3
- set -Eeuxo pipefail
3
+ set -eu
4
4
 
5
- bundle exec bin/pact-broker record-deployment \
5
+ bundle exec bin/pact-broker record-release \
6
6
  --pacticipant "Pact Broker Client" --version $GITHUB_SHA \
7
7
  --environment production
@@ -29,7 +29,7 @@ export PACT_BROKER_TOKEN=${PACT_BROKER_TOKEN:-"localhost"}
29
29
  # --contract-published
30
30
 
31
31
 
32
- bundle exec bin/pact-broker publish scripts/foo-bar.json \
32
+ bundle exec bin/pact-broker publish script/foo-bar.json \
33
33
  --consumer-app-version 1.2.26 \
34
34
  --auto-detect-version-properties \
35
35
  --build-url http://mybuild \
@@ -1,4 +1,11 @@
1
1
  #!/usr/bin/env ruby
2
+ require "bundler/inline"
3
+
4
+ gemfile do
5
+ source "https://rubygems.org"
6
+ gem "pact_broker-client", path: "."
7
+ end
8
+
2
9
  require "stringio"
3
10
  require "pact_broker/client/cli/broker"
4
11
  require "pactflow/client/cli/pactflow"
@@ -0,0 +1,37 @@
1
+ {
2
+ "consumer": {
3
+ "name": "MyConsumer"
4
+ },
5
+ "interactions": [
6
+ {
7
+ "description": "request",
8
+ "providerStates": [
9
+ {
10
+ "name": "state 2"
11
+ }
12
+ ],
13
+ "request": {
14
+ "method": "GET",
15
+ "path": "/2"
16
+ },
17
+ "response": {
18
+ "status": 200
19
+ }
20
+ }
21
+ ],
22
+ "metadata": {
23
+ "pact-js": {
24
+ "version": "11.0.2"
25
+ },
26
+ "pactRust": {
27
+ "ffi": "0.4.0",
28
+ "models": "1.0.4"
29
+ },
30
+ "pactSpecification": {
31
+ "version": "3.0.0"
32
+ }
33
+ },
34
+ "provider": {
35
+ "name": "MyProvider"
36
+ }
37
+ }
@@ -0,0 +1,37 @@
1
+ {
2
+ "consumer": {
3
+ "name": "MyConsumer"
4
+ },
5
+ "interactions": [
6
+ {
7
+ "description": "request",
8
+ "providerStates": [
9
+ {
10
+ "name": "state 1"
11
+ }
12
+ ],
13
+ "request": {
14
+ "method": "GET",
15
+ "path": "/1"
16
+ },
17
+ "response": {
18
+ "status": 200
19
+ }
20
+ }
21
+ ],
22
+ "metadata": {
23
+ "pact-js": {
24
+ "version": "11.0.2"
25
+ },
26
+ "pactRust": {
27
+ "ffi": "0.4.0",
28
+ "models": "1.0.4"
29
+ },
30
+ "pactSpecification": {
31
+ "version": "3.0.0"
32
+ }
33
+ },
34
+ "provider": {
35
+ "name": "MyProvider"
36
+ }
37
+ }
@@ -0,0 +1,19 @@
1
+ -----BEGIN CERTIFICATE-----
2
+ MIIDATCCAemgAwIBAgIUWfQF2Mh+eFd3q+cSVgekpaMTh9MwDQYJKoZIhvcNAQEL
3
+ BQAwDzENMAsGA1UEAwwETXlDQTAgFw0yMzA5MTkxMTA2MjZaGA8yMTIzMDgyNjEx
4
+ MDYyNlowDzENMAsGA1UEAwwETXlDQTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCC
5
+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 @@ describe "pact-broker can-i-deploy", skip_windows: true do
18
18
  end
19
19
  end
20
20
 
21
- context "when the pacticipants can't be deployed" do
22
- subject { `bundle exec bin/pact-broker can-i-deploy --pacticipant Wiffle --version 1.2.3 --pacticipant Meep --version 4.5.6 --broker-base-url http://localhost:5000` }
23
-
24
- it "returns an error exit code" do
25
- subject
26
- expect($?.exitstatus).to_not eq 0
27
- end
28
- end
29
-
30
21
  after(:all) do
31
22
  Process.kill 'KILL', @pipe.pid
32
23
  end
@@ -0,0 +1,39 @@
1
+ require "open3"
2
+ require "pact_broker/client/cli/broker"
3
+
4
+ # This is not the ideal way to write a test, but I tried to write it with an in memory invocation,
5
+ # and I couldn't get the capture to work, and it became super complicated.
6
+
7
+ RSpec.describe "using unknown options", skip_windows: true do
8
+ let(:unknown_switches_text) { "Unknown switches" }
9
+ let(:warning_text) { "This is a warning"}
10
+ let(:command) { "bundle exec bin/pact-broker can-i-deploy --pacticipant Foo --foo --broker-base-url http://example.org" }
11
+
12
+ it "prints an 'unknown switches' warning to stderr and also includes the normal output of the command" do
13
+ stderr_lines = nil
14
+
15
+ Open3.popen3(command) do |stdin, stdout, stderr, thread|
16
+ stderr_lines = stderr.readlines
17
+ end
18
+
19
+ expect(stderr_lines.join("\n")).to include(unknown_switches_text)
20
+ expect(stderr_lines.join("\n")).to include(warning_text)
21
+
22
+ expect(stderr_lines.size).to be > 2
23
+ end
24
+
25
+
26
+ context "with PACT_BROKER_ERROR_ON_UNKNOWN_OPTION=true" do
27
+ it "prints an 'unknown switches' message to stderr and does NOT include the normal output of the command as it exits straight after" do
28
+ stderr_lines = nil
29
+
30
+ Open3.popen3({ "PACT_BROKER_ERROR_ON_UNKNOWN_OPTION" => "true" }, command) do |stdin, stdout, stderr, thread|
31
+ stderr_lines = stderr.readlines
32
+ end
33
+
34
+ expect(stderr_lines.first).to include(unknown_switches_text)
35
+ expect(stderr_lines.join("\n")).to_not include(warning_text)
36
+ expect(stderr_lines.size).to eq 1
37
+ end
38
+ end
39
+ end
@@ -4,10 +4,12 @@ require 'pact_broker/client/git'
4
4
 
5
5
  module PactBroker::Client::CLI
6
6
  describe Broker do
7
- describe ".broker" do
7
+ describe '.broker' do
8
8
  before do
9
9
  allow(PactBroker::Client::PublishPacts).to receive(:call).and_return(result)
10
- allow(PactBroker::Client::Git).to receive(:branch).and_return("bar")
10
+ allow(PactBroker::Client::Git).to receive(:branch).and_return('bar')
11
+ allow(PactBroker::Client::Git).to receive(:commit).and_return('6.6.6')
12
+ allow(PactBroker::Client::Git).to receive(:build_url).and_return('build_url')
11
13
  subject.options = OpenStruct.new(minimum_valid_options)
12
14
  allow($stdout).to receive(:puts)
13
15
  end
@@ -30,7 +32,7 @@ module PactBroker::Client::CLI
30
32
  expect(PactBroker::Client::PublishPacts).to receive(:call).with(
31
33
  "http://pact-broker",
32
34
  ["spec/support/cli_test_pacts/foo.json"],
33
- { number: "1.2.3", tags: [], version_required: false },
35
+ { number: "1.2.3", tags: [] },
34
36
  {},
35
37
  { pact_broker_base_url: 'http://pact-broker' }
36
38
  )
@@ -151,7 +153,7 @@ module PactBroker::Client::CLI
151
153
  expect(PactBroker::Client::PublishPacts).to receive(:call).with(
152
154
  anything,
153
155
  anything,
154
- hash_including(branch: "main", version_required: true),
156
+ hash_including(branch: "main"),
155
157
  anything,
156
158
  anything
157
159
  )
@@ -159,50 +161,55 @@ module PactBroker::Client::CLI
159
161
  end
160
162
  end
161
163
 
162
- context "with --auto-detect-version-properties on by default" do
164
+ context "with --auto-detect-version-properties specified" do
163
165
  before do
164
166
  subject.options = OpenStruct.new(
165
- minimum_valid_options.merge(auto_detect_version_properties: true)
167
+ minimum_valid_options.merge(auto_detect_version_properties: true, consumer_app_version: nil)
166
168
  )
167
- allow(subject).to receive(:explict_auto_detect_version_properties).and_return(false)
168
169
  end
169
170
 
170
171
  it "determines the git branch name" do
171
- expect(PactBroker::Client::Git).to receive(:branch).with(raise_error: false)
172
+ expect(PactBroker::Client::Git).to receive(:branch).with(raise_error: true)
172
173
  invoke_broker
173
174
  end
174
175
 
175
- it "passes in the auto detected branch option with version_required: false" do
176
+ it "passes in the auto detected branch option" do
176
177
  expect(PactBroker::Client::PublishPacts).to receive(:call).with(
177
178
  anything,
178
179
  anything,
179
- hash_including(branch: "bar", version_required: false),
180
+ hash_including(branch: "bar"),
180
181
  anything,
181
182
  anything
182
183
  )
183
184
  invoke_broker
184
185
  end
185
- end
186
186
 
187
+ it 'determines the commit sha' do
188
+ expect(PactBroker::Client::Git).to receive(:commit).with(raise_error: true)
189
+ invoke_broker
190
+ end
187
191
 
188
- context "with --auto-detect-version-properties specified explicitly" do
189
- before do
190
- subject.options = OpenStruct.new(
191
- minimum_valid_options.merge(auto_detect_version_properties: true)
192
+ it 'passes in the auto detected commit sha option' do
193
+ expect(PactBroker::Client::PublishPacts).to receive(:call).with(
194
+ anything,
195
+ anything,
196
+ hash_including(number: '6.6.6'),
197
+ anything,
198
+ anything
192
199
  )
193
- allow(subject).to receive(:explict_auto_detect_version_properties).and_return(true)
200
+ invoke_broker
194
201
  end
195
202
 
196
- it "determines the git branch name" do
197
- expect(PactBroker::Client::Git).to receive(:branch).with(raise_error: true)
203
+ it 'determines the build URL' do
204
+ expect(PactBroker::Client::Git).to receive(:build_url)
198
205
  invoke_broker
199
206
  end
200
207
 
201
- it "passes in the auto detected branch option with version_required: true" do
208
+ it 'passes in the auto detected build URL' do
202
209
  expect(PactBroker::Client::PublishPacts).to receive(:call).with(
203
210
  anything,
204
211
  anything,
205
- hash_including(branch: "bar", version_required: true),
212
+ hash_including(build_url: 'build_url'),
206
213
  anything,
207
214
  anything
208
215
  )
@@ -220,7 +227,7 @@ module PactBroker::Client::CLI
220
227
  expect(PactBroker::Client::PublishPacts).to receive(:call).with(
221
228
  anything,
222
229
  anything,
223
- hash_including(branch: "specified-branch", version_required: true),
230
+ hash_including(branch: "specified-branch"),
224
231
  anything,
225
232
  anything
226
233
  )
@@ -248,6 +255,16 @@ module PactBroker::Client::CLI
248
255
  end
249
256
  end
250
257
 
258
+ context "with no consumer_app_version" do
259
+ before do
260
+ subject.options.consumer_app_version = nil
261
+ end
262
+
263
+ it "raises an error" do
264
+ expect { invoke_broker }.to raise_error ::Thor::RequiredArgumentMissingError, /--consumer-app-version/
265
+ end
266
+ end
267
+
251
268
  context "with basic auth options specified" do
252
269
  before do
253
270
  subject.options = OpenStruct.new(
@@ -7,6 +7,10 @@ module PactBroker::Client::CLI
7
7
  end
8
8
 
9
9
  class TestThor < CustomThor
10
+ def self.exit_on_failure?
11
+ false
12
+ end
13
+
10
14
  desc 'ARGUMENT', 'This is the description'
11
15
  def test_default(argument)
12
16
  Delegate.call(argument: argument)
@@ -96,6 +100,29 @@ module PactBroker::Client::CLI
96
100
  TestThor.start(%w{test_pact_broker_client_options})
97
101
  end
98
102
 
103
+ describe "when someone copy pastes from Word and uses an em dash instead of a normal dash" do
104
+ before do
105
+ allow(TestThor).to receive(:exit_with_error_code)
106
+ end
107
+
108
+ it "exits with an error message" do
109
+ expect($stdout).to receive(:puts).with(/contains an em dash/)
110
+ expect(TestThor).to receive(:exit_with_error_code)
111
+ TestThor.start(["test_default", "\u2014\u2014bar"])
112
+ end
113
+ end
114
+
115
+ describe ".handle_help" do
116
+ context "when the last argument is --help or -h" do
117
+ it "turns it into the form that Thor expects, which is a really odd one" do
118
+ expect(TestThor.handle_help(["foo", "--help"])).to eq ["help", "foo"]
119
+ expect(TestThor.handle_help(["foo", "-h"])).to eq ["help", "foo"]
120
+ expect(TestThor.handle_help(["-h"])).to eq ["help"]
121
+ expect(TestThor.handle_help(["--help"])).to eq ["help"]
122
+ end
123
+ end
124
+ end
125
+
99
126
  describe ".turn_muliple_tag_options_into_array" do
100
127
  it "turns '--tag foo --tag bar' into '--tag foo bar'" do
101
128
  input = %w{--ignore this --tag foo --tag bar --wiffle --that}