pact_broker-client 1.51.0 → 1.53.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 854312863c664ff8f355fcab3d2cb3733bf7c229f75b98aa9f2f9187a93d5409
4
- data.tar.gz: c02cfe9055664950a2811e3351c701431e5a6916a6a06e21e34aab14ee94520c
3
+ metadata.gz: d6662ad835f144252e2a6fd78f98e52b381794629dcbfb8085fa1acb0b28ece0
4
+ data.tar.gz: b0ec70c258bb01ae05801070596dbb02fe23a8f674d2bab53117c40b75a6d59f
5
5
  SHA512:
6
- metadata.gz: d5be4a8a3fc89a6606aac689d9da2a335393d0ef8e0b01e7f09c5745798c475ff1b53be34b00284c00e0cadaffecd834a75d03cca9805c8b386e2c9f223af8ec
7
- data.tar.gz: dc9192512acf2a696f635274b504042a960c8d3eded2ae7b07e17e1dc982de0badc177686fb62d9516d9976cc5d9a5fd9564b4d02bf47f6ad2bcc3e56576a590
6
+ metadata.gz: 0f20176d5773873c3cd9a41711a7d4405721f95017132702e6be84430a63baef7101aefcb2b43e05546536d974306c7677b529bd8c2d6e32701432de67e0fe44
7
+ data.tar.gz: b4fc4fa3bd5096b5281d98478cc59d8732a31c29ec7f959922c064193135fd613740220230449e2c5ea3b98611f555b372545549fd22fb52050cc7710a582023
data/CHANGELOG.md CHANGED
@@ -1,3 +1,32 @@
1
+ <a name="v1.53.0"></a>
2
+ ### v1.53.0 (2021-09-29)
3
+
4
+ #### Features
5
+
6
+ * allow pacts to be published using the old API by setting the environment variable PACT_BROKER_FEATURES=publish_pacts_using_old_api ([7c34132](/../../commit/7c34132))
7
+
8
+ <a name="v1.52.0"></a>
9
+ ### v1.52.0 (2021-09-29)
10
+
11
+ #### Features
12
+
13
+ * rename target to application-instance for record-deployment and record-undeployment (backwards compatible) ([53d23eb](/../../commit/53d23eb))
14
+
15
+ <a name="v1.51.2"></a>
16
+ ### v1.51.2 (2021-09-27)
17
+
18
+ #### Bug Fixes
19
+
20
+ * **deps**
21
+ * lock httparty to 0.18.1 ([1ab2d9c](/../../commit/1ab2d9c))
22
+
23
+ <a name="v1.51.1"></a>
24
+ ### v1.51.1 (2021-09-22)
25
+
26
+ #### Bug Fixes
27
+
28
+ * remove deprecated method of handling branches ([6d26487](/../../commit/6d26487))
29
+
1
30
  <a name="v1.51.0"></a>
2
31
  ### v1.51.0 (2021-09-22)
3
32
 
data/README.md CHANGED
@@ -275,29 +275,33 @@ Usage:
275
275
  pact-broker record-deployment --environment=ENVIRONMENT -a, --pacticipant=PACTICIPANT -b, --broker-base-url=BROKER_BASE_URL -e, --version=VERSION
276
276
 
277
277
  Options:
278
- -a, --pacticipant=PACTICIPANT
278
+ -a, --pacticipant=PACTICIPANT
279
279
  # The name of the pacticipant that was deployed.
280
- -e, --version=VERSION
280
+ -e, --version=VERSION
281
281
  # The pacticipant version number that was deployed.
282
- --environment=ENVIRONMENT
282
+ --environment=ENVIRONMENT
283
283
  # The name of the environment that the pacticipant version was
284
284
  deployed to.
285
- [--target=TARGET]
286
- # Optional. The target of the deployment - a logical identifer
287
- required to differentiate deployments when there are multiple
288
- instances of the same application in an environment.
289
- -o, [--output=OUTPUT]
285
+ [--application-instance=APPLICATION_INSTANCE]
286
+ # Optional. The application instance to which the deployment has
287
+ occurred - a logical identifer required to differentiate
288
+ deployments when there are multiple instances of the same
289
+ application in an environment. This field was called 'target'
290
+ in a beta release.
291
+ [--target=TARGET]
292
+ # Renamed to application_instance
293
+ -o, [--output=OUTPUT]
290
294
  # json or text
291
295
  # Default: text
292
- -b, --broker-base-url=BROKER_BASE_URL
296
+ -b, --broker-base-url=BROKER_BASE_URL
293
297
  # The base URL of the Pact Broker
294
- -u, [--broker-username=BROKER_USERNAME]
298
+ -u, [--broker-username=BROKER_USERNAME]
295
299
  # Pact Broker basic auth username
296
- -p, [--broker-password=BROKER_PASSWORD]
300
+ -p, [--broker-password=BROKER_PASSWORD]
297
301
  # Pact Broker basic auth password
298
- -k, [--broker-token=BROKER_TOKEN]
302
+ -k, [--broker-token=BROKER_TOKEN]
299
303
  # Pact Broker bearer token
300
- -v, [--verbose], [--no-verbose]
304
+ -v, [--verbose], [--no-verbose]
301
305
  # Verbose output. Default: false
302
306
  ```
303
307
 
@@ -310,28 +314,34 @@ Usage:
310
314
  pact-broker record-undeployment --environment=ENVIRONMENT -a, --pacticipant=PACTICIPANT -b, --broker-base-url=BROKER_BASE_URL
311
315
 
312
316
  Options:
313
- -a, --pacticipant=PACTICIPANT
317
+ -a, --pacticipant=PACTICIPANT
314
318
  # The name of the pacticipant that was undeployed.
315
- --environment=ENVIRONMENT
319
+ --environment=ENVIRONMENT
316
320
  # The name of the environment that the pacticipant version was
317
321
  undeployed from.
318
- [--target=TARGET]
322
+ [--application-instance=APPLICATION_INSTANCE]
323
+ # Optional. The application instance from which the application
324
+ is being undeployed - a logical identifer required to
325
+ differentiate deployments when there are multiple instances of
326
+ the same application in an environment. This field was called
327
+ 'target' in a beta release.
328
+ [--target=TARGET]
319
329
  # Optional. The target that the application is being undeployed
320
330
  from - a logical identifer required to differentiate
321
331
  deployments when there are multiple instances of the same
322
332
  application in an environment.
323
- -o, [--output=OUTPUT]
333
+ -o, [--output=OUTPUT]
324
334
  # json or text
325
335
  # Default: text
326
- -b, --broker-base-url=BROKER_BASE_URL
336
+ -b, --broker-base-url=BROKER_BASE_URL
327
337
  # The base URL of the Pact Broker
328
- -u, [--broker-username=BROKER_USERNAME]
338
+ -u, [--broker-username=BROKER_USERNAME]
329
339
  # Pact Broker basic auth username
330
- -p, [--broker-password=BROKER_PASSWORD]
340
+ -p, [--broker-password=BROKER_PASSWORD]
331
341
  # Pact Broker basic auth password
332
- -k, [--broker-token=BROKER_TOKEN]
342
+ -k, [--broker-token=BROKER_TOKEN]
333
343
  # Pact Broker bearer token
334
- -v, [--verbose], [--no-verbose]
344
+ -v, [--verbose], [--no-verbose]
335
345
  # Verbose output. Default: false
336
346
  ```
337
347
 
@@ -469,8 +479,8 @@ Description:
469
479
  support for environments, deployments and releases. For documentation on how to use can-i-deploy with tags, please see
470
480
  https://docs.pact.io/pact_broker/client_cli/can_i_deploy_usage_with_tags/
471
481
 
472
- Before `can-i-deploy` can be used, the relevant environment resources must first be created in the Pact Broker using the `create-environment` command. The "test"
473
- and "production" environments will have been seeded for you. You can check the existing environments by running `pact-broker list-environments`. See
482
+ Before `can-i-deploy` can be used, the relevant environment resources must first be created in the Pact Broker using the `create-environment` command. The
483
+ "test" and "production" environments will have been seeded for you. You can check the existing environments by running `pact-broker list-environments`. See
474
484
  https://docs.pact.io/pact_broker/client_cli/readme#environments for more information.
475
485
 
476
486
  $ pact-broker create-environment --name "uat" --display-name "UAT" --no-production
@@ -480,8 +490,8 @@ Description:
480
490
 
481
491
  $ pact-broker record-deployment --pacticipant Foo --version 173153ae0 --environment uat
482
492
 
483
- Before an application is deployed or released to an environment, the can-i-deploy command must be run to check that the application version is safe to deploy with
484
- the versions of each integrated application that are already in that environment.
493
+ Before an application is deployed or released to an environment, the can-i-deploy command must be run to check that the application version is safe to deploy
494
+ with the versions of each integrated application that are already in that environment.
485
495
 
486
496
  $ pact-broker can-i-deploy --pacticipant PACTICIPANT --version VERSION --to-environment ENVIRONMENT
487
497
 
@@ -489,8 +499,8 @@ Description:
489
499
 
490
500
  $ pact-broker can-i-deploy --pacticipant Foo --version 173153ae0 --to-environment test
491
501
 
492
- Can-i-deploy can also be used to check if arbitrary versions have a successful verification. When asking "Can I deploy this application version with the latest version
493
- from the main branch of another application" it functions as a "can I merge" check.
502
+ Can-i-deploy can also be used to check if arbitrary versions have a successful verification. When asking "Can I deploy this application version with the
503
+ latest version from the main branch of another application" it functions as a "can I merge" check.
494
504
 
495
505
  $ pact-broker can-i-deploy --pacticipant Foo 173153ae0 \ --pacticipant Bar --latest main
496
506
 
@@ -628,8 +638,8 @@ Options:
628
638
  ```
629
639
 
630
640
  Description:
631
- Create a curl command that executes the request that you want your webhook to execute, then replace "curl" with "pact-broker create-webhook" and add the consumer,
632
- provider, event types and broker details. Note that the URL must be the first parameter when executing create-webhook.
641
+ Create a curl command that executes the request that you want your webhook to execute, then replace "curl" with "pact-broker create-webhook" and add the
642
+ consumer, provider, event types and broker details. Note that the URL must be the first parameter when executing create-webhook.
633
643
 
634
644
  Note that the -u option from the curl command clashes with the -u option from the pact-broker CLI. When used in this command, the -u will be used as a curl
635
645
  option. Please use the --broker-username or environment variable for the Pact Broker username.
@@ -686,9 +696,9 @@ Options:
686
696
  ```
687
697
 
688
698
  Description:
689
- Create a curl command that executes the request that you want your webhook to execute, then replace "curl" with "pact-broker create-or-update-webhook" and add the
690
- consumer, provider, event types and broker details. Note that the URL must be the first parameter when executing create-or-update-webhook and a uuid must
691
- also be provided. You can generate a valid UUID by using the `generate-uuid` command.
699
+ Create a curl command that executes the request that you want your webhook to execute, then replace "curl" with "pact-broker create-or-update-webhook" and
700
+ add the consumer, provider, event types and broker details. Note that the URL must be the first parameter when executing create-or-update-webhook and a uuid
701
+ must also be provided. You can generate a valid UUID by using the `generate-uuid` command.
692
702
 
693
703
  Note that the -u option from the curl command clashes with the -u option from the pact-broker CLI. When used in this command, the -u will be used as a curl
694
704
  option. Please use the --broker-username or environment variable for the Pact Broker username.
@@ -40,8 +40,6 @@
40
40
 
41
41
  * [A request for the index resource](#a_request_for_the_index_resource_given_the_pb:pacticipant-version_and_pb:environments_relations_exist_in_the_index_resource) given the pb:pacticipant-version and pb:environments relations exist in the index resource
42
42
 
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
-
45
43
  * [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
44
 
47
45
  * [A request for the index resource with the webhook relation](#a_request_for_the_index_resource_with_the_webhook_relation)
@@ -58,10 +56,6 @@
58
56
 
59
57
  * [A request to create a pacticipant](#a_request_to_create_a_pacticipant)
60
58
 
61
- * [A request to create a pacticipant version](#a_request_to_create_a_pacticipant_version_given_version_26f353580936ad3b9baddb17b00e84f33c69e7cb_of_pacticipant_Foo_does_exist) given version 26f353580936ad3b9baddb17b00e84f33c69e7cb of pacticipant Foo does exist
62
-
63
- * [A request to create a pacticipant version](#a_request_to_create_a_pacticipant_version_given_version_26f353580936ad3b9baddb17b00e84f33c69e7cb_of_pacticipant_Foo_does_not_exist) given version 26f353580936ad3b9baddb17b00e84f33c69e7cb of pacticipant Foo does not exist
64
-
65
59
  * [A request to create a webhook for a consumer and provider](#a_request_to_create_a_webhook_for_a_consumer_and_provider_given_&#39;Condor&#39;_does_not_exist_in_the_pact-broker) given 'Condor' does not exist in the pact-broker
66
60
 
67
61
  * [A request to create a webhook with a JSON body and a uuid](#a_request_to_create_a_webhook_with_a_JSON_body_and_a_uuid_given_the_&#39;Pricing_Service&#39;_and_&#39;Condor&#39;_already_exist_in_the_pact-broker) given the 'Pricing Service' and 'Condor' already exist in the pact-broker
@@ -859,33 +853,6 @@ Pact Broker will respond with:
859
853
  }
860
854
  }
861
855
  ```
862
- <a name="a_request_for_the_index_resource_given_the_pb:pacticipant-version_relation_exists_in_the_index_resource"></a>
863
- Given **the pb:pacticipant-version relation exists in the index resource**, upon receiving **a request for the index resource** from Pact Broker Client, with
864
- ```json
865
- {
866
- "method": "get",
867
- "path": "/",
868
- "headers": {
869
- "Accept": "application/hal+json"
870
- }
871
- }
872
- ```
873
- Pact Broker will respond with:
874
- ```json
875
- {
876
- "status": 200,
877
- "headers": {
878
- "Content-Type": "application/hal+json;charset=utf-8"
879
- },
880
- "body": {
881
- "_links": {
882
- "pb:pacticipant-version": {
883
- "href": "http://localhost:1234/HAL-REL-PLACEHOLDER-INDEX-PB-PACTICIPANT-VERSION-{pacticipant}-{version}"
884
- }
885
- }
886
- }
887
- }
888
- ```
889
856
  <a name="a_request_for_the_index_resource_given_the_pb:publish-contracts_relations_exists_in_the_index_resource"></a>
890
857
  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
858
  ```json
@@ -1165,74 +1132,6 @@ Pact Broker will respond with:
1165
1132
  }
1166
1133
  }
1167
1134
  ```
1168
- <a name="a_request_to_create_a_pacticipant_version_given_version_26f353580936ad3b9baddb17b00e84f33c69e7cb_of_pacticipant_Foo_does_exist"></a>
1169
- Given **version 26f353580936ad3b9baddb17b00e84f33c69e7cb of pacticipant Foo does exist**, upon receiving **a request to create a pacticipant version** from Pact Broker Client, with
1170
- ```json
1171
- {
1172
- "method": "put",
1173
- "path": "/HAL-REL-PLACEHOLDER-INDEX-PB-PACTICIPANT-VERSION-Foo-26f353580936ad3b9baddb17b00e84f33c69e7cb",
1174
- "headers": {
1175
- "Content-Type": "application/json",
1176
- "Accept": "application/hal+json"
1177
- },
1178
- "body": {
1179
- "branch": "main",
1180
- "buildUrl": "http://my-ci/builds/1"
1181
- }
1182
- }
1183
- ```
1184
- Pact Broker will respond with:
1185
- ```json
1186
- {
1187
- "status": 200,
1188
- "headers": {
1189
- "Content-Type": "application/hal+json;charset=utf-8"
1190
- },
1191
- "body": {
1192
- "number": "26f353580936ad3b9baddb17b00e84f33c69e7cb",
1193
- "buildUrl": "http://my-ci/builds/1",
1194
- "_links": {
1195
- "self": {
1196
- "href": "http://localhost:1234/some-url"
1197
- }
1198
- }
1199
- }
1200
- }
1201
- ```
1202
- <a name="a_request_to_create_a_pacticipant_version_given_version_26f353580936ad3b9baddb17b00e84f33c69e7cb_of_pacticipant_Foo_does_not_exist"></a>
1203
- Given **version 26f353580936ad3b9baddb17b00e84f33c69e7cb of pacticipant Foo does not exist**, upon receiving **a request to create a pacticipant version** from Pact Broker Client, with
1204
- ```json
1205
- {
1206
- "method": "put",
1207
- "path": "/HAL-REL-PLACEHOLDER-INDEX-PB-PACTICIPANT-VERSION-Foo-26f353580936ad3b9baddb17b00e84f33c69e7cb",
1208
- "headers": {
1209
- "Content-Type": "application/json",
1210
- "Accept": "application/hal+json"
1211
- },
1212
- "body": {
1213
- "branch": "main",
1214
- "buildUrl": "http://my-ci/builds/1"
1215
- }
1216
- }
1217
- ```
1218
- Pact Broker will respond with:
1219
- ```json
1220
- {
1221
- "status": 201,
1222
- "headers": {
1223
- "Content-Type": "application/hal+json;charset=utf-8"
1224
- },
1225
- "body": {
1226
- "number": "26f353580936ad3b9baddb17b00e84f33c69e7cb",
1227
- "buildUrl": "http://my-ci/builds/1",
1228
- "_links": {
1229
- "self": {
1230
- "href": "http://localhost:1234/some-url"
1231
- }
1232
- }
1233
- }
1234
- }
1235
- ```
1236
1135
  <a name="a_request_to_create_a_webhook_for_a_consumer_and_provider_given_&#39;Condor&#39;_does_not_exist_in_the_pact-broker"></a>
1237
1136
  Given **'Condor' does not exist in the pact-broker**, upon receiving **a request to create a webhook for a consumer and provider** from Pact Broker Client, with
1238
1137
  ```json
@@ -2230,6 +2129,7 @@ Given **version 5556b8149bf8bac76bc30f50a8a2dd4c22c85f30 of pacticipant Foo exis
2230
2129
  "Accept": "application/hal+json"
2231
2130
  },
2232
2131
  "body": {
2132
+ "applicationInstance": "blue",
2233
2133
  "target": "blue"
2234
2134
  }
2235
2135
  }
@@ -14,16 +14,18 @@ module PactBroker
14
14
  method_option :pacticipant, required: true, aliases: "-a", desc: "The name of the pacticipant that was deployed."
15
15
  method_option :version, required: true, aliases: "-e", desc: "The pacticipant version number that was deployed."
16
16
  method_option :environment, required: true, desc: "The name of the environment that the pacticipant version was deployed to."
17
- method_option :target, default: nil, required: false, desc: "Optional. The target of the deployment - a logical identifer required to differentiate deployments when there are multiple instances of the same application in an environment."
17
+ method_option :application_instance, default: nil, required: false, desc: "Optional. The application instance to which the deployment has occurred - a logical identifer required to differentiate deployments when there are multiple instances of the same application in an environment. This field was called 'target' in a beta release."
18
+ method_option :target, hidden: true, default: nil, required: false, desc: "Renamed to application_instance"
18
19
  output_option_json_or_text
19
20
  shared_authentication_options
20
21
 
21
22
  def record_deployment
23
+ $stderr.puts("WARN: target has been renamed to application-instance") if options.target
22
24
  params = {
23
25
  pacticipant_name: options.pacticipant,
24
26
  version_number: options.version,
25
27
  environment_name: options.environment,
26
- target: options.target
28
+ application_instance: options.application_instance || options.target
27
29
  }
28
30
  execute_deployment_command(params, "RecordDeployment")
29
31
  end
@@ -32,15 +34,17 @@ module PactBroker
32
34
  long_desc "Note that use of this command is only required if you are permanently removing an application instance from an environment. It is not required if you are deploying over a previous version, as record-deployment will automatically mark the previously deployed version as undeployed for you. See #{RECORD_UNDEPLOYMENT_HELP_URL} for more information."
33
35
  method_option :pacticipant, required: true, aliases: "-a", desc: "The name of the pacticipant that was undeployed."
34
36
  method_option :environment, required: true, desc: "The name of the environment that the pacticipant version was undeployed from."
37
+ method_option :application_instance, default: nil, required: false, desc: "Optional. The application instance from which the application is being undeployed - a logical identifer required to differentiate deployments when there are multiple instances of the same application in an environment. This field was called 'target' in a beta release."
35
38
  method_option :target, default: nil, required: false, desc: "Optional. The target that the application is being undeployed from - a logical identifer required to differentiate deployments when there are multiple instances of the same application in an environment."
36
39
  output_option_json_or_text
37
40
  shared_authentication_options
38
41
 
39
42
  def record_undeployment
43
+ $stderr.puts("WARN: target has been renamed to application-instance") if options.target
40
44
  params = {
41
45
  pacticipant_name: options.pacticipant,
42
46
  environment_name: options.environment,
43
- target: options.target
47
+ application_instance: options.application_instance || options.target
44
48
  }
45
49
  execute_deployment_command(params, "RecordUndeployment")
46
50
  end
@@ -6,12 +6,12 @@ module PactBroker
6
6
  class RecordDeployment < PactBroker::Client::Deployments::RecordRelease
7
7
  def initialize(params, options, pact_broker_client_options)
8
8
  super
9
- @target = params.fetch(:target)
9
+ @application_instance = params.fetch(:application_instance)
10
10
  end
11
11
 
12
12
  private
13
13
 
14
- attr_reader :target
14
+ attr_reader :application_instance
15
15
 
16
16
  def action
17
17
  "deployment"
@@ -22,12 +22,13 @@ module PactBroker
22
22
  end
23
23
 
24
24
  def record_action_request_body
25
- { target: target }.compact
25
+ # for backwards compatibility with old broker
26
+ { applicationInstance: application_instance, target: application_instance }.compact
26
27
  end
27
28
 
28
29
  def result_text_message
29
- if target
30
- "#{super} (target #{target})"
30
+ if application_instance
31
+ "#{super} (application instance #{application_instance})"
31
32
  else
32
33
  super
33
34
  end
@@ -8,7 +8,7 @@ module PactBroker
8
8
  super
9
9
  @pacticipant_name = params.fetch(:pacticipant_name)
10
10
  @environment_name = params.fetch(:environment_name)
11
- @target = params.fetch(:target)
11
+ @application_instance = params.fetch(:application_instance)
12
12
  end
13
13
 
14
14
  private
@@ -21,7 +21,7 @@ module PactBroker
21
21
  end
22
22
  end
23
23
 
24
- attr_reader :pacticipant_name, :environment_name, :target
24
+ attr_reader :pacticipant_name, :environment_name, :application_instance
25
25
 
26
26
  def currently_deployed_versions_link
27
27
  environment_resource._link("pb:currently-deployed-deployed-versions", "pb:currently-deployed-versions") or raise PactBroker::Client::Error.new(not_supported_message)
@@ -31,14 +31,19 @@ module PactBroker
31
31
  @deployed_version_links ||= currently_deployed_versions_link.get!(pacticipant: pacticipant_name).embedded_entities!("deployedVersions")
32
32
  end
33
33
 
34
- def currently_deployed_version_entities_for_pacticipant_and_target
34
+ def currently_deployed_version_entities_for_pacticipant_and_instance
35
35
  currently_deployed_version_entities_for_pacticipant.select do | entity |
36
- entity.target == target
36
+ if application_instance
37
+ entity.applicationInstance == application_instance || entity.target == application_instance
38
+ else
39
+ entity.applicationInstance == nil && entity.target == nil
40
+ end
41
+
37
42
  end
38
43
  end
39
44
 
40
45
  def undeployed_versions_resources
41
- @undeployed_versions_resources ||= currently_deployed_version_entities_for_pacticipant_and_target.collect do | entity |
46
+ @undeployed_versions_resources ||= currently_deployed_version_entities_for_pacticipant_and_instance.collect do | entity |
42
47
  entity._link!("self").patch(currentlyDeployed: false)
43
48
  end
44
49
  end
@@ -75,7 +80,7 @@ module PactBroker
75
80
  message = "Recorded #{action} of #{pacticipant_name}"
76
81
  message = "#{message} version #{version.number}" if (version && version.number)
77
82
  message = "#{message} from #{environment_name} environment"
78
- message = "#{message} (target #{target})" if target
83
+ message = "#{message} (application instance #{application_instance})" if application_instance
79
84
  message
80
85
  end
81
86
 
@@ -92,19 +97,22 @@ module PactBroker
92
97
  "No pacticipant with name '#{pacticipant_name}' found."
93
98
  else
94
99
  if currently_deployed_version_entities_for_pacticipant.any?
95
- target_does_not_match_message
100
+ application_instance_does_not_match_message
96
101
  else
97
102
  "#{pacticipant_name} is not currently deployed to #{environment_name} environment. Cannot record undeployment."
98
103
  end
99
104
  end
100
105
  end
101
106
 
102
- def target_does_not_match_message
103
- potential_targets = currently_deployed_version_entities_for_pacticipant.collect(&:target).collect { |target| target || "<no target>"}
104
- if target
105
- "#{pacticipant_name} is not currently deployed to target '#{target}' in #{environment_name} environment. Please specify one of the following targets to record the undeployment from: #{potential_targets.join(", ")}"
107
+ def application_instance_does_not_match_message
108
+ potential_application_instances = currently_deployed_version_entities_for_pacticipant.collect{|e| e.applicationInstance || e.target }
109
+
110
+ if application_instance
111
+ omit_text = potential_application_instances.include?(nil) ? "omit the application instance to undeploy from the anonymous instance" : nil
112
+ specify_text = potential_application_instances.compact.any? ? "specify one of the following application instances to record the undeployment from: #{potential_application_instances.compact.join(", ")}" : nil
113
+ "#{pacticipant_name} is not currently deployed to application instance '#{application_instance}' in #{environment_name} environment. Please #{[omit_text, specify_text].compact.join(" or ")}."
106
114
  else
107
- "Please specify one of the following targets to record the undeployment from: #{potential_targets.join(", ")}"
115
+ "Please specify one of the following application instances to record the undeployment from: #{potential_application_instances.compact.join(", ")}"
108
116
  end
109
117
  end
110
118
 
@@ -28,7 +28,7 @@ module PactBroker
28
28
 
29
29
  def call
30
30
  validate
31
- if index_resource.can?("pb:publish-contracts")
31
+ if !force_use_old_api? && index_resource.can?("pb:publish-contracts")
32
32
  publish_pacts
33
33
  PactBroker::Client::CommandResult.new(success?, message)
34
34
  else
@@ -40,6 +40,10 @@ module PactBroker
40
40
 
41
41
  attr_reader :pact_broker_base_url, :pact_file_paths, :consumer_version_params, :consumer_version_number, :branch, :tags, :build_url, :options, :pact_broker_client_options, :response_entities
42
42
 
43
+ def force_use_old_api?
44
+ ENV.fetch("PACT_BROKER_FEATURES", "").include?("publish_pacts_using_old_api")
45
+ end
46
+
43
47
  def request_body_for(consumer_name)
44
48
  {
45
49
  pacticipantName: consumer_name,
@@ -25,14 +25,13 @@ module PactBroker
25
25
  @branch = consumer_version_params[:branch]
26
26
  @build_url = consumer_version_params[:build_url]
27
27
  @tags = consumer_version_params[:tags] ? consumer_version_params[:tags].collect{ |tag| tag.respond_to?(:strip) ? tag.strip : tag } : []
28
- @version_required = consumer_version_params[:version_required]
29
28
  @pact_broker_client_options = pact_broker_client_options
30
29
  end
31
30
 
32
31
  def call
33
32
  validate
34
33
  $stdout.puts("")
35
- result = create_consumer_versions && apply_tags && publish_pacts
34
+ result = apply_tags && publish_pacts
36
35
  $stdout.puts("")
37
36
  if result
38
37
  PactBroker::Client::CommandResult.new(true)
@@ -59,10 +58,6 @@ module PactBroker
59
58
  end
60
59
  end
61
60
 
62
- def can_create_version_with_branch?
63
- @can_create_version_with_branch ||= index_resource.can?('pb:pacticipant-version')
64
- end
65
-
66
61
  def merge_on_server?
67
62
  pact_broker_client_options[:write] == :merge
68
63
  end
@@ -96,49 +91,6 @@ module PactBroker
96
91
  end
97
92
  end
98
93
 
99
- def create_consumer_versions
100
- if create_versions?
101
- consumer_names.collect do | consumer_name |
102
- create_version(index_resource, consumer_name)
103
- end
104
- true
105
- else
106
- true
107
- end
108
- end
109
-
110
- def create_versions?
111
- if version_required
112
- if can_create_version_with_branch?
113
- true
114
- else
115
- raise PactBroker::Client::Error.new("This version of the Pact Broker does not support versions with branches or build URLs. Please upgrade your broker to 2.76.2 or later.")
116
- end
117
- elsif (branch || build_url) && can_create_version_with_branch?
118
- true
119
- else
120
- false
121
- end
122
- end
123
-
124
- def create_version(index_resource, consumer_name)
125
- Retry.while_error do
126
- version_resource = index_resource._link('pb:pacticipant-version').expand(version: consumer_version_number, pacticipant: consumer_name).put(version_body).assert_success!
127
- message = if version_resource.response.status == 200
128
- "Replaced version #{consumer_version_number} of #{consumer_name}"
129
- else
130
- "Created version #{consumer_version_number} of #{consumer_name}"
131
- end
132
-
133
- message = message + " (branch #{branch})" if branch
134
- $stdout.puts message
135
- if version_resource.response.status == 200
136
- $stdout.puts ::Term::ANSIColor.yellow("Replacing the version resource is not recommended under normal circumstances and may indicate that you have not configured your Pact pipeline correctly (unless you are just re-running a build for a particular commit). For more information see https://docs.pact.io/versioning")
137
- end
138
- true
139
- end
140
- end
141
-
142
94
  def version_body
143
95
  {
144
96
  branch: branch,
@@ -185,6 +137,9 @@ module PactBroker
185
137
  end
186
138
 
187
139
  def validate
140
+ if branch || build_url
141
+ $stdout.puts ::Term::ANSIColor.yellow("WARN: This version of the Pact Broker does not support versions with branches or build URLs. Please upgrade your broker to 2.86.0 or later.")
142
+ end
188
143
  raise PactBroker::Client::Error.new("Please specify the consumer_version_number") unless (consumer_version_number && consumer_version_number.to_s.strip.size > 0)
189
144
  raise PactBroker::Client::Error.new("Please specify the pact_broker_base_url") unless (pact_broker_base_url && pact_broker_base_url.to_s.strip.size > 0)
190
145
  raise PactBroker::Client::Error.new("No pact files found") unless (pact_file_paths && pact_file_paths.any?)
@@ -1,5 +1,5 @@
1
1
  module PactBroker
2
2
  module Client
3
- VERSION = '1.51.0'
3
+ VERSION = '1.53.0'
4
4
  end
5
5
  end
@@ -21,7 +21,7 @@ Gem::Specification.new do |gem|
21
21
  gem.require_paths = ["lib"]
22
22
  gem.license = 'MIT'
23
23
 
24
- gem.add_runtime_dependency 'httparty', '~>0.18'
24
+ gem.add_runtime_dependency 'httparty', '~>0.18.1' # https://github.com/jnunemaker/httparty/issues/733
25
25
  gem.add_runtime_dependency 'term-ansicolor', '~> 1.7'
26
26
  gem.add_runtime_dependency 'table_print', '~> 1.5'
27
27
  gem.add_runtime_dependency 'thor', '>= 0.20', '< 2.0'
@@ -1,5 +1,6 @@
1
1
  export PACT_BROKER_BASE_URL="http://localhost:9292"
2
2
  export PACT_BROKER_TOKEN="localhost"
3
+ #export PACT_BROKER_FEATURES=publish_pacts_using_old_api
3
4
 
4
5
  # bundle exec bin/pact-broker create-or-update-webhook http://localhost:9393 \
5
6
  # --uuid d40f38c3-aaa3-47f5-9161-95c07bc16b14 \
@@ -8,9 +8,19 @@ bundle exec bin/pact-broker record-deployment --pacticipant Foo --version 2 --en
8
8
  bundle exec bin/pact-broker record-deployment --pacticipant Foo --version 2 --environment test --target customer-1
9
9
  bundle exec bin/pact-broker record-deployment --pacticipant Foo --version 2 --environment test --target customer-1
10
10
 
11
+ bundle exec bin/pact-broker record-undeployment --pacticipant Foo --environment test --target customer-2
11
12
  bundle exec bin/pact-broker record-undeployment --pacticipant Foo --environment test
12
13
  bundle exec bin/pact-broker record-undeployment --pacticipant Foo --environment test
13
14
  bundle exec bin/pact-broker record-undeployment --pacticipant Foo --environment test --target customer-1
14
15
 
15
16
  bundle exec bin/pact-broker record-release --pacticipant Foo --version 2 --environment test
16
- bundle exec bin/pact-broker record-support-ended --pacticipant Foo --version 2 --environment test
17
+ bundle exec bin/pact-broker record-support-ended --pacticipant Foo --version 2 --environment test
18
+
19
+ bundle exec bin/pact-broker record-deployment --pacticipant Foo --version 2 --environment test
20
+ bundle exec bin/pact-broker record-deployment --pacticipant Foo --version 2 --environment test --application-instance customer-1
21
+ bundle exec bin/pact-broker record-deployment --pacticipant Foo --version 2 --environment test --application-instance customer-1
22
+
23
+ bundle exec bin/pact-broker record-undeployment --pacticipant Foo --environment test --application-instance customer-2
24
+ bundle exec bin/pact-broker record-undeployment --pacticipant Foo --environment test
25
+ bundle exec bin/pact-broker record-undeployment --pacticipant Foo --environment test
26
+ bundle exec bin/pact-broker record-undeployment --pacticipant Foo --environment test --application-instance customer-1
@@ -61,14 +61,14 @@ module PactBroker
61
61
  to_return(status: 200, body: record_deployment_body_hash.to_json , headers: {})
62
62
  end
63
63
 
64
- let(:target) { "blue" }
64
+ let(:application_instance) { "blue" }
65
65
 
66
66
  let(:params) do
67
67
  {
68
68
  pacticipant_name: "Foo",
69
69
  version_number: "1",
70
70
  environment_name: "test",
71
- target: target
71
+ application_instance: application_instance
72
72
  }
73
73
  end
74
74
 
@@ -186,13 +186,13 @@ module PactBroker
186
186
  end
187
187
 
188
188
  it "indicates the API was Pactflow" do
189
- expect(subject.message).to include "Recorded deployment of Foo version 1 to test environment (target blue) in Pactflow"
189
+ expect(subject.message).to include "Recorded deployment of Foo version 1 to test environment (application instance blue) in Pactflow"
190
190
  end
191
191
 
192
- context "when target is nil" do
193
- let(:target) { nil }
192
+ context "when application_instance is nil" do
193
+ let(:application_instance) { nil }
194
194
 
195
- it "does not include the target in the result message" do
195
+ it "does not include the application_instance in the result message" do
196
196
  expect(subject.message).to include "Recorded deployment of Foo version 1 to test environment in"
197
197
  end
198
198
  end
@@ -7,11 +7,11 @@ module PactBroker
7
7
  let(:params) do
8
8
  {
9
9
  pacticipant_name: "Foo",
10
- target: target,
10
+ application_instance: application_instance,
11
11
  environment_name: "test"
12
12
  }
13
13
  end
14
- let(:target) { "customer-1" }
14
+ let(:application_instance) { "customer-1" }
15
15
  let(:output) { "text" }
16
16
  let(:options) { { output: output, verbose: true } }
17
17
  let(:pact_broker_base_url) { "http://broker" }
@@ -131,7 +131,7 @@ module PactBroker
131
131
  subject { RecordUndeployment.call(params, options, pact_broker_client_options) }
132
132
 
133
133
  its(:success) { is_expected.to eq true }
134
- its(:message) { is_expected.to include "Recorded undeployment of Foo version 2 from test environment (target customer-1) in the Pact Broker" }
134
+ its(:message) { is_expected.to include "Recorded undeployment of Foo version 2 from test environment (application instance customer-1) in the Pact Broker" }
135
135
 
136
136
  context "when there is no pb:environments relation in the index" do
137
137
  let(:index_body_hash) do
@@ -173,8 +173,8 @@ module PactBroker
173
173
  end
174
174
 
175
175
  context "when a target is provided and there is no deployed version with a matching target" do
176
- let(:target) { "wrong" }
177
- let(:expected_message) { "Foo is not currently deployed to target 'wrong' in test environment. Please specify one of the following targets to record the undeployment from: customer-1, <no target>" }
176
+ let(:application_instance) { "wrong" }
177
+ let(:expected_message) { "Foo is not currently deployed to application instance 'wrong' in test environment. Please omit the application instance to undeploy from the anonymous instance or specify one of the following application instances to record the undeployment from: customer-1." }
178
178
 
179
179
  its(:success) { is_expected.to be false }
180
180
  its(:message) { is_expected.to include expected_message }
@@ -186,12 +186,20 @@ module PactBroker
186
186
  end
187
187
  end
188
188
 
189
+ context "when a target is provided and there is no deployed version with a matching target and all the application instances are set" do
190
+ let(:application_instance) { "wrong" }
191
+ let(:returned_target_2) { "customer-2" }
192
+ let(:expected_message) { "Foo is not currently deployed to application instance 'wrong' in test environment. Please specify one of the following application instances to record the undeployment from: customer-1, customer-2." }
193
+
194
+ its(:message) { is_expected.to include expected_message }
195
+ end
196
+
189
197
  context "when a target is not provided and there is no deployed verison without a target" do
190
- let(:target) { nil }
198
+ let(:application_instance) { nil }
191
199
  let(:returned_target_2) { "customer-2" }
192
200
 
193
201
  its(:success) { is_expected.to be false }
194
- its(:message) { is_expected.to include "Please specify one of the following targets to record the undeployment from: customer-1, customer-2" }
202
+ its(:message) { is_expected.to include "Please specify one of the following application instances to record the undeployment from: customer-1, customer-2" }
195
203
  end
196
204
 
197
205
  context "when there are no deployed versions for the pacticipant" do
@@ -263,80 +263,9 @@ module PactBroker
263
263
  context "when the broker does not support creation of a version with a branch but a branch is specified" do
264
264
  let(:branch) { "main" }
265
265
 
266
- context "when version_required is true" do
267
- let(:version_required) { true }
268
-
269
- it "raises an error" do
270
- expect { subject.call }.to raise_error PactBroker::Client::Error
271
- end
272
- end
273
- end
274
-
275
- context "when the broker supports creation of a version with a branch" do
276
- before do
277
- allow(version_link).to receive(:expand).and_return(version_link)
278
- allow(version_resource).to receive(:assert_success!).and_return(version_resource)
279
- allow(version_resource).to receive_message_chain(:response, :status).and_return(version_creation_response_status)
280
- end
281
- let(:can_create_version) { true }
282
- let(:version_link) { instance_double("PactBroker::Client::Hal::Link", put: version_resource) }
283
- let(:version_resource) { instance_double("PactBroker::Client::Hal::Entity") }
284
- let(:version_creation_response_status) { 201 }
285
-
286
- before do
287
- allow(index_resource).to receive(:_link).and_return(version_link)
288
- end
289
-
290
- context "when there is a branch, build_url or tags specified" do
291
- let(:tags) { ["dev"] }
292
- let(:branch) { ["main"] }
293
- let(:build_url) { "build_url" }
294
-
295
- it "creates a version with the branch, build_url and tags" do
296
- expect(index_resource).to receive(:_link)
297
- expect(version_link).to receive(:expand).with(pacticipant: "Consumer", version: "1.2.3")
298
- expect(version_link).to receive(:put).with(branch: branch, buildUrl: build_url)
299
- subject.call
300
- end
301
-
302
- context "when there is a branch but no tags" do
303
- let(:tags) { [] }
304
-
305
- it "does not set the tags, as this would overwrite the existing ones - not sure about this implementation" do
306
- expect(version_link).to receive(:put).with(branch: branch, buildUrl: build_url)
307
- subject.call
308
- end
309
- end
310
-
311
- context "when the version response status is 201" do
312
- it "puts a message indicating the version was created" do
313
- expect($stdout).to receive(:puts).with(/Created/)
314
- subject.call
315
- end
316
- end
317
-
318
- context "when the version response status is 200" do
319
- let(:version_creation_response_status) { 200 }
320
-
321
- it "puts a message indicating the version was replaced" do
322
- expect($stdout).to receive(:puts).with(/Replaced/)
323
- subject.call
324
- end
325
- end
326
- end
327
-
328
- context "when there is no branch, tags or build_url specified" do
329
- before do
330
- allow(Retry).to receive(:while_error) { |&block| block.call }
331
- end
332
- let(:tags) { [] }
333
- let(:branch) { nil }
334
- let(:build_url) { nil }
335
-
336
- it "does not create a version resource" do
337
- expect(index_resource).to_not receive(:_link)
338
- subject.call
339
- end
266
+ it "logs a warning" do
267
+ expect($stdout).to receive(:puts).with(/WARN: This version/)
268
+ subject.call
340
269
  end
341
270
  end
342
271
  end
@@ -186,110 +186,6 @@
186
186
  }
187
187
  }
188
188
  },
189
- {
190
- "description": "a request for the index resource",
191
- "providerState": "the pb:pacticipant-version relation exists in the index resource",
192
- "request": {
193
- "method": "get",
194
- "path": "/",
195
- "headers": {
196
- "Accept": "application/hal+json"
197
- }
198
- },
199
- "response": {
200
- "status": 200,
201
- "headers": {
202
- "Content-Type": "application/hal+json;charset=utf-8"
203
- },
204
- "body": {
205
- "_links": {
206
- "pb:pacticipant-version": {
207
- "href": "http://localhost:1234/HAL-REL-PLACEHOLDER-INDEX-PB-PACTICIPANT-VERSION-{pacticipant}-{version}"
208
- }
209
- }
210
- },
211
- "matchingRules": {
212
- "$.body._links.pb:pacticipant-version.href": {
213
- "match": "regex",
214
- "regex": "http:\\/\\/.*{pacticipant}.*{version}"
215
- }
216
- }
217
- }
218
- },
219
- {
220
- "description": "a request to create a pacticipant version",
221
- "providerState": "version 26f353580936ad3b9baddb17b00e84f33c69e7cb of pacticipant Foo does not exist",
222
- "request": {
223
- "method": "put",
224
- "path": "/HAL-REL-PLACEHOLDER-INDEX-PB-PACTICIPANT-VERSION-Foo-26f353580936ad3b9baddb17b00e84f33c69e7cb",
225
- "headers": {
226
- "Content-Type": "application/json",
227
- "Accept": "application/hal+json"
228
- },
229
- "body": {
230
- "branch": "main",
231
- "buildUrl": "http://my-ci/builds/1"
232
- }
233
- },
234
- "response": {
235
- "status": 201,
236
- "headers": {
237
- "Content-Type": "application/hal+json;charset=utf-8"
238
- },
239
- "body": {
240
- "number": "26f353580936ad3b9baddb17b00e84f33c69e7cb",
241
- "buildUrl": "http://my-ci/builds/1",
242
- "_links": {
243
- "self": {
244
- "href": "http://localhost:1234/some-url"
245
- }
246
- }
247
- },
248
- "matchingRules": {
249
- "$.body._links.self.href": {
250
- "match": "regex",
251
- "regex": "http:\\/\\/.*"
252
- }
253
- }
254
- }
255
- },
256
- {
257
- "description": "a request to create a pacticipant version",
258
- "providerState": "version 26f353580936ad3b9baddb17b00e84f33c69e7cb of pacticipant Foo does exist",
259
- "request": {
260
- "method": "put",
261
- "path": "/HAL-REL-PLACEHOLDER-INDEX-PB-PACTICIPANT-VERSION-Foo-26f353580936ad3b9baddb17b00e84f33c69e7cb",
262
- "headers": {
263
- "Content-Type": "application/json",
264
- "Accept": "application/hal+json"
265
- },
266
- "body": {
267
- "branch": "main",
268
- "buildUrl": "http://my-ci/builds/1"
269
- }
270
- },
271
- "response": {
272
- "status": 200,
273
- "headers": {
274
- "Content-Type": "application/hal+json;charset=utf-8"
275
- },
276
- "body": {
277
- "number": "26f353580936ad3b9baddb17b00e84f33c69e7cb",
278
- "buildUrl": "http://my-ci/builds/1",
279
- "_links": {
280
- "self": {
281
- "href": "http://localhost:1234/some-url"
282
- }
283
- }
284
- },
285
- "matchingRules": {
286
- "$.body._links.self.href": {
287
- "match": "regex",
288
- "regex": "http:\\/\\/.*"
289
- }
290
- }
291
- }
292
- },
293
189
  {
294
190
  "description": "a request to determine if Bar can be deployed with all Foo tagged prod, ignoring the verification for Foo version 3.4.5",
295
191
  "providerState": "provider Bar version 4.5.6 has a successful verification for Foo version 1.2.3 tagged prod and a failed verification for version 3.4.5 tagged prod",
@@ -1823,6 +1719,7 @@
1823
1719
  "Accept": "application/hal+json"
1824
1720
  },
1825
1721
  "body": {
1722
+ "applicationInstance": "blue",
1826
1723
  "target": "blue"
1827
1724
  }
1828
1725
  },
@@ -9,13 +9,13 @@ RSpec.describe "recording a deployment", pact: true do
9
9
  let(:version_number) { "5556b8149bf8bac76bc30f50a8a2dd4c22c85f30" }
10
10
  let(:environment_name) { "test" }
11
11
  let(:output) { "text" }
12
- let(:target) { "blue" }
12
+ let(:application_instance) { "blue" }
13
13
  let(:params) do
14
14
  {
15
15
  pacticipant_name: pacticipant_name,
16
16
  version_number: version_number,
17
17
  environment_name: environment_name,
18
- target: target
18
+ application_instance: application_instance
19
19
  }
20
20
  end
21
21
  let(:options) do
@@ -139,14 +139,15 @@ RSpec.describe "recording a deployment", pact: true do
139
139
  path: "/HAL-REL-PLACEHOLDER-PB-RECORD-DEPLOYMENT-FOO-5556B8149BF8BAC76BC30F50A8A2DD4C22C85F30-TEST",
140
140
  headers: post_request_headers,
141
141
  body: {
142
- target: target
142
+ applicationInstance: application_instance,
143
+ target: application_instance
143
144
  }
144
145
  )
145
146
  .will_respond_with(
146
147
  status: 201,
147
148
  headers: pact_broker_response_headers,
148
149
  body: {
149
- target: target
150
+ target: application_instance
150
151
  }
151
152
  )
152
153
  end
@@ -160,14 +161,14 @@ RSpec.describe "recording a deployment", pact: true do
160
161
 
161
162
  it "returns a success message" do
162
163
  expect(subject.success).to be true
163
- expect(subject.message).to include "Recorded deployment of Foo version 5556b8149bf8bac76bc30f50a8a2dd4c22c85f30 to test environment (target blue) in the Pact Broker."
164
+ expect(subject.message).to include "Recorded deployment of Foo version 5556b8149bf8bac76bc30f50a8a2dd4c22c85f30 to test environment (application instance blue) in the Pact Broker."
164
165
  end
165
166
 
166
167
  context "when the output is json" do
167
168
  let(:output) { "json" }
168
169
 
169
170
  it "returns the JSON payload" do
170
- expect(JSON.parse(subject.message)).to eq "target" => target
171
+ expect(JSON.parse(subject.message)).to eq "target" => application_instance
171
172
  end
172
173
  end
173
174
  end
@@ -8,12 +8,12 @@ RSpec.describe "recording an undeployment", pact: true do
8
8
  let(:pacticipant_name) { "Foo" }
9
9
  let(:environment_name) { "test" }
10
10
  let(:output) { "text" }
11
- let(:target) { "customer-1" }
11
+ let(:application_instance) { "customer-1" }
12
12
  let(:params) do
13
13
  {
14
14
  pacticipant_name: pacticipant_name,
15
15
  environment_name: environment_name,
16
- target: target
16
+ application_instance: application_instance
17
17
  }
18
18
  end
19
19
  let(:options) do
@@ -100,7 +100,7 @@ RSpec.describe "recording an undeployment", pact: true do
100
100
  _embedded: {
101
101
  deployedVersions: [
102
102
  {
103
- target: target,
103
+ target: application_instance,
104
104
  _links: {
105
105
  self: {
106
106
  href: Pact.term(pact_broker.mock_service_base_url + deployed_version_placeholder_path, /^http/)
@@ -150,7 +150,7 @@ RSpec.describe "recording an undeployment", pact: true do
150
150
 
151
151
  it "returns a success message" do
152
152
  expect(subject.success).to be true
153
- expect(subject.message).to include "Recorded undeployment of Foo version 2 from test environment (target customer-1) in the Pact Broker"
153
+ expect(subject.message).to include "Recorded undeployment of Foo version 2 from test environment (application instance customer-1) in the Pact Broker"
154
154
  end
155
155
 
156
156
  context "when the output is json" do
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.51.0
4
+ version: 1.53.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-09-21 00:00:00.000000000 Z
11
+ date: 2021-09-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0.18'
19
+ version: 0.18.1
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0.18'
26
+ version: 0.18.1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: term-ansicolor
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -380,7 +380,6 @@ files:
380
380
  - spec/service_providers/extra_goodies_spec.rb
381
381
  - spec/service_providers/list_environments_spec.rb
382
382
  - spec/service_providers/list_latest_pact_versions_spec.rb.bak
383
- - spec/service_providers/pact_broker_client_create_version_spec.rb
384
383
  - spec/service_providers/pact_broker_client_matrix_ignore_spec.rb
385
384
  - spec/service_providers/pact_broker_client_matrix_spec.rb
386
385
  - spec/service_providers/pact_broker_client_pacticipant_version_spec.rb
@@ -431,7 +430,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
431
430
  - !ruby/object:Gem::Version
432
431
  version: '0'
433
432
  requirements: []
434
- rubygems_version: 3.2.27
433
+ rubygems_version: 3.2.28
435
434
  signing_key:
436
435
  specification_version: 4
437
436
  summary: See description
@@ -488,7 +487,6 @@ test_files:
488
487
  - spec/service_providers/extra_goodies_spec.rb
489
488
  - spec/service_providers/list_environments_spec.rb
490
489
  - spec/service_providers/list_latest_pact_versions_spec.rb.bak
491
- - spec/service_providers/pact_broker_client_create_version_spec.rb
492
490
  - spec/service_providers/pact_broker_client_matrix_ignore_spec.rb
493
491
  - spec/service_providers/pact_broker_client_matrix_spec.rb
494
492
  - spec/service_providers/pact_broker_client_pacticipant_version_spec.rb
@@ -1,88 +0,0 @@
1
- require_relative 'pact_helper'
2
- require 'pact_broker/client'
3
- require 'pact_broker/client/publish_pacts_the_old_way'
4
-
5
- describe PactBroker::Client::Versions, pact: true do
6
-
7
- include_context "pact broker"
8
-
9
-
10
- describe "creating a pacticipant version" do
11
- before do
12
- allow(publish_pacts_the_old_way).to receive(:consumer_names).and_return(["Foo"])
13
- allow($stdout).to receive(:puts)
14
- end
15
- let(:version_path) { "/HAL-REL-PLACEHOLDER-INDEX-PB-PACTICIPANT-VERSION-{pacticipant}-{version}" }
16
- let(:version_url) { pact_broker.mock_service_base_url + version_path }
17
- let(:number) { "26f353580936ad3b9baddb17b00e84f33c69e7cb" }
18
- let(:branch) { "main" }
19
- let(:build_url) { "http://my-ci/builds/1" }
20
- let(:consumer_version_params) { { number: number, branch: branch, build_url: build_url } }
21
- let(:publish_pacts_the_old_way) { PactBroker::Client::PublishPactsTheOldWay.new(pact_broker.mock_service_base_url, ["some-pact.json"], consumer_version_params, {}) }
22
- let(:provider_state) { "version #{number} of pacticipant Foo does not exist" }
23
- let(:expected_response_status) { 201 }
24
-
25
- subject { publish_pacts_the_old_way.send(:create_consumer_versions) }
26
-
27
- before do
28
- pact_broker
29
- .given("the pb:pacticipant-version relation exists in the index resource")
30
- .upon_receiving("a request for the index resource")
31
- .with(
32
- method: :get,
33
- path: '/',
34
- headers: get_request_headers).
35
- will_respond_with(
36
- status: 200,
37
- headers: pact_broker_response_headers,
38
- body: {
39
- _links: {
40
- :'pb:pacticipant-version' => {
41
- href: Pact.term(version_url, /http:\/\/.*{pacticipant}.*{version}/)
42
- }
43
- }
44
- }
45
- )
46
-
47
- pact_broker
48
- .given(provider_state)
49
- .upon_receiving("a request to create a pacticipant version")
50
- .with(
51
- method: :put,
52
- path: "/HAL-REL-PLACEHOLDER-INDEX-PB-PACTICIPANT-VERSION-Foo-#{number}",
53
- headers: put_request_headers,
54
- body: {
55
- branch: branch,
56
- buildUrl: build_url
57
- }).
58
- will_respond_with(
59
- status: expected_response_status,
60
- headers: pact_broker_response_headers,
61
- body: {
62
- number: number,
63
- buildUrl: build_url,
64
- _links: {
65
- self: {
66
- href: Pact.term('http://localhost:1234/some-url', %r{http://.*})
67
- }
68
- }
69
- }
70
- )
71
- end
72
-
73
- context "when the version does not already exist" do
74
- it "returns true" do
75
- expect(subject).to be true
76
- end
77
- end
78
-
79
- context "when the version does exist" do
80
- let(:provider_state) { "version #{number} of pacticipant Foo does exist" }
81
- let(:expected_response_status) { 200 }
82
-
83
- it "returns true" do
84
- expect(subject).to be true
85
- end
86
- end
87
- end
88
- end