pact_broker-client 1.55.0 → 1.56.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.
- checksums.yaml +4 -4
- data/.github/workflows/test.yml +1 -1
- data/CHANGELOG.md +7 -0
- data/README.md +8 -0
- data/doc/pacts/markdown/Pact Broker Client - Pact Broker.md +222 -0
- data/lib/pact_broker/client/cli/webhook_commands.rb +16 -1
- data/lib/pact_broker/client/environments/environment_command.rb +1 -1
- data/lib/pact_broker/client/version.rb +1 -1
- data/lib/pact_broker/client/webhooks/create.rb +4 -0
- data/spec/lib/pact_broker/client/cli/broker_run_webhook_commands_spec.rb +55 -0
- data/spec/pacts/pact_broker_client-pact_broker.json +234 -0
- data/spec/service_providers/webhooks_create_spec.rb +58 -0
- 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: 449848d07d065628a69bd18154f106f438cadcb51cccd11a3e5214000a17dce2
|
4
|
+
data.tar.gz: 187e875cee98166e6fe85f2bd76314ac642a131a8a4cd48f861694eac5daf002
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 354fb2790242a8b7c64f568306013055f07223fd5f016d441f0fb6addb479ac1ed59467733a5d44264d5800d13500b9b652964cc7fc34341778b5472c5c7e3c0
|
7
|
+
data.tar.gz: 0fc195c4957214522ecce949daaa9b08f84f5024c82ceea0bc16cf197493b6fd042fb1886c1da31dec25767a2ef3fd439eaf6894cb422282b8654901e796f4f1
|
data/.github/workflows/test.yml
CHANGED
@@ -37,7 +37,7 @@ jobs:
|
|
37
37
|
- run: |
|
38
38
|
rm -rf spec/pacts/*
|
39
39
|
bundle exec rspec spec/service_providers/
|
40
|
-
bundle exec rake pact:publish:pactflow
|
40
|
+
VERBOSE=true bundle exec rake pact:publish:pactflow
|
41
41
|
env:
|
42
42
|
PACT_BROKER_TOKEN: ${{ secrets.PACTFLOW_PACT_OSS_TOKEN }}
|
43
43
|
PACT_BROKER_FEATURES: ${{ matrix.feature }}
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -607,8 +607,12 @@ Options:
|
|
607
607
|
# Webhook basic auth username and password eg. username:password
|
608
608
|
[--consumer=CONSUMER]
|
609
609
|
# Consumer name
|
610
|
+
[--consumer-label=CONSUMER_LABEL]
|
611
|
+
# Consumer label
|
610
612
|
[--provider=PROVIDER]
|
611
613
|
# Provider name
|
614
|
+
[--provider-label=PROVIDER_LABEL]
|
615
|
+
# Provider label
|
612
616
|
[--description=DESCRIPTION]
|
613
617
|
# Webhook description
|
614
618
|
[--contract-content-changed], [--no-contract-content-changed]
|
@@ -663,8 +667,12 @@ Options:
|
|
663
667
|
# Webhook basic auth username and password eg. username:password
|
664
668
|
[--consumer=CONSUMER]
|
665
669
|
# Consumer name
|
670
|
+
[--consumer-label=CONSUMER_LABEL]
|
671
|
+
# Consumer label
|
666
672
|
[--provider=PROVIDER]
|
667
673
|
# Provider name
|
674
|
+
[--provider-label=PROVIDER_LABEL]
|
675
|
+
# Provider label
|
668
676
|
[--description=DESCRIPTION]
|
669
677
|
# Webhook description
|
670
678
|
[--contract-content-changed], [--no-contract-content-changed]
|
@@ -64,10 +64,14 @@
|
|
64
64
|
|
65
65
|
* [A request to create a webhook with a JSON body for a consumer and provider](#a_request_to_create_a_webhook_with_a_JSON_body_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
|
66
66
|
|
67
|
+
* [A request to create a webhook with a JSON body for a consumer specified by a label](#a_request_to_create_a_webhook_with_a_JSON_body_for_a_consumer_specified_by_a_label)
|
68
|
+
|
67
69
|
* [A request to create a webhook with a JSON body for a consumer that does not exist](#a_request_to_create_a_webhook_with_a_JSON_body_for_a_consumer_that_does_not_exist)
|
68
70
|
|
69
71
|
* [A request to create a webhook with a JSON body for a provider](#a_request_to_create_a_webhook_with_a_JSON_body_for_a_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
|
70
72
|
|
73
|
+
* [A request to create a webhook with a JSON body for a provider specified by a label](#a_request_to_create_a_webhook_with_a_JSON_body_for_a_provider_specified_by_a_label)
|
74
|
+
|
71
75
|
* [A request to create a webhook with a non-JSON body for a consumer and provider](#a_request_to_create_a_webhook_with_a_non-JSON_body_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
|
72
76
|
|
73
77
|
* [A request to create a webhook with every possible event type](#a_request_to_create_a_webhook_with_every_possible_event_type_given_the_'Pricing_Service'_and_'Condor'_already_exist_in_the_pact-broker) given the 'Pricing Service' and 'Condor' already exist in the pact-broker
|
@@ -1089,6 +1093,16 @@ Pact Broker will respond with:
|
|
1089
1093
|
},
|
1090
1094
|
"body": {
|
1091
1095
|
"description": "a webhook",
|
1096
|
+
"request": {
|
1097
|
+
"body": {
|
1098
|
+
"some": "body"
|
1099
|
+
}
|
1100
|
+
},
|
1101
|
+
"events": [
|
1102
|
+
{
|
1103
|
+
"name": "contract_content_changed"
|
1104
|
+
}
|
1105
|
+
],
|
1092
1106
|
"_links": {
|
1093
1107
|
"self": {
|
1094
1108
|
"href": "http://localhost:1234/some-url",
|
@@ -1222,6 +1236,16 @@ Pact Broker will respond with:
|
|
1222
1236
|
},
|
1223
1237
|
"body": {
|
1224
1238
|
"description": "a webhook",
|
1239
|
+
"request": {
|
1240
|
+
"body": {
|
1241
|
+
"some": "body"
|
1242
|
+
}
|
1243
|
+
},
|
1244
|
+
"events": [
|
1245
|
+
{
|
1246
|
+
"name": "contract_content_changed"
|
1247
|
+
}
|
1248
|
+
],
|
1225
1249
|
"_links": {
|
1226
1250
|
"self": {
|
1227
1251
|
"href": "http://localhost:1234/some-url",
|
@@ -1276,6 +1300,16 @@ Pact Broker will respond with:
|
|
1276
1300
|
},
|
1277
1301
|
"body": {
|
1278
1302
|
"description": "a webhook",
|
1303
|
+
"request": {
|
1304
|
+
"body": {
|
1305
|
+
"some": "body"
|
1306
|
+
}
|
1307
|
+
},
|
1308
|
+
"events": [
|
1309
|
+
{
|
1310
|
+
"name": "contract_content_changed"
|
1311
|
+
}
|
1312
|
+
],
|
1279
1313
|
"_links": {
|
1280
1314
|
"self": {
|
1281
1315
|
"href": "http://localhost:1234/some-url",
|
@@ -1327,6 +1361,80 @@ Pact Broker will respond with:
|
|
1327
1361
|
},
|
1328
1362
|
"body": {
|
1329
1363
|
"description": "a webhook",
|
1364
|
+
"request": {
|
1365
|
+
"body": {
|
1366
|
+
"some": "body"
|
1367
|
+
}
|
1368
|
+
},
|
1369
|
+
"events": [
|
1370
|
+
{
|
1371
|
+
"name": "contract_content_changed"
|
1372
|
+
}
|
1373
|
+
],
|
1374
|
+
"_links": {
|
1375
|
+
"self": {
|
1376
|
+
"href": "http://localhost:1234/some-url",
|
1377
|
+
"title": "A title"
|
1378
|
+
}
|
1379
|
+
}
|
1380
|
+
}
|
1381
|
+
}
|
1382
|
+
```
|
1383
|
+
<a name="a_request_to_create_a_webhook_with_a_JSON_body_for_a_consumer_specified_by_a_label"></a>
|
1384
|
+
Upon receiving **a request to create a webhook with a JSON body for a consumer specified by a label** from Pact Broker Client, with
|
1385
|
+
```json
|
1386
|
+
{
|
1387
|
+
"method": "post",
|
1388
|
+
"path": "/HAL-REL-PLACEHOLDER-PB-WEBHOOKS",
|
1389
|
+
"headers": {
|
1390
|
+
"Content-Type": "application/json",
|
1391
|
+
"Accept": "application/hal+json"
|
1392
|
+
},
|
1393
|
+
"body": {
|
1394
|
+
"description": "a webhook",
|
1395
|
+
"events": [
|
1396
|
+
{
|
1397
|
+
"name": "contract_content_changed"
|
1398
|
+
}
|
1399
|
+
],
|
1400
|
+
"request": {
|
1401
|
+
"url": "https://webhook",
|
1402
|
+
"method": "POST",
|
1403
|
+
"headers": {
|
1404
|
+
"Foo": "bar",
|
1405
|
+
"Bar": "foo"
|
1406
|
+
},
|
1407
|
+
"body": {
|
1408
|
+
"some": "body"
|
1409
|
+
},
|
1410
|
+
"username": "username",
|
1411
|
+
"password": "password"
|
1412
|
+
},
|
1413
|
+
"consumer": {
|
1414
|
+
"label": "consumer_label"
|
1415
|
+
}
|
1416
|
+
}
|
1417
|
+
}
|
1418
|
+
```
|
1419
|
+
Pact Broker will respond with:
|
1420
|
+
```json
|
1421
|
+
{
|
1422
|
+
"status": 201,
|
1423
|
+
"headers": {
|
1424
|
+
"Content-Type": "application/hal+json;charset=utf-8"
|
1425
|
+
},
|
1426
|
+
"body": {
|
1427
|
+
"description": "a webhook",
|
1428
|
+
"request": {
|
1429
|
+
"body": {
|
1430
|
+
"some": "body"
|
1431
|
+
}
|
1432
|
+
},
|
1433
|
+
"events": [
|
1434
|
+
{
|
1435
|
+
"name": "contract_content_changed"
|
1436
|
+
}
|
1437
|
+
],
|
1330
1438
|
"_links": {
|
1331
1439
|
"self": {
|
1332
1440
|
"href": "http://localhost:1234/some-url",
|
@@ -1433,6 +1541,80 @@ Pact Broker will respond with:
|
|
1433
1541
|
},
|
1434
1542
|
"body": {
|
1435
1543
|
"description": "a webhook",
|
1544
|
+
"request": {
|
1545
|
+
"body": {
|
1546
|
+
"some": "body"
|
1547
|
+
}
|
1548
|
+
},
|
1549
|
+
"events": [
|
1550
|
+
{
|
1551
|
+
"name": "contract_content_changed"
|
1552
|
+
}
|
1553
|
+
],
|
1554
|
+
"_links": {
|
1555
|
+
"self": {
|
1556
|
+
"href": "http://localhost:1234/some-url",
|
1557
|
+
"title": "A title"
|
1558
|
+
}
|
1559
|
+
}
|
1560
|
+
}
|
1561
|
+
}
|
1562
|
+
```
|
1563
|
+
<a name="a_request_to_create_a_webhook_with_a_JSON_body_for_a_provider_specified_by_a_label"></a>
|
1564
|
+
Upon receiving **a request to create a webhook with a JSON body for a provider specified by a label** from Pact Broker Client, with
|
1565
|
+
```json
|
1566
|
+
{
|
1567
|
+
"method": "post",
|
1568
|
+
"path": "/HAL-REL-PLACEHOLDER-PB-WEBHOOKS",
|
1569
|
+
"headers": {
|
1570
|
+
"Content-Type": "application/json",
|
1571
|
+
"Accept": "application/hal+json"
|
1572
|
+
},
|
1573
|
+
"body": {
|
1574
|
+
"description": "a webhook",
|
1575
|
+
"events": [
|
1576
|
+
{
|
1577
|
+
"name": "contract_content_changed"
|
1578
|
+
}
|
1579
|
+
],
|
1580
|
+
"request": {
|
1581
|
+
"url": "https://webhook",
|
1582
|
+
"method": "POST",
|
1583
|
+
"headers": {
|
1584
|
+
"Foo": "bar",
|
1585
|
+
"Bar": "foo"
|
1586
|
+
},
|
1587
|
+
"body": {
|
1588
|
+
"some": "body"
|
1589
|
+
},
|
1590
|
+
"username": "username",
|
1591
|
+
"password": "password"
|
1592
|
+
},
|
1593
|
+
"provider": {
|
1594
|
+
"label": "provider_label"
|
1595
|
+
}
|
1596
|
+
}
|
1597
|
+
}
|
1598
|
+
```
|
1599
|
+
Pact Broker will respond with:
|
1600
|
+
```json
|
1601
|
+
{
|
1602
|
+
"status": 201,
|
1603
|
+
"headers": {
|
1604
|
+
"Content-Type": "application/hal+json;charset=utf-8"
|
1605
|
+
},
|
1606
|
+
"body": {
|
1607
|
+
"description": "a webhook",
|
1608
|
+
"request": {
|
1609
|
+
"body": {
|
1610
|
+
"some": "body"
|
1611
|
+
}
|
1612
|
+
},
|
1613
|
+
"events": [
|
1614
|
+
{
|
1615
|
+
"name": "contract_content_changed"
|
1616
|
+
}
|
1617
|
+
],
|
1436
1618
|
"_links": {
|
1437
1619
|
"self": {
|
1438
1620
|
"href": "http://localhost:1234/some-url",
|
@@ -1482,6 +1664,14 @@ Pact Broker will respond with:
|
|
1482
1664
|
},
|
1483
1665
|
"body": {
|
1484
1666
|
"description": "a webhook",
|
1667
|
+
"request": {
|
1668
|
+
"body": "<xml></xml>"
|
1669
|
+
},
|
1670
|
+
"events": [
|
1671
|
+
{
|
1672
|
+
"name": "contract_content_changed"
|
1673
|
+
}
|
1674
|
+
],
|
1485
1675
|
"_links": {
|
1486
1676
|
"self": {
|
1487
1677
|
"href": "http://localhost:1234/some-url",
|
@@ -1545,6 +1735,28 @@ Pact Broker will respond with:
|
|
1545
1735
|
},
|
1546
1736
|
"body": {
|
1547
1737
|
"description": "a webhook",
|
1738
|
+
"request": {
|
1739
|
+
"body": {
|
1740
|
+
"some": "body"
|
1741
|
+
}
|
1742
|
+
},
|
1743
|
+
"events": [
|
1744
|
+
{
|
1745
|
+
"name": "contract_content_changed"
|
1746
|
+
},
|
1747
|
+
{
|
1748
|
+
"name": "contract_published"
|
1749
|
+
},
|
1750
|
+
{
|
1751
|
+
"name": "provider_verification_published"
|
1752
|
+
},
|
1753
|
+
{
|
1754
|
+
"name": "provider_verification_succeeded"
|
1755
|
+
},
|
1756
|
+
{
|
1757
|
+
"name": "provider_verification_failed"
|
1758
|
+
}
|
1759
|
+
],
|
1548
1760
|
"_links": {
|
1549
1761
|
"self": {
|
1550
1762
|
"href": "http://localhost:1234/some-url",
|
@@ -2550,6 +2762,16 @@ Pact Broker will respond with:
|
|
2550
2762
|
},
|
2551
2763
|
"body": {
|
2552
2764
|
"description": "a webhook",
|
2765
|
+
"request": {
|
2766
|
+
"body": {
|
2767
|
+
"some": "body"
|
2768
|
+
}
|
2769
|
+
},
|
2770
|
+
"events": [
|
2771
|
+
{
|
2772
|
+
"name": "contract_content_changed"
|
2773
|
+
}
|
2774
|
+
],
|
2553
2775
|
"_links": {
|
2554
2776
|
"self": {
|
2555
2777
|
"href": "http://localhost:1234/some-url",
|
@@ -15,7 +15,9 @@ module PactBroker
|
|
15
15
|
method_option :data, aliases: "-d", desc: "Webhook payload (file or string)"
|
16
16
|
method_option :user, aliases: "-u", desc: "Webhook basic auth username and password eg. username:password"
|
17
17
|
method_option :consumer, desc: "Consumer name"
|
18
|
+
method_option :consumer_label, desc: "Consumer label, mutually exclusive with consumer name"
|
18
19
|
method_option :provider, desc: "Provider name"
|
20
|
+
method_option :provider_label, desc: "Provider label, mutually exclusive with provider name"
|
19
21
|
method_option :description, desc: "Webhook description"
|
20
22
|
method_option :contract_content_changed, type: :boolean, desc: "Trigger this webhook when the pact content changes"
|
21
23
|
method_option :contract_published, type: :boolean, desc: "Trigger this webhook when a pact is published"
|
@@ -70,6 +72,7 @@ module PactBroker
|
|
70
72
|
end
|
71
73
|
|
72
74
|
def parse_webhook_options(webhook_url)
|
75
|
+
validate_mutual_exclusiveness_of_participant_name_and_label_options
|
73
76
|
events = parse_webhook_events
|
74
77
|
|
75
78
|
# TODO update for contract_requiring_verification_published when released
|
@@ -102,7 +105,9 @@ module PactBroker
|
|
102
105
|
password: password,
|
103
106
|
body: body,
|
104
107
|
consumer: options.consumer,
|
108
|
+
consumer_label: options.consumer_label,
|
105
109
|
provider: options.provider,
|
110
|
+
provider_label: options.provider_label,
|
106
111
|
events: events,
|
107
112
|
team_uuid: options.team_uuid
|
108
113
|
}
|
@@ -118,10 +123,20 @@ module PactBroker
|
|
118
123
|
rescue PactBroker::Client::Error => e
|
119
124
|
raise WebhookCreationError, "#{e.class} - #{e.message}"
|
120
125
|
end
|
126
|
+
|
127
|
+
def validate_mutual_exclusiveness_of_participant_name_and_label_options
|
128
|
+
if options.consumer && options.consumer_label
|
129
|
+
raise WebhookCreationError.new("Consumer name (--consumer) and label (--consumer_label) options are mutually exclusive")
|
130
|
+
end
|
131
|
+
|
132
|
+
if options.provider && options.provider_label
|
133
|
+
raise WebhookCreationError.new("Provider name (--provider) and label (--provider_label) options are mutually exclusive")
|
134
|
+
end
|
135
|
+
end
|
121
136
|
end
|
122
137
|
end
|
123
138
|
end
|
124
139
|
end
|
125
140
|
end
|
126
141
|
end
|
127
|
-
end
|
142
|
+
end
|
@@ -81,10 +81,14 @@ module PactBroker
|
|
81
81
|
|
82
82
|
if params.consumer
|
83
83
|
body[:consumer] = { name: params.consumer }
|
84
|
+
elsif params.consumer_label
|
85
|
+
body[:consumer] = { label: params.consumer_label }
|
84
86
|
end
|
85
87
|
|
86
88
|
if params.provider
|
87
89
|
body[:provider] = { name: params.provider }
|
90
|
+
elsif params.provider_label
|
91
|
+
body[:provider] = { label: params.provider_label }
|
88
92
|
end
|
89
93
|
|
90
94
|
if params.team_uuid
|
@@ -49,7 +49,9 @@ module PactBroker
|
|
49
49
|
password: "password",
|
50
50
|
body: "data",
|
51
51
|
consumer: "consumer",
|
52
|
+
consumer_label: nil,
|
52
53
|
provider: "provider",
|
54
|
+
provider_label: nil,
|
53
55
|
events: ["contract_content_changed"],
|
54
56
|
team_uuid: "1234"
|
55
57
|
}.tap { |it| Pact::Fixture.add_fixture(:create_webhook_params, it) }
|
@@ -223,6 +225,59 @@ module PactBroker
|
|
223
225
|
expect { subject }.to raise_error(WebhookCreationError, /foo/)
|
224
226
|
end
|
225
227
|
end
|
228
|
+
|
229
|
+
end
|
230
|
+
|
231
|
+
context "when both consumer name and label options are specified" do
|
232
|
+
before do
|
233
|
+
options_hash[:consumer_label] = "consumer_label"
|
234
|
+
broker.options = OpenStruct.new(options_hash)
|
235
|
+
end
|
236
|
+
|
237
|
+
it "raises a WebhookCreationError" do
|
238
|
+
expect { subject }.to raise_error(
|
239
|
+
WebhookCreationError,
|
240
|
+
"Consumer name (--consumer) and label (--consumer_label) options are mutually exclusive"
|
241
|
+
)
|
242
|
+
end
|
243
|
+
end
|
244
|
+
|
245
|
+
context "when both provider name and label options are specified" do
|
246
|
+
before do
|
247
|
+
options_hash[:provider_label] = "provider_label"
|
248
|
+
broker.options = OpenStruct.new(options_hash)
|
249
|
+
end
|
250
|
+
|
251
|
+
it "raises a WebhookCreationError" do
|
252
|
+
expect { subject }.to raise_error(
|
253
|
+
WebhookCreationError,
|
254
|
+
"Provider name (--provider) and label (--provider_label) options are mutually exclusive"
|
255
|
+
)
|
256
|
+
end
|
257
|
+
end
|
258
|
+
|
259
|
+
context "when participant labels are specified" do
|
260
|
+
before do
|
261
|
+
options_hash.delete(:consumer)
|
262
|
+
options_hash.delete(:provider)
|
263
|
+
options_hash.merge!(consumer_label: 'consumer_label', provider_label: 'provider_label')
|
264
|
+
expected_params.merge!(
|
265
|
+
consumer: nil,
|
266
|
+
consumer_label: 'consumer_label',
|
267
|
+
provider: nil,
|
268
|
+
provider_label: 'provider_label'
|
269
|
+
)
|
270
|
+
|
271
|
+
broker.options = OpenStruct.new(options_hash)
|
272
|
+
end
|
273
|
+
|
274
|
+
it "calls PactBroker::Client::Webhooks::Create with participant labels in params" do
|
275
|
+
expect(PactBroker::Client::Webhooks::Create).to receive(:call) do | params, _, _ |
|
276
|
+
expect(params).to eq expected_params
|
277
|
+
command_result
|
278
|
+
end
|
279
|
+
subject
|
280
|
+
end
|
226
281
|
end
|
227
282
|
end
|
228
283
|
end
|
@@ -1995,6 +1995,16 @@
|
|
1995
1995
|
},
|
1996
1996
|
"body": {
|
1997
1997
|
"description": "a webhook",
|
1998
|
+
"request": {
|
1999
|
+
"body": {
|
2000
|
+
"some": "body"
|
2001
|
+
}
|
2002
|
+
},
|
2003
|
+
"events": [
|
2004
|
+
{
|
2005
|
+
"name": "contract_content_changed"
|
2006
|
+
}
|
2007
|
+
],
|
1998
2008
|
"_links": {
|
1999
2009
|
"self": {
|
2000
2010
|
"href": "http://localhost:1234/some-url",
|
@@ -2067,6 +2077,28 @@
|
|
2067
2077
|
},
|
2068
2078
|
"body": {
|
2069
2079
|
"description": "a webhook",
|
2080
|
+
"request": {
|
2081
|
+
"body": {
|
2082
|
+
"some": "body"
|
2083
|
+
}
|
2084
|
+
},
|
2085
|
+
"events": [
|
2086
|
+
{
|
2087
|
+
"name": "contract_content_changed"
|
2088
|
+
},
|
2089
|
+
{
|
2090
|
+
"name": "contract_published"
|
2091
|
+
},
|
2092
|
+
{
|
2093
|
+
"name": "provider_verification_published"
|
2094
|
+
},
|
2095
|
+
{
|
2096
|
+
"name": "provider_verification_succeeded"
|
2097
|
+
},
|
2098
|
+
{
|
2099
|
+
"name": "provider_verification_failed"
|
2100
|
+
}
|
2101
|
+
],
|
2070
2102
|
"_links": {
|
2071
2103
|
"self": {
|
2072
2104
|
"href": "http://localhost:1234/some-url",
|
@@ -2125,6 +2157,14 @@
|
|
2125
2157
|
},
|
2126
2158
|
"body": {
|
2127
2159
|
"description": "a webhook",
|
2160
|
+
"request": {
|
2161
|
+
"body": "<xml></xml>"
|
2162
|
+
},
|
2163
|
+
"events": [
|
2164
|
+
{
|
2165
|
+
"name": "contract_content_changed"
|
2166
|
+
}
|
2167
|
+
],
|
2128
2168
|
"_links": {
|
2129
2169
|
"self": {
|
2130
2170
|
"href": "http://localhost:1234/some-url",
|
@@ -2323,6 +2363,88 @@
|
|
2323
2363
|
},
|
2324
2364
|
"body": {
|
2325
2365
|
"description": "a webhook",
|
2366
|
+
"request": {
|
2367
|
+
"body": {
|
2368
|
+
"some": "body"
|
2369
|
+
}
|
2370
|
+
},
|
2371
|
+
"events": [
|
2372
|
+
{
|
2373
|
+
"name": "contract_content_changed"
|
2374
|
+
}
|
2375
|
+
],
|
2376
|
+
"_links": {
|
2377
|
+
"self": {
|
2378
|
+
"href": "http://localhost:1234/some-url",
|
2379
|
+
"title": "A title"
|
2380
|
+
}
|
2381
|
+
}
|
2382
|
+
},
|
2383
|
+
"matchingRules": {
|
2384
|
+
"$.body.description": {
|
2385
|
+
"match": "type"
|
2386
|
+
},
|
2387
|
+
"$.body._links.self.href": {
|
2388
|
+
"match": "regex",
|
2389
|
+
"regex": "http:\\/\\/.*"
|
2390
|
+
},
|
2391
|
+
"$.body._links.self.title": {
|
2392
|
+
"match": "type"
|
2393
|
+
}
|
2394
|
+
}
|
2395
|
+
}
|
2396
|
+
},
|
2397
|
+
{
|
2398
|
+
"description": "a request to create a webhook with a JSON body for a consumer specified by a label",
|
2399
|
+
"request": {
|
2400
|
+
"method": "post",
|
2401
|
+
"path": "/HAL-REL-PLACEHOLDER-PB-WEBHOOKS",
|
2402
|
+
"headers": {
|
2403
|
+
"Content-Type": "application/json",
|
2404
|
+
"Accept": "application/hal+json"
|
2405
|
+
},
|
2406
|
+
"body": {
|
2407
|
+
"description": "a webhook",
|
2408
|
+
"events": [
|
2409
|
+
{
|
2410
|
+
"name": "contract_content_changed"
|
2411
|
+
}
|
2412
|
+
],
|
2413
|
+
"request": {
|
2414
|
+
"url": "https://webhook",
|
2415
|
+
"method": "POST",
|
2416
|
+
"headers": {
|
2417
|
+
"Foo": "bar",
|
2418
|
+
"Bar": "foo"
|
2419
|
+
},
|
2420
|
+
"body": {
|
2421
|
+
"some": "body"
|
2422
|
+
},
|
2423
|
+
"username": "username",
|
2424
|
+
"password": "password"
|
2425
|
+
},
|
2426
|
+
"consumer": {
|
2427
|
+
"label": "consumer_label"
|
2428
|
+
}
|
2429
|
+
}
|
2430
|
+
},
|
2431
|
+
"response": {
|
2432
|
+
"status": 201,
|
2433
|
+
"headers": {
|
2434
|
+
"Content-Type": "application/hal+json;charset=utf-8"
|
2435
|
+
},
|
2436
|
+
"body": {
|
2437
|
+
"description": "a webhook",
|
2438
|
+
"request": {
|
2439
|
+
"body": {
|
2440
|
+
"some": "body"
|
2441
|
+
}
|
2442
|
+
},
|
2443
|
+
"events": [
|
2444
|
+
{
|
2445
|
+
"name": "contract_content_changed"
|
2446
|
+
}
|
2447
|
+
],
|
2326
2448
|
"_links": {
|
2327
2449
|
"self": {
|
2328
2450
|
"href": "http://localhost:1234/some-url",
|
@@ -2442,6 +2564,88 @@
|
|
2442
2564
|
},
|
2443
2565
|
"body": {
|
2444
2566
|
"description": "a webhook",
|
2567
|
+
"request": {
|
2568
|
+
"body": {
|
2569
|
+
"some": "body"
|
2570
|
+
}
|
2571
|
+
},
|
2572
|
+
"events": [
|
2573
|
+
{
|
2574
|
+
"name": "contract_content_changed"
|
2575
|
+
}
|
2576
|
+
],
|
2577
|
+
"_links": {
|
2578
|
+
"self": {
|
2579
|
+
"href": "http://localhost:1234/some-url",
|
2580
|
+
"title": "A title"
|
2581
|
+
}
|
2582
|
+
}
|
2583
|
+
},
|
2584
|
+
"matchingRules": {
|
2585
|
+
"$.body.description": {
|
2586
|
+
"match": "type"
|
2587
|
+
},
|
2588
|
+
"$.body._links.self.href": {
|
2589
|
+
"match": "regex",
|
2590
|
+
"regex": "http:\\/\\/.*"
|
2591
|
+
},
|
2592
|
+
"$.body._links.self.title": {
|
2593
|
+
"match": "type"
|
2594
|
+
}
|
2595
|
+
}
|
2596
|
+
}
|
2597
|
+
},
|
2598
|
+
{
|
2599
|
+
"description": "a request to create a webhook with a JSON body for a provider specified by a label",
|
2600
|
+
"request": {
|
2601
|
+
"method": "post",
|
2602
|
+
"path": "/HAL-REL-PLACEHOLDER-PB-WEBHOOKS",
|
2603
|
+
"headers": {
|
2604
|
+
"Content-Type": "application/json",
|
2605
|
+
"Accept": "application/hal+json"
|
2606
|
+
},
|
2607
|
+
"body": {
|
2608
|
+
"description": "a webhook",
|
2609
|
+
"events": [
|
2610
|
+
{
|
2611
|
+
"name": "contract_content_changed"
|
2612
|
+
}
|
2613
|
+
],
|
2614
|
+
"request": {
|
2615
|
+
"url": "https://webhook",
|
2616
|
+
"method": "POST",
|
2617
|
+
"headers": {
|
2618
|
+
"Foo": "bar",
|
2619
|
+
"Bar": "foo"
|
2620
|
+
},
|
2621
|
+
"body": {
|
2622
|
+
"some": "body"
|
2623
|
+
},
|
2624
|
+
"username": "username",
|
2625
|
+
"password": "password"
|
2626
|
+
},
|
2627
|
+
"provider": {
|
2628
|
+
"label": "provider_label"
|
2629
|
+
}
|
2630
|
+
}
|
2631
|
+
},
|
2632
|
+
"response": {
|
2633
|
+
"status": 201,
|
2634
|
+
"headers": {
|
2635
|
+
"Content-Type": "application/hal+json;charset=utf-8"
|
2636
|
+
},
|
2637
|
+
"body": {
|
2638
|
+
"description": "a webhook",
|
2639
|
+
"request": {
|
2640
|
+
"body": {
|
2641
|
+
"some": "body"
|
2642
|
+
}
|
2643
|
+
},
|
2644
|
+
"events": [
|
2645
|
+
{
|
2646
|
+
"name": "contract_content_changed"
|
2647
|
+
}
|
2648
|
+
],
|
2445
2649
|
"_links": {
|
2446
2650
|
"self": {
|
2447
2651
|
"href": "http://localhost:1234/some-url",
|
@@ -2501,6 +2705,16 @@
|
|
2501
2705
|
},
|
2502
2706
|
"body": {
|
2503
2707
|
"description": "a webhook",
|
2708
|
+
"request": {
|
2709
|
+
"body": {
|
2710
|
+
"some": "body"
|
2711
|
+
}
|
2712
|
+
},
|
2713
|
+
"events": [
|
2714
|
+
{
|
2715
|
+
"name": "contract_content_changed"
|
2716
|
+
}
|
2717
|
+
],
|
2504
2718
|
"_links": {
|
2505
2719
|
"self": {
|
2506
2720
|
"href": "http://localhost:1234/some-url",
|
@@ -2597,6 +2811,16 @@
|
|
2597
2811
|
},
|
2598
2812
|
"body": {
|
2599
2813
|
"description": "a webhook",
|
2814
|
+
"request": {
|
2815
|
+
"body": {
|
2816
|
+
"some": "body"
|
2817
|
+
}
|
2818
|
+
},
|
2819
|
+
"events": [
|
2820
|
+
{
|
2821
|
+
"name": "contract_content_changed"
|
2822
|
+
}
|
2823
|
+
],
|
2600
2824
|
"_links": {
|
2601
2825
|
"self": {
|
2602
2826
|
"href": "http://localhost:1234/some-url",
|
@@ -2663,6 +2887,16 @@
|
|
2663
2887
|
},
|
2664
2888
|
"body": {
|
2665
2889
|
"description": "a webhook",
|
2890
|
+
"request": {
|
2891
|
+
"body": {
|
2892
|
+
"some": "body"
|
2893
|
+
}
|
2894
|
+
},
|
2895
|
+
"events": [
|
2896
|
+
{
|
2897
|
+
"name": "contract_content_changed"
|
2898
|
+
}
|
2899
|
+
],
|
2666
2900
|
"_links": {
|
2667
2901
|
"self": {
|
2668
2902
|
"href": "http://localhost:1234/some-url",
|
@@ -54,6 +54,14 @@ RSpec.describe "creating a webhook", pact: true do
|
|
54
54
|
headers: pact_broker_response_headers,
|
55
55
|
body: {
|
56
56
|
description: Pact.like("a webhook"),
|
57
|
+
request: {
|
58
|
+
body: {
|
59
|
+
some: "body"
|
60
|
+
}
|
61
|
+
},
|
62
|
+
events: [
|
63
|
+
name: "contract_content_changed"
|
64
|
+
],
|
57
65
|
_links: {
|
58
66
|
self: {
|
59
67
|
href: Pact.term('http://localhost:1234/some-url', %r{http://.*}),
|
@@ -92,6 +100,7 @@ RSpec.describe "creating a webhook", pact: true do
|
|
92
100
|
before do
|
93
101
|
params.merge!(events: event_names)
|
94
102
|
request_body.merge!("events" => event_names.map{ |event_name| { "name" => event_name } })
|
103
|
+
success_response[:body].merge!(events: event_names.map{ |event_name| { "name" => event_name } })
|
95
104
|
|
96
105
|
pact_broker
|
97
106
|
.given("the 'Pricing Service' and 'Condor' already exist in the pact-broker")
|
@@ -112,6 +121,7 @@ RSpec.describe "creating a webhook", pact: true do
|
|
112
121
|
context "when a valid webhook with an XML body is submitted" do
|
113
122
|
before do
|
114
123
|
request_body["request"]["body"] = body
|
124
|
+
success_response[:body][:request][:body] = body
|
115
125
|
|
116
126
|
pact_broker
|
117
127
|
.given("the 'Pricing Service' and 'Condor' already exist in the pact-broker")
|
@@ -207,6 +217,30 @@ RSpec.describe "creating a webhook", pact: true do
|
|
207
217
|
end
|
208
218
|
end
|
209
219
|
|
220
|
+
context "when consumer is specified using a label" do
|
221
|
+
before do
|
222
|
+
params.delete(:consumer)
|
223
|
+
params.delete(:provider)
|
224
|
+
params.merge!(consumer_label: "consumer_label")
|
225
|
+
request_body["consumer"] = { "label" => "consumer_label" }
|
226
|
+
mock_pact_broker_index(self)
|
227
|
+
|
228
|
+
pact_broker
|
229
|
+
.upon_receiving("a request to create a webhook with a JSON body for a consumer specified by a label")
|
230
|
+
.with(
|
231
|
+
method: :post,
|
232
|
+
path: placeholder_path('pb:webhooks'),
|
233
|
+
headers: post_request_headers,
|
234
|
+
body: request_body)
|
235
|
+
.will_respond_with(success_response)
|
236
|
+
end
|
237
|
+
|
238
|
+
it "returns a CommandResult with success = true" do
|
239
|
+
expect(subject.success).to be true
|
240
|
+
expect(subject.message).to eq "Webhook \"a webhook\" created"
|
241
|
+
end
|
242
|
+
end
|
243
|
+
|
210
244
|
context "when only a consumer is specified and it does not exist" do
|
211
245
|
before do
|
212
246
|
params.delete(:provider)
|
@@ -257,6 +291,30 @@ RSpec.describe "creating a webhook", pact: true do
|
|
257
291
|
end
|
258
292
|
end
|
259
293
|
|
294
|
+
context "when provider is specified using a label" do
|
295
|
+
before do
|
296
|
+
params.delete(:consumer)
|
297
|
+
params.delete(:provider)
|
298
|
+
params.merge!(provider_label: "provider_label")
|
299
|
+
request_body["provider"] = { "label" => "provider_label" }
|
300
|
+
mock_pact_broker_index(self)
|
301
|
+
|
302
|
+
pact_broker
|
303
|
+
.upon_receiving("a request to create a webhook with a JSON body for a provider specified by a label")
|
304
|
+
.with(
|
305
|
+
method: :post,
|
306
|
+
path: placeholder_path('pb:webhooks'),
|
307
|
+
headers: post_request_headers,
|
308
|
+
body: request_body)
|
309
|
+
.will_respond_with(success_response)
|
310
|
+
end
|
311
|
+
|
312
|
+
it "returns a CommandResult with success = true" do
|
313
|
+
expect(subject.success).to be true
|
314
|
+
expect(subject.message).to eq "Webhook \"a webhook\" created"
|
315
|
+
end
|
316
|
+
end
|
317
|
+
|
260
318
|
context "when neither consumer nor provider are specified" do
|
261
319
|
before do
|
262
320
|
params.delete(:consumer)
|
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.56.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-10-
|
11
|
+
date: 2021-10-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|