pact_broker-client 1.34.0 → 1.38.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/release_gem.yml +1 -0
  3. data/.github/workflows/test.yml +23 -0
  4. data/CHANGELOG.md +39 -0
  5. data/README.md +15 -3
  6. data/Rakefile +2 -0
  7. data/doc/pacts/markdown/Pact Broker Client - Pact Broker.md +331 -8
  8. data/lib/pact_broker/client.rb +1 -1
  9. data/lib/pact_broker/client/backports.rb +13 -0
  10. data/lib/pact_broker/client/cli/broker.rb +112 -34
  11. data/lib/pact_broker/client/cli/can_i_deploy_long_desc.txt +18 -9
  12. data/lib/pact_broker/client/cli/create_or_update_webhook_long_desc.txt +3 -1
  13. data/lib/pact_broker/client/cli/create_webhook_long_desc.txt +2 -0
  14. data/lib/pact_broker/client/cli/custom_thor.rb +11 -17
  15. data/lib/pact_broker/client/git.rb +43 -22
  16. data/lib/pact_broker/client/hal/entity.rb +44 -3
  17. data/lib/pact_broker/client/hal/http_client.rb +5 -1
  18. data/lib/pact_broker/client/hal/links.rb +39 -0
  19. data/lib/pact_broker/client/hal_client_methods.rb +11 -0
  20. data/lib/pact_broker/client/hash_refinements.rb +19 -0
  21. data/lib/pact_broker/client/matrix.rb +2 -1
  22. data/lib/pact_broker/client/matrix/text_formatter.rb +46 -11
  23. data/lib/pact_broker/client/publish_pacts.rb +85 -14
  24. data/lib/pact_broker/client/tasks/publication_task.rb +37 -6
  25. data/lib/pact_broker/client/version.rb +1 -1
  26. data/lib/pact_broker/client/versions/record_deployment.rb +109 -0
  27. data/lib/pact_broker/client/versions/record_undeployment.rb +125 -0
  28. data/pact-broker-client.gemspec +2 -1
  29. data/script/publish-pact.sh +7 -1
  30. data/script/record-deployment.sh +4 -0
  31. data/script/trigger-release.sh +1 -1
  32. data/spec/lib/pact_broker/client/cli/broker_can_i_deploy_spec.rb +51 -6
  33. data/spec/lib/pact_broker/client/cli/broker_publish_spec.rb +108 -12
  34. data/spec/lib/pact_broker/client/cli/custom_thor_spec.rb +1 -7
  35. data/spec/lib/pact_broker/client/git_spec.rb +39 -2
  36. data/spec/lib/pact_broker/client/hal/entity_spec.rb +4 -3
  37. data/spec/lib/pact_broker/client/matrix/text_formatter_spec.rb +29 -4
  38. data/spec/lib/pact_broker/client/publish_pacts_spec.rb +99 -6
  39. data/spec/lib/pact_broker/client/tasks/publication_task_spec.rb +88 -10
  40. data/spec/lib/pact_broker/client/versions/describe_spec.rb +0 -1
  41. data/spec/lib/pact_broker/client/versions/record_deployment_spec.rb +82 -0
  42. data/spec/pacts/pact_broker_client-pact_broker.json +335 -8
  43. data/spec/service_providers/pact_broker_client_create_version_spec.rb +89 -0
  44. data/spec/service_providers/pact_broker_client_matrix_spec.rb +4 -0
  45. data/spec/service_providers/pact_broker_client_versions_spec.rb +1 -2
  46. data/spec/service_providers/record_deployment_spec.rb +219 -0
  47. data/spec/spec_helper.rb +2 -0
  48. data/spec/support/matrix.json +6 -1
  49. data/spec/support/matrix.txt +3 -3
  50. data/spec/support/matrix_error.txt +3 -3
  51. data/spec/support/matrix_with_results.txt +10 -0
  52. data/tasks/pact.rake +2 -0
  53. metadata +36 -8
  54. data/.travis.yml +0 -11
@@ -3,7 +3,6 @@ require 'pact_broker/client/tasks/publication_task'
3
3
  require 'pact_broker/client/publish_pacts'
4
4
 
5
5
  module PactBroker::Client
6
-
7
6
  describe PublicationTask do
8
7
 
9
8
  before do
@@ -22,7 +21,6 @@ module PactBroker::Client
22
21
  let(:pattern) { "spec/pacts/*.json" }
23
22
 
24
23
  describe "default task" do
25
-
26
24
  before :all do
27
25
  PactBroker::Client::PublicationTask.new do | task |
28
26
  task.consumer_version = '1.2.3'
@@ -31,7 +29,7 @@ module PactBroker::Client
31
29
 
32
30
  context "when pacts are succesfully published" do
33
31
  it "invokes PublishPacts with the default values" do
34
- expect(PactBroker::Client::PublishPacts).to receive(:new).with('http://pact-broker', pact_file_list, '1.2.3', [], {}).and_return(publish_pacts)
32
+ 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)
35
33
  expect(publish_pacts).to receive(:call).and_return(true)
36
34
  Rake::Task['pact:publish'].execute
37
35
  end
@@ -54,7 +52,7 @@ module PactBroker::Client
54
52
  end
55
53
 
56
54
  it "invokes PublishPacts with the write method set" do
57
- expect(PactBroker::Client::PublishPacts).to receive(:new).with('http://pact-broker', pact_file_list, '1.2.3', [], {write: :merge}).and_return(publish_pacts)
55
+ 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)
58
56
  expect(publish_pacts).to receive(:call).and_return(true)
59
57
  Rake::Task['pact:publish:merge'].execute
60
58
  end
@@ -65,17 +63,98 @@ module PactBroker::Client
65
63
  PactBroker::Client::PublicationTask.new(:git_branch) do | task |
66
64
  task.consumer_version = '1.2.3'
67
65
  task.tag_with_git_branch = true
66
+ task.auto_detect_version_properties = false
68
67
  task.tags = ['bar']
69
68
  end
70
69
  end
71
70
 
72
- it "invokes PublishPacts with the git branch name as a tag" do
73
- expect(PactBroker::Client::PublishPacts).to receive(:new).with(anything, anything, anything, ['bar', 'foo'], anything).and_return(publish_pacts)
71
+ it "gets the git branch name" do
72
+ expect(PactBroker::Client::Git).to receive(:branch).with(raise_error: true)
73
+ Rake::Task['pact:publish:git_branch'].execute
74
+ end
74
75
 
76
+ it "invokes PublishPacts with the git branch name as a tag" do
77
+ expect(PactBroker::Client::PublishPacts).to receive(:new).with(anything, anything, hash_including(tags: ['bar', 'foo']), anything).and_return(publish_pacts)
75
78
  Rake::Task['pact:publish:git_branch'].execute
76
79
  end
77
80
  end
78
81
 
82
+ context "when auto_detect_version_properties is explicitly set to true" do
83
+ before :all do
84
+ PactBroker::Client::PublicationTask.new(:git_branch_auto_detect_true) do | task |
85
+ task.consumer_version = '1.2.3'
86
+ task.auto_detect_version_properties = true
87
+ end
88
+ end
89
+
90
+ it "gets the git branch name" do
91
+ expect(PactBroker::Client::Git).to receive(:branch).with(raise_error: true)
92
+ Rake::Task['pact:publish:git_branch_auto_detect_true'].execute
93
+ end
94
+
95
+ it "invokes PublishPacts with the branch name" do
96
+ expect(PactBroker::Client::PublishPacts).to receive(:new).with(anything, anything, hash_including(branch: "foo"), anything).and_return(publish_pacts)
97
+ Rake::Task['pact:publish:git_branch_auto_detect_true'].execute
98
+ end
99
+ end
100
+
101
+ context "when auto_detect_version_properties is explicitly set to true and the branch is specified" do
102
+ before :all do
103
+ PactBroker::Client::PublicationTask.new(:git_branch_auto_detect_true_with_branch) do | task |
104
+ task.consumer_version = '1.2.3'
105
+ task.auto_detect_version_properties = true
106
+ task.branch = "main"
107
+ end
108
+ end
109
+
110
+ it "does not get the branch name" do
111
+ expect(PactBroker::Client::Git).to_not receive(:branch)
112
+ Rake::Task['pact:publish:git_branch_auto_detect_true_with_branch'].execute
113
+ end
114
+
115
+ it "invokes PublishPacts with the specified branch name" do
116
+ expect(PactBroker::Client::PublishPacts).to receive(:new).with(anything, anything, hash_including(branch: "main"), anything).and_return(publish_pacts)
117
+ Rake::Task['pact:publish:git_branch_auto_detect_true_with_branch'].execute
118
+ end
119
+ end
120
+
121
+ context "when auto_detect_version_properties is explicitly set to false" do
122
+ before :all do
123
+ PactBroker::Client::PublicationTask.new(:git_branch_auto_detect_false) do | task |
124
+ task.consumer_version = '1.2.3'
125
+ task.auto_detect_version_properties = false
126
+ end
127
+ end
128
+
129
+ it "does not get the git branch name" do
130
+ expect(PactBroker::Client::Git).to_not receive(:branch)
131
+ Rake::Task['pact:publish:git_branch_auto_detect_false'].execute
132
+ end
133
+
134
+ it "invokes PublishPacts without the branch name" do
135
+ expect(PactBroker::Client::PublishPacts).to receive(:new).with(anything, anything, hash_not_including(branch: "foo"), anything).and_return(publish_pacts)
136
+ Rake::Task['pact:publish:git_branch_auto_detect_false'].execute
137
+ end
138
+ end
139
+
140
+ context "when auto_detect_version_properties is left as its default" do
141
+ before :all do
142
+ PactBroker::Client::PublicationTask.new(:git_branch_auto_detect_default) do | task |
143
+ task.consumer_version = '1.2.3'
144
+ end
145
+ end
146
+
147
+ it "gets the git branch name" do
148
+ expect(PactBroker::Client::Git).to receive(:branch).with(raise_error: false)
149
+ Rake::Task['pact:publish:git_branch_auto_detect_default'].execute
150
+ end
151
+
152
+ it "invokes PublishPacts with the branch name" do
153
+ expect(PactBroker::Client::PublishPacts).to receive(:new).with(anything, anything, hash_including(branch: "foo"), anything).and_return(publish_pacts)
154
+ Rake::Task['pact:publish:git_branch_auto_detect_default'].execute
155
+ end
156
+ end
157
+
79
158
  describe "custom task" do
80
159
 
81
160
  before :all do
@@ -98,10 +177,9 @@ module PactBroker::Client
98
177
 
99
178
  it "invokes PublishPacts with the customised values" do
100
179
  expect(PactBroker::Client::PublishPacts).to receive(:new).with(
101
- @pact_broker_base_url,
102
- pact_file_list,
103
- '1.2.3',
104
- [@tag],
180
+ @pact_broker_base_url,
181
+ pact_file_list,
182
+ { number: "1.2.3", tags: [@tag], branch: "foo", version_required: false},
105
183
  { basic_auth: @pact_broker_basic_auth, token: @pact_broker_token }
106
184
  )
107
185
  expect(publish_pacts).to receive(:call).and_return(true)
@@ -5,7 +5,6 @@ module PactBroker
5
5
  class Versions
6
6
  describe Describe do
7
7
  describe ".call" do
8
-
9
8
  let(:versions_client) do
10
9
  instance_double('PactBroker::Client::Versions', latest: version_hash)
11
10
  end
@@ -0,0 +1,82 @@
1
+ require 'pact_broker/client/versions/record_deployment'
2
+
3
+ module PactBroker
4
+ module Client
5
+ class Versions
6
+ describe RecordDeployment do
7
+ describe ".call" do
8
+ let(:broker_base_url) { "http://broker" }
9
+ let(:index_body_hash) do
10
+ {
11
+ _links: {}
12
+ }
13
+ end
14
+ let!(:index_request) do
15
+ stub_request(:get, broker_base_url).to_return(status: 200, body: index_body_hash.to_json, headers: { "Content-Type" => "application/hal+json" } )
16
+ end
17
+
18
+ let(:replaced_previous_deployed_version) { true }
19
+
20
+ let(:params) do
21
+ {
22
+ pacticipant_name: "Foo",
23
+ version_number: "1",
24
+ environment_name: "test",
25
+ replaced_previous_deployed_version: replaced_previous_deployed_version,
26
+ output: "text"
27
+ }
28
+ end
29
+
30
+ let(:pact_broker_client_options) { {} }
31
+
32
+ subject { RecordDeployment.call(params, broker_base_url, pact_broker_client_options) }
33
+
34
+ context "when the pb:environments relation does not exist" do
35
+ it "returns an error response" do
36
+ expect(subject.success).to be false
37
+ expect(subject.message).to include "does not support"
38
+ end
39
+ end
40
+
41
+ context "when the response headers contain Pactflow" do
42
+ before do
43
+ allow_any_instance_of(RecordDeployment).to receive(:check_if_command_supported)
44
+ allow_any_instance_of(RecordDeployment).to receive(:check_environment_exists)
45
+ allow_any_instance_of(RecordDeployment).to receive(:record_deployment)
46
+ allow_any_instance_of(RecordDeployment).to receive(:deployed_version_resource).and_return(deployed_version_resource)
47
+ end
48
+
49
+ let(:response_headers) { { "X-Pactflow-Sha" => "abc" } }
50
+
51
+ let(:deployed_version_resource) do
52
+ double('PactBroker::Client::Hal::Entity', response: double('response', headers: response_headers) )
53
+ end
54
+
55
+ it "indicates the API was Pactflow" do
56
+ expect(subject.message).to include "Recorded deployment of Foo version 1 to test in Pactflow"
57
+ end
58
+ end
59
+
60
+ context "when replaced_previous_deployed_version is false" do
61
+ before do
62
+ allow_any_instance_of(RecordDeployment).to receive(:check_if_command_supported)
63
+ allow_any_instance_of(RecordDeployment).to receive(:check_environment_exists)
64
+ allow_any_instance_of(RecordDeployment).to receive(:record_deployment)
65
+ allow_any_instance_of(RecordDeployment).to receive(:pact_broker_name).and_return("")
66
+ end
67
+
68
+ let(:replaced_previous_deployed_version) { false }
69
+
70
+ let(:deployed_version_resource) do
71
+ double('PactBroker::Client::Hal::Entity', response: double('response', headers: response_headers) )
72
+ end
73
+
74
+ it "does not include the message about marking the previous version as undeployed" do
75
+ expect(subject.message).to_not include "undeployed"
76
+ end
77
+ end
78
+ end
79
+ end
80
+ end
81
+ end
82
+ end
@@ -186,6 +186,112 @@
186
186
  }
187
187
  }
188
188
  },
189
+ {
190
+ "description": "a request for the index resource",
191
+ "providerState": "the pb:pacticipant-version relation exists in the index resource",
192
+ "request": {
193
+ "method": "get",
194
+ "path": "/",
195
+ "headers": {
196
+ "Accept": "application/hal+json"
197
+ }
198
+ },
199
+ "response": {
200
+ "status": 200,
201
+ "headers": {
202
+ "Content-Type": "application/hal+json;charset=utf-8"
203
+ },
204
+ "body": {
205
+ "_links": {
206
+ "pb:pacticipant-version": {
207
+ "href": "http://localhost:1234/HAL-REL-PLACEHOLDER-INDEX-PB-PACTICIPANT-VERSION-{pacticipant}-{version}"
208
+ }
209
+ }
210
+ },
211
+ "matchingRules": {
212
+ "$.body._links.pb:pacticipant-version.href": {
213
+ "match": "regex",
214
+ "regex": "http:\\/\\/.*{pacticipant}.*{version}"
215
+ }
216
+ }
217
+ }
218
+ },
219
+ {
220
+ "description": "a request to create a pacticipant version",
221
+ "providerState": "version 26f353580936ad3b9baddb17b00e84f33c69e7cb of pacticipant Foo does not exist",
222
+ "request": {
223
+ "method": "put",
224
+ "path": "/HAL-REL-PLACEHOLDER-INDEX-PB-PACTICIPANT-VERSION-Foo-26f353580936ad3b9baddb17b00e84f33c69e7cb",
225
+ "headers": {
226
+ "Content-Type": "application/json",
227
+ "Accept": "application/hal+json"
228
+ },
229
+ "body": {
230
+ "branch": "main",
231
+ "buildUrl": "http://my-ci/builds/1"
232
+ }
233
+ },
234
+ "response": {
235
+ "status": 201,
236
+ "headers": {
237
+ "Content-Type": "application/hal+json;charset=utf-8"
238
+ },
239
+ "body": {
240
+ "number": "26f353580936ad3b9baddb17b00e84f33c69e7cb",
241
+ "branch": "main",
242
+ "buildUrl": "http://my-ci/builds/1",
243
+ "_links": {
244
+ "self": {
245
+ "href": "http://localhost:1234/some-url"
246
+ }
247
+ }
248
+ },
249
+ "matchingRules": {
250
+ "$.body._links.self.href": {
251
+ "match": "regex",
252
+ "regex": "http:\\/\\/.*"
253
+ }
254
+ }
255
+ }
256
+ },
257
+ {
258
+ "description": "a request to create a pacticipant version",
259
+ "providerState": "version 26f353580936ad3b9baddb17b00e84f33c69e7cb of pacticipant Foo does exist",
260
+ "request": {
261
+ "method": "put",
262
+ "path": "/HAL-REL-PLACEHOLDER-INDEX-PB-PACTICIPANT-VERSION-Foo-26f353580936ad3b9baddb17b00e84f33c69e7cb",
263
+ "headers": {
264
+ "Content-Type": "application/json",
265
+ "Accept": "application/hal+json"
266
+ },
267
+ "body": {
268
+ "branch": "main",
269
+ "buildUrl": "http://my-ci/builds/1"
270
+ }
271
+ },
272
+ "response": {
273
+ "status": 200,
274
+ "headers": {
275
+ "Content-Type": "application/hal+json;charset=utf-8"
276
+ },
277
+ "body": {
278
+ "number": "26f353580936ad3b9baddb17b00e84f33c69e7cb",
279
+ "branch": "main",
280
+ "buildUrl": "http://my-ci/builds/1",
281
+ "_links": {
282
+ "self": {
283
+ "href": "http://localhost:1234/some-url"
284
+ }
285
+ }
286
+ },
287
+ "matchingRules": {
288
+ "$.body._links.self.href": {
289
+ "match": "regex",
290
+ "regex": "http:\\/\\/.*"
291
+ }
292
+ }
293
+ }
294
+ },
189
295
  {
190
296
  "description": "a request for the compatibility matrix for Foo version 1.2.3 and Bar version 4.5.6",
191
297
  "providerState": "the pact for Foo version 1.2.3 has been verified by Bar version 4.5.6",
@@ -221,7 +327,12 @@
221
327
  },
222
328
  "verificationResult": {
223
329
  "verifiedAt": "2017-10-10T12:49:04+11:00",
224
- "success": true
330
+ "success": true,
331
+ "_links": {
332
+ "self": {
333
+ "href": "http://result"
334
+ }
335
+ }
225
336
  },
226
337
  "pact": {
227
338
  "createdAt": "2017-10-10T12:49:04+11:00"
@@ -271,7 +382,12 @@
271
382
  },
272
383
  "verificationResult": {
273
384
  "verifiedAt": "2017-10-10T12:49:04+11:00",
274
- "success": true
385
+ "success": true,
386
+ "_links": {
387
+ "self": {
388
+ "href": "http://result"
389
+ }
390
+ }
275
391
  },
276
392
  "pact": {
277
393
  "createdAt": "2017-10-10T12:49:04+11:00"
@@ -321,7 +437,12 @@
321
437
  },
322
438
  "verificationResult": {
323
439
  "verifiedAt": "2017-10-10T12:49:04+11:00",
324
- "success": true
440
+ "success": true,
441
+ "_links": {
442
+ "self": {
443
+ "href": "http://result"
444
+ }
445
+ }
325
446
  },
326
447
  "pact": {
327
448
  "createdAt": "2017-10-10T12:49:04+11:00"
@@ -418,7 +539,12 @@
418
539
  },
419
540
  "verificationResult": {
420
541
  "verifiedAt": "2017-10-10T12:49:04+11:00",
421
- "success": true
542
+ "success": true,
543
+ "_links": {
544
+ "self": {
545
+ "href": "http://result"
546
+ }
547
+ }
422
548
  },
423
549
  "pact": {
424
550
  "createdAt": "2017-10-10T12:49:04+11:00"
@@ -439,7 +565,12 @@
439
565
  },
440
566
  "verificationResult": {
441
567
  "verifiedAt": "2017-10-10T12:49:04+11:00",
442
- "success": true
568
+ "success": true,
569
+ "_links": {
570
+ "self": {
571
+ "href": "http://result"
572
+ }
573
+ }
443
574
  },
444
575
  "pact": {
445
576
  "createdAt": "2017-10-10T12:49:04+11:00"
@@ -492,7 +623,12 @@
492
623
  },
493
624
  "verificationResult": {
494
625
  "verifiedAt": "2017-10-10T12:49:04+11:00",
495
- "success": true
626
+ "success": true,
627
+ "_links": {
628
+ "self": {
629
+ "href": "http://result"
630
+ }
631
+ }
496
632
  },
497
633
  "pact": {
498
634
  "createdAt": "2017-10-10T12:49:04+11:00"
@@ -542,7 +678,12 @@
542
678
  },
543
679
  "verificationResult": {
544
680
  "verifiedAt": "2017-10-10T12:49:04+11:00",
545
- "success": true
681
+ "success": true,
682
+ "_links": {
683
+ "self": {
684
+ "href": "http://result"
685
+ }
686
+ }
546
687
  },
547
688
  "pact": {
548
689
  "createdAt": "2017-10-10T12:49:04+11:00"
@@ -592,7 +733,12 @@
592
733
  },
593
734
  "verificationResult": {
594
735
  "verifiedAt": "2017-10-10T12:49:04+11:00",
595
- "success": true
736
+ "success": true,
737
+ "_links": {
738
+ "self": {
739
+ "href": "http://result"
740
+ }
741
+ }
596
742
  },
597
743
  "pact": {
598
744
  "createdAt": "2017-10-10T12:49:04+11:00"
@@ -1404,6 +1550,187 @@
1404
1550
  }
1405
1551
  }
1406
1552
  },
1553
+ {
1554
+ "description": "a request for the index resource",
1555
+ "providerState": "the pb:pacticipant-version and pb:environments relations exist in the index resource",
1556
+ "request": {
1557
+ "method": "GET",
1558
+ "path": "/",
1559
+ "headers": {
1560
+ "Accept": "application/hal+json"
1561
+ }
1562
+ },
1563
+ "response": {
1564
+ "status": 200,
1565
+ "headers": {
1566
+ "Content-Type": "application/hal+json;charset=utf-8"
1567
+ },
1568
+ "body": {
1569
+ "_links": {
1570
+ "pb:pacticipant-version": {
1571
+ "href": "http://localhost:1234/HAL-REL-PLACEHOLDER-PB-PACTICIPANT-VERSION-{pacticipant}-{version}"
1572
+ },
1573
+ "pb:environments": {
1574
+ "href": "http://localhost:1234/HAL-REL-PLACEHOLDER-PB-ENVIRONMENTS"
1575
+ }
1576
+ }
1577
+ },
1578
+ "matchingRules": {
1579
+ "$.body._links.pb:pacticipant-version.href": {
1580
+ "match": "regex",
1581
+ "regex": "http:\\/\\/.*{pacticipant}.*{version}"
1582
+ },
1583
+ "$.body._links.pb:environments.href": {
1584
+ "match": "regex",
1585
+ "regex": "http:\\/\\/.*"
1586
+ }
1587
+ }
1588
+ }
1589
+ },
1590
+ {
1591
+ "description": "a request for a pacticipant version",
1592
+ "providerState": "version 5556b8149bf8bac76bc30f50a8a2dd4c22c85f30 of pacticipant Foo exists with a test environment available for deployment",
1593
+ "request": {
1594
+ "method": "GET",
1595
+ "path": "/HAL-REL-PLACEHOLDER-PB-PACTICIPANT-VERSION-Foo-5556b8149bf8bac76bc30f50a8a2dd4c22c85f30",
1596
+ "headers": {
1597
+ "Accept": "application/hal+json"
1598
+ }
1599
+ },
1600
+ "response": {
1601
+ "status": 200,
1602
+ "headers": {
1603
+ "Content-Type": "application/hal+json;charset=utf-8"
1604
+ },
1605
+ "body": {
1606
+ "_links": {
1607
+ "pb:record-deployment": [
1608
+ {
1609
+ "name": "test",
1610
+ "href": "http://localhost:1234/HAL-REL-PLACEHOLDER-PB-RECORD-DEPLOYMENT-FOO-5556B8149BF8BAC76BC30F50A8A2DD4C22C85F30-TEST"
1611
+ }
1612
+ ]
1613
+ }
1614
+ },
1615
+ "matchingRules": {
1616
+ "$.body._links.pb:record-deployment[0].href": {
1617
+ "match": "regex",
1618
+ "regex": "http:\\/\\/.*"
1619
+ }
1620
+ }
1621
+ }
1622
+ },
1623
+ {
1624
+ "description": "a request to record a deployment",
1625
+ "providerState": "version 5556b8149bf8bac76bc30f50a8a2dd4c22c85f30 of pacticipant Foo exists with a test environment available for deployment",
1626
+ "request": {
1627
+ "method": "POST",
1628
+ "path": "/HAL-REL-PLACEHOLDER-PB-RECORD-DEPLOYMENT-FOO-5556B8149BF8BAC76BC30F50A8A2DD4C22C85F30-TEST",
1629
+ "headers": {
1630
+ "Content-Type": "application/json",
1631
+ "Accept": "application/hal+json"
1632
+ },
1633
+ "body": {
1634
+ "replacedPreviousDeployedVersion": true
1635
+ }
1636
+ },
1637
+ "response": {
1638
+ "status": 201,
1639
+ "headers": {
1640
+ "Content-Type": "application/hal+json;charset=utf-8"
1641
+ },
1642
+ "body": {
1643
+ "replacedPreviousDeployedVersion": true
1644
+ }
1645
+ }
1646
+ },
1647
+ {
1648
+ "description": "a request for a pacticipant version",
1649
+ "providerState": "version 5556b8149bf8bac76bc30f50a8a2dd4c22c85f30 of pacticipant Foo does not exist",
1650
+ "request": {
1651
+ "method": "GET",
1652
+ "path": "/HAL-REL-PLACEHOLDER-PB-PACTICIPANT-VERSION-Foo-5556b8149bf8bac76bc30f50a8a2dd4c22c85f30",
1653
+ "headers": {
1654
+ "Accept": "application/hal+json"
1655
+ }
1656
+ },
1657
+ "response": {
1658
+ "status": 404,
1659
+ "headers": {
1660
+ }
1661
+ }
1662
+ },
1663
+ {
1664
+ "description": "a request for a pacticipant version",
1665
+ "providerState": "version 5556b8149bf8bac76bc30f50a8a2dd4c22c85f30 of pacticipant Foo exists with 2 environments that aren't test available for deployment",
1666
+ "request": {
1667
+ "method": "GET",
1668
+ "path": "/HAL-REL-PLACEHOLDER-PB-PACTICIPANT-VERSION-Foo-5556b8149bf8bac76bc30f50a8a2dd4c22c85f30",
1669
+ "headers": {
1670
+ "Accept": "application/hal+json"
1671
+ }
1672
+ },
1673
+ "response": {
1674
+ "status": 200,
1675
+ "headers": {
1676
+ "Content-Type": "application/hal+json;charset=utf-8"
1677
+ },
1678
+ "body": {
1679
+ "_links": {
1680
+ "pb:record-deployment": [
1681
+ {
1682
+ "name": "prod",
1683
+ "href": "href"
1684
+ },
1685
+ {
1686
+ "name": "dev",
1687
+ "href": "href"
1688
+ }
1689
+ ]
1690
+ }
1691
+ },
1692
+ "matchingRules": {
1693
+ "$.body._links.pb:record-deployment[0]": {
1694
+ "match": "type"
1695
+ },
1696
+ "$.body._links.pb:record-deployment[1]": {
1697
+ "match": "type"
1698
+ }
1699
+ }
1700
+ }
1701
+ },
1702
+ {
1703
+ "description": "a request for the environments",
1704
+ "providerState": "an environment with name test exists",
1705
+ "request": {
1706
+ "method": "GET",
1707
+ "path": "/HAL-REL-PLACEHOLDER-PB-ENVIRONMENTS",
1708
+ "headers": {
1709
+ "Accept": "application/hal+json"
1710
+ }
1711
+ },
1712
+ "response": {
1713
+ "status": 200,
1714
+ "headers": {
1715
+ "Content-Type": "application/hal+json;charset=utf-8"
1716
+ },
1717
+ "body": {
1718
+ "_links": {
1719
+ "pb:environments": [
1720
+ {
1721
+ "name": "test",
1722
+ "href": "href"
1723
+ }
1724
+ ]
1725
+ }
1726
+ },
1727
+ "matchingRules": {
1728
+ "$.body._links.pb:environments[0].href": {
1729
+ "match": "type"
1730
+ }
1731
+ }
1732
+ }
1733
+ },
1407
1734
  {
1408
1735
  "description": "a request to create a webhook with a JSON body for a consumer and provider",
1409
1736
  "providerState": "the 'Pricing Service' and 'Condor' already exist in the pact-broker",