pact_broker-client 1.45.0 → 1.48.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 +15 -1
- data/CHANGELOG.md +31 -0
- data/README.md +51 -47
- data/doc/pacts/markdown/Pact Broker Client - Pact Broker.md +315 -1
- data/doc/pacts/markdown/Pact Broker Client - Pactflow.md +94 -0
- data/doc/pacts/markdown/README.md +1 -0
- data/lib/pact_broker/client/cli/broker.rb +9 -139
- data/lib/pact_broker/client/cli/custom_thor.rb +0 -16
- data/lib/pact_broker/client/cli/matrix_commands.rb +93 -0
- data/lib/pact_broker/client/cli/webhook_commands.rb +122 -0
- data/lib/pact_broker/client/deployments/record_support_ended.rb +1 -1
- data/lib/pact_broker/client/deployments/record_undeployment.rb +1 -1
- data/lib/pact_broker/client/matrix/resource.rb +4 -0
- data/lib/pact_broker/client/verification_required.rb +34 -0
- data/lib/pact_broker/client/version.rb +1 -1
- data/lib/pact_broker/client/webhooks/create.rb +14 -8
- data/script/record-deployment.sh +1 -1
- data/script/record-deployments-and-releases.sh +0 -2
- data/script/record-undeployment.sh +1 -1
- data/script/webhook-commands.sh +12 -0
- data/spec/lib/pact_broker/client/cli/broker_can_i_deploy_spec.rb +1 -1
- data/spec/lib/pact_broker/client/cli/broker_run_webhook_commands_spec.rb +4 -2
- data/spec/lib/pact_broker/client/deployments/record_support_ended_spec.rb +1 -1
- data/spec/lib/pact_broker/client/deployments/record_undeployment_spec.rb +1 -1
- data/spec/pacts/pact_broker_client-pact_broker.json +317 -1
- data/spec/pacts/pact_broker_client-pactflow.json +118 -0
- data/spec/service_providers/pact_helper.rb +15 -10
- data/spec/service_providers/pactflow_webhooks_create_spec.rb +86 -0
- data/spec/service_providers/record_deployment_spec.rb +1 -3
- data/spec/service_providers/record_release_spec.rb +1 -3
- data/spec/service_providers/record_undeployment_spec.rb +2 -4
- data/spec/service_providers/webhooks_create_spec.rb +1 -1
- data/spec/spec_helper.rb +1 -0
- metadata +12 -3
@@ -0,0 +1,118 @@
|
|
1
|
+
{
|
2
|
+
"consumer": {
|
3
|
+
"name": "Pact Broker Client"
|
4
|
+
},
|
5
|
+
"provider": {
|
6
|
+
"name": "Pactflow"
|
7
|
+
},
|
8
|
+
"interactions": [
|
9
|
+
{
|
10
|
+
"description": "a request for the index resource",
|
11
|
+
"request": {
|
12
|
+
"method": "get",
|
13
|
+
"path": "/",
|
14
|
+
"headers": {
|
15
|
+
"Accept": "application/hal+json"
|
16
|
+
}
|
17
|
+
},
|
18
|
+
"response": {
|
19
|
+
"status": 200,
|
20
|
+
"headers": {
|
21
|
+
"Content-Type": "application/hal+json;charset=utf-8"
|
22
|
+
},
|
23
|
+
"body": {
|
24
|
+
"_links": {
|
25
|
+
"pb:webhooks": {
|
26
|
+
"href": "http://localhost:1235/HAL-REL-PLACEHOLDER-PB-WEBHOOKS"
|
27
|
+
},
|
28
|
+
"pb:pacticipants": {
|
29
|
+
"href": "http://localhost:1235/HAL-REL-PLACEHOLDER-PB-PACTICIPANTS"
|
30
|
+
},
|
31
|
+
"pb:pacticipant": {
|
32
|
+
"href": "http://localhost:1235/HAL-REL-PLACEHOLDER-PB-PACTICIPANT-{pacticipant}"
|
33
|
+
}
|
34
|
+
}
|
35
|
+
},
|
36
|
+
"matchingRules": {
|
37
|
+
"$.body._links.pb:webhooks.href": {
|
38
|
+
"match": "regex",
|
39
|
+
"regex": "http:\\/\\/.*"
|
40
|
+
},
|
41
|
+
"$.body._links.pb:pacticipants.href": {
|
42
|
+
"match": "regex",
|
43
|
+
"regex": "http:\\/\\/.*"
|
44
|
+
},
|
45
|
+
"$.body._links.pb:pacticipant.href": {
|
46
|
+
"match": "regex",
|
47
|
+
"regex": "http:\\/\\/.*{pacticipant}"
|
48
|
+
}
|
49
|
+
}
|
50
|
+
}
|
51
|
+
},
|
52
|
+
{
|
53
|
+
"description": "a request to create a webhook for a team",
|
54
|
+
"providerState": "a team with UUID 2abbc12a-427d-432a-a521-c870af1739d9 exists",
|
55
|
+
"request": {
|
56
|
+
"method": "post",
|
57
|
+
"path": "/HAL-REL-PLACEHOLDER-PB-WEBHOOKS",
|
58
|
+
"headers": {
|
59
|
+
"Content-Type": "application/json",
|
60
|
+
"Accept": "application/hal+json"
|
61
|
+
},
|
62
|
+
"body": {
|
63
|
+
"description": "a webhook",
|
64
|
+
"events": [
|
65
|
+
{
|
66
|
+
"name": "contract_content_changed"
|
67
|
+
}
|
68
|
+
],
|
69
|
+
"request": {
|
70
|
+
"url": "https://webhook",
|
71
|
+
"method": "POST",
|
72
|
+
"headers": {
|
73
|
+
"Foo": "bar",
|
74
|
+
"Bar": "foo"
|
75
|
+
},
|
76
|
+
"body": {
|
77
|
+
"some": "body"
|
78
|
+
}
|
79
|
+
},
|
80
|
+
"teamUuid": "2abbc12a-427d-432a-a521-c870af1739d9"
|
81
|
+
}
|
82
|
+
},
|
83
|
+
"response": {
|
84
|
+
"status": 201,
|
85
|
+
"headers": {
|
86
|
+
"Content-Type": "application/hal+json;charset=utf-8"
|
87
|
+
},
|
88
|
+
"body": {
|
89
|
+
"description": "a webhook",
|
90
|
+
"teamUuid": "2abbc12a-427d-432a-a521-c870af1739d9",
|
91
|
+
"_links": {
|
92
|
+
"self": {
|
93
|
+
"href": "http://localhost:1234/some-url",
|
94
|
+
"title": "A title"
|
95
|
+
}
|
96
|
+
}
|
97
|
+
},
|
98
|
+
"matchingRules": {
|
99
|
+
"$.body.description": {
|
100
|
+
"match": "type"
|
101
|
+
},
|
102
|
+
"$.body._links.self.href": {
|
103
|
+
"match": "regex",
|
104
|
+
"regex": "http:\\/\\/.*"
|
105
|
+
},
|
106
|
+
"$.body._links.self.title": {
|
107
|
+
"match": "type"
|
108
|
+
}
|
109
|
+
}
|
110
|
+
}
|
111
|
+
}
|
112
|
+
],
|
113
|
+
"metadata": {
|
114
|
+
"pactSpecification": {
|
115
|
+
"version": "2.0.0"
|
116
|
+
}
|
117
|
+
}
|
118
|
+
}
|
@@ -8,7 +8,6 @@ Pact.configure do | config |
|
|
8
8
|
end
|
9
9
|
|
10
10
|
Pact.service_consumer 'Pact Broker Client' do
|
11
|
-
|
12
11
|
has_pact_with "Pact Broker" do
|
13
12
|
mock_service :pact_broker do
|
14
13
|
port 1234
|
@@ -16,6 +15,12 @@ Pact.service_consumer 'Pact Broker Client' do
|
|
16
15
|
end
|
17
16
|
end
|
18
17
|
|
18
|
+
has_pact_with "Pactflow" do
|
19
|
+
mock_service :pactflow do
|
20
|
+
port 1235
|
21
|
+
pact_specification_version "2.0"
|
22
|
+
end
|
23
|
+
end
|
19
24
|
end
|
20
25
|
|
21
26
|
module PactBrokerPactHelperMethods
|
@@ -30,22 +35,22 @@ module PactBrokerPactHelperMethods
|
|
30
35
|
path
|
31
36
|
end
|
32
37
|
|
33
|
-
def placeholder_url(relation, params = [])
|
34
|
-
"#{
|
38
|
+
def placeholder_url(relation, params = [], mock_service = pact_broker)
|
39
|
+
"#{mock_service.mock_service_base_url}#{placeholder_path(relation, params)}"
|
35
40
|
end
|
36
41
|
|
37
|
-
def placeholder_url_term(relation, params = [])
|
42
|
+
def placeholder_url_term(relation, params = [], mock_service = pact_broker)
|
38
43
|
regexp = "http:\/\/.*"
|
39
44
|
if params.any?
|
40
45
|
joined_params_for_regexp = params.collect{ |param| "{#{param}}"}.join(".*")
|
41
46
|
regexp = "#{regexp}#{joined_params_for_regexp}"
|
42
47
|
end
|
43
48
|
|
44
|
-
Pact.term(placeholder_url(relation, params), /#{regexp}/)
|
49
|
+
Pact.term(placeholder_url(relation, params, mock_service), /#{regexp}/)
|
45
50
|
end
|
46
51
|
|
47
|
-
def mock_pact_broker_index(context)
|
48
|
-
|
52
|
+
def mock_pact_broker_index(context, mock_service = pact_broker)
|
53
|
+
mock_service
|
49
54
|
.upon_receiving("a request for the index resource")
|
50
55
|
.with(
|
51
56
|
method: :get,
|
@@ -57,13 +62,13 @@ module PactBrokerPactHelperMethods
|
|
57
62
|
body: {
|
58
63
|
_links: {
|
59
64
|
:'pb:webhooks' => {
|
60
|
-
href: placeholder_url_term('pb:webhooks')
|
65
|
+
href: placeholder_url_term('pb:webhooks', [], mock_service)
|
61
66
|
},
|
62
67
|
:'pb:pacticipants' => {
|
63
|
-
href: placeholder_url_term('pb:pacticipants')
|
68
|
+
href: placeholder_url_term('pb:pacticipants', [], mock_service)
|
64
69
|
},
|
65
70
|
:'pb:pacticipant' => {
|
66
|
-
href: placeholder_url_term('pb:pacticipant', ['pacticipant'])
|
71
|
+
href: placeholder_url_term('pb:pacticipant', ['pacticipant'], mock_service)
|
67
72
|
}
|
68
73
|
}
|
69
74
|
}
|
@@ -0,0 +1,86 @@
|
|
1
|
+
require_relative 'pact_helper'
|
2
|
+
require 'pact_broker/client/webhooks/create'
|
3
|
+
|
4
|
+
RSpec.describe "creating a webhook in Pactflow", pact: true do
|
5
|
+
|
6
|
+
include_context "pact broker"
|
7
|
+
include PactBrokerPactHelperMethods
|
8
|
+
|
9
|
+
let(:params) do
|
10
|
+
{
|
11
|
+
description: "a webhook",
|
12
|
+
events: %w{contract_content_changed},
|
13
|
+
http_method: "POST",
|
14
|
+
url: "https://webhook",
|
15
|
+
headers: { "Foo" => "bar", "Bar" => "foo"},
|
16
|
+
body: body,
|
17
|
+
team_uuid: "2abbc12a-427d-432a-a521-c870af1739d9"
|
18
|
+
}
|
19
|
+
end
|
20
|
+
|
21
|
+
let(:body) { { some: "body" }.to_json }
|
22
|
+
|
23
|
+
let(:request_body) do
|
24
|
+
{
|
25
|
+
"description" => "a webhook",
|
26
|
+
"events" => [
|
27
|
+
"name" => "contract_content_changed"
|
28
|
+
],
|
29
|
+
"request" => {
|
30
|
+
"url" => "https://webhook",
|
31
|
+
"method" => "POST",
|
32
|
+
"headers" => {
|
33
|
+
"Foo" => "bar",
|
34
|
+
"Bar" => "foo"
|
35
|
+
},
|
36
|
+
"body" => {
|
37
|
+
"some" => "body"
|
38
|
+
},
|
39
|
+
},
|
40
|
+
"teamUuid" => "2abbc12a-427d-432a-a521-c870af1739d9"
|
41
|
+
}
|
42
|
+
end
|
43
|
+
|
44
|
+
let(:response_status) { 201 }
|
45
|
+
let(:success_response) do
|
46
|
+
{
|
47
|
+
status: response_status,
|
48
|
+
headers: pact_broker_response_headers,
|
49
|
+
body: {
|
50
|
+
description: Pact.like("a webhook"),
|
51
|
+
teamUuid: "2abbc12a-427d-432a-a521-c870af1739d9",
|
52
|
+
_links: {
|
53
|
+
self: {
|
54
|
+
href: Pact.term('http://localhost:1234/some-url', %r{http://.*}),
|
55
|
+
title: Pact.like("A title")
|
56
|
+
}
|
57
|
+
}
|
58
|
+
}
|
59
|
+
}
|
60
|
+
end
|
61
|
+
|
62
|
+
let(:pact_broker_client_options) { {} }
|
63
|
+
|
64
|
+
subject { PactBroker::Client::Webhooks::Create.call(params, pactflow.mock_service_base_url, pact_broker_client_options) }
|
65
|
+
|
66
|
+
context "when a valid webhook with a team specified is submitted" do
|
67
|
+
before do
|
68
|
+
mock_pact_broker_index(self, pactflow)
|
69
|
+
pactflow
|
70
|
+
.given("a team with UUID 2abbc12a-427d-432a-a521-c870af1739d9 exists")
|
71
|
+
.upon_receiving("a request to create a webhook for a team")
|
72
|
+
.with(
|
73
|
+
method: :post,
|
74
|
+
path: '/HAL-REL-PLACEHOLDER-PB-WEBHOOKS',
|
75
|
+
headers: post_request_headers,
|
76
|
+
body: request_body)
|
77
|
+
.will_respond_with(success_response)
|
78
|
+
end
|
79
|
+
|
80
|
+
it "returns a CommandResult with success = true" do
|
81
|
+
expect(subject).to be_a PactBroker::Client::CommandResult
|
82
|
+
expect(subject.success).to be true
|
83
|
+
expect(subject.message).to eq "Webhook \"a webhook\" created"
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
@@ -1,9 +1,7 @@
|
|
1
1
|
require 'service_providers/pact_helper'
|
2
2
|
require 'pact_broker/client/deployments/record_deployment'
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
RSpec.describe "recording a deployment", pact: true, skip: !deployment_feature_on do
|
4
|
+
RSpec.describe "recording a deployment", pact: true do
|
7
5
|
include_context "pact broker"
|
8
6
|
include PactBrokerPactHelperMethods
|
9
7
|
|
@@ -1,9 +1,7 @@
|
|
1
1
|
require 'service_providers/pact_helper'
|
2
2
|
require 'pact_broker/client/deployments/record_deployment'
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
RSpec.describe "recording a release", pact: true, skip: !deployment_feature_on do
|
4
|
+
RSpec.describe "recording a release", pact: true do
|
7
5
|
include_context "pact broker"
|
8
6
|
include PactBrokerPactHelperMethods
|
9
7
|
|
@@ -1,9 +1,7 @@
|
|
1
1
|
require 'service_providers/pact_helper'
|
2
2
|
require 'pact_broker/client/deployments/record_undeployment'
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
RSpec.describe "recording an undeployment", pact: true, skip: !deployment_feature_on do
|
4
|
+
RSpec.describe "recording an undeployment", pact: true do
|
7
5
|
include_context "pact broker"
|
8
6
|
include PactBrokerPactHelperMethods
|
9
7
|
|
@@ -77,7 +75,7 @@ RSpec.describe "recording an undeployment", pact: true, skip: !deployment_featur
|
|
77
75
|
headers: pact_broker_response_headers,
|
78
76
|
body: {
|
79
77
|
_links: {
|
80
|
-
:'pb:currently-deployed-versions' => {
|
78
|
+
:'pb:currently-deployed-deployed-versions' => {
|
81
79
|
href: Pact.term( pact_broker.mock_service_base_url + currently_deployed_versions_placeholder_path, /^http.*/)
|
82
80
|
}
|
83
81
|
}
|
@@ -134,7 +134,7 @@ RSpec.describe "creating a webhook", pact: true do
|
|
134
134
|
context "when an invalid webhook is submitted" do
|
135
135
|
before do
|
136
136
|
params[:url] = nil
|
137
|
-
request_body["request"]
|
137
|
+
request_body["request"].delete("url")
|
138
138
|
|
139
139
|
pact_broker
|
140
140
|
.given("the 'Pricing Service' and 'Condor' already exist in the pact-broker")
|
data/spec/spec_helper.rb
CHANGED
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.48.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-08-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -230,6 +230,7 @@ files:
|
|
230
230
|
- doc/markdown/Pact Broker Client - Pact Broker.md
|
231
231
|
- doc/markdown/README.md
|
232
232
|
- doc/pacts/markdown/Pact Broker Client - Pact Broker.md
|
233
|
+
- doc/pacts/markdown/Pact Broker Client - Pactflow.md
|
233
234
|
- doc/pacts/markdown/README.md
|
234
235
|
- example/scripts/README.md
|
235
236
|
- example/scripts/deploy-consumer.sh
|
@@ -249,9 +250,11 @@ files:
|
|
249
250
|
- lib/pact_broker/client/cli/custom_thor.rb
|
250
251
|
- lib/pact_broker/client/cli/deployment_commands.rb
|
251
252
|
- lib/pact_broker/client/cli/environment_commands.rb
|
253
|
+
- lib/pact_broker/client/cli/matrix_commands.rb
|
252
254
|
- lib/pact_broker/client/cli/pacticipant_commands.rb
|
253
255
|
- lib/pact_broker/client/cli/record_deployment_long_desc.txt
|
254
256
|
- lib/pact_broker/client/cli/version_selector_options_parser.rb
|
257
|
+
- lib/pact_broker/client/cli/webhook_commands.rb
|
255
258
|
- lib/pact_broker/client/colorize_notices.rb
|
256
259
|
- lib/pact_broker/client/command_result.rb
|
257
260
|
- lib/pact_broker/client/create_tag.rb
|
@@ -304,6 +307,7 @@ files:
|
|
304
307
|
- lib/pact_broker/client/string_refinements.rb
|
305
308
|
- lib/pact_broker/client/tasks.rb
|
306
309
|
- lib/pact_broker/client/tasks/publication_task.rb
|
310
|
+
- lib/pact_broker/client/verification_required.rb
|
307
311
|
- lib/pact_broker/client/version.rb
|
308
312
|
- lib/pact_broker/client/versions.rb
|
309
313
|
- lib/pact_broker/client/versions/describe.rb
|
@@ -323,6 +327,7 @@ files:
|
|
323
327
|
- script/record-undeployment.sh
|
324
328
|
- script/release.sh
|
325
329
|
- script/trigger-release.sh
|
330
|
+
- script/webhook-commands.sh
|
326
331
|
- spec/fixtures/approvals/can_i_deploy_failure_dry_run.approved.txt
|
327
332
|
- spec/fixtures/approvals/can_i_deploy_ignore.approved.txt
|
328
333
|
- spec/fixtures/approvals/can_i_deploy_success_dry_run.approved.txt
|
@@ -368,6 +373,7 @@ files:
|
|
368
373
|
- spec/lib/pact_broker/client/versions_spec.rb
|
369
374
|
- spec/lib/pact_broker/client/webhooks/create_spec.rb
|
370
375
|
- spec/pacts/pact_broker_client-pact_broker.json
|
376
|
+
- spec/pacts/pact_broker_client-pactflow.json
|
371
377
|
- spec/service_providers/create_environment_spec.rb
|
372
378
|
- spec/service_providers/extra_goodies_spec.rb
|
373
379
|
- spec/service_providers/list_environments_spec.rb
|
@@ -383,6 +389,7 @@ files:
|
|
383
389
|
- spec/service_providers/pact_broker_client_tags_spec.rb
|
384
390
|
- spec/service_providers/pact_broker_client_versions_spec.rb
|
385
391
|
- spec/service_providers/pact_helper.rb
|
392
|
+
- spec/service_providers/pactflow_webhooks_create_spec.rb
|
386
393
|
- spec/service_providers/pacticipants_create_spec.rb
|
387
394
|
- spec/service_providers/publish_pacts_spec.rb
|
388
395
|
- spec/service_providers/record_deployment_spec.rb
|
@@ -422,7 +429,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
422
429
|
- !ruby/object:Gem::Version
|
423
430
|
version: '0'
|
424
431
|
requirements: []
|
425
|
-
rubygems_version: 3.2.
|
432
|
+
rubygems_version: 3.2.25
|
426
433
|
signing_key:
|
427
434
|
specification_version: 4
|
428
435
|
summary: See description
|
@@ -472,6 +479,7 @@ test_files:
|
|
472
479
|
- spec/lib/pact_broker/client/versions_spec.rb
|
473
480
|
- spec/lib/pact_broker/client/webhooks/create_spec.rb
|
474
481
|
- spec/pacts/pact_broker_client-pact_broker.json
|
482
|
+
- spec/pacts/pact_broker_client-pactflow.json
|
475
483
|
- spec/service_providers/create_environment_spec.rb
|
476
484
|
- spec/service_providers/extra_goodies_spec.rb
|
477
485
|
- spec/service_providers/list_environments_spec.rb
|
@@ -487,6 +495,7 @@ test_files:
|
|
487
495
|
- spec/service_providers/pact_broker_client_tags_spec.rb
|
488
496
|
- spec/service_providers/pact_broker_client_versions_spec.rb
|
489
497
|
- spec/service_providers/pact_helper.rb
|
498
|
+
- spec/service_providers/pactflow_webhooks_create_spec.rb
|
490
499
|
- spec/service_providers/pacticipants_create_spec.rb
|
491
500
|
- spec/service_providers/publish_pacts_spec.rb
|
492
501
|
- spec/service_providers/record_deployment_spec.rb
|