pact_broker-client 1.50.0 → 1.51.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/doc/pacts/markdown/Pact Broker Client - Pact Broker.md +100 -0
- data/lib/pact_broker/client/publish_pacts.rb +5 -6
- data/lib/pact_broker/client/version.rb +1 -1
- data/script/publish-pact.sh +1 -1
- data/spec/pacts/pact_broker_client-pact_broker.json +106 -0
- data/spec/service_providers/publish_pacts_spec.rb +3 -6
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 854312863c664ff8f355fcab3d2cb3733bf7c229f75b98aa9f2f9187a93d5409
|
|
4
|
+
data.tar.gz: c02cfe9055664950a2811e3351c701431e5a6916a6a06e21e34aab14ee94520c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d5be4a8a3fc89a6606aac689d9da2a335393d0ef8e0b01e7f09c5745798c475ff1b53be34b00284c00e0cadaffecd834a75d03cca9805c8b386e2c9f223af8ec
|
|
7
|
+
data.tar.gz: dc9192512acf2a696f635274b504042a960c8d3eded2ae7b07e17e1dc982de0badc177686fb62d9516d9976cc5d9a5fd9564b4d02bf47f6ad2bcc3e56576a590
|
data/.github/workflows/test.yml
CHANGED
data/CHANGELOG.md
CHANGED
|
@@ -42,6 +42,8 @@
|
|
|
42
42
|
|
|
43
43
|
* [A request for the index resource](#a_request_for_the_index_resource_given_the_pb:pacticipant-version_relation_exists_in_the_index_resource) given the pb:pacticipant-version relation exists in the index resource
|
|
44
44
|
|
|
45
|
+
* [A request for the index resource](#a_request_for_the_index_resource_given_the_pb:publish-contracts_relations_exists_in_the_index_resource) given the pb:publish-contracts relations exists in the index resource
|
|
46
|
+
|
|
45
47
|
* [A request for the index resource with the webhook relation](#a_request_for_the_index_resource_with_the_webhook_relation)
|
|
46
48
|
|
|
47
49
|
* [A request for the list of the latest pacts from all consumers for the Pricing Service'](#a_request_for_the_list_of_the_latest_pacts_from_all_consumers_for_the_Pricing_Service'_given_a_latest_pact_between_Condor_and_the_Pricing_Service_exists) given a latest pact between Condor and the Pricing Service exists
|
|
@@ -100,6 +102,8 @@
|
|
|
100
102
|
|
|
101
103
|
* [A request to publish a pact with method put](#a_request_to_publish_a_pact_with_method_put_given_the_'Pricing_Service'_and_'Condor'_already_exist_in_the_pact-broker,_and_Condor_already_has_a_pact_published_for_version_1.3.0) given the 'Pricing Service' and 'Condor' already exist in the pact-broker, and Condor already has a pact published for version 1.3.0
|
|
102
104
|
|
|
105
|
+
* [A request to publish contracts](#a_request_to_publish_contracts)
|
|
106
|
+
|
|
103
107
|
* [A request to record a deployment](#a_request_to_record_a_deployment_given_version_5556b8149bf8bac76bc30f50a8a2dd4c22c85f30_of_pacticipant_Foo_exists_with_a_test_environment_available_for_deployment) given version 5556b8149bf8bac76bc30f50a8a2dd4c22c85f30 of pacticipant Foo exists with a test environment available for deployment
|
|
104
108
|
|
|
105
109
|
* [A request to record a release](#a_request_to_record_a_release_given_version_5556b8149bf8bac76bc30f50a8a2dd4c22c85f30_of_pacticipant_Foo_exists_with_a_test_environment_available_for_deployment) given version 5556b8149bf8bac76bc30f50a8a2dd4c22c85f30 of pacticipant Foo exists with a test environment available for deployment
|
|
@@ -882,6 +886,33 @@ Pact Broker will respond with:
|
|
|
882
886
|
}
|
|
883
887
|
}
|
|
884
888
|
```
|
|
889
|
+
<a name="a_request_for_the_index_resource_given_the_pb:publish-contracts_relations_exists_in_the_index_resource"></a>
|
|
890
|
+
Given **the pb:publish-contracts relations exists in the index resource**, upon receiving **a request for the index resource** from Pact Broker Client, with
|
|
891
|
+
```json
|
|
892
|
+
{
|
|
893
|
+
"method": "GET",
|
|
894
|
+
"path": "/",
|
|
895
|
+
"headers": {
|
|
896
|
+
"Accept": "application/hal+json"
|
|
897
|
+
}
|
|
898
|
+
}
|
|
899
|
+
```
|
|
900
|
+
Pact Broker will respond with:
|
|
901
|
+
```json
|
|
902
|
+
{
|
|
903
|
+
"status": 200,
|
|
904
|
+
"headers": {
|
|
905
|
+
"Content-Type": "application/hal+json;charset=utf-8"
|
|
906
|
+
},
|
|
907
|
+
"body": {
|
|
908
|
+
"_links": {
|
|
909
|
+
"pb:publish-contracts": {
|
|
910
|
+
"href": "http://localhost:1234/HAL-REL-PLACEHOLDER-PB-PUBLISH-CONTRACTS"
|
|
911
|
+
}
|
|
912
|
+
}
|
|
913
|
+
}
|
|
914
|
+
}
|
|
915
|
+
```
|
|
885
916
|
<a name="a_request_for_the_index_resource_with_the_webhook_relation"></a>
|
|
886
917
|
Upon receiving **a request for the index resource with the webhook relation** from Pact Broker Client, with
|
|
887
918
|
```json
|
|
@@ -2119,6 +2150,75 @@ Pact Broker will respond with:
|
|
|
2119
2150
|
}
|
|
2120
2151
|
}
|
|
2121
2152
|
```
|
|
2153
|
+
<a name="a_request_to_publish_contracts"></a>
|
|
2154
|
+
Upon receiving **a request to publish contracts** from Pact Broker Client, with
|
|
2155
|
+
```json
|
|
2156
|
+
{
|
|
2157
|
+
"method": "POST",
|
|
2158
|
+
"path": "/HAL-REL-PLACEHOLDER-PB-PUBLISH-CONTRACTS",
|
|
2159
|
+
"headers": {
|
|
2160
|
+
"Content-Type": "application/json",
|
|
2161
|
+
"Accept": "application/hal+json"
|
|
2162
|
+
},
|
|
2163
|
+
"body": {
|
|
2164
|
+
"pacticipantName": "Foo",
|
|
2165
|
+
"pacticipantVersionNumber": "5556b8149bf8bac76bc30f50a8a2dd4c22c85f30",
|
|
2166
|
+
"branch": "main",
|
|
2167
|
+
"tags": [
|
|
2168
|
+
"dev"
|
|
2169
|
+
],
|
|
2170
|
+
"buildUrl": "http://build",
|
|
2171
|
+
"contracts": [
|
|
2172
|
+
{
|
|
2173
|
+
"consumerName": "Foo",
|
|
2174
|
+
"providerName": "Bar",
|
|
2175
|
+
"specification": "pact",
|
|
2176
|
+
"contentType": "application/json",
|
|
2177
|
+
"content": "eyJjb25zdW1lciI6eyJuYW1lIjoiRm9vIn0sInByb3ZpZGVyIjp7Im5hbWUiOiJCYXIifSwiaW50ZXJhY3Rpb25zIjpbeyJkZXNjcmlwdGlvbiI6ImFuIGV4YW1wbGUgcmVxdWVzdCIsInByb3ZpZGVyU3RhdGUiOiJhIHByb3ZpZGVyIHN0YXRlIiwicmVxdWVzdCI6eyJtZXRob2QiOiJHRVQiLCJwYXRoIjoiLyIsImhlYWRlcnMiOnt9fSwicmVzcG9uc2UiOnsic3RhdHVzIjoyMDAsImhlYWRlcnMiOnsiQ29udGVudC1UeXBlIjoiYXBwbGljYXRpb24vaGFsK2pzb24ifX19XSwibWV0YWRhdGEiOnsicGFjdFNwZWNpZmljYXRpb24iOnsidmVyc2lvbiI6IjIuMC4wIn19fQ==",
|
|
2178
|
+
"onConflict": "merge"
|
|
2179
|
+
}
|
|
2180
|
+
]
|
|
2181
|
+
}
|
|
2182
|
+
}
|
|
2183
|
+
```
|
|
2184
|
+
Pact Broker will respond with:
|
|
2185
|
+
```json
|
|
2186
|
+
{
|
|
2187
|
+
"status": 200,
|
|
2188
|
+
"headers": {
|
|
2189
|
+
"Content-Type": "application/hal+json;charset=utf-8"
|
|
2190
|
+
},
|
|
2191
|
+
"body": {
|
|
2192
|
+
"_embedded": {
|
|
2193
|
+
"pacticipant": {
|
|
2194
|
+
"name": "Foo"
|
|
2195
|
+
},
|
|
2196
|
+
"version": {
|
|
2197
|
+
"number": "5556b8149bf8bac76bc30f50a8a2dd4c22c85f30",
|
|
2198
|
+
"buildUrl": "http://build"
|
|
2199
|
+
}
|
|
2200
|
+
},
|
|
2201
|
+
"logs": [
|
|
2202
|
+
{
|
|
2203
|
+
"level": "info",
|
|
2204
|
+
"message": "some message"
|
|
2205
|
+
}
|
|
2206
|
+
],
|
|
2207
|
+
"_links": {
|
|
2208
|
+
"pb:pacticipant-version-tags": [
|
|
2209
|
+
{
|
|
2210
|
+
"name": "dev"
|
|
2211
|
+
}
|
|
2212
|
+
],
|
|
2213
|
+
"pb:contracts": [
|
|
2214
|
+
{
|
|
2215
|
+
"href": "http://some-pact"
|
|
2216
|
+
}
|
|
2217
|
+
]
|
|
2218
|
+
}
|
|
2219
|
+
}
|
|
2220
|
+
}
|
|
2221
|
+
```
|
|
2122
2222
|
<a name="a_request_to_record_a_deployment_given_version_5556b8149bf8bac76bc30f50a8a2dd4c22c85f30_of_pacticipant_Foo_exists_with_a_test_environment_available_for_deployment"></a>
|
|
2123
2223
|
Given **version 5556b8149bf8bac76bc30f50a8a2dd4c22c85f30 of pacticipant Foo exists with a test environment available for deployment**, upon receiving **a request to record a deployment** from Pact Broker Client, with
|
|
2124
2224
|
```json
|
|
@@ -28,7 +28,7 @@ module PactBroker
|
|
|
28
28
|
|
|
29
29
|
def call
|
|
30
30
|
validate
|
|
31
|
-
if
|
|
31
|
+
if index_resource.can?("pb:publish-contracts")
|
|
32
32
|
publish_pacts
|
|
33
33
|
PactBroker::Client::CommandResult.new(success?, message)
|
|
34
34
|
else
|
|
@@ -115,9 +115,8 @@ module PactBroker
|
|
|
115
115
|
specification: "pact",
|
|
116
116
|
contentType: "application/json",
|
|
117
117
|
content: Base64.strict_encode64(pact_hash.to_json),
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
}
|
|
118
|
+
onConflict: on_conflict
|
|
119
|
+
}.compact
|
|
121
120
|
end
|
|
122
121
|
end
|
|
123
122
|
|
|
@@ -137,8 +136,8 @@ module PactBroker
|
|
|
137
136
|
pact_files.collect(&:consumer_name).uniq
|
|
138
137
|
end
|
|
139
138
|
|
|
140
|
-
def
|
|
141
|
-
options[:merge] ? "merge" :
|
|
139
|
+
def on_conflict
|
|
140
|
+
options[:merge] ? "merge" : nil
|
|
142
141
|
end
|
|
143
142
|
|
|
144
143
|
def validate
|
data/script/publish-pact.sh
CHANGED
|
@@ -28,7 +28,7 @@ bundle exec bin/pact-broker create-or-update-webhook http://localhost:9393 \
|
|
|
28
28
|
# --contract-published
|
|
29
29
|
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
bundle exec bin/pact-broker publish spec/pacts/pact_broker_client-pact_broker.json \
|
|
32
32
|
--consumer-app-version 1.2.26 \
|
|
33
33
|
--broker-base-url http://localhost:9292 \
|
|
34
34
|
--broker-token localhost \
|
|
@@ -1636,6 +1636,112 @@
|
|
|
1636
1636
|
}
|
|
1637
1637
|
}
|
|
1638
1638
|
},
|
|
1639
|
+
{
|
|
1640
|
+
"description": "a request for the index resource",
|
|
1641
|
+
"providerState": "the pb:publish-contracts relations exists in the index resource",
|
|
1642
|
+
"request": {
|
|
1643
|
+
"method": "GET",
|
|
1644
|
+
"path": "/",
|
|
1645
|
+
"headers": {
|
|
1646
|
+
"Accept": "application/hal+json"
|
|
1647
|
+
}
|
|
1648
|
+
},
|
|
1649
|
+
"response": {
|
|
1650
|
+
"status": 200,
|
|
1651
|
+
"headers": {
|
|
1652
|
+
"Content-Type": "application/hal+json;charset=utf-8"
|
|
1653
|
+
},
|
|
1654
|
+
"body": {
|
|
1655
|
+
"_links": {
|
|
1656
|
+
"pb:publish-contracts": {
|
|
1657
|
+
"href": "http://localhost:1234/HAL-REL-PLACEHOLDER-PB-PUBLISH-CONTRACTS"
|
|
1658
|
+
}
|
|
1659
|
+
}
|
|
1660
|
+
},
|
|
1661
|
+
"matchingRules": {
|
|
1662
|
+
"$.body._links.pb:publish-contracts.href": {
|
|
1663
|
+
"match": "regex",
|
|
1664
|
+
"regex": "http:\\/\\/.*"
|
|
1665
|
+
}
|
|
1666
|
+
}
|
|
1667
|
+
}
|
|
1668
|
+
},
|
|
1669
|
+
{
|
|
1670
|
+
"description": "a request to publish contracts",
|
|
1671
|
+
"request": {
|
|
1672
|
+
"method": "POST",
|
|
1673
|
+
"path": "/HAL-REL-PLACEHOLDER-PB-PUBLISH-CONTRACTS",
|
|
1674
|
+
"headers": {
|
|
1675
|
+
"Content-Type": "application/json",
|
|
1676
|
+
"Accept": "application/hal+json"
|
|
1677
|
+
},
|
|
1678
|
+
"body": {
|
|
1679
|
+
"pacticipantName": "Foo",
|
|
1680
|
+
"pacticipantVersionNumber": "5556b8149bf8bac76bc30f50a8a2dd4c22c85f30",
|
|
1681
|
+
"branch": "main",
|
|
1682
|
+
"tags": [
|
|
1683
|
+
"dev"
|
|
1684
|
+
],
|
|
1685
|
+
"buildUrl": "http://build",
|
|
1686
|
+
"contracts": [
|
|
1687
|
+
{
|
|
1688
|
+
"consumerName": "Foo",
|
|
1689
|
+
"providerName": "Bar",
|
|
1690
|
+
"specification": "pact",
|
|
1691
|
+
"contentType": "application/json",
|
|
1692
|
+
"content": "eyJjb25zdW1lciI6eyJuYW1lIjoiRm9vIn0sInByb3ZpZGVyIjp7Im5hbWUiOiJCYXIifSwiaW50ZXJhY3Rpb25zIjpbeyJkZXNjcmlwdGlvbiI6ImFuIGV4YW1wbGUgcmVxdWVzdCIsInByb3ZpZGVyU3RhdGUiOiJhIHByb3ZpZGVyIHN0YXRlIiwicmVxdWVzdCI6eyJtZXRob2QiOiJHRVQiLCJwYXRoIjoiLyIsImhlYWRlcnMiOnt9fSwicmVzcG9uc2UiOnsic3RhdHVzIjoyMDAsImhlYWRlcnMiOnsiQ29udGVudC1UeXBlIjoiYXBwbGljYXRpb24vaGFsK2pzb24ifX19XSwibWV0YWRhdGEiOnsicGFjdFNwZWNpZmljYXRpb24iOnsidmVyc2lvbiI6IjIuMC4wIn19fQ==",
|
|
1693
|
+
"onConflict": "merge"
|
|
1694
|
+
}
|
|
1695
|
+
]
|
|
1696
|
+
}
|
|
1697
|
+
},
|
|
1698
|
+
"response": {
|
|
1699
|
+
"status": 200,
|
|
1700
|
+
"headers": {
|
|
1701
|
+
"Content-Type": "application/hal+json;charset=utf-8"
|
|
1702
|
+
},
|
|
1703
|
+
"body": {
|
|
1704
|
+
"_embedded": {
|
|
1705
|
+
"pacticipant": {
|
|
1706
|
+
"name": "Foo"
|
|
1707
|
+
},
|
|
1708
|
+
"version": {
|
|
1709
|
+
"number": "5556b8149bf8bac76bc30f50a8a2dd4c22c85f30",
|
|
1710
|
+
"buildUrl": "http://build"
|
|
1711
|
+
}
|
|
1712
|
+
},
|
|
1713
|
+
"logs": [
|
|
1714
|
+
{
|
|
1715
|
+
"level": "info",
|
|
1716
|
+
"message": "some message"
|
|
1717
|
+
}
|
|
1718
|
+
],
|
|
1719
|
+
"_links": {
|
|
1720
|
+
"pb:pacticipant-version-tags": [
|
|
1721
|
+
{
|
|
1722
|
+
"name": "dev"
|
|
1723
|
+
}
|
|
1724
|
+
],
|
|
1725
|
+
"pb:contracts": [
|
|
1726
|
+
{
|
|
1727
|
+
"href": "http://some-pact"
|
|
1728
|
+
}
|
|
1729
|
+
]
|
|
1730
|
+
}
|
|
1731
|
+
},
|
|
1732
|
+
"matchingRules": {
|
|
1733
|
+
"$.body.logs": {
|
|
1734
|
+
"min": 1
|
|
1735
|
+
},
|
|
1736
|
+
"$.body.logs[*].*": {
|
|
1737
|
+
"match": "type"
|
|
1738
|
+
},
|
|
1739
|
+
"$.body._links.pb:contracts[0].href": {
|
|
1740
|
+
"match": "type"
|
|
1741
|
+
}
|
|
1742
|
+
}
|
|
1743
|
+
}
|
|
1744
|
+
},
|
|
1639
1745
|
{
|
|
1640
1746
|
"description": "a request for the index resource",
|
|
1641
1747
|
"providerState": "the pb:pacticipant-version and pb:environments relations exist in the index resource",
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
require 'pact_broker/client/publish_pacts'
|
|
2
2
|
require 'service_providers/pact_helper'
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
RSpec.describe "publishing contracts", pact: true, skip: !publish_contracts_feature_on do
|
|
4
|
+
RSpec.describe "publishing contracts", pact: true do
|
|
7
5
|
before do
|
|
8
6
|
allow_any_instance_of(PactBroker::Client::Hal::HttpClient).to receive(:sleep)
|
|
9
7
|
allow_any_instance_of(PactBroker::Client::Hal::HttpClient).to receive(:default_max_tries).and_return(1)
|
|
@@ -27,7 +25,7 @@ RSpec.describe "publishing contracts", pact: true, skip: !publish_contracts_feat
|
|
|
27
25
|
end
|
|
28
26
|
let(:pact_file_path_1) { "spec/fixtures/foo-bar.json" }
|
|
29
27
|
let(:pact_file_paths) { [pact_file_path_1] }
|
|
30
|
-
let(:options) { {} }
|
|
28
|
+
let(:options) { { merge: true } }
|
|
31
29
|
let(:pact_broker_client_options) { {} }
|
|
32
30
|
let(:expected_content) { Base64.strict_encode64(JSON.parse(File.read(pact_file_path_1)).to_json) }
|
|
33
31
|
let(:request_body) do
|
|
@@ -44,8 +42,7 @@ RSpec.describe "publishing contracts", pact: true, skip: !publish_contracts_feat
|
|
|
44
42
|
specification: "pact",
|
|
45
43
|
contentType: "application/json",
|
|
46
44
|
content: expected_content,
|
|
47
|
-
|
|
48
|
-
onConflict: "overwrite"
|
|
45
|
+
onConflict: "merge"
|
|
49
46
|
}
|
|
50
47
|
]
|
|
51
48
|
}
|
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.51.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-09-21 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: httparty
|
|
@@ -431,7 +431,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
431
431
|
- !ruby/object:Gem::Version
|
|
432
432
|
version: '0'
|
|
433
433
|
requirements: []
|
|
434
|
-
rubygems_version: 3.2.
|
|
434
|
+
rubygems_version: 3.2.27
|
|
435
435
|
signing_key:
|
|
436
436
|
specification_version: 4
|
|
437
437
|
summary: See description
|