pact_broker-client 0.0.1 → 0.0.2
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.
- data/Gemfile.lock +5 -5
- data/README.md +2 -93
- data/Rakefile +2 -2
- data/lib/pact_broker/client/pacticipants.rb +15 -1
- data/lib/pact_broker/client/pacts.rb +3 -3
- data/lib/pact_broker/client/publish_pacts.rb +1 -0
- data/lib/pact_broker/client/tasks/publication_task.rb +1 -0
- data/lib/pact_broker/client/version.rb +1 -1
- data/lib/pact_broker/client/versions.rb +1 -1
- data/spec/pacts/pact_broker_client-pact_broker.json +124 -26
- data/spec/service_providers/extra_goodies_spec.rb +71 -0
- data/spec/service_providers/pact_broker_client_spec.rb +23 -31
- data/spec/spec_helper.rb +7 -0
- data/spec/support/pacticipant_get.json +19 -0
- data/spec/support/pacticipants_list.json +26 -0
- data/tasks/pact.rake +7 -0
- metadata +11 -4
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
pact_broker-client (0.0.
|
4
|
+
pact_broker-client (0.0.2)
|
5
5
|
httparty
|
6
6
|
json
|
7
7
|
pact
|
@@ -29,7 +29,7 @@ GEM
|
|
29
29
|
json (1.8.1)
|
30
30
|
method_source (0.8.2)
|
31
31
|
multi_xml (0.5.5)
|
32
|
-
pact (1.0.
|
32
|
+
pact (1.0.20)
|
33
33
|
awesome_print (~> 1.1.0)
|
34
34
|
find_a_port (~> 1.0.1)
|
35
35
|
json
|
@@ -51,17 +51,17 @@ GEM
|
|
51
51
|
rspec-core (~> 2.14.0)
|
52
52
|
rspec-expectations (~> 2.14.0)
|
53
53
|
rspec-mocks (~> 2.14.0)
|
54
|
-
rspec-core (2.14.
|
54
|
+
rspec-core (2.14.7)
|
55
55
|
rspec-expectations (2.14.3)
|
56
56
|
diff-lcs (>= 1.1.3, < 2.0)
|
57
57
|
rspec-fire (1.2.0)
|
58
58
|
rspec (~> 2.11)
|
59
59
|
rspec-mocks (2.14.4)
|
60
60
|
slop (3.4.6)
|
61
|
-
thin (1.6.
|
61
|
+
thin (1.6.1)
|
62
62
|
daemons (>= 1.0.9)
|
63
63
|
eventmachine (>= 1.0.0)
|
64
|
-
rack (>= 1.
|
64
|
+
rack (>= 1.0.0)
|
65
65
|
thor (0.18.1)
|
66
66
|
|
67
67
|
PLATFORMS
|
data/README.md
CHANGED
@@ -1,94 +1,3 @@
|
|
1
|
-
#
|
1
|
+
# Pact Broker Client
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
Information here will be consumed by the Treasure Map (via the Rumour Mill). Therefore, please retain the existing formatting on this page, importantly:
|
6
|
-
|
7
|
-
* The service name at the top of the page
|
8
|
-
* The location of this description text (between service name and Custodian(s)
|
9
|
-
* Component Custodian(s)
|
10
|
-
|
11
|
-
Other headings can be deleted if they are not relevant.
|
12
|
-
|
13
|
-
**NOTE: The following is provided for convenience. Please check it carefully before your first commit.**
|
14
|
-
|
15
|
-
## Component Custodian(s)
|
16
|
-
|
17
|
-
Enter Custodian(s) here
|
18
|
-
|
19
|
-
## Development
|
20
|
-
|
21
|
-
Enter any developer instructions here.
|
22
|
-
|
23
|
-
### Database setup
|
24
|
-
|
25
|
-
Instructions to set up the database for local testing.
|
26
|
-
|
27
|
-
Then run migrations:
|
28
|
-
|
29
|
-
$ bundle exec rake db:migrate
|
30
|
-
|
31
|
-
### Testing
|
32
|
-
|
33
|
-
$ bundle exec rake
|
34
|
-
|
35
|
-
### Running
|
36
|
-
|
37
|
-
Instructions to run the service locally.
|
38
|
-
|
39
|
-
### Debugging
|
40
|
-
|
41
|
-
Any specific debugging tools built in to the service (health check is assumed so don't include that).
|
42
|
-
|
43
|
-
### Build
|
44
|
-
|
45
|
-
**edit the below and add the correct endpoint**
|
46
|
-
|
47
|
-
[Standalone (Bamboo)](http://master.cd.vpc.realestate.com.au/browse/YOUR_NEW_SERVICE_BUILD)
|
48
|
-
|
49
|
-
## Deployment
|
50
|
-
|
51
|
-
Deployment scripts have been generated using [biq-deploy](https://git.realestate.com.au/business-systems/biq-deploy).
|
52
|
-
|
53
|
-
#### EC2 environments
|
54
|
-
|
55
|
-
Before deploying to EC2 environments, you may wish to check that the build you wish to deploy has been indexed.
|
56
|
-
|
57
|
-
1. Log in into the agent unix box:
|
58
|
-
|
59
|
-
$ rea-ec2-ssh agent-01.biq
|
60
|
-
|
61
|
-
2. See the list of versions indexed and verify the expected version in the list:
|
62
|
-
|
63
|
-
$ yum list --showduplicates --enablerepo=rea-el6-dev pact_broker_client
|
64
|
-
|
65
|
-
You can get up an running with these scripts like so (from within the pact_broker_client project on your local machine):
|
66
|
-
|
67
|
-
$ cd deploy
|
68
|
-
$ bundle
|
69
|
-
$ bundle exec bin/pact-broker-client-deploy-ec2 --help
|
70
|
-
|
71
|
-
When deploying to an EC2 environment for the first time, you must create a node for the app:
|
72
|
-
|
73
|
-
$ bundle exec bin/pact-broker-client-deploy-ec2 -t create -s $YOUR_SUBDOMAIN -p dev
|
74
|
-
|
75
|
-
The first time the service is deployed, a database must be created. After adding the [required config values](https://git.realestate.com.au/business-systems/pact_broker_client/blob/master/lib/environment_variables.rb) to the
|
76
|
-
environment's config-svc, you can run the db provision task:
|
77
|
-
|
78
|
-
$ bundle exec bin/pact-broker-client-deploy-ec2 -t db_provision -s $YOUR_SUBDOMAIN
|
79
|
-
|
80
|
-
Then you are free to migrate the db from then on:
|
81
|
-
|
82
|
-
$ bundle exec bin/pact-broker-client-deploy-ec2 -t db_migrate -s $YOUR_SUBDOMAIN
|
83
|
-
|
84
|
-
To deploy to a test environment (eg biq-qa1):
|
85
|
-
|
86
|
-
$ bundle exec bin/pact-broker-client-deploy-ec2 -t deploy -s biq-qa1 -p dev -y
|
87
|
-
|
88
|
-
#### Production
|
89
|
-
|
90
|
-
Refer to the [production deployment readme](https://git.realestate.com.au/business-systems/pact_broker_client/blob/master/README-ProdDeploy.md).
|
91
|
-
|
92
|
-
### Architecture
|
93
|
-
|
94
|
-
Any important architectural information.
|
3
|
+
A client for the Pact Broker. Publishes pacts to, and retrieves pacts from, the pact broker.
|
data/Rakefile
CHANGED
@@ -20,8 +20,8 @@ Bundler::GemHelper.install_tasks
|
|
20
20
|
require 'rspec/core/rake_task'
|
21
21
|
#require 'geminabox-client'
|
22
22
|
|
23
|
-
Dir.glob('lib/tasks/**/*.rake').each { |task| load task }
|
24
|
-
Dir.glob('tasks/**/*.rake').each { |task| load task }
|
23
|
+
Dir.glob('lib/tasks/**/*.rake').each { |task| load "#{Dir.pwd}/#{task}" }
|
24
|
+
Dir.glob('tasks/**/*.rake').each { |task| load "#{Dir.pwd}/#{task}" }
|
25
25
|
RSpec::Core::RakeTask.new(:spec)
|
26
26
|
|
27
27
|
task :default => [:spec]
|
@@ -16,6 +16,20 @@ module PactBroker
|
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
|
+
def get1 options
|
20
|
+
response = get(pacticipant_base_url(options), headers: default_get_headers)
|
21
|
+
handle_response(response) do
|
22
|
+
response.to_hash
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def list
|
27
|
+
response = get("/pacticipants", headers: default_get_headers)
|
28
|
+
handle_response(response) do
|
29
|
+
response.to_hash
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
19
33
|
def repository_url options
|
20
34
|
response = get("#{pacticipant_base_url(options)}/repository_url", headers: default_get_headers.merge('Accept' => 'text/plain'))
|
21
35
|
handle_response(response) do
|
@@ -26,7 +40,7 @@ module PactBroker
|
|
26
40
|
private
|
27
41
|
|
28
42
|
def pacticipant_base_url options
|
29
|
-
"/
|
43
|
+
"/pacticipants/#{encode_param(options[:pacticipant])}"
|
30
44
|
end
|
31
45
|
|
32
46
|
end
|
@@ -8,7 +8,7 @@ module PactBroker
|
|
8
8
|
|
9
9
|
def publish options
|
10
10
|
consumer_version = options[:consumer_version]
|
11
|
-
pact_string = options[:
|
11
|
+
pact_string = options[:pact_json]
|
12
12
|
consumer_contract = ::Pact::ConsumerContract.from_json pact_string
|
13
13
|
url = save_consumer_contract_url consumer_contract, consumer_version
|
14
14
|
response = self.class.put(url, body: pact_string, headers: default_put_headers)
|
@@ -31,14 +31,14 @@ module PactBroker
|
|
31
31
|
def find_last_consumer_contract_url options
|
32
32
|
consumer_name = encode_param(options[:consumer])
|
33
33
|
provider_name = encode_param(options[:provider])
|
34
|
-
"/
|
34
|
+
"/pacticipants/#{consumer_name}/versions/last/pacts/#{provider_name}"
|
35
35
|
end
|
36
36
|
|
37
37
|
def save_consumer_contract_url consumer_contract, consumer_version
|
38
38
|
consumer_name = encode_param(consumer_contract.consumer.name)
|
39
39
|
provider_name = encode_param(consumer_contract.provider.name)
|
40
40
|
version = encode_param(consumer_version)
|
41
|
-
"/
|
41
|
+
"/pacticipants/#{consumer_name}/versions/#{version}/pacts/#{provider_name}"
|
42
42
|
end
|
43
43
|
end
|
44
44
|
end
|
@@ -25,6 +25,7 @@ module PactBroker
|
|
25
25
|
|
26
26
|
def publish_pact pact_file
|
27
27
|
begin
|
28
|
+
puts "Publishing #{pact_file} to pact broker at #{pact_broker_base_url}"
|
28
29
|
pact_broker_client.pacticipants.versions.pacts.publish(pact_json: File.read(pact_file), consumer_version: consumer_version)
|
29
30
|
true
|
30
31
|
rescue => e
|
@@ -29,6 +29,7 @@ module PactBroker
|
|
29
29
|
|
30
30
|
def rake_task
|
31
31
|
namespace :pact do
|
32
|
+
desc "Publish pacts to pact broker"
|
32
33
|
task task_name do
|
33
34
|
require 'pact_broker/client/publish_pacts'
|
34
35
|
success = PactBroker::Client::PublishPacts.new(pact_broker_base_url, FileList[@pattern], consumer_version).call
|
@@ -6,12 +6,115 @@
|
|
6
6
|
"name": "Pact Broker Client"
|
7
7
|
},
|
8
8
|
"interactions": [
|
9
|
+
{
|
10
|
+
"description": "a request to list pacticipants",
|
11
|
+
"provider_state": "'Condor' exists in the pact-broker",
|
12
|
+
"request": {
|
13
|
+
"method": "get",
|
14
|
+
"path": "/pacticipants",
|
15
|
+
"headers": {
|
16
|
+
}
|
17
|
+
},
|
18
|
+
"response": {
|
19
|
+
"headers": {
|
20
|
+
"Content-Type": "application/json+hal;charset=utf-8"
|
21
|
+
},
|
22
|
+
"status": 200,
|
23
|
+
"body": {
|
24
|
+
"_links": {
|
25
|
+
"self": {
|
26
|
+
"href": "http://localhost:1234/pacticipants"
|
27
|
+
},
|
28
|
+
"pacticipants": [
|
29
|
+
{
|
30
|
+
"href": "http://localhost:1234/pacticipants/Condor",
|
31
|
+
"name": "Condor"
|
32
|
+
}
|
33
|
+
]
|
34
|
+
},
|
35
|
+
"pacticipants": [
|
36
|
+
{
|
37
|
+
"_links": {
|
38
|
+
"self": {
|
39
|
+
"href": "http://localhost:1234/pacticipants/Condor"
|
40
|
+
}
|
41
|
+
},
|
42
|
+
"name": "Condor",
|
43
|
+
"_embedded": {
|
44
|
+
"last_version": {
|
45
|
+
"_links": {
|
46
|
+
"self": {
|
47
|
+
"href": "http://localhost:1234/pacticipants/Condor/versions/1.3.0"
|
48
|
+
}
|
49
|
+
},
|
50
|
+
"number": "1.3.0"
|
51
|
+
}
|
52
|
+
}
|
53
|
+
}
|
54
|
+
]
|
55
|
+
}
|
56
|
+
}
|
57
|
+
},
|
58
|
+
{
|
59
|
+
"description": "a request to get the Pricing Service",
|
60
|
+
"provider_state": "the 'Pricing Service' already exists in the pact-broker",
|
61
|
+
"request": {
|
62
|
+
"method": "get",
|
63
|
+
"path": "/pacticipants/Pricing%20Service",
|
64
|
+
"headers": {
|
65
|
+
}
|
66
|
+
},
|
67
|
+
"response": {
|
68
|
+
"headers": {
|
69
|
+
"Content-Type": "application/json+hal;charset=utf-8"
|
70
|
+
},
|
71
|
+
"status": 200,
|
72
|
+
"body": {
|
73
|
+
"_links": {
|
74
|
+
"self": {
|
75
|
+
"href": "http://localhost:1234/pacticipants/Pricing%20Service"
|
76
|
+
},
|
77
|
+
"versions": {
|
78
|
+
"href": "http://localhost:1234/pacticipants/Pricing%20Service/versions"
|
79
|
+
},
|
80
|
+
"last_version": {
|
81
|
+
"href": "http://localhost:1234/pacticipants/Pricing%20Service/versions/last"
|
82
|
+
}
|
83
|
+
},
|
84
|
+
"name": "Pricing Service",
|
85
|
+
"repository_url": "git@git.realestate.com.au:business-systems/pricing-service",
|
86
|
+
"_embedded": {
|
87
|
+
"last_version": {
|
88
|
+
"_links": {
|
89
|
+
"self": {
|
90
|
+
"href": "http://localhost:1234/pacticipants/Pricing%20Service/versions/1.3.0"
|
91
|
+
}
|
92
|
+
},
|
93
|
+
"number": "1.3.0"
|
94
|
+
}
|
95
|
+
}
|
96
|
+
}
|
97
|
+
}
|
98
|
+
},
|
99
|
+
{
|
100
|
+
"description": "a request to get the Pricing Service",
|
101
|
+
"provider_state": "the 'Pricing Service' does not exist in the pact-broker",
|
102
|
+
"request": {
|
103
|
+
"method": "get",
|
104
|
+
"path": "/pacticipants/Pricing%20Service",
|
105
|
+
"headers": {
|
106
|
+
}
|
107
|
+
},
|
108
|
+
"response": {
|
109
|
+
"status": 404
|
110
|
+
}
|
111
|
+
},
|
9
112
|
{
|
10
113
|
"description": "a request to publish a pact",
|
11
114
|
"provider_state": "the 'Pricing Service' already exists in the pact-broker",
|
12
115
|
"request": {
|
13
116
|
"method": "put",
|
14
|
-
"path": "/
|
117
|
+
"path": "/pacticipants/Condor/versions/1.3.0/pacts/Pricing%20Service",
|
15
118
|
"body": {
|
16
119
|
"consumer": {
|
17
120
|
"name": "Condor"
|
@@ -38,7 +141,7 @@
|
|
38
141
|
"provider_state": "the 'Pricing Service' and 'Condor' already exist in the pact-broker, and Condor already has a pact published for version 1.3.0",
|
39
142
|
"request": {
|
40
143
|
"method": "put",
|
41
|
-
"path": "/
|
144
|
+
"path": "/pacticipants/Condor/versions/1.3.0/pacts/Pricing%20Service",
|
42
145
|
"body": {
|
43
146
|
"consumer": {
|
44
147
|
"name": "Condor"
|
@@ -65,7 +168,7 @@
|
|
65
168
|
"provider_state": "'Condor' already exist in the pact-broker, but the 'Pricing Service' does not",
|
66
169
|
"request": {
|
67
170
|
"method": "put",
|
68
|
-
"path": "/
|
171
|
+
"path": "/pacticipants/Condor/versions/1.3.0/pacts/Pricing%20Service",
|
69
172
|
"body": {
|
70
173
|
"consumer": {
|
71
174
|
"name": "Condor"
|
@@ -92,7 +195,7 @@
|
|
92
195
|
"provider_state": "an error occurs while publishing a pact",
|
93
196
|
"request": {
|
94
197
|
"method": "put",
|
95
|
-
"path": "/
|
198
|
+
"path": "/pacticipants/Condor/versions/1.3.0/pacts/Pricing%20Service",
|
96
199
|
"body": {
|
97
200
|
"consumer": {
|
98
201
|
"name": "Condor"
|
@@ -128,9 +231,9 @@
|
|
128
231
|
"provider_state": "the 'Pricing Service' does not exist in the pact-broker",
|
129
232
|
"request": {
|
130
233
|
"method": "patch",
|
131
|
-
"path": "/
|
234
|
+
"path": "/pacticipants/Pricing%20Service",
|
132
235
|
"body": {
|
133
|
-
"repository_url": "git@git.realestate.com.au:business-systems/
|
236
|
+
"repository_url": "git@git.realestate.com.au:business-systems/pricing-service"
|
134
237
|
},
|
135
238
|
"headers": {
|
136
239
|
"Content-Type": "application/json+patch"
|
@@ -147,9 +250,9 @@
|
|
147
250
|
"provider_state": "the 'Pricing Service' already exists in the pact-broker",
|
148
251
|
"request": {
|
149
252
|
"method": "patch",
|
150
|
-
"path": "/
|
253
|
+
"path": "/pacticipants/Pricing%20Service",
|
151
254
|
"body": {
|
152
|
-
"repository_url": "git@git.realestate.com.au:business-systems/
|
255
|
+
"repository_url": "git@git.realestate.com.au:business-systems/pricing-service"
|
153
256
|
},
|
154
257
|
"headers": {
|
155
258
|
"Content-Type": "application/json+patch"
|
@@ -166,7 +269,7 @@
|
|
166
269
|
"provider_state": "the 'Pricing Service' does not exist in the pact-broker",
|
167
270
|
"request": {
|
168
271
|
"method": "get",
|
169
|
-
"path": "/
|
272
|
+
"path": "/pacticipants/Pricing%20Service/repository_url",
|
170
273
|
"headers": {
|
171
274
|
"Accept": "text/plain"
|
172
275
|
}
|
@@ -182,7 +285,7 @@
|
|
182
285
|
"provider_state": "the 'Pricing Service' already exists in the pact-broker",
|
183
286
|
"request": {
|
184
287
|
"method": "get",
|
185
|
-
"path": "/
|
288
|
+
"path": "/pacticipants/Pricing%20Service/repository_url",
|
186
289
|
"headers": {
|
187
290
|
"Accept": "text/plain"
|
188
291
|
}
|
@@ -192,7 +295,7 @@
|
|
192
295
|
"headers": {
|
193
296
|
"Content-Type": "text/plain;charset=utf-8"
|
194
297
|
},
|
195
|
-
"body": "git@git.realestate.com.au:business-systems/
|
298
|
+
"body": "git@git.realestate.com.au:business-systems/pricing-service"
|
196
299
|
}
|
197
300
|
},
|
198
301
|
{
|
@@ -200,13 +303,12 @@
|
|
200
303
|
"provider_state": "'Condor' exists in the pact-broker",
|
201
304
|
"request": {
|
202
305
|
"method": "patch",
|
203
|
-
"path": "/
|
306
|
+
"path": "/pacticipants/Condor/versions/1.3.0",
|
204
307
|
"body": {
|
205
308
|
"tags": [
|
206
309
|
"prod"
|
207
310
|
],
|
208
|
-
"repository_ref": "packages/condor-1.3.0"
|
209
|
-
"repository_url": "git@git.realestate.com.au:business-systems/condor.git"
|
311
|
+
"repository_ref": "packages/condor-1.3.0"
|
210
312
|
},
|
211
313
|
"headers": {
|
212
314
|
"Content-Type": "application/json+patch"
|
@@ -223,13 +325,12 @@
|
|
223
325
|
"provider_state": "'Condor' does not exist in the pact-broker",
|
224
326
|
"request": {
|
225
327
|
"method": "patch",
|
226
|
-
"path": "/
|
328
|
+
"path": "/pacticipants/Condor/versions/1.3.0",
|
227
329
|
"body": {
|
228
330
|
"tags": [
|
229
331
|
"prod"
|
230
332
|
],
|
231
|
-
"repository_ref": "packages/condor-1.3.0"
|
232
|
-
"repository_url": "git@git.realestate.com.au:business-systems/condor.git"
|
333
|
+
"repository_ref": "packages/condor-1.3.0"
|
233
334
|
},
|
234
335
|
"headers": {
|
235
336
|
"Content-Type": "application/json+patch"
|
@@ -246,9 +347,8 @@
|
|
246
347
|
"provider_state": "a pact between Condor and the Pricing Service exists",
|
247
348
|
"request": {
|
248
349
|
"method": "get",
|
249
|
-
"path": "/
|
350
|
+
"path": "/pacticipants/Condor/versions/last/pacts/Pricing%20Service",
|
250
351
|
"headers": {
|
251
|
-
"Accept": "application/json"
|
252
352
|
}
|
253
353
|
},
|
254
354
|
"response": {
|
@@ -275,9 +375,8 @@
|
|
275
375
|
"provider_state": "no pact between Condor and the Pricing Service exists",
|
276
376
|
"request": {
|
277
377
|
"method": "get",
|
278
|
-
"path": "/
|
378
|
+
"path": "/pacticipants/Condor/versions/last/pacts/Pricing%20Service",
|
279
379
|
"headers": {
|
280
|
-
"Accept": "application/json"
|
281
380
|
}
|
282
381
|
},
|
283
382
|
"response": {
|
@@ -291,7 +390,7 @@
|
|
291
390
|
"provider_state": "a pact between Condor and the Pricing Service exists for the production version of Condor",
|
292
391
|
"request": {
|
293
392
|
"method": "get",
|
294
|
-
"path": "/
|
393
|
+
"path": "/pacticipants/Condor/versions/last/pacts/Pricing%20Service",
|
295
394
|
"headers": {
|
296
395
|
"Accept": "application/json"
|
297
396
|
},
|
@@ -319,7 +418,7 @@
|
|
319
418
|
"provider_state": "a version with production details exists for the Pricing Service",
|
320
419
|
"request": {
|
321
420
|
"method": "get",
|
322
|
-
"path": "/
|
421
|
+
"path": "/pacticipants/Pricing%20Service/versions/last",
|
323
422
|
"headers": {
|
324
423
|
"Accept": "application/json"
|
325
424
|
},
|
@@ -332,7 +431,6 @@
|
|
332
431
|
},
|
333
432
|
"body": {
|
334
433
|
"number": "1.2.3",
|
335
|
-
"repository_url": "git@git.realestate.com.au:business-systems/pricing-service.git",
|
336
434
|
"repository_ref": "package/pricing-service-1.2.3",
|
337
435
|
"tags": [
|
338
436
|
"prod"
|
@@ -345,7 +443,7 @@
|
|
345
443
|
"provider_state": "no version exists for the Pricing Service",
|
346
444
|
"request": {
|
347
445
|
"method": "get",
|
348
|
-
"path": "/
|
446
|
+
"path": "/pacticipants/Pricing%20Service/versions/last",
|
349
447
|
"headers": {
|
350
448
|
"Accept": "application/json"
|
351
449
|
}
|
@@ -359,7 +457,7 @@
|
|
359
457
|
],
|
360
458
|
"metadata": {
|
361
459
|
"pact_gem": {
|
362
|
-
"version": "1.0.
|
460
|
+
"version": "1.0.20"
|
363
461
|
}
|
364
462
|
}
|
365
463
|
}
|
@@ -0,0 +1,71 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require_relative 'pact_helper'
|
3
|
+
|
4
|
+
|
5
|
+
module PactBroker::Client
|
6
|
+
describe PactBrokerClient, :pact => true do
|
7
|
+
|
8
|
+
let(:pact_broker_client) { PactBrokerClient.new(base_url: 'http://localhost:1234') }
|
9
|
+
|
10
|
+
describe "listing pacticipants" do
|
11
|
+
context "when a pacticipant exists" do
|
12
|
+
let(:response_body) { JSON.parse(File.read("./spec/support/pacticipants_list.json"))}
|
13
|
+
before do
|
14
|
+
pact_broker.
|
15
|
+
given("'Condor' exists in the pact-broker").
|
16
|
+
upon_receiving("a request to list pacticipants").
|
17
|
+
with(
|
18
|
+
method: :get,
|
19
|
+
path: '/pacticipants',
|
20
|
+
headers: {} ).
|
21
|
+
will_respond_with( headers: {'Content-Type' => 'application/json+hal;charset=utf-8'},
|
22
|
+
status: 200,
|
23
|
+
body: response_body
|
24
|
+
)
|
25
|
+
end
|
26
|
+
it "returns the response body" do
|
27
|
+
expect(pact_broker_client.pacticipants.list).to eq response_body
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe "get pacticipant" do
|
33
|
+
context "when the pacticipant exists" do
|
34
|
+
let(:response_body) { JSON.parse(File.read("./spec/support/pacticipant_get.json"))}
|
35
|
+
let(:options) { {pacticipant: 'Pricing Service'}}
|
36
|
+
before do
|
37
|
+
pact_broker.
|
38
|
+
given("the 'Pricing Service' already exists in the pact-broker").
|
39
|
+
upon_receiving("a request to get the Pricing Service").
|
40
|
+
with(
|
41
|
+
method: :get,
|
42
|
+
path: '/pacticipants/Pricing%20Service',
|
43
|
+
headers: {} ).
|
44
|
+
will_respond_with( headers: {'Content-Type' => 'application/json+hal;charset=utf-8'},
|
45
|
+
status: 200,
|
46
|
+
body: response_body
|
47
|
+
)
|
48
|
+
end
|
49
|
+
it "returns the response body" do
|
50
|
+
expect(pact_broker_client.pacticipants.get1(options)).to eq response_body
|
51
|
+
end
|
52
|
+
end
|
53
|
+
context "when the pacticipant does not exist" do
|
54
|
+
let(:options) { {pacticipant: 'Pricing Service'}}
|
55
|
+
before do
|
56
|
+
pact_broker.
|
57
|
+
given("the 'Pricing Service' does not exist in the pact-broker").
|
58
|
+
upon_receiving("a request to get the Pricing Service").
|
59
|
+
with(
|
60
|
+
method: :get,
|
61
|
+
path: '/pacticipants/Pricing%20Service',
|
62
|
+
headers: {} ).
|
63
|
+
will_respond_with( status: 404 )
|
64
|
+
end
|
65
|
+
it "returns nil" do
|
66
|
+
expect(pact_broker_client.pacticipants.get1(options)).to be_nil
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
@@ -1,13 +1,6 @@
|
|
1
1
|
require_relative 'pact_helper'
|
2
2
|
require 'pact_broker/client'
|
3
3
|
|
4
|
-
def silence_warnings
|
5
|
-
old_verbose, $VERBOSE = $VERBOSE, nil
|
6
|
-
yield
|
7
|
-
ensure
|
8
|
-
$VERBOSE = old_verbose
|
9
|
-
end
|
10
|
-
|
11
4
|
module PactBroker::Client
|
12
5
|
describe PactBrokerClient, :pact => true do
|
13
6
|
|
@@ -38,7 +31,7 @@ module PactBroker::Client
|
|
38
31
|
|
39
32
|
describe "publishing a pact" do
|
40
33
|
|
41
|
-
let(:options) { {
|
34
|
+
let(:options) { { pact_json: pact_json, consumer_version: consumer_version }}
|
42
35
|
|
43
36
|
context "when the provider already exists in the pact-broker" do
|
44
37
|
before do
|
@@ -47,7 +40,7 @@ module PactBroker::Client
|
|
47
40
|
upon_receiving("a request to publish a pact").
|
48
41
|
with({
|
49
42
|
method: :put,
|
50
|
-
path: '/
|
43
|
+
path: '/pacticipants/Condor/versions/1.3.0/pacts/Pricing%20Service',
|
51
44
|
headers: default_request_headers,
|
52
45
|
body: pact_hash }).
|
53
46
|
will_respond_with( headers: pact_broker_response_headers,
|
@@ -66,7 +59,7 @@ module PactBroker::Client
|
|
66
59
|
upon_receiving("a request to publish a pact").
|
67
60
|
with({
|
68
61
|
method: :put,
|
69
|
-
path: '/
|
62
|
+
path: '/pacticipants/Condor/versions/1.3.0/pacts/Pricing%20Service',
|
70
63
|
headers: default_request_headers,
|
71
64
|
body: pact_hash }).
|
72
65
|
will_respond_with( headers: pact_broker_response_headers,
|
@@ -85,7 +78,7 @@ module PactBroker::Client
|
|
85
78
|
upon_receiving("a request to publish a pact").
|
86
79
|
with({
|
87
80
|
method: :put,
|
88
|
-
path: '/
|
81
|
+
path: '/pacticipants/Condor/versions/1.3.0/pacts/Pricing%20Service',
|
89
82
|
headers: default_request_headers,
|
90
83
|
body: pact_hash }).
|
91
84
|
will_respond_with( headers: pact_broker_response_headers,
|
@@ -104,7 +97,7 @@ module PactBroker::Client
|
|
104
97
|
upon_receiving("a request to publish a pact").
|
105
98
|
with({
|
106
99
|
method: :put,
|
107
|
-
path: '/
|
100
|
+
path: '/pacticipants/Condor/versions/1.3.0/pacts/Pricing%20Service',
|
108
101
|
headers: default_request_headers,
|
109
102
|
body: pact_hash }).
|
110
103
|
will_respond_with({
|
@@ -122,7 +115,7 @@ module PactBroker::Client
|
|
122
115
|
|
123
116
|
end
|
124
117
|
|
125
|
-
let(:repository_url ) { "git@git.realestate.com.au:business-systems/
|
118
|
+
let(:repository_url ) { "git@git.realestate.com.au:business-systems/pricing-service" }
|
126
119
|
|
127
120
|
describe "registering a repository url" do
|
128
121
|
context "where the pacticipant does not already exist in the pact-broker" do
|
@@ -132,7 +125,7 @@ module PactBroker::Client
|
|
132
125
|
upon_receiving("a request to register the repository URL of a pacticipant").
|
133
126
|
with(
|
134
127
|
method: :patch,
|
135
|
-
path: '/
|
128
|
+
path: '/pacticipants/Pricing%20Service',
|
136
129
|
headers: patch_request_headers,
|
137
130
|
body: {repository_url: repository_url} ).
|
138
131
|
will_respond_with(
|
@@ -151,7 +144,7 @@ module PactBroker::Client
|
|
151
144
|
upon_receiving("a request to register the repository URL of a pacticipant").
|
152
145
|
with(
|
153
146
|
method: :patch,
|
154
|
-
path: '/
|
147
|
+
path: '/pacticipants/Pricing%20Service',
|
155
148
|
headers: patch_request_headers,
|
156
149
|
body: {repository_url: repository_url} ).
|
157
150
|
will_respond_with(
|
@@ -173,7 +166,7 @@ module PactBroker::Client
|
|
173
166
|
upon_receiving("a request to retrieve the repository URL of the 'Pricing Service'").
|
174
167
|
with(
|
175
168
|
method: :get,
|
176
|
-
path: '/
|
169
|
+
path: '/pacticipants/Pricing%20Service/repository_url',
|
177
170
|
headers: get_request_headers.merge({'Accept' => 'text/plain'})).
|
178
171
|
will_respond_with(
|
179
172
|
status: 404,
|
@@ -191,7 +184,7 @@ module PactBroker::Client
|
|
191
184
|
upon_receiving("a request to retrieve the repository URL of the 'Pricing Service'").
|
192
185
|
with(
|
193
186
|
method: :get,
|
194
|
-
path: '/
|
187
|
+
path: '/pacticipants/Pricing%20Service/repository_url',
|
195
188
|
headers: get_request_headers.merge({'Accept' => 'text/plain'})).
|
196
189
|
will_respond_with(
|
197
190
|
status: 200,
|
@@ -208,7 +201,7 @@ module PactBroker::Client
|
|
208
201
|
describe "tagging a version with prod details" do
|
209
202
|
let(:repository_ref) { "packages/condor-#{version}" }
|
210
203
|
|
211
|
-
let(:tag_options) { {pacticipant: 'Condor', version: version, repository_ref: repository_ref,
|
204
|
+
let(:tag_options) { {pacticipant: 'Condor', version: version, repository_ref: repository_ref, :tag => 'prod'} }
|
212
205
|
context "when the component exists" do
|
213
206
|
before do
|
214
207
|
pact_broker.
|
@@ -216,9 +209,9 @@ module PactBroker::Client
|
|
216
209
|
upon_receiving("a request to tag the production version of Condor").
|
217
210
|
with(
|
218
211
|
method: :patch,
|
219
|
-
path: '/
|
212
|
+
path: '/pacticipants/Condor/versions/1.3.0',
|
220
213
|
headers: patch_request_headers,
|
221
|
-
body: {:tags => ['prod'], :repository_ref => repository_ref
|
214
|
+
body: {:tags => ['prod'], :repository_ref => repository_ref } ).
|
222
215
|
will_respond_with(
|
223
216
|
status: 200,
|
224
217
|
headers: pact_broker_response_headers
|
@@ -235,9 +228,9 @@ module PactBroker::Client
|
|
235
228
|
upon_receiving("a request to tag the production version of Condor").
|
236
229
|
with(
|
237
230
|
method: :patch,
|
238
|
-
path: '/
|
231
|
+
path: '/pacticipants/Condor/versions/1.3.0',
|
239
232
|
headers: patch_request_headers,
|
240
|
-
body: {:tags => ['prod'], :repository_ref => repository_ref
|
233
|
+
body: {:tags => ['prod'], :repository_ref => repository_ref } ).
|
241
234
|
will_respond_with(
|
242
235
|
status: 201,
|
243
236
|
headers: pact_broker_response_headers
|
@@ -260,8 +253,8 @@ module PactBroker::Client
|
|
260
253
|
upon_receiving("a request to retrieve the latest pact between Condor and the Pricing Service").
|
261
254
|
with({
|
262
255
|
method: :get,
|
263
|
-
path: '/
|
264
|
-
headers:
|
256
|
+
path: '/pacticipants/Condor/versions/last/pacts/Pricing%20Service',
|
257
|
+
headers: {}
|
265
258
|
}).
|
266
259
|
will_respond_with({
|
267
260
|
status: 200,
|
@@ -283,8 +276,8 @@ module PactBroker::Client
|
|
283
276
|
upon_receiving("a request to retrieve the latest pact between Condor and the Pricing Service").
|
284
277
|
with({
|
285
278
|
method: :get,
|
286
|
-
path: '/
|
287
|
-
headers:
|
279
|
+
path: '/pacticipants/Condor/versions/last/pacts/Pricing%20Service',
|
280
|
+
headers: {}
|
288
281
|
}).
|
289
282
|
will_respond_with({
|
290
283
|
status: 404,
|
@@ -305,7 +298,7 @@ module PactBroker::Client
|
|
305
298
|
upon_receiving("a request to retrieve the pact between the production verison of Condor and the Pricing Service").
|
306
299
|
with({
|
307
300
|
method: :get,
|
308
|
-
path: '/
|
301
|
+
path: '/pacticipants/Condor/versions/last/pacts/Pricing%20Service',
|
309
302
|
query: 'tag=prod',
|
310
303
|
headers: get_request_headers
|
311
304
|
}).
|
@@ -328,15 +321,14 @@ module PactBroker::Client
|
|
328
321
|
describe "retriving versions" do
|
329
322
|
context "when retrieving the production details of a version" do
|
330
323
|
context "when a version is found" do
|
331
|
-
let(:repository_url) { "git@git.realestate.com.au:business-systems/pricing-service.git" }
|
332
324
|
let(:repository_ref) { "package/pricing-service-1.2.3"}
|
333
325
|
let(:tags) { ['prod']}
|
334
|
-
let(:body) { { number: '1.2.3',
|
326
|
+
let(:body) { { number: '1.2.3', repository_ref: repository_ref, tags: tags } }
|
335
327
|
before do
|
336
328
|
pact_broker.
|
337
329
|
given("a version with production details exists for the Pricing Service").
|
338
330
|
upon_receiving("a request for the latest version tagged with 'prod'").
|
339
|
-
with(method: :get, path: '/
|
331
|
+
with(method: :get, path: '/pacticipants/Pricing%20Service/versions/last', query: 'tag=prod', headers: get_request_headers).
|
340
332
|
will_respond_with( status: 200,
|
341
333
|
headers: pact_broker_response_headers.merge({'Content-Type' => 'application/json;charset=utf-8'}),
|
342
334
|
body: body )
|
@@ -351,7 +343,7 @@ module PactBroker::Client
|
|
351
343
|
pact_broker.
|
352
344
|
given("no version exists for the Pricing Service").
|
353
345
|
upon_receiving("a request for the latest version").
|
354
|
-
with(method: :get, path: '/
|
346
|
+
with(method: :get, path: '/pacticipants/Pricing%20Service/versions/last', headers: get_request_headers).
|
355
347
|
will_respond_with( status: 404, headers: pact_broker_response_headers )
|
356
348
|
end
|
357
349
|
it 'returns nil' do
|
data/spec/spec_helper.rb
CHANGED
@@ -0,0 +1,19 @@
|
|
1
|
+
{
|
2
|
+
"_links": {
|
3
|
+
"self": { "href": "http://localhost:1234/pacticipants/Pricing%20Service" },
|
4
|
+
"versions": { "href": "http://localhost:1234/pacticipants/Pricing%20Service/versions" },
|
5
|
+
"last_version": { "href": "http://localhost:1234/pacticipants/Pricing%20Service/versions/last" }
|
6
|
+
},
|
7
|
+
"name" : "Pricing Service",
|
8
|
+
"repository_url": "git@git.realestate.com.au:business-systems/pricing-service",
|
9
|
+
"_embedded" : {
|
10
|
+
"last_version" : {
|
11
|
+
"_links" : {
|
12
|
+
"self": {
|
13
|
+
"href": "http://localhost:1234/pacticipants/Pricing%20Service/versions/1.3.0"
|
14
|
+
}
|
15
|
+
},
|
16
|
+
"number" : "1.3.0"
|
17
|
+
}
|
18
|
+
}
|
19
|
+
}
|
@@ -0,0 +1,26 @@
|
|
1
|
+
{
|
2
|
+
"_links": {
|
3
|
+
"self": { "href": "http://localhost:1234/pacticipants" },
|
4
|
+
"pacticipants": [
|
5
|
+
{ "href": "http://localhost:1234/pacticipants/Condor", "name": "Condor" }
|
6
|
+
]
|
7
|
+
},
|
8
|
+
"pacticipants" : [{
|
9
|
+
"_links": {
|
10
|
+
"self" : {
|
11
|
+
"href" : "http://localhost:1234/pacticipants/Condor"
|
12
|
+
}
|
13
|
+
},
|
14
|
+
"name" : "Condor",
|
15
|
+
"_embedded" : {
|
16
|
+
"last_version" : {
|
17
|
+
"_links" : {
|
18
|
+
"self": {
|
19
|
+
"href": "http://localhost:1234/pacticipants/Condor/versions/1.3.0"
|
20
|
+
}
|
21
|
+
},
|
22
|
+
"number" : "1.3.0"
|
23
|
+
}
|
24
|
+
}
|
25
|
+
}]
|
26
|
+
}
|
data/tasks/pact.rake
ADDED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pact_broker-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-11-
|
12
|
+
date: 2013-11-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: pact
|
@@ -169,9 +169,13 @@ files:
|
|
169
169
|
- spec/lib/pact_broker/client/publish_pacts_spec.rb
|
170
170
|
- spec/lib/pact_broker/client/tasks/publication_task_spec.rb
|
171
171
|
- spec/pacts/pact_broker_client-pact_broker.json
|
172
|
+
- spec/service_providers/extra_goodies_spec.rb
|
172
173
|
- spec/service_providers/pact_broker_client_spec.rb
|
173
174
|
- spec/service_providers/pact_helper.rb
|
174
175
|
- spec/spec_helper.rb
|
176
|
+
- spec/support/pacticipant_get.json
|
177
|
+
- spec/support/pacticipants_list.json
|
178
|
+
- tasks/pact.rake
|
175
179
|
homepage: https://github.com/bethesque/pact_broker-client.git
|
176
180
|
licenses:
|
177
181
|
- MIT
|
@@ -187,7 +191,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
187
191
|
version: '0'
|
188
192
|
segments:
|
189
193
|
- 0
|
190
|
-
hash:
|
194
|
+
hash: -1865173993885174069
|
191
195
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
192
196
|
none: false
|
193
197
|
requirements:
|
@@ -196,7 +200,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
196
200
|
version: '0'
|
197
201
|
segments:
|
198
202
|
- 0
|
199
|
-
hash:
|
203
|
+
hash: -1865173993885174069
|
200
204
|
requirements: []
|
201
205
|
rubyforge_project:
|
202
206
|
rubygems_version: 1.8.23
|
@@ -208,6 +212,9 @@ test_files:
|
|
208
212
|
- spec/lib/pact_broker/client/publish_pacts_spec.rb
|
209
213
|
- spec/lib/pact_broker/client/tasks/publication_task_spec.rb
|
210
214
|
- spec/pacts/pact_broker_client-pact_broker.json
|
215
|
+
- spec/service_providers/extra_goodies_spec.rb
|
211
216
|
- spec/service_providers/pact_broker_client_spec.rb
|
212
217
|
- spec/service_providers/pact_helper.rb
|
213
218
|
- spec/spec_helper.rb
|
219
|
+
- spec/support/pacticipant_get.json
|
220
|
+
- spec/support/pacticipants_list.json
|