pact 1.57.0 → 1.58.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2f5bff8179ed3588a9363fd864b36527a51672bc2f0812778e188f60571975c1
4
- data.tar.gz: 8bec6ad8f69b8a60836256c261f32c288624ae1a876e452acedfc62daeffebc8
3
+ metadata.gz: c0eccb0bdb60c799b434febc79b825448330f476eb1fd9041d85067b73afa12f
4
+ data.tar.gz: 552f9f3e11377b6bc4ebb0cb5a30ee5f95f5689ac7dcf0b74a59ec7688eaafac
5
5
  SHA512:
6
- metadata.gz: a0638972bc29d64815a6d29fbd46a88092eb0d748e21f0da41cde9e485c63fa1158cbf03d9b4d638d273b1caff78470d07d40377be176804fab62e96aecce043
7
- data.tar.gz: 9161da6d7c9490db14c7472ca54e0c8a0d7a8fdad65f033694a31db8d80097f3a343098fc41f4c12fb59f12a3ae5a36f2b5503ade581eeb1f9c0f8fb66e74920
6
+ metadata.gz: ef8d1d0f38c7370d36c1643592b82f45415e18065fb1ae3cc07f63f6eb20c082c80376995e3c0388b1bd85e432ada99bc13b4c2024d66ea1f1d2a511a6efa298
7
+ data.tar.gz: bb42f0d27a63304df146884e152f60f8628c673db09d52c6ff979a2c1508973522cf4f09bb7cb87dea0c2139ca500c745038a0f4702b1f38e67cae6838a68292
data/CHANGELOG.md CHANGED
@@ -1,3 +1,14 @@
1
+ <a name="v1.58.0"></a>
2
+ ### v1.58.0 (2021-09-01)
3
+
4
+ #### Features
5
+
6
+ * support publishing verification results with a version branch ([da2facf](/../../commit/da2facf))
7
+
8
+ #### Bug Fixes
9
+
10
+ * gracefully handle display of username that causes InvalidComponentError to be raised when composing a URI ([cecb98f](/../../commit/cecb98f))
11
+
1
12
  <a name="v1.57.0"></a>
2
13
  ### v1.57.0 (2021-01-27)
3
14
 
@@ -48,7 +48,7 @@ module Pact
48
48
  def perform_request request, uri
49
49
  response = Retry.until_true do
50
50
  http = Net::HTTP.new(uri.host, uri.port, :ENV)
51
- http.set_debug_output(output_stream) if verbose
51
+ http.set_debug_output(output_stream) if verbose || ENV['VERBOSE'] == 'true'
52
52
  http.use_ssl = (uri.scheme == 'https')
53
53
  http.ca_file = ENV['SSL_CERT_FILE'] if ENV['SSL_CERT_FILE'] && ENV['SSL_CERT_FILE'] != ''
54
54
  http.ca_path = ENV['SSL_CERT_DIR'] if ENV['SSL_CERT_DIR'] && ENV['SSL_CERT_DIR'] != ''
@@ -10,7 +10,7 @@ module Pact
10
10
  module PactBroker
11
11
  class FetchPactURIsForVerification
12
12
  include PactSelectionDescription
13
- attr_reader :provider, :consumer_version_selectors, :provider_version_tags, :broker_base_url, :http_client_options, :http_client, :options
13
+ attr_reader :provider, :consumer_version_selectors, :provider_version_branch, :provider_version_tags, :broker_base_url, :http_client_options, :http_client, :options
14
14
 
15
15
  PACTS_FOR_VERIFICATION_RELATION = 'pb:provider-pacts-for-verification'.freeze
16
16
  PACTS_FOR_VERIFICATION_RELATION_BETA = 'beta:provider-pacts-for-verification'.freeze
@@ -20,9 +20,10 @@ module Pact
20
20
  SELF = 'self'.freeze
21
21
  EMBEDDED = '_embedded'.freeze
22
22
 
23
- def initialize(provider, consumer_version_selectors, provider_version_tags, broker_base_url, http_client_options, options = {})
23
+ def initialize(provider, consumer_version_selectors, provider_version_branch, provider_version_tags, broker_base_url, http_client_options, options = {})
24
24
  @provider = provider
25
25
  @consumer_version_selectors = consumer_version_selectors || []
26
+ @provider_version_branch = provider_version_branch
26
27
  @provider_version_tags = [*provider_version_tags]
27
28
  @http_client_options = http_client_options
28
29
  @broker_base_url = broker_base_url
@@ -30,8 +31,8 @@ module Pact
30
31
  @options = options
31
32
  end
32
33
 
33
- def self.call(provider, consumer_version_selectors, provider_version_tags, broker_base_url, http_client_options, options = {})
34
- new(provider, consumer_version_selectors, provider_version_tags, broker_base_url, http_client_options, options).call
34
+ def self.call(provider, consumer_version_selectors, provider_version_branch, provider_version_tags, broker_base_url, http_client_options, options = {})
35
+ new(provider, consumer_version_selectors, provider_version_branch, provider_version_tags, broker_base_url, http_client_options, options).call
35
36
  end
36
37
 
37
38
  def call
@@ -76,6 +77,7 @@ module Pact
76
77
  q["includePendingStatus"] = true if options[:include_pending_status]
77
78
  q["consumerVersionSelectors"] = consumer_version_selectors if consumer_version_selectors.any?
78
79
  q["providerVersionTags"] = provider_version_tags if provider_version_tags.any?
80
+ q["providerVersionBranch"] = provider_version_branch if provider_version_branch
79
81
  q["includeWipPactsSince"] = options[:include_wip_pacts_since] if options[:include_wip_pacts_since]
80
82
  q
81
83
  end
@@ -15,10 +15,11 @@ module Pact
15
15
  # in parent scope, it will clash with these ones,
16
16
  # so put an underscore in front of the name to be safer.
17
17
 
18
- attr_accessor :_provider_name, :_pact_broker_base_url, :_consumer_version_tags, :_provider_version_tags, :_basic_auth_options, :_enable_pending, :_include_wip_pacts_since, :_verbose, :_consumer_version_selectors
18
+ attr_accessor :_provider_name, :_pact_broker_base_url, :_consumer_version_tags, :_provider_version_branch, :_provider_version_tags, :_basic_auth_options, :_enable_pending, :_include_wip_pacts_since, :_verbose, :_consumer_version_selectors
19
19
 
20
- def initialize(provider_name, provider_version_tags)
20
+ def initialize(provider_name, provider_version_branch, provider_version_tags)
21
21
  @_provider_name = provider_name
22
+ @_provider_version_branch = provider_version_branch
22
23
  @_provider_version_tags = provider_version_tags
23
24
  @_consumer_version_tags = []
24
25
  @_consumer_version_selectors = []
@@ -69,6 +70,7 @@ module Pact
69
70
  fetch_pacts = Pact::PactBroker::FetchPactURIsForVerification.new(
70
71
  _provider_name,
71
72
  consumer_version_selectors,
73
+ _provider_version_branch,
72
74
  _provider_version_tags,
73
75
  _pact_broker_base_url,
74
76
  _basic_auth_options.merge(verbose: _verbose),
@@ -4,9 +4,11 @@ module Pact
4
4
  class ServiceProviderConfig
5
5
 
6
6
  attr_accessor :application_version
7
+ attr_reader :branch
7
8
 
8
- def initialize application_version, tags, publish_verification_results, &app_block
9
+ def initialize application_version, branch, tags, publish_verification_results, &app_block
9
10
  @application_version = application_version
11
+ @branch = branch
10
12
  @tags = [*tags]
11
13
  @publish_verification_results = publish_verification_results
12
14
  @app_block = app_block
@@ -15,7 +15,7 @@ module Pact
15
15
 
16
16
  extend Pact::DSL
17
17
 
18
- attr_accessor :name, :app_block, :application_version, :tags, :publish_verification_results
18
+ attr_accessor :name, :app_block, :application_version, :branch, :tags, :publish_verification_results
19
19
 
20
20
  CONFIG_RU_APP = lambda {
21
21
  unless File.exist? Pact.configuration.config_ru_path
@@ -44,6 +44,10 @@ module Pact
44
44
  self.tags = tags
45
45
  end
46
46
 
47
+ def app_version_branch branch
48
+ self.branch = branch
49
+ end
50
+
47
51
  def publish_verification_results publish_verification_results
48
52
  self.publish_verification_results = publish_verification_results
49
53
  Pact::RSpec.with_rspec_2 do
@@ -65,7 +69,7 @@ module Pact
65
69
  end
66
70
 
67
71
  def create_pact_verification_from_broker(&block)
68
- PactVerificationFromBroker.build(name, tags, &block)
72
+ PactVerificationFromBroker.build(name, branch, tags, &block)
69
73
  end
70
74
 
71
75
  def finalize
@@ -85,7 +89,7 @@ module Pact
85
89
  end
86
90
 
87
91
  def create_service_provider
88
- Pact.configuration.provider = ServiceProviderConfig.new(application_version, tags, publish_verification_results, &@app_block)
92
+ Pact.configuration.provider = ServiceProviderConfig.new(application_version, branch, tags, publish_verification_results, &@app_block)
89
93
  end
90
94
  end
91
95
  end
@@ -30,7 +30,11 @@ module Pact
30
30
 
31
31
  def to_s
32
32
  if basic_auth? && http_or_https_uri?
33
- URI(@uri).tap { |x| x.userinfo="#{username}:*****"}.to_s
33
+ begin
34
+ URI(@uri).tap { |x| x.userinfo="#{username}:*****"}.to_s
35
+ rescue URI::InvalidComponentError
36
+ URI(@uri).tap { |x| x.userinfo="*****:*****"}.to_s
37
+ end
34
38
  elsif personal_access_token? && http_or_https_uri?
35
39
  URI(@uri).tap { |x| x.userinfo="*****"}.to_s
36
40
  else
@@ -45,7 +49,7 @@ module Pact
45
49
  private def http_or_https_uri?
46
50
  uri.start_with?('http://', 'https://')
47
51
  end
48
-
52
+
49
53
  end
50
54
  end
51
55
  end
@@ -16,6 +16,7 @@ module Pact
16
16
  PUBLISH_RELATION = 'pb:publish-verification-results'.freeze
17
17
  PROVIDER_RELATION = 'pb:provider'.freeze
18
18
  VERSION_TAG_RELATION = 'pb:version-tag'.freeze
19
+ BRANCH_VERSION_RELATION = 'pb:branch-version'.freeze
19
20
 
20
21
  def self.call pact_source, verification_result, options = {}
21
22
  new(pact_source, verification_result, options).call
@@ -31,6 +32,7 @@ module Pact
31
32
 
32
33
  def call
33
34
  if can_publish_verification_results?
35
+ create_branch_version_if_configured
34
36
  tag_versions_if_configured
35
37
  publish_verification_results
36
38
  true
@@ -72,8 +74,28 @@ module Pact
72
74
  end
73
75
  end
74
76
 
77
+ def create_branch_version_if_configured
78
+ if Pact.configuration.provider.branch
79
+ branch_version_link = provider_entity._link(BRANCH_VERSION_RELATION)
80
+ if branch_version_link
81
+ version_number = Pact.configuration.provider.application_version
82
+ branch = Pact.configuration.provider.branch
83
+
84
+ Pact.configuration.output_stream.puts "INFO: Creating #{provider_name} version #{version_number} with branch \"#{branch}\""
85
+ branch_entity = branch_version_link.expand(
86
+ version: version_number,
87
+ branch: branch
88
+ ).put
89
+ unless branch_entity.success?
90
+ raise PublicationError.new("Error returned from tagging request: status=#{branch_entity.response.code} body=#{branch_entity.response.body}")
91
+ end
92
+ else
93
+ raise PublicationError.new("This version of the Pact Broker does not support version branches. Please update to version 2.58.0 or later.")
94
+ end
95
+ end
96
+ end
97
+
75
98
  def tag_versions
76
- provider_entity = pact_entity.get(PROVIDER_RELATION)
77
99
  tag_link = provider_entity._link(VERSION_TAG_RELATION) || hacky_tag_url(provider_entity)
78
100
  provider_application_version = Pact.configuration.provider.application_version
79
101
 
@@ -111,6 +133,10 @@ module Pact
111
133
  def provider_name
112
134
  pact_source.pact_hash['provider']['name']
113
135
  end
136
+
137
+ def provider_entity
138
+ @provider_entity ||= pact_entity.get(PROVIDER_RELATION)
139
+ end
114
140
  end
115
141
  end
116
142
  end
data/lib/pact/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  # Remember to bump pact-provider-proxy when this changes major version
2
2
  module Pact
3
- VERSION = "1.57.0"
3
+ VERSION = "1.58.0"
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pact
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.57.0
4
+ version: 1.58.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Fraser
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2021-01-31 00:00:00.000000000 Z
15
+ date: 2021-09-07 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: rspec
@@ -405,7 +405,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
405
405
  - !ruby/object:Gem::Version
406
406
  version: '0'
407
407
  requirements: []
408
- rubygems_version: 3.2.7
408
+ rubygems_version: 3.2.27
409
409
  signing_key:
410
410
  specification_version: 4
411
411
  summary: Enables consumer driven contract testing, providing a mock service and DSL