pact_broker-client 1.75.3 → 1.76.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.
Files changed (113) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +15 -0
  3. data/lib/pact_broker/client/can_i_deploy.rb +1 -1
  4. data/lib/pact_broker/client/version.rb +1 -1
  5. metadata +5 -216
  6. data/.github/workflows/test.yml +0 -59
  7. data/.rspec +0 -3
  8. data/lib/pact_broker/client/pacts/list_latest_versions.rb +0 -66
  9. data/lib/pact_broker/client/webhooks/test.rb +0 -16
  10. data/pact-broker-client.gemspec +0 -31
  11. data/spec/fixtures/MyConsumer-MyProvider (1).json +0 -37
  12. data/spec/fixtures/MyConsumer-MyProvider.json +0 -37
  13. data/spec/fixtures/approvals/can_i_deploy_failure_dry_run.approved.txt +0 -7
  14. data/spec/fixtures/approvals/can_i_deploy_ignore.approved.txt +0 -13
  15. data/spec/fixtures/approvals/can_i_deploy_success_dry_run.approved.txt +0 -7
  16. data/spec/fixtures/approvals/describe_environment.approved.txt +0 -7
  17. data/spec/fixtures/approvals/describe_pacticipant.approved.txt +0 -2
  18. data/spec/fixtures/approvals/list_environments.approved.txt +0 -3
  19. data/spec/fixtures/approvals/publish_provider_contract.approved.txt +0 -2
  20. data/spec/fixtures/certificates/ca_cert.pem +0 -19
  21. data/spec/fixtures/certificates/ca_cert.srl +0 -1
  22. data/spec/fixtures/certificates/ca_key.pem +0 -28
  23. data/spec/fixtures/certificates/client_cert.pem +0 -17
  24. data/spec/fixtures/certificates/key.pem +0 -28
  25. data/spec/fixtures/certificates/server.csr +0 -15
  26. data/spec/fixtures/certificates/unsigned_cert.pem +0 -19
  27. data/spec/fixtures/certificates/unsigned_key.pem +0 -28
  28. data/spec/fixtures/foo-bar.json +0 -31
  29. data/spec/integration/can_i_deploy_spec.rb +0 -24
  30. data/spec/integration/can_i_merge_spec.rb +0 -44
  31. data/spec/integration/create_version_tag_spec.rb +0 -20
  32. data/spec/integration/describe_environment_spec.rb +0 -31
  33. data/spec/integration/publish_provider_contract_spec.rb +0 -53
  34. data/spec/integration/unknown_options_spec.rb +0 -39
  35. data/spec/lib/pact_broker/client/base_client_spec.rb +0 -182
  36. data/spec/lib/pact_broker/client/branches/delete_branch_spec.rb +0 -103
  37. data/spec/lib/pact_broker/client/can_i_deploy_spec.rb +0 -250
  38. data/spec/lib/pact_broker/client/cli/broker_can_i_deploy_spec.rb +0 -196
  39. data/spec/lib/pact_broker/client/cli/broker_create_or_update_webhook_spec.rb +0 -23
  40. data/spec/lib/pact_broker/client/cli/broker_create_webhook_spec.rb +0 -23
  41. data/spec/lib/pact_broker/client/cli/broker_publish_spec.rb +0 -327
  42. data/spec/lib/pact_broker/client/cli/broker_run_webhook_commands_spec.rb +0 -287
  43. data/spec/lib/pact_broker/client/cli/custom_thor_spec.rb +0 -174
  44. data/spec/lib/pact_broker/client/cli/version_selector_options_parser_spec.rb +0 -97
  45. data/spec/lib/pact_broker/client/deployments/record_deployment_spec.rb +0 -224
  46. data/spec/lib/pact_broker/client/deployments/record_support_ended_spec.rb +0 -208
  47. data/spec/lib/pact_broker/client/deployments/record_undeployment_spec.rb +0 -227
  48. data/spec/lib/pact_broker/client/environments/delete_environment_spec.rb +0 -120
  49. data/spec/lib/pact_broker/client/environments/describe_environment_spec.rb +0 -89
  50. data/spec/lib/pact_broker/client/environments/update_environment_spec.rb +0 -167
  51. data/spec/lib/pact_broker/client/generate_display_name_spec.rb +0 -39
  52. data/spec/lib/pact_broker/client/git_spec.rb +0 -159
  53. data/spec/lib/pact_broker/client/hal/authorization_header_redactor_spec.rb +0 -17
  54. data/spec/lib/pact_broker/client/hal/entity_spec.rb +0 -149
  55. data/spec/lib/pact_broker/client/hal/http_client_spec.rb +0 -238
  56. data/spec/lib/pact_broker/client/hal/link_spec.rb +0 -127
  57. data/spec/lib/pact_broker/client/matrix/abbreviate_version_number_spec.rb +0 -42
  58. data/spec/lib/pact_broker/client/matrix/resource_spec.rb +0 -70
  59. data/spec/lib/pact_broker/client/matrix/text_formatter_spec.rb +0 -63
  60. data/spec/lib/pact_broker/client/matrix_spec.rb +0 -17
  61. data/spec/lib/pact_broker/client/merge_pacts_spec.rb +0 -198
  62. data/spec/lib/pact_broker/client/pact_broker_client_spec.rb +0 -47
  63. data/spec/lib/pact_broker/client/pacticipants/create_spec.rb +0 -31
  64. data/spec/lib/pact_broker/client/pacticipants_spec.rb +0 -18
  65. data/spec/lib/pact_broker/client/publish_pacts_the_old_way_spec.rb +0 -272
  66. data/spec/lib/pact_broker/client/retry_spec.rb +0 -119
  67. data/spec/lib/pact_broker/client/tasks/publication_task_spec.rb +0 -231
  68. data/spec/lib/pact_broker/client/versions/create_spec.rb +0 -174
  69. data/spec/lib/pact_broker/client/versions/describe_spec.rb +0 -64
  70. data/spec/lib/pact_broker/client/versions_spec.rb +0 -34
  71. data/spec/lib/pact_broker/client/webhooks/create_spec.rb +0 -99
  72. data/spec/lib/pactflow/client/provider_contracts/publish_spec.rb +0 -179
  73. data/spec/pacts/pact_broker_client-pact_broker.json +0 -2969
  74. data/spec/pacts/pact_broker_client-pactflow.json +0 -288
  75. data/spec/readme_spec.rb +0 -16
  76. data/spec/service_providers/create_environment_spec.rb +0 -78
  77. data/spec/service_providers/delete_branch_spec.rb +0 -68
  78. data/spec/service_providers/extra_goodies_spec.rb +0 -108
  79. data/spec/service_providers/list_environments_spec.rb +0 -77
  80. data/spec/service_providers/list_latest_pact_versions_spec.rb.bak +0 -44
  81. data/spec/service_providers/pact_broker_client_matrix_ignore_spec.rb +0 -98
  82. data/spec/service_providers/pact_broker_client_matrix_spec.rb +0 -292
  83. data/spec/service_providers/pact_broker_client_pacticipant_version_spec.rb +0 -56
  84. data/spec/service_providers/pact_broker_client_publish_spec.rb +0 -135
  85. data/spec/service_providers/pact_broker_client_register_repository_spec.rb +0 -49
  86. data/spec/service_providers/pact_broker_client_retrieve_all_pacts_for_provider_spec.rb +0 -53
  87. data/spec/service_providers/pact_broker_client_retrieve_pact_spec.rb +0 -109
  88. data/spec/service_providers/pact_broker_client_tags_spec.rb +0 -101
  89. data/spec/service_providers/pact_broker_client_versions_spec.rb +0 -113
  90. data/spec/service_providers/pact_helper.rb +0 -136
  91. data/spec/service_providers/pactflow_publish_provider_contract_spec.rb +0 -137
  92. data/spec/service_providers/pactflow_publish_provider_contract_the_old_way_spec.rb +0 -129
  93. data/spec/service_providers/pactflow_webhooks_create_spec.rb +0 -86
  94. data/spec/service_providers/pacticipants_create_spec.rb +0 -119
  95. data/spec/service_providers/publish_pacts_spec.rb +0 -114
  96. data/spec/service_providers/record_deployment_spec.rb +0 -199
  97. data/spec/service_providers/record_release_spec.rb +0 -130
  98. data/spec/service_providers/record_undeployment_spec.rb +0 -164
  99. data/spec/service_providers/webhooks_create_spec.rb +0 -391
  100. data/spec/spec_helper.rb +0 -68
  101. data/spec/support/approvals.rb +0 -26
  102. data/spec/support/cli_test_pacts/bar.json +0 -0
  103. data/spec/support/cli_test_pacts/foo.json +0 -0
  104. data/spec/support/latest_pacts_for_provider.json +0 -15
  105. data/spec/support/matrix.json +0 -35
  106. data/spec/support/matrix.txt +0 -3
  107. data/spec/support/matrix_error.txt +0 -3
  108. data/spec/support/matrix_with_results.txt +0 -10
  109. data/spec/support/pacticipant_get.json +0 -18
  110. data/spec/support/pacticipants_list.json +0 -26
  111. data/spec/support/pacts_latest_list.json +0 -41
  112. data/spec/support/shared_context.rb +0 -25
  113. data/spec/support/ssl_server.rb +0 -42
@@ -1,288 +0,0 @@
1
- {
2
- "consumer": {
3
- "name": "Pact Broker Client"
4
- },
5
- "provider": {
6
- "name": "PactFlow"
7
- },
8
- "interactions": [
9
- {
10
- "description": "a request for the index resource",
11
- "providerState": "the pb:publish-provider-contract relation exists in the index resource",
12
- "request": {
13
- "method": "GET",
14
- "path": "/",
15
- "headers": {
16
- "Accept": "application/hal+json"
17
- }
18
- },
19
- "response": {
20
- "status": 200,
21
- "headers": {
22
- "Content-Type": "application/hal+json;charset=utf-8"
23
- },
24
- "body": {
25
- "_links": {
26
- "pf:publish-provider-contract": {
27
- "href": "http://localhost:1235/HAL-REL-PLACEHOLDER-PF-PUBLISH-PROVIDER-CONTRACT-{provider}"
28
- }
29
- }
30
- },
31
- "matchingRules": {
32
- "$.body._links.pf:publish-provider-contract.href": {
33
- "match": "regex",
34
- "regex": "http:\\/\\/.*{provider}"
35
- }
36
- }
37
- }
38
- },
39
- {
40
- "description": "a request to publish a provider contract",
41
- "request": {
42
- "method": "post",
43
- "path": "/HAL-REL-PLACEHOLDER-PF-PUBLISH-PROVIDER-CONTRACT-Bar",
44
- "headers": {
45
- "Content-Type": "application/json",
46
- "Accept": "application/hal+json,application/problem+json"
47
- },
48
- "body": {
49
- "pacticipantVersionNumber": "1",
50
- "tags": [
51
- "dev"
52
- ],
53
- "branch": "main",
54
- "buildUrl": "http://build",
55
- "contract": {
56
- "content": "LS0tCnNvbWU6IGNvbnRyYWN0Cg==",
57
- "contentType": "application/yaml",
58
- "specification": "oas",
59
- "selfVerificationResults": {
60
- "success": true,
61
- "content": "c29tZSByZXN1bHRz",
62
- "contentType": "text/plain",
63
- "format": "text",
64
- "verifier": "my custom tool",
65
- "verifierVersion": "1.0"
66
- }
67
- }
68
- }
69
- },
70
- "response": {
71
- "status": 200,
72
- "headers": {
73
- "Content-Type": "application/hal+json;charset=utf-8"
74
- },
75
- "body": {
76
- "notices": [
77
- {
78
- "text": "some notice",
79
- "type": "info"
80
- }
81
- ],
82
- "_embedded": {
83
- "version": {
84
- "number": "1"
85
- }
86
- },
87
- "_links": {
88
- "pb:pacticipant-version-tags": [
89
- {
90
- }
91
- ],
92
- "pb:branch-version": {
93
- }
94
- }
95
- },
96
- "matchingRules": {
97
- "$.body.notices": {
98
- "min": 1
99
- },
100
- "$.body.notices[*].*": {
101
- "match": "type"
102
- }
103
- }
104
- }
105
- },
106
- {
107
- "description": "a request to create a provider contract",
108
- "request": {
109
- "method": "put",
110
- "path": "/contracts/provider/Bar/version/1",
111
- "headers": {
112
- "Content-Type": "application/json",
113
- "Accept": "application/hal+json"
114
- },
115
- "body": {
116
- "content": "LS0tCnNvbWU6IGNvbnRyYWN0Cg==",
117
- "contractType": "oas",
118
- "contentType": "application/yaml",
119
- "verificationResults": {
120
- "success": true,
121
- "content": "c29tZSByZXN1bHRz",
122
- "contentType": "text/plain",
123
- "format": "text",
124
- "verifier": "my custom tool",
125
- "verifierVersion": "1.0"
126
- }
127
- }
128
- },
129
- "response": {
130
- "status": 201,
131
- "headers": {
132
- "Content-Type": "application/hal+json;charset=utf-8"
133
- }
134
- }
135
- },
136
- {
137
- "description": "a request to create a provider contract",
138
- "providerState": "there is a pf:ui href in the response",
139
- "request": {
140
- "method": "put",
141
- "path": "/contracts/provider/Bar/version/1",
142
- "headers": {
143
- "Content-Type": "application/json",
144
- "Accept": "application/hal+json"
145
- },
146
- "body": {
147
- "content": "LS0tCnNvbWU6IGNvbnRyYWN0Cg==",
148
- "contractType": "oas",
149
- "contentType": "application/yaml",
150
- "verificationResults": {
151
- "success": true,
152
- "content": "c29tZSByZXN1bHRz",
153
- "contentType": "text/plain",
154
- "format": "text",
155
- "verifier": "my custom tool",
156
- "verifierVersion": "1.0"
157
- }
158
- }
159
- },
160
- "response": {
161
- "status": 201,
162
- "headers": {
163
- "Content-Type": "application/hal+json;charset=utf-8"
164
- },
165
- "body": {
166
- "_links": {
167
- "pf:ui": {
168
- "href": "some-url"
169
- }
170
- }
171
- },
172
- "matchingRules": {
173
- "$.body._links.pf:ui.href": {
174
- "match": "type"
175
- }
176
- }
177
- }
178
- },
179
- {
180
- "description": "a request for the index resource",
181
- "request": {
182
- "method": "get",
183
- "path": "/",
184
- "headers": {
185
- "Accept": "application/hal+json"
186
- }
187
- },
188
- "response": {
189
- "status": 200,
190
- "headers": {
191
- "Content-Type": "application/hal+json;charset=utf-8"
192
- },
193
- "body": {
194
- "_links": {
195
- "pb:webhooks": {
196
- "href": "http://localhost:1235/HAL-REL-PLACEHOLDER-PB-WEBHOOKS"
197
- },
198
- "pb:pacticipants": {
199
- "href": "http://localhost:1235/HAL-REL-PLACEHOLDER-PB-PACTICIPANTS"
200
- },
201
- "pb:pacticipant": {
202
- "href": "http://localhost:1235/HAL-REL-PLACEHOLDER-PB-PACTICIPANT-{pacticipant}"
203
- }
204
- }
205
- },
206
- "matchingRules": {
207
- "$.body._links.pb:webhooks.href": {
208
- "match": "regex",
209
- "regex": "http:\\/\\/.*"
210
- },
211
- "$.body._links.pb:pacticipants.href": {
212
- "match": "regex",
213
- "regex": "http:\\/\\/.*"
214
- },
215
- "$.body._links.pb:pacticipant.href": {
216
- "match": "regex",
217
- "regex": "http:\\/\\/.*{pacticipant}"
218
- }
219
- }
220
- }
221
- },
222
- {
223
- "description": "a request to create a webhook for a team",
224
- "providerState": "a team with UUID 2abbc12a-427d-432a-a521-c870af1739d9 exists",
225
- "request": {
226
- "method": "post",
227
- "path": "/HAL-REL-PLACEHOLDER-PB-WEBHOOKS",
228
- "headers": {
229
- "Content-Type": "application/json",
230
- "Accept": "application/hal+json"
231
- },
232
- "body": {
233
- "description": "a webhook",
234
- "events": [
235
- {
236
- "name": "contract_content_changed"
237
- }
238
- ],
239
- "request": {
240
- "url": "https://webhook",
241
- "method": "POST",
242
- "headers": {
243
- "Foo": "bar",
244
- "Bar": "foo"
245
- },
246
- "body": {
247
- "some": "body"
248
- }
249
- },
250
- "teamUuid": "2abbc12a-427d-432a-a521-c870af1739d9"
251
- }
252
- },
253
- "response": {
254
- "status": 201,
255
- "headers": {
256
- "Content-Type": "application/hal+json;charset=utf-8"
257
- },
258
- "body": {
259
- "description": "a webhook",
260
- "teamUuid": "2abbc12a-427d-432a-a521-c870af1739d9",
261
- "_links": {
262
- "self": {
263
- "href": "http://localhost:1234/some-url",
264
- "title": "A title"
265
- }
266
- }
267
- },
268
- "matchingRules": {
269
- "$.body.description": {
270
- "match": "type"
271
- },
272
- "$.body._links.self.href": {
273
- "match": "regex",
274
- "regex": "http:\\/\\/.*"
275
- },
276
- "$.body._links.self.title": {
277
- "match": "type"
278
- }
279
- }
280
- }
281
- }
282
- ],
283
- "metadata": {
284
- "pactSpecification": {
285
- "version": "2.0.0"
286
- }
287
- }
288
- }
data/spec/readme_spec.rb DELETED
@@ -1,16 +0,0 @@
1
- require "pact_broker/client/cli/broker"
2
-
3
- RSpec.describe "the README" do
4
- NOT_DOCUMENTED = ["version"]
5
- COMMANDS = PactBroker::Client::CLI::Broker
6
- .commands
7
- .values
8
- .collect(&:usage).collect { | usage | usage.split(" ").first } - NOT_DOCUMENTED
9
- README = File.read("README.md")
10
-
11
- COMMANDS.each do | command |
12
- it "includes the documentation for #{command}" do
13
- expect(README.include?("\n#### " + command)).to be_truthy
14
- end
15
- end
16
- end
@@ -1,78 +0,0 @@
1
- require 'service_providers/pact_helper'
2
- require 'pact_broker/client/environments/create_environment'
3
-
4
- RSpec.describe "create an environment", pact: true, skip: true do
5
- include_context "pact broker"
6
- include PactBrokerPactHelperMethods
7
-
8
- let(:params) do
9
- {
10
- name: "test",
11
- display_name: "Test",
12
- production: false,
13
- contact_name: "Foo team",
14
- contact_email_address: "foo@bar.com"
15
-
16
- }
17
- end
18
- let(:pact_broker_client_options) { {} }
19
- let(:request_body) do
20
- {
21
- name: "test",
22
- displayName: "Test",
23
- production: false,
24
- contacts: [{
25
- name: "Foo team",
26
- details: {
27
- emailAddress: "foo@bar.com"
28
- }
29
- }]
30
- }
31
- end
32
-
33
- subject { PactBroker::Client::Environments::CreateEnvironment.call(params, broker_base_url, pact_broker_client_options) }
34
-
35
- def mock_index
36
- pact_broker
37
- .given("the pb:environments relation exists in the index resource")
38
- .upon_receiving("a request for the index resource")
39
- .with(
40
- method: "GET",
41
- path: '/',
42
- headers: get_request_headers).
43
- will_respond_with(
44
- status: 200,
45
- headers: pact_broker_response_headers,
46
- body: {
47
- _links: {
48
- :'pb:environments' => {
49
- href: placeholder_url_term("pb:environments")
50
- }
51
- }
52
- }
53
- )
54
- end
55
-
56
- def mock_environment_creation_request
57
- pact_broker
58
- .upon_receiving("a request to create an environment")
59
- .with(
60
- method: "POST",
61
- path: "/HAL-REL-PLACEHOLDER-PB-ENVIRONMENTS",
62
- headers: post_request_headers,
63
- body: request_body
64
- )
65
- .will_respond_with(
66
- status: 201,
67
- headers: pact_broker_response_headers,
68
- body: request_body.merge("uuid" => Pact.like("ffe683ef-dcd7-4e4f-877d-f6eb3db8e86e"))
69
- )
70
- end
71
-
72
- it "returns a success result" do
73
- mock_index
74
- mock_environment_creation_request
75
- expect(subject.success).to be true
76
- expect(subject.message).to include "Created test environment in the Pact Broker with UUID ffe683ef-dcd7-4e4f-877d-f6eb3db8e86e"
77
- end
78
- end
@@ -1,68 +0,0 @@
1
- require "service_providers/pact_helper"
2
- require "pact_broker/client/branches/delete_branch"
3
-
4
- RSpec.describe "delete a branch", pact: true do
5
- include_context "pact broker"
6
- include PactBrokerPactHelperMethods
7
-
8
- let(:params) do
9
- {
10
- pacticipant: "Foo",
11
- branch: "main",
12
- error_when_not_found: true
13
- }
14
- end
15
-
16
- let(:options) do
17
- {
18
- verbose: verbose
19
- }
20
- end
21
-
22
- let(:pact_broker_base_url) { pact_broker.mock_service_base_url }
23
- let(:pact_broker_client_options) { { pact_broker_base_url: pact_broker_base_url } }
24
- let(:response_headers) { { "Content-Type" => "application/hal+json"} }
25
- let(:verbose) { false }
26
-
27
- subject { PactBroker::Client::Branches::DeleteBranch.call(params, options, pact_broker_client_options) }
28
-
29
- def mock_index
30
- pact_broker
31
- .given("the pb:pacticipant-branch relation exists in the index resource")
32
- .upon_receiving("a request for the index resource")
33
- .with(
34
- method: "GET",
35
- path: '/',
36
- headers: get_request_headers).
37
- will_respond_with(
38
- status: 200,
39
- headers: pact_broker_response_headers,
40
- body: {
41
- _links: {
42
- :'pb:pacticipant-branch' => {
43
- href: placeholder_url_term("pb:pacticipant-branch", ["pacticipant", "branch"], pact_broker)
44
- }
45
- }
46
- }
47
- )
48
- end
49
-
50
- def mock_branch_delete_request
51
- pact_broker
52
- .given("a branch named main exists for pacticipant Foo")
53
- .upon_receiving("a request to delete a pacticipant branch")
54
- .with(
55
- method: "DELETE",
56
- path: placeholder_path("pb:pacticipant-branch", ["Foo", "main"])
57
- )
58
- .will_respond_with(
59
- status: 204
60
- )
61
- end
62
-
63
- it "returns a success result" do
64
- mock_index
65
- mock_branch_delete_request
66
- expect(subject.success).to be true
67
- end
68
- end
@@ -1,108 +0,0 @@
1
- require 'spec_helper'
2
- require_relative 'pact_helper'
3
- require 'pact_broker/client/pact_broker_client'
4
-
5
-
6
- module PactBroker::Client
7
- describe PactBrokerClient, :pact => true do
8
-
9
- let(:pact_broker_client) { PactBrokerClient.new(base_url: 'http://localhost:1234') }
10
-
11
- describe "listing pacts" do
12
- context "when pacts exist" do
13
- let(:response_body) { JSON.parse(File.read("./spec/support/pacts_latest_list.json"))}
14
- let(:expected_pacts) do
15
- [{
16
- :consumer => {
17
- :name => 'Condor',
18
- :version => {
19
- :number => '1.3.0'
20
- }
21
- },
22
- :provider => {
23
- :name => 'Pricing Service'
24
- }
25
- }
26
- ]
27
- end
28
- before do
29
- pact_broker.
30
- given("a pact between Condor and the Pricing Service exists").
31
- upon_receiving("a request to list the latest pacts").
32
- with(
33
- method: :get,
34
- path: '/pacts/latest',
35
- headers: {} ).
36
- will_respond_with( headers: {'Content-Type' => Pact.term(generate: 'application/hal+json', matcher: %r{application/hal\+json})},
37
- status: 200,
38
- body: response_body
39
- )
40
- end
41
- it "returns the response body" do
42
- expect(pact_broker_client.pacts.list_latest).to eq(expected_pacts)
43
- end
44
- end
45
- end
46
-
47
- describe "listing pacticipants" do
48
- context "when a pacticipant exists" do
49
- let(:response_body) { JSON.parse(File.read("./spec/support/pacticipants_list.json"))}
50
- before do
51
- pact_broker.
52
- given("'Condor' exists in the pact-broker").
53
- upon_receiving("a request to list pacticipants").
54
- with(
55
- method: :get,
56
- path: '/pacticipants',
57
- headers: {} ).
58
- will_respond_with( headers: {'Content-Type' => Pact.term(generate: 'application/hal+json', matcher: %r{application/hal\+json})},
59
- status: 200,
60
- body: response_body
61
- )
62
- end
63
- it "returns the response body" do
64
- expect(pact_broker_client.pacticipants.list).to eq response_body
65
- end
66
- end
67
- end
68
-
69
- describe "get pacticipant" do
70
- context "when the pacticipant exists" do
71
- let(:response_body) { JSON.parse(File.read("./spec/support/pacticipant_get.json"))}
72
- let(:options) { {pacticipant: 'Pricing Service'}}
73
- before do
74
- pact_broker.
75
- given("the 'Pricing Service' already exists in the pact-broker").
76
- upon_receiving("a request to get the Pricing Service").
77
- with(
78
- method: :get,
79
- path: '/pacticipants/Pricing%20Service',
80
- headers: {} ).
81
- will_respond_with( headers: {'Content-Type' => Pact.term(generate: 'application/hal+json', matcher: %r{application/hal\+json})},
82
- status: 200,
83
- body: response_body
84
- )
85
- end
86
- it "returns the response body" do
87
- expect(pact_broker_client.pacticipants.get1(options)).to eq response_body
88
- end
89
- end
90
- context "when the pacticipant does not exist" do
91
- let(:options) { {pacticipant: 'Pricing Service'}}
92
- before do
93
- pact_broker.
94
- given("the 'Pricing Service' does not exist in the pact-broker").
95
- upon_receiving("a request to get the Pricing Service").
96
- with(
97
- method: :get,
98
- path: '/pacticipants/Pricing%20Service',
99
- headers: {} ).
100
- will_respond_with( status: 404 )
101
- end
102
- it "returns nil" do
103
- expect(pact_broker_client.pacticipants.get1(options)).to be_nil
104
- end
105
- end
106
- end
107
- end
108
- end
@@ -1,77 +0,0 @@
1
- require 'service_providers/pact_helper'
2
- require 'pact_broker/client/environments/list_environments'
3
-
4
- RSpec.describe "list environments", pact: true, skip: true do
5
- include_context "pact broker"
6
- include PactBrokerPactHelperMethods
7
-
8
- let(:params) { { output: output } }
9
- let(:output) { "text" }
10
- let(:pact_broker_client_options) { {} }
11
- let(:response_body) do
12
- {
13
- _embedded: {
14
- environments: Pact.each_like(
15
- {
16
- uuid: "78e85fb2-9df1-48da-817e-c9bea6294e01",
17
- name: "test",
18
- displayName: "Test",
19
- production: false,
20
- contacts: [{
21
- name: "Foo team",
22
- details: {
23
- emailAddress: "foo@bar.com"
24
- }
25
- }]
26
- }
27
- )
28
- }
29
- }
30
- end
31
-
32
- subject { PactBroker::Client::Environments::ListEnvironments.call(params, broker_base_url, pact_broker_client_options) }
33
-
34
- def mock_index
35
- pact_broker
36
- .given("the pb:environments relation exists in the index resource")
37
- .upon_receiving("a request for the index resource")
38
- .with(
39
- method: "GET",
40
- path: '/',
41
- headers: get_request_headers).
42
- will_respond_with(
43
- status: 200,
44
- headers: pact_broker_response_headers,
45
- body: {
46
- _links: {
47
- :'pb:environments' => {
48
- href: placeholder_url_term("pb:environments")
49
- }
50
- }
51
- }
52
- )
53
- end
54
-
55
- def mock_get_environments
56
- pact_broker
57
- .given("an environment exists")
58
- .upon_receiving("a request to list the environments")
59
- .with(
60
- method: "GET",
61
- path: "/HAL-REL-PLACEHOLDER-PB-ENVIRONMENTS",
62
- headers: get_request_headers
63
- )
64
- .will_respond_with(
65
- status: 200,
66
- headers: pact_broker_response_headers,
67
- body: response_body
68
- )
69
- end
70
-
71
- it "returns a success result" do
72
- mock_index
73
- mock_get_environments
74
- expect(subject.success).to be true
75
- Approvals.verify(subject.message, :name => "list_environments", format: :txt)
76
- end
77
- end
@@ -1,44 +0,0 @@
1
- require 'pact_broker/client/pacts/list_latest_versions'
2
-
3
- module PactBroker::Client
4
- describe Pacts::ListLatestVersions, :pact => true do
5
-
6
- let(:pact_broker_client) { PactBrokerClient.new(base_url: 'http://localhost:1234') }
7
-
8
- describe "listing pacts" do
9
- context "when pacts exist" do
10
- let(:response_body) { JSON.parse(File.read("./spec/support/pacts_latest_list.json"))}
11
- let(:expected_pacts) do
12
- [{
13
- :consumer => {
14
- :name => 'Condor',
15
- :version => {
16
- :number => '1.3.0'
17
- }
18
- },
19
- :provider => {
20
- :name => 'Pricing Service'
21
- }
22
- }
23
- ]
24
- end
25
- before do
26
- pact_broker.
27
- given("a pact between Condor and the Pricing Service exists").
28
- upon_receiving("a request to list the latest pacts").
29
- with(
30
- method: :get,
31
- path: '/pacts/latest',
32
- headers: {} ).
33
- will_respond_with( headers: {'Content-Type' => Pact.term(generate: 'application/hal+json', matcher: %r{application/hal\+json})},
34
- status: 200,
35
- body: response_body
36
- )
37
- end
38
- it "returns the response body" do
39
- expect(pact_broker_client.pacts.list_latest).to eq(expected_pacts)
40
- end
41
- end
42
- end
43
- end
44
- end