pact_broker-client 1.38.1 → 1.41.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/CHANGELOG.md +38 -0
  4. data/Gemfile +4 -0
  5. data/README.md +18 -0
  6. data/bin/pact-broker +6 -0
  7. data/doc/pacts/markdown/Pact Broker Client - Pact Broker.md +61 -140
  8. data/example/scripts/publish-pact.sh +1 -1
  9. data/lib/pact_broker/client/base_client.rb +1 -1
  10. data/lib/pact_broker/client/can_i_deploy.rb +20 -3
  11. data/lib/pact_broker/client/cli/broker.rb +35 -10
  12. data/lib/pact_broker/client/cli/record_deployment_long_desc.txt +0 -0
  13. data/lib/pact_broker/client/cli/version_selector_options_parser.rb +4 -0
  14. data/lib/pact_broker/client/colorize_notices.rb +31 -0
  15. data/lib/pact_broker/client/hal/entity.rb +16 -0
  16. data/lib/pact_broker/client/hal/http_client.rb +37 -1
  17. data/lib/pact_broker/client/hal/link.rb +12 -0
  18. data/lib/pact_broker/client/hal/links.rb +15 -0
  19. data/lib/pact_broker/client/hal_client_methods.rb +8 -0
  20. data/lib/pact_broker/client/matrix.rb +4 -0
  21. data/lib/pact_broker/client/matrix/abbreviate_version_number.rb +15 -0
  22. data/lib/pact_broker/client/matrix/resource.rb +26 -1
  23. data/lib/pact_broker/client/matrix/text_formatter.rb +11 -8
  24. data/lib/pact_broker/client/pacts.rb +0 -1
  25. data/lib/pact_broker/client/publish_pacts.rb +94 -128
  26. data/lib/pact_broker/client/publish_pacts_the_old_way.rb +194 -0
  27. data/lib/pact_broker/client/tasks/publication_task.rb +3 -3
  28. data/lib/pact_broker/client/version.rb +1 -1
  29. data/lib/pact_broker/client/versions/record_deployment.rb +6 -6
  30. data/lib/pact_broker/client/versions/record_undeployment.rb +45 -68
  31. data/pact-broker-client.gemspec +1 -0
  32. data/script/approve-all.sh +6 -0
  33. data/script/publish-pact.sh +36 -5
  34. data/script/record-deployment.sh +1 -3
  35. data/script/record-undeployment.sh +4 -0
  36. data/spec/fixtures/approvals/can_i_deploy_ignore.approved.txt +13 -0
  37. data/spec/fixtures/foo-bar.json +31 -0
  38. data/spec/lib/pact_broker/client/can_i_deploy_spec.rb +47 -5
  39. data/spec/lib/pact_broker/client/cli/broker_can_i_deploy_spec.rb +3 -3
  40. data/spec/lib/pact_broker/client/cli/broker_publish_spec.rb +36 -7
  41. data/spec/lib/pact_broker/client/cli/version_selector_options_parser_spec.rb +21 -0
  42. data/spec/lib/pact_broker/client/hal/http_client_spec.rb +64 -7
  43. data/spec/lib/pact_broker/client/pacticipants/create_spec.rb +3 -0
  44. data/spec/lib/pact_broker/client/{publish_pacts_spec.rb → publish_pacts_the_old_way_spec.rb} +10 -9
  45. data/spec/lib/pact_broker/client/tasks/publication_task_spec.rb +18 -12
  46. data/spec/lib/pact_broker/client/versions/record_deployment_spec.rb +5 -5
  47. data/spec/pacts/pact_broker_client-pact_broker.json +50 -124
  48. data/spec/service_providers/pact_broker_client_create_version_spec.rb +4 -4
  49. data/spec/service_providers/pact_broker_client_matrix_ignore_spec.rb +98 -0
  50. data/spec/service_providers/publish_pacts_spec.rb +116 -0
  51. data/spec/service_providers/record_deployment_spec.rb +6 -7
  52. data/spec/spec_helper.rb +2 -1
  53. data/spec/support/approvals.rb +26 -0
  54. data/spec/support/shared_context.rb +6 -2
  55. metadata +41 -5
@@ -1,8 +1,7 @@
1
1
  require 'service_providers/pact_helper'
2
2
  require 'pact_broker/client/versions/record_deployment'
3
3
 
4
- RSpec.describe "recording a deployment", pact: true do
5
-
4
+ RSpec.describe "recording a deployment", pact: true, skip: true do
6
5
  include_context "pact broker"
7
6
  include PactBrokerPactHelperMethods
8
7
 
@@ -10,13 +9,13 @@ RSpec.describe "recording a deployment", pact: true do
10
9
  let(:version_number) { "5556b8149bf8bac76bc30f50a8a2dd4c22c85f30" }
11
10
  let(:environment_name) { "test" }
12
11
  let(:output) { "text" }
13
- let(:replaced_previous_deployed_version) { true }
12
+ let(:target) { "blue" }
14
13
  let(:params) do
15
14
  {
16
15
  pacticipant_name: pacticipant_name,
17
16
  version_number: version_number,
18
17
  environment_name: environment_name,
19
- replaced_previous_deployed_version: replaced_previous_deployed_version,
18
+ target: target,
20
19
  output: output
21
20
  }
22
21
  end
@@ -148,14 +147,14 @@ RSpec.describe "recording a deployment", pact: true do
148
147
  path: "/HAL-REL-PLACEHOLDER-PB-RECORD-DEPLOYMENT-FOO-5556B8149BF8BAC76BC30F50A8A2DD4C22C85F30-TEST",
149
148
  headers: post_request_headers,
150
149
  body: {
151
- replacedPreviousDeployedVersion: replaced_previous_deployed_version
150
+ target: target
152
151
  }
153
152
  )
154
153
  .will_respond_with(
155
154
  status: 201,
156
155
  headers: pact_broker_response_headers,
157
156
  body: {
158
- replacedPreviousDeployedVersion: replaced_previous_deployed_version
157
+ target: target
159
158
  }
160
159
  )
161
160
  end
@@ -176,7 +175,7 @@ RSpec.describe "recording a deployment", pact: true do
176
175
  let(:output) { "json" }
177
176
 
178
177
  it "returns the JSON payload" do
179
- expect(JSON.parse(subject.message)).to eq "replacedPreviousDeployedVersion" => replaced_previous_deployed_version
178
+ expect(JSON.parse(subject.message)).to eq "target" => target
180
179
  end
181
180
  end
182
181
  end
data/spec/spec_helper.rb CHANGED
@@ -1,10 +1,11 @@
1
1
  require 'webmock/rspec'
2
2
 
3
- ENV['PACT_BROKER_FEATURES'] = 'deployments'
3
+ ENV['PACT_BROKER_FEATURES'] = 'deployments publish_contracts ignore'
4
4
 
5
5
  WebMock.disable_net_connect!(allow_localhost: true)
6
6
 
7
7
  require "./spec/support/shared_context.rb"
8
+ require "./spec/support/approvals.rb"
8
9
 
9
10
  is_windows = (RbConfig::CONFIG['host_os'] =~ /bccwin|cygwin|djgpp|mingw|mswin|wince/i) != nil
10
11
  is_ci = ENV['CI'] == 'true'
@@ -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)
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
- shared_context "pact broker" do
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 }
@@ -16,5 +21,4 @@ shared_context "pact broker" do
16
21
  let(:put_request_headers) { { 'Content-Type' => 'application/json', 'Accept' => 'application/hal+json'} }
17
22
  let(:post_request_headers) { { 'Content-Type' => 'application/json', 'Accept' => 'application/hal+json'} }
18
23
  let(:get_request_headers) { { 'Accept' => 'application/hal+json'} }
19
-
20
24
  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.38.1
4
+ version: 1.41.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-03-22 00:00:00.000000000 Z
11
+ date: 2021-05-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -170,6 +170,26 @@ 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
173
193
  description: Client for the Pact Broker. Publish, retrieve and query pacts and verification
174
194
  results.
175
195
  email:
@@ -212,7 +232,9 @@ files:
212
232
  - lib/pact_broker/client/cli/create_or_update_webhook_long_desc.txt
213
233
  - lib/pact_broker/client/cli/create_webhook_long_desc.txt
214
234
  - lib/pact_broker/client/cli/custom_thor.rb
235
+ - lib/pact_broker/client/cli/record_deployment_long_desc.txt
215
236
  - lib/pact_broker/client/cli/version_selector_options_parser.rb
237
+ - lib/pact_broker/client/colorize_notices.rb
216
238
  - lib/pact_broker/client/command_result.rb
217
239
  - lib/pact_broker/client/create_tag.rb
218
240
  - lib/pact_broker/client/error.rb
@@ -227,6 +249,7 @@ files:
227
249
  - lib/pact_broker/client/hal_client_methods.rb
228
250
  - lib/pact_broker/client/hash_refinements.rb
229
251
  - lib/pact_broker/client/matrix.rb
252
+ - lib/pact_broker/client/matrix/abbreviate_version_number.rb
230
253
  - lib/pact_broker/client/matrix/formatter.rb
231
254
  - lib/pact_broker/client/matrix/json_formatter.rb
232
255
  - lib/pact_broker/client/matrix/resource.rb
@@ -240,6 +263,7 @@ files:
240
263
  - lib/pact_broker/client/pacts.rb
241
264
  - lib/pact_broker/client/pacts/list_latest_versions.rb
242
265
  - lib/pact_broker/client/publish_pacts.rb
266
+ - lib/pact_broker/client/publish_pacts_the_old_way.rb
243
267
  - lib/pact_broker/client/retry.rb
244
268
  - lib/pact_broker/client/tasks.rb
245
269
  - lib/pact_broker/client/tasks/publication_task.rb
@@ -255,12 +279,16 @@ files:
255
279
  - lib/pact_broker/client/webhooks/test.rb
256
280
  - lib/pact_broker_client.rb
257
281
  - pact-broker-client.gemspec
282
+ - script/approve-all.sh
258
283
  - script/create-pacticipant.sh
259
284
  - script/generate-cli-usage.sh
260
285
  - script/publish-pact.sh
261
286
  - script/record-deployment.sh
287
+ - script/record-undeployment.sh
262
288
  - script/release.sh
263
289
  - script/trigger-release.sh
290
+ - spec/fixtures/approvals/can_i_deploy_ignore.approved.txt
291
+ - spec/fixtures/foo-bar.json
264
292
  - spec/integration/can_i_deploy_spec.rb
265
293
  - spec/integration/create_version_tag_spec.rb
266
294
  - spec/lib/pact_broker/client/base_client_spec.rb
@@ -284,7 +312,7 @@ files:
284
312
  - spec/lib/pact_broker/client/pact_broker_client_spec.rb
285
313
  - spec/lib/pact_broker/client/pacticipants/create_spec.rb
286
314
  - spec/lib/pact_broker/client/pacticipants_spec.rb
287
- - spec/lib/pact_broker/client/publish_pacts_spec.rb
315
+ - spec/lib/pact_broker/client/publish_pacts_the_old_way_spec.rb
288
316
  - spec/lib/pact_broker/client/retry_spec.rb
289
317
  - spec/lib/pact_broker/client/tasks/publication_task_spec.rb
290
318
  - spec/lib/pact_broker/client/versions/describe_spec.rb
@@ -295,6 +323,7 @@ files:
295
323
  - spec/service_providers/extra_goodies_spec.rb
296
324
  - spec/service_providers/list_latest_pact_versions_spec.rb.bak
297
325
  - spec/service_providers/pact_broker_client_create_version_spec.rb
326
+ - spec/service_providers/pact_broker_client_matrix_ignore_spec.rb
298
327
  - spec/service_providers/pact_broker_client_matrix_spec.rb
299
328
  - spec/service_providers/pact_broker_client_pacticipant_version_spec.rb
300
329
  - spec/service_providers/pact_broker_client_publish_spec.rb
@@ -305,9 +334,11 @@ files:
305
334
  - spec/service_providers/pact_broker_client_versions_spec.rb
306
335
  - spec/service_providers/pact_helper.rb
307
336
  - spec/service_providers/pacticipants_create_spec.rb
337
+ - spec/service_providers/publish_pacts_spec.rb
308
338
  - spec/service_providers/record_deployment_spec.rb
309
339
  - spec/service_providers/webhooks_create_spec.rb
310
340
  - spec/spec_helper.rb
341
+ - spec/support/approvals.rb
311
342
  - spec/support/cli_test_pacts/bar.json
312
343
  - spec/support/cli_test_pacts/foo.json
313
344
  - spec/support/latest_pacts_for_provider.json
@@ -339,11 +370,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
339
370
  - !ruby/object:Gem::Version
340
371
  version: '0'
341
372
  requirements: []
342
- rubygems_version: 3.2.15
373
+ rubygems_version: 3.2.17
343
374
  signing_key:
344
375
  specification_version: 4
345
376
  summary: See description
346
377
  test_files:
378
+ - spec/fixtures/approvals/can_i_deploy_ignore.approved.txt
379
+ - spec/fixtures/foo-bar.json
347
380
  - spec/integration/can_i_deploy_spec.rb
348
381
  - spec/integration/create_version_tag_spec.rb
349
382
  - spec/lib/pact_broker/client/base_client_spec.rb
@@ -367,7 +400,7 @@ test_files:
367
400
  - spec/lib/pact_broker/client/pact_broker_client_spec.rb
368
401
  - spec/lib/pact_broker/client/pacticipants/create_spec.rb
369
402
  - spec/lib/pact_broker/client/pacticipants_spec.rb
370
- - spec/lib/pact_broker/client/publish_pacts_spec.rb
403
+ - spec/lib/pact_broker/client/publish_pacts_the_old_way_spec.rb
371
404
  - spec/lib/pact_broker/client/retry_spec.rb
372
405
  - spec/lib/pact_broker/client/tasks/publication_task_spec.rb
373
406
  - spec/lib/pact_broker/client/versions/describe_spec.rb
@@ -378,6 +411,7 @@ test_files:
378
411
  - spec/service_providers/extra_goodies_spec.rb
379
412
  - spec/service_providers/list_latest_pact_versions_spec.rb.bak
380
413
  - spec/service_providers/pact_broker_client_create_version_spec.rb
414
+ - spec/service_providers/pact_broker_client_matrix_ignore_spec.rb
381
415
  - spec/service_providers/pact_broker_client_matrix_spec.rb
382
416
  - spec/service_providers/pact_broker_client_pacticipant_version_spec.rb
383
417
  - spec/service_providers/pact_broker_client_publish_spec.rb
@@ -388,9 +422,11 @@ test_files:
388
422
  - spec/service_providers/pact_broker_client_versions_spec.rb
389
423
  - spec/service_providers/pact_helper.rb
390
424
  - spec/service_providers/pacticipants_create_spec.rb
425
+ - spec/service_providers/publish_pacts_spec.rb
391
426
  - spec/service_providers/record_deployment_spec.rb
392
427
  - spec/service_providers/webhooks_create_spec.rb
393
428
  - spec/spec_helper.rb
429
+ - spec/support/approvals.rb
394
430
  - spec/support/cli_test_pacts/bar.json
395
431
  - spec/support/cli_test_pacts/foo.json
396
432
  - spec/support/latest_pacts_for_provider.json