pact_broker-client 1.25.0 → 1.25.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +16 -0
- data/doc/pacts/markdown/Pact Broker Client - Pact Broker.md +66 -0
- data/lib/pact_broker/client/cli/broker.rb +1 -0
- data/lib/pact_broker/client/cli/custom_thor.rb +24 -13
- data/lib/pact_broker/client/hal/entity.rb +1 -3
- data/lib/pact_broker/client/hal/link.rb +1 -1
- data/lib/pact_broker/client/version.rb +1 -1
- data/lib/pact_broker/client/webhooks/create.rb +7 -1
- data/spec/lib/pact_broker/client/cli/broker_run_webhook_commands_spec.rb +2 -0
- data/spec/lib/pact_broker/client/cli/custom_thor_spec.rb +6 -0
- data/spec/lib/pact_broker/client/hal/entity_spec.rb +1 -0
- data/spec/lib/pact_broker/client/webhooks/create_spec.rb +22 -0
- data/spec/pacts/pact_broker_client-pact_broker.json +94 -0
- data/spec/service_providers/webhooks_create_spec.rb +46 -17
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7c78c1aac0ad2d50892f581f5bf0bb77b4b73e32b1ae359ae94a62eb4d62855b
|
4
|
+
data.tar.gz: 509cc602635703e5ff07520ef5b0163ff47ed4cbaadebca33de0ebced3d34bdd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 38988ea9692c16df96c3ba1c18cbd2509286efede5b7e72d2561540ffeb78e0d5e442a83aacd26f2ca61f4939a2e4458130bcdc0f605e1711c304590f281e9e0
|
7
|
+
data.tar.gz: 2efd70539e123a3b2b7ffbe7f2c691f497ba4dc1034fb25d4fd5800faa4cae50bbd2960ba3a87a149decb5127bdc7621873f51d60ab48dc988f5059bad3a6125
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,19 @@
|
|
1
|
+
<a name="v1.25.1"></a>
|
2
|
+
### v1.25.1 (2020-04-02)
|
3
|
+
|
4
|
+
|
5
|
+
#### Features
|
6
|
+
|
7
|
+
* **create-or-update-webhook**
|
8
|
+
* print 'created' or 'updated' based on response status ([0c34090](/../../commit/0c34090))
|
9
|
+
|
10
|
+
|
11
|
+
#### Bug Fixes
|
12
|
+
|
13
|
+
* incorrect require path for hal entity ([64f3b7b](/../../commit/64f3b7b))
|
14
|
+
* correctly handle multiple parameters specified in the format --name=value ([946001b](/../../commit/946001b))
|
15
|
+
|
16
|
+
|
1
17
|
<a name="v1.25.0"></a>
|
2
18
|
### v1.25.0 (2020-02-18)
|
3
19
|
|
@@ -92,6 +92,8 @@
|
|
92
92
|
|
93
93
|
* [A request to tag the production version of Condor](#a_request_to_tag_the_production_version_of_Condor_given_'Condor'_exists_in_the_pact-broker) given 'Condor' exists in the pact-broker
|
94
94
|
|
95
|
+
* [A request to update a webhook](#a_request_to_update_a_webhook_given_a_webhook_with_the_uuid_696c5f93-1b7f-44bc-8d03-59440fcaa9a0_exists) given a webhook with the uuid 696c5f93-1b7f-44bc-8d03-59440fcaa9a0 exists
|
96
|
+
|
95
97
|
* [An invalid request to create a webhook for a consumer and provider](#an_invalid_request_to_create_a_webhook_for_a_consumer_and_provider_given_the_'Pricing_Service'_and_'Condor'_already_exist_in_the_pact-broker) given the 'Pricing Service' and 'Condor' already exist in the pact-broker
|
96
98
|
|
97
99
|
#### Interactions
|
@@ -766,6 +768,7 @@ Pact Broker will respond with:
|
|
766
768
|
"Content-Type": "application/hal+json;charset=utf-8"
|
767
769
|
},
|
768
770
|
"body": {
|
771
|
+
"description": "a webhook",
|
769
772
|
"_links": {
|
770
773
|
"self": {
|
771
774
|
"href": "http://localhost:1234/some-url",
|
@@ -864,6 +867,7 @@ Pact Broker will respond with:
|
|
864
867
|
"Content-Type": "application/hal+json;charset=utf-8"
|
865
868
|
},
|
866
869
|
"body": {
|
870
|
+
"description": "a webhook",
|
867
871
|
"_links": {
|
868
872
|
"self": {
|
869
873
|
"href": "http://localhost:1234/some-url",
|
@@ -917,6 +921,7 @@ Pact Broker will respond with:
|
|
917
921
|
"Content-Type": "application/hal+json;charset=utf-8"
|
918
922
|
},
|
919
923
|
"body": {
|
924
|
+
"description": "a webhook",
|
920
925
|
"_links": {
|
921
926
|
"self": {
|
922
927
|
"href": "http://localhost:1234/some-url",
|
@@ -967,6 +972,7 @@ Pact Broker will respond with:
|
|
967
972
|
"Content-Type": "application/hal+json;charset=utf-8"
|
968
973
|
},
|
969
974
|
"body": {
|
975
|
+
"description": "a webhook",
|
970
976
|
"_links": {
|
971
977
|
"self": {
|
972
978
|
"href": "http://localhost:1234/some-url",
|
@@ -1072,6 +1078,7 @@ Pact Broker will respond with:
|
|
1072
1078
|
"Content-Type": "application/hal+json;charset=utf-8"
|
1073
1079
|
},
|
1074
1080
|
"body": {
|
1081
|
+
"description": "a webhook",
|
1075
1082
|
"_links": {
|
1076
1083
|
"self": {
|
1077
1084
|
"href": "http://localhost:1234/some-url",
|
@@ -1120,6 +1127,7 @@ Pact Broker will respond with:
|
|
1120
1127
|
"Content-Type": "application/hal+json;charset=utf-8"
|
1121
1128
|
},
|
1122
1129
|
"body": {
|
1130
|
+
"description": "a webhook",
|
1123
1131
|
"_links": {
|
1124
1132
|
"self": {
|
1125
1133
|
"href": "http://localhost:1234/some-url",
|
@@ -1182,6 +1190,7 @@ Pact Broker will respond with:
|
|
1182
1190
|
"Content-Type": "application/hal+json;charset=utf-8"
|
1183
1191
|
},
|
1184
1192
|
"body": {
|
1193
|
+
"description": "a webhook",
|
1185
1194
|
"_links": {
|
1186
1195
|
"self": {
|
1187
1196
|
"href": "http://localhost:1234/some-url",
|
@@ -1800,6 +1809,63 @@ Pact Broker will respond with:
|
|
1800
1809
|
}
|
1801
1810
|
}
|
1802
1811
|
```
|
1812
|
+
<a name="a_request_to_update_a_webhook_given_a_webhook_with_the_uuid_696c5f93-1b7f-44bc-8d03-59440fcaa9a0_exists"></a>
|
1813
|
+
Given **a webhook with the uuid 696c5f93-1b7f-44bc-8d03-59440fcaa9a0 exists**, upon receiving **a request to update a webhook** from Pact Broker Client, with
|
1814
|
+
```json
|
1815
|
+
{
|
1816
|
+
"method": "put",
|
1817
|
+
"path": "/webhooks/696c5f93-1b7f-44bc-8d03-59440fcaa9a0",
|
1818
|
+
"headers": {
|
1819
|
+
"Content-Type": "application/json",
|
1820
|
+
"Accept": "application/hal+json"
|
1821
|
+
},
|
1822
|
+
"body": {
|
1823
|
+
"description": "a webhook",
|
1824
|
+
"events": [
|
1825
|
+
{
|
1826
|
+
"name": "contract_content_changed"
|
1827
|
+
}
|
1828
|
+
],
|
1829
|
+
"request": {
|
1830
|
+
"url": "https://webhook",
|
1831
|
+
"method": "POST",
|
1832
|
+
"headers": {
|
1833
|
+
"Foo": "bar",
|
1834
|
+
"Bar": "foo"
|
1835
|
+
},
|
1836
|
+
"body": {
|
1837
|
+
"some": "body"
|
1838
|
+
},
|
1839
|
+
"username": "username",
|
1840
|
+
"password": "password"
|
1841
|
+
},
|
1842
|
+
"provider": {
|
1843
|
+
"name": "Pricing Service"
|
1844
|
+
},
|
1845
|
+
"consumer": {
|
1846
|
+
"name": "Condor"
|
1847
|
+
}
|
1848
|
+
}
|
1849
|
+
}
|
1850
|
+
```
|
1851
|
+
Pact Broker will respond with:
|
1852
|
+
```json
|
1853
|
+
{
|
1854
|
+
"status": 200,
|
1855
|
+
"headers": {
|
1856
|
+
"Content-Type": "application/hal+json;charset=utf-8"
|
1857
|
+
},
|
1858
|
+
"body": {
|
1859
|
+
"description": "a webhook",
|
1860
|
+
"_links": {
|
1861
|
+
"self": {
|
1862
|
+
"href": "http://localhost:1234/some-url",
|
1863
|
+
"title": "A title"
|
1864
|
+
}
|
1865
|
+
}
|
1866
|
+
}
|
1867
|
+
}
|
1868
|
+
```
|
1803
1869
|
<a name="an_invalid_request_to_create_a_webhook_for_a_consumer_and_provider_given_the_'Pricing_Service'_and_'Condor'_already_exist_in_the_pact-broker"></a>
|
1804
1870
|
Given **the 'Pricing Service' and 'Condor' already exist in the pact-broker**, upon receiving **an invalid request to create a webhook for a consumer and provider** from Pact Broker Client, with
|
1805
1871
|
```json
|
@@ -45,20 +45,31 @@ module PactBroker
|
|
45
45
|
def self.turn_muliple_tag_options_into_array argv
|
46
46
|
new_argv = []
|
47
47
|
opt_name = nil
|
48
|
-
argv.each_with_index do |
|
49
|
-
if
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
new_argv
|
48
|
+
argv.each_with_index do | word, i |
|
49
|
+
if word.start_with?('-')
|
50
|
+
if word.include?('=')
|
51
|
+
opt_name, opt_value = word.split('=', 2)
|
52
|
+
|
53
|
+
existing = new_argv.find { | a | a.first == opt_name }
|
54
|
+
if existing
|
55
|
+
existing << opt_value
|
56
|
+
else
|
57
|
+
new_argv << [opt_name, opt_value]
|
58
|
+
end
|
59
|
+
else
|
60
|
+
opt_name = word
|
61
|
+
existing = new_argv.find { | a | a.first == opt_name }
|
62
|
+
if !existing
|
63
|
+
new_argv << [word]
|
64
|
+
end
|
54
65
|
end
|
55
66
|
else
|
56
67
|
if opt_name
|
57
68
|
existing = new_argv.find { | a | a.first == opt_name }
|
58
|
-
existing <<
|
69
|
+
existing << word
|
59
70
|
opt_name = nil
|
60
71
|
else
|
61
|
-
new_argv << [
|
72
|
+
new_argv << [word]
|
62
73
|
end
|
63
74
|
end
|
64
75
|
end
|
@@ -76,17 +87,17 @@ module PactBroker
|
|
76
87
|
end
|
77
88
|
|
78
89
|
def self.shared_options_for_webhook_commands
|
79
|
-
method_option :request, banner: "METHOD", aliases: "-X", desc: "HTTP method", required: true
|
80
|
-
method_option :header, aliases: "-H", type: :array, desc: "Header"
|
81
|
-
method_option :data, aliases: "-d", desc: "
|
82
|
-
method_option :user, aliases: "-u", desc: "
|
90
|
+
method_option :request, banner: "METHOD", aliases: "-X", desc: "Webhook HTTP method", required: true
|
91
|
+
method_option :header, aliases: "-H", type: :array, desc: "Webhook Header"
|
92
|
+
method_option :data, aliases: "-d", desc: "Webhook payload (file or string)"
|
93
|
+
method_option :user, aliases: "-u", desc: "Webhook basic auth username and password eg. username:password"
|
83
94
|
method_option :consumer, desc: "Consumer name"
|
84
95
|
method_option :provider, desc: "Provider name"
|
85
96
|
method_option :broker_base_url, required: true, aliases: "-b", desc: "The base URL of the Pact Broker"
|
86
97
|
method_option :broker_username, desc: "Pact Broker basic auth username"
|
87
98
|
method_option :broker_password, aliases: "-p", desc: "Pact Broker basic auth password"
|
88
99
|
method_option :broker_token, aliases: "-k", desc: "Pact Broker bearer token"
|
89
|
-
method_option :description, desc: "
|
100
|
+
method_option :description, desc: "Wwebhook description"
|
90
101
|
method_option :contract_content_changed, type: :boolean, desc: "Trigger this webhook when the pact content changes"
|
91
102
|
method_option :contract_published, type: :boolean, desc: "Trigger this webhook when a pact is published"
|
92
103
|
method_option :provider_verification_published, type: :boolean, desc: "Trigger this webhook when a provider verification result is published"
|
@@ -6,11 +6,9 @@ module PactBroker
|
|
6
6
|
module Client
|
7
7
|
module Hal
|
8
8
|
class RelationNotFoundError < ::PactBroker::Client::Error; end
|
9
|
-
|
10
9
|
class ErrorResponseReturned < ::PactBroker::Client::Error; end
|
11
10
|
|
12
11
|
class Entity
|
13
|
-
|
14
12
|
def initialize(href, data, http_client, response = nil)
|
15
13
|
@href = href
|
16
14
|
@data = data
|
@@ -71,7 +69,7 @@ module PactBroker
|
|
71
69
|
elsif @links.key?(method_name)
|
72
70
|
Link.new(@links[method_name], @client).run(*args)
|
73
71
|
else
|
74
|
-
|
72
|
+
nil
|
75
73
|
end
|
76
74
|
end
|
77
75
|
|
@@ -62,7 +62,7 @@ module PactBroker
|
|
62
62
|
private
|
63
63
|
|
64
64
|
def wrap_response(href, http_response)
|
65
|
-
require '
|
65
|
+
require 'pact_broker/client/hal/entity' # avoid circular reference
|
66
66
|
if http_response.success?
|
67
67
|
Entity.new(href, http_response.body, @http_client, http_response)
|
68
68
|
else
|
@@ -101,7 +101,13 @@ module PactBroker
|
|
101
101
|
end
|
102
102
|
|
103
103
|
def success_result(webhook_entity)
|
104
|
-
|
104
|
+
action = webhook_entity.response.status == 201 ? "created" : "updated"
|
105
|
+
name = if webhook_entity.description && webhook_entity.description.size > 0
|
106
|
+
webhook_entity.description
|
107
|
+
else
|
108
|
+
webhook_entity._link('self').title_or_name
|
109
|
+
end
|
110
|
+
CommandResult.new(true, "Webhook #{name.inspect} #{action}")
|
105
111
|
end
|
106
112
|
|
107
113
|
def error_result(message)
|
@@ -22,6 +22,7 @@ module PactBroker
|
|
22
22
|
let(:options_hash) do
|
23
23
|
{
|
24
24
|
uuid: '9999',
|
25
|
+
description: "some webhook",
|
25
26
|
request: "POST",
|
26
27
|
header: header,
|
27
28
|
data: data,
|
@@ -39,6 +40,7 @@ module PactBroker
|
|
39
40
|
let(:expected_params) do
|
40
41
|
{
|
41
42
|
uuid: '9999',
|
43
|
+
description: "some webhook",
|
42
44
|
http_method: "POST",
|
43
45
|
url: "http://webhook",
|
44
46
|
headers: { "Foo" => "bar", "Bar" => "foo"},
|
@@ -109,6 +109,12 @@ module PactBroker::Client::CLI
|
|
109
109
|
expect(TestThor.turn_muliple_tag_options_into_array(input)).to eq output
|
110
110
|
end
|
111
111
|
|
112
|
+
it "turns '--tag=foo --tag=bar' into '--tag foo bar'" do
|
113
|
+
input = %w{--ignore this --tag=foo --tag=bar --wiffle --that}
|
114
|
+
output = %w{--ignore this --tag foo bar --wiffle --that }
|
115
|
+
expect(TestThor.turn_muliple_tag_options_into_array(input)).to eq output
|
116
|
+
end
|
117
|
+
|
112
118
|
it "doesn't change anything when there are no duplicate options" do
|
113
119
|
input = %w{--ignore this --taggy foo --blah bar --wiffle --that}
|
114
120
|
expect(TestThor.turn_muliple_tag_options_into_array(input)).to eq input
|
@@ -70,6 +70,28 @@ module PactBroker
|
|
70
70
|
expect(subject.message).to match /"some":"error"/
|
71
71
|
end
|
72
72
|
end
|
73
|
+
|
74
|
+
context "when there is an empty description returned" do
|
75
|
+
let!(:webhook_request) do
|
76
|
+
stub_request(:post, "http://broker/webhooks").to_return(status: 200, body: response_body.to_json, headers: { "Content-Type" => "application/hal+json" })
|
77
|
+
end
|
78
|
+
|
79
|
+
let(:response_body) do
|
80
|
+
{
|
81
|
+
description: "",
|
82
|
+
_links: {
|
83
|
+
self: {
|
84
|
+
href: "href",
|
85
|
+
title: "the title"
|
86
|
+
}
|
87
|
+
}
|
88
|
+
}
|
89
|
+
end
|
90
|
+
|
91
|
+
it "uses the self title in the message instead" do
|
92
|
+
expect(subject.message).to include "the title"
|
93
|
+
end
|
94
|
+
end
|
73
95
|
end
|
74
96
|
end
|
75
97
|
end
|
@@ -1287,6 +1287,7 @@
|
|
1287
1287
|
"Content-Type": "application/hal+json;charset=utf-8"
|
1288
1288
|
},
|
1289
1289
|
"body": {
|
1290
|
+
"description": "a webhook",
|
1290
1291
|
"_links": {
|
1291
1292
|
"self": {
|
1292
1293
|
"href": "http://localhost:1234/some-url",
|
@@ -1295,6 +1296,9 @@
|
|
1295
1296
|
}
|
1296
1297
|
},
|
1297
1298
|
"matchingRules": {
|
1299
|
+
"$.body.description": {
|
1300
|
+
"match": "type"
|
1301
|
+
},
|
1298
1302
|
"$.body._links.self.href": {
|
1299
1303
|
"match": "regex",
|
1300
1304
|
"regex": "http:\\/\\/.*"
|
@@ -1355,6 +1359,7 @@
|
|
1355
1359
|
"Content-Type": "application/hal+json;charset=utf-8"
|
1356
1360
|
},
|
1357
1361
|
"body": {
|
1362
|
+
"description": "a webhook",
|
1358
1363
|
"_links": {
|
1359
1364
|
"self": {
|
1360
1365
|
"href": "http://localhost:1234/some-url",
|
@@ -1363,6 +1368,9 @@
|
|
1363
1368
|
}
|
1364
1369
|
},
|
1365
1370
|
"matchingRules": {
|
1371
|
+
"$.body.description": {
|
1372
|
+
"match": "type"
|
1373
|
+
},
|
1366
1374
|
"$.body._links.self.href": {
|
1367
1375
|
"match": "regex",
|
1368
1376
|
"regex": "http:\\/\\/.*"
|
@@ -1409,6 +1417,7 @@
|
|
1409
1417
|
"Content-Type": "application/hal+json;charset=utf-8"
|
1410
1418
|
},
|
1411
1419
|
"body": {
|
1420
|
+
"description": "a webhook",
|
1412
1421
|
"_links": {
|
1413
1422
|
"self": {
|
1414
1423
|
"href": "http://localhost:1234/some-url",
|
@@ -1417,6 +1426,9 @@
|
|
1417
1426
|
}
|
1418
1427
|
},
|
1419
1428
|
"matchingRules": {
|
1429
|
+
"$.body.description": {
|
1430
|
+
"match": "type"
|
1431
|
+
},
|
1420
1432
|
"$.body._links.self.href": {
|
1421
1433
|
"match": "regex",
|
1422
1434
|
"regex": "http:\\/\\/.*"
|
@@ -1590,6 +1602,7 @@
|
|
1590
1602
|
"Content-Type": "application/hal+json;charset=utf-8"
|
1591
1603
|
},
|
1592
1604
|
"body": {
|
1605
|
+
"description": "a webhook",
|
1593
1606
|
"_links": {
|
1594
1607
|
"self": {
|
1595
1608
|
"href": "http://localhost:1234/some-url",
|
@@ -1598,6 +1611,9 @@
|
|
1598
1611
|
}
|
1599
1612
|
},
|
1600
1613
|
"matchingRules": {
|
1614
|
+
"$.body.description": {
|
1615
|
+
"match": "type"
|
1616
|
+
},
|
1601
1617
|
"$.body._links.self.href": {
|
1602
1618
|
"match": "regex",
|
1603
1619
|
"regex": "http:\\/\\/.*"
|
@@ -1705,6 +1721,7 @@
|
|
1705
1721
|
"Content-Type": "application/hal+json;charset=utf-8"
|
1706
1722
|
},
|
1707
1723
|
"body": {
|
1724
|
+
"description": "a webhook",
|
1708
1725
|
"_links": {
|
1709
1726
|
"self": {
|
1710
1727
|
"href": "http://localhost:1234/some-url",
|
@@ -1713,6 +1730,9 @@
|
|
1713
1730
|
}
|
1714
1731
|
},
|
1715
1732
|
"matchingRules": {
|
1733
|
+
"$.body.description": {
|
1734
|
+
"match": "type"
|
1735
|
+
},
|
1716
1736
|
"$.body._links.self.href": {
|
1717
1737
|
"match": "regex",
|
1718
1738
|
"regex": "http:\\/\\/.*"
|
@@ -1760,6 +1780,7 @@
|
|
1760
1780
|
"Content-Type": "application/hal+json;charset=utf-8"
|
1761
1781
|
},
|
1762
1782
|
"body": {
|
1783
|
+
"description": "a webhook",
|
1763
1784
|
"_links": {
|
1764
1785
|
"self": {
|
1765
1786
|
"href": "http://localhost:1234/some-url",
|
@@ -1768,6 +1789,9 @@
|
|
1768
1789
|
}
|
1769
1790
|
},
|
1770
1791
|
"matchingRules": {
|
1792
|
+
"$.body.description": {
|
1793
|
+
"match": "type"
|
1794
|
+
},
|
1771
1795
|
"$.body._links.self.href": {
|
1772
1796
|
"match": "regex",
|
1773
1797
|
"regex": "http:\\/\\/.*"
|
@@ -1852,6 +1876,73 @@
|
|
1852
1876
|
"Content-Type": "application/hal+json;charset=utf-8"
|
1853
1877
|
},
|
1854
1878
|
"body": {
|
1879
|
+
"description": "a webhook",
|
1880
|
+
"_links": {
|
1881
|
+
"self": {
|
1882
|
+
"href": "http://localhost:1234/some-url",
|
1883
|
+
"title": "A title"
|
1884
|
+
}
|
1885
|
+
}
|
1886
|
+
},
|
1887
|
+
"matchingRules": {
|
1888
|
+
"$.body.description": {
|
1889
|
+
"match": "type"
|
1890
|
+
},
|
1891
|
+
"$.body._links.self.href": {
|
1892
|
+
"match": "regex",
|
1893
|
+
"regex": "http:\\/\\/.*"
|
1894
|
+
},
|
1895
|
+
"$.body._links.self.title": {
|
1896
|
+
"match": "type"
|
1897
|
+
}
|
1898
|
+
}
|
1899
|
+
}
|
1900
|
+
},
|
1901
|
+
{
|
1902
|
+
"description": "a request to update a webhook",
|
1903
|
+
"providerState": "a webhook with the uuid 696c5f93-1b7f-44bc-8d03-59440fcaa9a0 exists",
|
1904
|
+
"request": {
|
1905
|
+
"method": "put",
|
1906
|
+
"path": "/webhooks/696c5f93-1b7f-44bc-8d03-59440fcaa9a0",
|
1907
|
+
"headers": {
|
1908
|
+
"Content-Type": "application/json",
|
1909
|
+
"Accept": "application/hal+json"
|
1910
|
+
},
|
1911
|
+
"body": {
|
1912
|
+
"description": "a webhook",
|
1913
|
+
"events": [
|
1914
|
+
{
|
1915
|
+
"name": "contract_content_changed"
|
1916
|
+
}
|
1917
|
+
],
|
1918
|
+
"request": {
|
1919
|
+
"url": "https://webhook",
|
1920
|
+
"method": "POST",
|
1921
|
+
"headers": {
|
1922
|
+
"Foo": "bar",
|
1923
|
+
"Bar": "foo"
|
1924
|
+
},
|
1925
|
+
"body": {
|
1926
|
+
"some": "body"
|
1927
|
+
},
|
1928
|
+
"username": "username",
|
1929
|
+
"password": "password"
|
1930
|
+
},
|
1931
|
+
"provider": {
|
1932
|
+
"name": "Pricing Service"
|
1933
|
+
},
|
1934
|
+
"consumer": {
|
1935
|
+
"name": "Condor"
|
1936
|
+
}
|
1937
|
+
}
|
1938
|
+
},
|
1939
|
+
"response": {
|
1940
|
+
"status": 200,
|
1941
|
+
"headers": {
|
1942
|
+
"Content-Type": "application/hal+json;charset=utf-8"
|
1943
|
+
},
|
1944
|
+
"body": {
|
1945
|
+
"description": "a webhook",
|
1855
1946
|
"_links": {
|
1856
1947
|
"self": {
|
1857
1948
|
"href": "http://localhost:1234/some-url",
|
@@ -1860,6 +1951,9 @@
|
|
1860
1951
|
}
|
1861
1952
|
},
|
1862
1953
|
"matchingRules": {
|
1954
|
+
"$.body.description": {
|
1955
|
+
"match": "type"
|
1956
|
+
},
|
1863
1957
|
"$.body._links.self.href": {
|
1864
1958
|
"match": "regex",
|
1865
1959
|
"regex": "http:\\/\\/.*"
|
@@ -47,11 +47,13 @@ RSpec.describe "creating a webhook", pact: true do
|
|
47
47
|
}
|
48
48
|
end
|
49
49
|
|
50
|
+
let(:response_status) { 201 }
|
50
51
|
let(:success_response) do
|
51
52
|
{
|
52
|
-
status:
|
53
|
+
status: response_status,
|
53
54
|
headers: pact_broker_response_headers,
|
54
55
|
body: {
|
56
|
+
description: Pact.like("a webhook"),
|
55
57
|
_links: {
|
56
58
|
self: {
|
57
59
|
href: Pact.term('http://localhost:1234/some-url', %r{http://.*}),
|
@@ -82,7 +84,7 @@ RSpec.describe "creating a webhook", pact: true do
|
|
82
84
|
it "returns a CommandResult with success = true" do
|
83
85
|
expect(subject).to be_a PactBroker::Client::CommandResult
|
84
86
|
expect(subject.success).to be true
|
85
|
-
expect(subject.message).to eq "Webhook \"
|
87
|
+
expect(subject.message).to eq "Webhook \"a webhook\" created"
|
86
88
|
end
|
87
89
|
end
|
88
90
|
|
@@ -201,7 +203,7 @@ RSpec.describe "creating a webhook", pact: true do
|
|
201
203
|
|
202
204
|
it "returns a CommandResult with success = true" do
|
203
205
|
expect(subject.success).to be true
|
204
|
-
expect(subject.message).to eq "Webhook \"
|
206
|
+
expect(subject.message).to eq "Webhook \"a webhook\" created"
|
205
207
|
end
|
206
208
|
end
|
207
209
|
|
@@ -282,23 +284,50 @@ RSpec.describe "creating a webhook", pact: true do
|
|
282
284
|
request_body["provider"] = { "name" => "Pricing Service" }
|
283
285
|
request_body["consumer"] = { "name" => "Condor" }
|
284
286
|
mock_pact_broker_index_with_webhook_relation(self)
|
285
|
-
|
286
|
-
pact_broker
|
287
|
-
.upon_receiving("a request to create a webhook with a JSON body and a uuid")
|
288
|
-
.given("the 'Pricing Service' and 'Condor' already exist in the pact-broker")
|
289
|
-
.with(
|
290
|
-
method: :put,
|
291
|
-
path: "/webhooks/#{uuid}",
|
292
|
-
headers: put_request_headers,
|
293
|
-
body: request_body)
|
294
|
-
.will_respond_with(success_response)
|
295
287
|
end
|
288
|
+
|
296
289
|
let(:uuid) { '696c5f93-1b7f-44bc-8d03-59440fcaa9a0' }
|
297
290
|
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
291
|
+
context "when the webhook does not already exist" do
|
292
|
+
before do
|
293
|
+
pact_broker
|
294
|
+
.upon_receiving("a request to create a webhook with a JSON body and a uuid")
|
295
|
+
.given("the 'Pricing Service' and 'Condor' already exist in the pact-broker")
|
296
|
+
.with(
|
297
|
+
method: :put,
|
298
|
+
path: "/webhooks/#{uuid}",
|
299
|
+
headers: put_request_headers,
|
300
|
+
body: request_body)
|
301
|
+
.will_respond_with(success_response)
|
302
|
+
end
|
303
|
+
|
304
|
+
it "returns a CommandResult with success = true" do
|
305
|
+
expect(subject).to be_a PactBroker::Client::CommandResult
|
306
|
+
expect(subject.success).to be true
|
307
|
+
expect(subject.message).to eq "Webhook \"a webhook\" created"
|
308
|
+
end
|
309
|
+
end
|
310
|
+
|
311
|
+
context "when the webhook does exist" do
|
312
|
+
before do
|
313
|
+
pact_broker
|
314
|
+
.upon_receiving("a request to update a webhook")
|
315
|
+
.given("a webhook with the uuid #{uuid} exists")
|
316
|
+
.with(
|
317
|
+
method: :put,
|
318
|
+
path: "/webhooks/#{uuid}",
|
319
|
+
headers: put_request_headers,
|
320
|
+
body: request_body)
|
321
|
+
.will_respond_with(success_response)
|
322
|
+
end
|
323
|
+
|
324
|
+
let(:response_status) { 200 }
|
325
|
+
|
326
|
+
it "returns a CommandResult with success = true" do
|
327
|
+
expect(subject).to be_a PactBroker::Client::CommandResult
|
328
|
+
expect(subject.success).to be true
|
329
|
+
expect(subject.message).to eq "Webhook \"a webhook\" updated"
|
330
|
+
end
|
302
331
|
end
|
303
332
|
end
|
304
333
|
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.25.
|
4
|
+
version: 1.25.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Beth Skurrie
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-02
|
11
|
+
date: 2020-04-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|