pact_broker-client 1.77.0 → 1.78.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/.ruby-version +1 -1
- data/CHANGELOG.md +12 -0
- data/Dockerfile +1 -1
- data/Gemfile +14 -4
- data/Rakefile +5 -0
- data/doc/pacts/markdown/Pact Broker Client - Pact Broker.md +15 -208
- data/doc/pacts/markdown/Pact Broker Client - PactFlow.md +1 -1
- data/doc/pacts/markdown/Pact Broker Client V2 - Pact Broker.md +2799 -0
- data/doc/pacts/markdown/Pact Broker Client V2 - PactFlow.md +267 -0
- data/doc/pacts/markdown/README.md +1 -1
- data/lib/pact_broker/client/base_client.rb +15 -3
- data/lib/pact_broker/client/hal/http_client.rb +4 -0
- data/lib/pact_broker/client/user_agent.rb +20 -0
- data/lib/pact_broker/client/version.rb +1 -1
- data/lib/pact_broker/client/versions.rb +1 -1
- metadata +6 -7
- data/script/ci/delete-branch-in-pactflow.sh +0 -22
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
### A pact between Pact Broker Client V2 and PactFlow
|
|
2
|
+
|
|
3
|
+
#### Requests from Pact Broker Client V2 to PactFlow
|
|
4
|
+
|
|
5
|
+
* [A request for the index resource](#a_request_for_the_index_resource)
|
|
6
|
+
|
|
7
|
+
* [A request for the index resource](#a_request_for_the_index_resource_given_the_pb:publish-provider-contract_relation_exists_in_the_index_resource) given the pb:publish-provider-contract relation exists in the index resource
|
|
8
|
+
|
|
9
|
+
* [A request to create a provider contract](#a_request_to_create_a_provider_contract)
|
|
10
|
+
|
|
11
|
+
* [A request to create a provider contract](#a_request_to_create_a_provider_contract_given_there_is_a_pf:ui_href_in_the_response) given there is a pf:ui href in the response
|
|
12
|
+
|
|
13
|
+
* [A request to create a webhook for a team](#a_request_to_create_a_webhook_for_a_team_given_a_team_with_UUID_2abbc12a-427d-432a-a521-c870af1739d9_exists) given a team with UUID 2abbc12a-427d-432a-a521-c870af1739d9 exists
|
|
14
|
+
|
|
15
|
+
* [A request to publish a provider contract](#a_request_to_publish_a_provider_contract)
|
|
16
|
+
|
|
17
|
+
#### Interactions
|
|
18
|
+
|
|
19
|
+
<a name="a_request_for_the_index_resource"></a>
|
|
20
|
+
Upon receiving **a request for the index resource** from Pact Broker Client V2, with
|
|
21
|
+
```json
|
|
22
|
+
{
|
|
23
|
+
"method": "GET",
|
|
24
|
+
"path": "/",
|
|
25
|
+
"headers": {
|
|
26
|
+
"Accept": "application/hal+json"
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
```
|
|
30
|
+
PactFlow will respond with:
|
|
31
|
+
```json
|
|
32
|
+
{
|
|
33
|
+
"status": 200,
|
|
34
|
+
"headers": {
|
|
35
|
+
"Content-Type": "application/hal+json;charset=utf-8"
|
|
36
|
+
},
|
|
37
|
+
"body": {
|
|
38
|
+
"_links": {
|
|
39
|
+
"pb:pacticipant": {
|
|
40
|
+
"href": "/pacticipants/{pacticipant}"
|
|
41
|
+
},
|
|
42
|
+
"pb:pacticipants": {
|
|
43
|
+
"href": "/pacticipants"
|
|
44
|
+
},
|
|
45
|
+
"pb:webhooks": {
|
|
46
|
+
"href": "/webhooks"
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
```
|
|
52
|
+
<a name="a_request_for_the_index_resource_given_the_pb:publish-provider-contract_relation_exists_in_the_index_resource"></a>
|
|
53
|
+
Given **the pb:publish-provider-contract relation exists in the index resource**, upon receiving **a request for the index resource** from Pact Broker Client V2, with
|
|
54
|
+
```json
|
|
55
|
+
{
|
|
56
|
+
"method": "GET",
|
|
57
|
+
"path": "/",
|
|
58
|
+
"headers": {
|
|
59
|
+
"Accept": "application/hal+json"
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
```
|
|
63
|
+
PactFlow will respond with:
|
|
64
|
+
```json
|
|
65
|
+
{
|
|
66
|
+
"status": 200,
|
|
67
|
+
"headers": {
|
|
68
|
+
"Content-Type": "application/hal+json;charset=utf-8"
|
|
69
|
+
},
|
|
70
|
+
"body": {
|
|
71
|
+
"_links": {
|
|
72
|
+
"pf:publish-provider-contract": {
|
|
73
|
+
"href": "/provider-contracts/provider/{provider}/publish"
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
```
|
|
79
|
+
<a name="a_request_to_create_a_provider_contract"></a>
|
|
80
|
+
Upon receiving **a request to create a provider contract** from Pact Broker Client V2, with
|
|
81
|
+
```json
|
|
82
|
+
{
|
|
83
|
+
"method": "PUT",
|
|
84
|
+
"path": "/contracts/provider/Bar/version/1",
|
|
85
|
+
"headers": {
|
|
86
|
+
"Accept": "application/hal+json",
|
|
87
|
+
"Content-Type": "application/json"
|
|
88
|
+
},
|
|
89
|
+
"body": {
|
|
90
|
+
"content": "LS0tCnNvbWU6IGNvbnRyYWN0Cg==",
|
|
91
|
+
"contentType": "application/yaml",
|
|
92
|
+
"contractType": "oas",
|
|
93
|
+
"verificationResults": {
|
|
94
|
+
"content": "c29tZSByZXN1bHRz",
|
|
95
|
+
"contentType": "text/plain",
|
|
96
|
+
"format": "text",
|
|
97
|
+
"success": true,
|
|
98
|
+
"verifier": "my custom tool",
|
|
99
|
+
"verifierVersion": "1.0"
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
```
|
|
104
|
+
PactFlow will respond with:
|
|
105
|
+
```json
|
|
106
|
+
{
|
|
107
|
+
"status": 201,
|
|
108
|
+
"headers": {
|
|
109
|
+
"Content-Type": "application/hal+json;charset=utf-8"
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
```
|
|
113
|
+
<a name="a_request_to_create_a_provider_contract_given_there_is_a_pf:ui_href_in_the_response"></a>
|
|
114
|
+
Given **there is a pf:ui href in the response**, upon receiving **a request to create a provider contract** from Pact Broker Client V2, with
|
|
115
|
+
```json
|
|
116
|
+
{
|
|
117
|
+
"method": "PUT",
|
|
118
|
+
"path": "/contracts/provider/Bar/version/1",
|
|
119
|
+
"headers": {
|
|
120
|
+
"Accept": "application/hal+json",
|
|
121
|
+
"Content-Type": "application/json"
|
|
122
|
+
},
|
|
123
|
+
"body": {
|
|
124
|
+
"content": "LS0tCnNvbWU6IGNvbnRyYWN0Cg==",
|
|
125
|
+
"contentType": "application/yaml",
|
|
126
|
+
"contractType": "oas",
|
|
127
|
+
"verificationResults": {
|
|
128
|
+
"content": "c29tZSByZXN1bHRz",
|
|
129
|
+
"contentType": "text/plain",
|
|
130
|
+
"format": "text",
|
|
131
|
+
"success": true,
|
|
132
|
+
"verifier": "my custom tool",
|
|
133
|
+
"verifierVersion": "1.0"
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
```
|
|
138
|
+
PactFlow will respond with:
|
|
139
|
+
```json
|
|
140
|
+
{
|
|
141
|
+
"status": 201,
|
|
142
|
+
"headers": {
|
|
143
|
+
"Content-Type": "application/hal+json;charset=utf-8"
|
|
144
|
+
},
|
|
145
|
+
"body": {
|
|
146
|
+
"_links": {
|
|
147
|
+
"pf:ui": {
|
|
148
|
+
"href": "some-url"
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
```
|
|
154
|
+
<a name="a_request_to_create_a_webhook_for_a_team_given_a_team_with_UUID_2abbc12a-427d-432a-a521-c870af1739d9_exists"></a>
|
|
155
|
+
Given **a team with UUID 2abbc12a-427d-432a-a521-c870af1739d9 exists**, upon receiving **a request to create a webhook for a team** from Pact Broker Client V2, with
|
|
156
|
+
```json
|
|
157
|
+
{
|
|
158
|
+
"method": "POST",
|
|
159
|
+
"path": "/webhooks",
|
|
160
|
+
"headers": {
|
|
161
|
+
"Accept": "application/hal+json",
|
|
162
|
+
"Content-Type": "application/json"
|
|
163
|
+
},
|
|
164
|
+
"body": {
|
|
165
|
+
"description": "a webhook",
|
|
166
|
+
"events": [
|
|
167
|
+
{
|
|
168
|
+
"name": "contract_content_changed"
|
|
169
|
+
}
|
|
170
|
+
],
|
|
171
|
+
"request": {
|
|
172
|
+
"body": {
|
|
173
|
+
"some": "body"
|
|
174
|
+
},
|
|
175
|
+
"headers": {
|
|
176
|
+
"Bar": "foo",
|
|
177
|
+
"Foo": "bar"
|
|
178
|
+
},
|
|
179
|
+
"method": "POST",
|
|
180
|
+
"url": "https://webhook"
|
|
181
|
+
},
|
|
182
|
+
"teamUuid": "2abbc12a-427d-432a-a521-c870af1739d9"
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
```
|
|
186
|
+
PactFlow will respond with:
|
|
187
|
+
```json
|
|
188
|
+
{
|
|
189
|
+
"status": 201,
|
|
190
|
+
"headers": {
|
|
191
|
+
"Content-Type": "application/hal+json;charset=utf-8"
|
|
192
|
+
},
|
|
193
|
+
"body": {
|
|
194
|
+
"_links": {
|
|
195
|
+
"self": {
|
|
196
|
+
"href": "/some-url",
|
|
197
|
+
"title": "A title"
|
|
198
|
+
}
|
|
199
|
+
},
|
|
200
|
+
"description": "a webhook",
|
|
201
|
+
"teamUuid": "2abbc12a-427d-432a-a521-c870af1739d9"
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
```
|
|
205
|
+
<a name="a_request_to_publish_a_provider_contract"></a>
|
|
206
|
+
Upon receiving **a request to publish a provider contract** from Pact Broker Client V2, with
|
|
207
|
+
```json
|
|
208
|
+
{
|
|
209
|
+
"method": "POST",
|
|
210
|
+
"path": "/provider-contracts/provider/Bar/publish",
|
|
211
|
+
"headers": {
|
|
212
|
+
"Accept": "application/hal+json, application/problem+json",
|
|
213
|
+
"Content-Type": "application/json"
|
|
214
|
+
},
|
|
215
|
+
"body": {
|
|
216
|
+
"branch": "main",
|
|
217
|
+
"buildUrl": "http://build",
|
|
218
|
+
"contract": {
|
|
219
|
+
"content": "LS0tCnNvbWU6IGNvbnRyYWN0Cg==",
|
|
220
|
+
"contentType": "application/yaml",
|
|
221
|
+
"selfVerificationResults": {
|
|
222
|
+
"content": "c29tZSByZXN1bHRz",
|
|
223
|
+
"contentType": "text/plain",
|
|
224
|
+
"format": "text",
|
|
225
|
+
"success": true,
|
|
226
|
+
"verifier": "my custom tool",
|
|
227
|
+
"verifierVersion": "1.0"
|
|
228
|
+
},
|
|
229
|
+
"specification": "oas"
|
|
230
|
+
},
|
|
231
|
+
"pacticipantVersionNumber": "1",
|
|
232
|
+
"tags": [
|
|
233
|
+
"dev"
|
|
234
|
+
]
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
```
|
|
238
|
+
PactFlow will respond with:
|
|
239
|
+
```json
|
|
240
|
+
{
|
|
241
|
+
"status": 200,
|
|
242
|
+
"headers": {
|
|
243
|
+
"Content-Type": "application/hal+json;charset=utf-8"
|
|
244
|
+
},
|
|
245
|
+
"body": {
|
|
246
|
+
"_embedded": {
|
|
247
|
+
"version": {
|
|
248
|
+
"number": "1"
|
|
249
|
+
}
|
|
250
|
+
},
|
|
251
|
+
"_links": {
|
|
252
|
+
"pb:branch-version": {
|
|
253
|
+
},
|
|
254
|
+
"pb:pacticipant-version-tags": [
|
|
255
|
+
{
|
|
256
|
+
}
|
|
257
|
+
]
|
|
258
|
+
},
|
|
259
|
+
"notices": [
|
|
260
|
+
{
|
|
261
|
+
"text": "some notice",
|
|
262
|
+
"type": "info"
|
|
263
|
+
}
|
|
264
|
+
]
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
```
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
require 'erb'
|
|
4
4
|
require 'httparty'
|
|
5
5
|
require 'pact_broker/client/error'
|
|
6
|
+
require 'pact_broker/client/user_agent'
|
|
6
7
|
require 'cgi'
|
|
7
8
|
|
|
8
9
|
module PactBroker
|
|
@@ -104,15 +105,16 @@ module PactBroker
|
|
|
104
105
|
end
|
|
105
106
|
|
|
106
107
|
def patch url, options
|
|
107
|
-
|
|
108
|
+
enriched = enrich_options(options)
|
|
109
|
+
self.class.patch(url, @default_options.merge(enriched.merge(body: options[:body].to_json)))
|
|
108
110
|
end
|
|
109
111
|
|
|
110
112
|
def put url, options = {}, &block
|
|
111
|
-
self.class.put(url, @default_options.merge(options), &block)
|
|
113
|
+
self.class.put(url, @default_options.merge(enrich_options(options)), &block)
|
|
112
114
|
end
|
|
113
115
|
|
|
114
116
|
def get url, options = {}, &block
|
|
115
|
-
self.class.get(url, @default_options.merge(options), &block)
|
|
117
|
+
self.class.get(url, @default_options.merge(enrich_options(options)), &block)
|
|
116
118
|
end
|
|
117
119
|
|
|
118
120
|
def url_for_relation relation_name, params
|
|
@@ -133,6 +135,16 @@ module PactBroker
|
|
|
133
135
|
def verbose?
|
|
134
136
|
@verbose
|
|
135
137
|
end
|
|
138
|
+
|
|
139
|
+
private
|
|
140
|
+
|
|
141
|
+
def enrich_options(options)
|
|
142
|
+
options.merge(headers: user_agent_header.merge(options.fetch(:headers, {})))
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
def user_agent_header
|
|
146
|
+
{ 'User-Agent' => PactBroker::Client.user_agent_string('httparty', HTTParty::VERSION) }
|
|
147
|
+
end
|
|
136
148
|
end
|
|
137
149
|
end
|
|
138
150
|
end
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
require 'pact_broker/client/retry'
|
|
2
2
|
require 'pact_broker/client/hal/authorization_header_redactor'
|
|
3
|
+
require 'pact_broker/client/user_agent'
|
|
3
4
|
require 'net/http'
|
|
4
5
|
require 'json'
|
|
5
6
|
require 'openssl'
|
|
@@ -58,6 +59,9 @@ module PactBroker
|
|
|
58
59
|
request.body = body if body
|
|
59
60
|
request.basic_auth username, password if username
|
|
60
61
|
request['Authorization'] = "Bearer #{token}" if token
|
|
62
|
+
unless headers.any? { |k, _| k.downcase == 'user-agent' }
|
|
63
|
+
request['User-Agent'] = PactBroker::Client.user_agent_string('net-http', Net::HTTP::VERSION)
|
|
64
|
+
end
|
|
61
65
|
request
|
|
62
66
|
end
|
|
63
67
|
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'pact_broker/client/version'
|
|
4
|
+
|
|
5
|
+
module PactBroker
|
|
6
|
+
module Client
|
|
7
|
+
class << self
|
|
8
|
+
attr_accessor :tool_identifier
|
|
9
|
+
|
|
10
|
+
def user_agent_string(http_lib_name, http_lib_version)
|
|
11
|
+
base = "pact_broker-client/#{VERSION} #{http_lib_name}/#{http_lib_version} ruby/#{RUBY_VERSION}"
|
|
12
|
+
if tool_identifier && !tool_identifier.empty?
|
|
13
|
+
"#{tool_identifier} #{base}"
|
|
14
|
+
else
|
|
15
|
+
base
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -29,7 +29,7 @@ module PactBroker
|
|
|
29
29
|
end
|
|
30
30
|
|
|
31
31
|
def tag options
|
|
32
|
-
response = put(tag_url(options), headers: default_put_headers
|
|
32
|
+
response = put(tag_url(options), headers: default_put_headers, body: {}.to_json)
|
|
33
33
|
handle_response(response) do
|
|
34
34
|
true
|
|
35
35
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
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.78.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Beth Skurrie
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: httparty
|
|
@@ -162,6 +161,8 @@ files:
|
|
|
162
161
|
- doc/CAN_I_DEPLOY_USAGE_WITH_TAGS.md
|
|
163
162
|
- doc/pacts/markdown/Pact Broker Client - Pact Broker.md
|
|
164
163
|
- doc/pacts/markdown/Pact Broker Client - PactFlow.md
|
|
164
|
+
- doc/pacts/markdown/Pact Broker Client V2 - Pact Broker.md
|
|
165
|
+
- doc/pacts/markdown/Pact Broker Client V2 - PactFlow.md
|
|
165
166
|
- doc/pacts/markdown/README.md
|
|
166
167
|
- example/scripts/README.md
|
|
167
168
|
- example/scripts/deploy-consumer.sh
|
|
@@ -248,6 +249,7 @@ files:
|
|
|
248
249
|
- lib/pact_broker/client/string_refinements.rb
|
|
249
250
|
- lib/pact_broker/client/tasks.rb
|
|
250
251
|
- lib/pact_broker/client/tasks/publication_task.rb
|
|
252
|
+
- lib/pact_broker/client/user_agent.rb
|
|
251
253
|
- lib/pact_broker/client/verification_required.rb
|
|
252
254
|
- lib/pact_broker/client/version.rb
|
|
253
255
|
- lib/pact_broker/client/versions.rb
|
|
@@ -266,7 +268,6 @@ files:
|
|
|
266
268
|
- pact-broker-client.gemspec
|
|
267
269
|
- script/approve-all.sh
|
|
268
270
|
- script/can-i-deploy.sh
|
|
269
|
-
- script/ci/delete-branch-in-pactflow.sh
|
|
270
271
|
- script/ci/record-release.sh
|
|
271
272
|
- script/create-pacticipant.sh
|
|
272
273
|
- script/foo-bar.json
|
|
@@ -286,7 +287,6 @@ homepage: https://github.com/pact-foundation/pact_broker-client.git
|
|
|
286
287
|
licenses:
|
|
287
288
|
- MIT
|
|
288
289
|
metadata: {}
|
|
289
|
-
post_install_message:
|
|
290
290
|
rdoc_options: []
|
|
291
291
|
require_paths:
|
|
292
292
|
- lib
|
|
@@ -301,8 +301,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
301
301
|
- !ruby/object:Gem::Version
|
|
302
302
|
version: '0'
|
|
303
303
|
requirements: []
|
|
304
|
-
rubygems_version:
|
|
305
|
-
signing_key:
|
|
304
|
+
rubygems_version: 4.0.14
|
|
306
305
|
specification_version: 4
|
|
307
306
|
summary: See description
|
|
308
307
|
test_files: []
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
|
|
3
|
-
set -Eeuo pipefail
|
|
4
|
-
|
|
5
|
-
echo "Deleting branch ${GIT_BRANCH} for ${PACTICIPANT} in Pactflow..."
|
|
6
|
-
ENCODED_GIT_BRANCH=$(echo "$GIT_BRANCH" | ruby -e "require 'erb'; puts ERB::Util.url_encode(ARGF.read.chomp)")
|
|
7
|
-
ENCODED_PACTICIPANT=$(echo "$PACTICIPANT" | ruby -e "require 'erb'; puts ERB::Util.url_encode(ARGF.read.chomp)")
|
|
8
|
-
BRANCH_URL="${PACT_BROKER_BASE_URL}/pacticipants/${ENCODED_PACTICIPANT}/branches/${ENCODED_GIT_BRANCH}"
|
|
9
|
-
|
|
10
|
-
output_file=$(mktemp)
|
|
11
|
-
|
|
12
|
-
status=$(curl -v -X DELETE "${BRANCH_URL}" -H "Authorization: Bearer ${PACT_BROKER_TOKEN}" 2>&1 | tee "${output_file}" | awk '/^< HTTP/{print $3}')
|
|
13
|
-
|
|
14
|
-
if [ "$status" = "404" ]; then
|
|
15
|
-
echo "Branch ${GIT_BRANCH} for ${PACTICIPANT} does not exist in Pactflow"
|
|
16
|
-
elif [ $status -ge 400 ]; then
|
|
17
|
-
cat "${output_file}"
|
|
18
|
-
echo "Error deleting branch in Pactflow"
|
|
19
|
-
exit 1
|
|
20
|
-
else
|
|
21
|
-
echo "Deleted branch ${GIT_BRANCH} for ${PACTICIPANT} in Pactflow"
|
|
22
|
-
fi
|