pact 1.57.0 → 1.61.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: 3fa7e68e5d7bae7690cd437dd16ad8ae62ac3df3ffc613288ad61db695db7893
4
+ data.tar.gz: eae97829dbde3d2f1ac593b928992af49ea115c46a17a5d7599a0420474a40e4
5
5
  SHA512:
6
- metadata.gz: a0638972bc29d64815a6d29fbd46a88092eb0d748e21f0da41cde9e485c63fa1158cbf03d9b4d638d273b1caff78470d07d40377be176804fab62e96aecce043
7
- data.tar.gz: 9161da6d7c9490db14c7472ca54e0c8a0d7a8fdad65f033694a31db8d80097f3a343098fc41f4c12fb59f12a3ae5a36f2b5503ade581eeb1f9c0f8fb66e74920
6
+ metadata.gz: 558da76fbb79adb908e6e33dcabe9fdd3a99d8d899121d60239adbdd428e57320812b978290124a722f7e63faf4fa97928e40e0beb5a951965edfc46ac1559b9
7
+ data.tar.gz: e8cb83d40823603b794ffcda15c9211f11a0632fd7a4a93c547fcdfc9734e06ae7cabac5edaee812a590c07f7839c13220e85a84a1d4366cb9f3f75dfb39f974
data/CHANGELOG.md CHANGED
@@ -1,3 +1,39 @@
1
+ <a name="v1.61.0"></a>
2
+ ### v1.61.0 (2021-12-16)
3
+
4
+ #### Features
5
+
6
+ * support description of matching_branch and matching_tag consumer version selectors ([8e8bb22](/../../commit/8e8bb22))
7
+
8
+ #### Bug Fixes
9
+
10
+ * pass through includePendingStatus to the 'pacts for verification' API when it is false ([f0e37a4](/../../commit/f0e37a4))
11
+
12
+ <a name="v1.60.0"></a>
13
+ ### v1.60.0 (2021-10-01)
14
+
15
+ #### Features
16
+
17
+ * allow SSL verification to be disabled in the HAL client by setting the environment variable PACT_DISABLE_SSL_VERIFICATION=true ([ce07d32](/../../commit/ce07d32))
18
+
19
+ <a name="v1.59.0"></a>
20
+ ### v1.59.0 (2021-09-07)
21
+
22
+ #### Features
23
+
24
+ * update descriptions for new consumer version selectors ([0471397](/../../commit/0471397))
25
+
26
+ <a name="v1.58.0"></a>
27
+ ### v1.58.0 (2021-09-01)
28
+
29
+ #### Features
30
+
31
+ * support publishing verification results with a version branch ([da2facf](/../../commit/da2facf))
32
+
33
+ #### Bug Fixes
34
+
35
+ * gracefully handle display of username that causes InvalidComponentError to be raised when composing a URI ([cecb98f](/../../commit/cecb98f))
36
+
1
37
  <a name="v1.57.0"></a>
2
38
  ### v1.57.0 (2021-01-27)
3
39
 
@@ -2,6 +2,7 @@ require 'pact/retry'
2
2
  require 'pact/hal/authorization_header_redactor'
3
3
  require 'net/http'
4
4
  require 'rack'
5
+ require 'openssl'
5
6
 
6
7
  module Pact
7
8
  module Hal
@@ -48,10 +49,16 @@ module Pact
48
49
  def perform_request request, uri
49
50
  response = Retry.until_true do
50
51
  http = Net::HTTP.new(uri.host, uri.port, :ENV)
51
- http.set_debug_output(output_stream) if verbose
52
+ http.set_debug_output(output_stream) if verbose?
52
53
  http.use_ssl = (uri.scheme == 'https')
53
54
  http.ca_file = ENV['SSL_CERT_FILE'] if ENV['SSL_CERT_FILE'] && ENV['SSL_CERT_FILE'] != ''
54
55
  http.ca_path = ENV['SSL_CERT_DIR'] if ENV['SSL_CERT_DIR'] && ENV['SSL_CERT_DIR'] != ''
56
+ if disable_ssl_verification?
57
+ if verbose?
58
+ Pact.configuration.output_stream.puts("SSL verification is disabled")
59
+ end
60
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE
61
+ end
55
62
  http.start do |http|
56
63
  http.request request
57
64
  end
@@ -63,6 +70,14 @@ module Pact
63
70
  AuthorizationHeaderRedactor.new(Pact.configuration.output_stream)
64
71
  end
65
72
 
73
+ def verbose?
74
+ verbose || ENV['VERBOSE'] == 'true'
75
+ end
76
+
77
+ def disable_ssl_verification?
78
+ ENV['PACT_DISABLE_SSL_VERIFICATION'] == 'true' || ENV['PACT_BROKER_DISABLE_SSL_VERIFICATION'] == 'true'
79
+ end
80
+
66
81
  class Response < SimpleDelegator
67
82
  def body
68
83
  bod = raw_body
@@ -0,0 +1,17 @@
1
+ module Pact
2
+ module HashRefinements
3
+ refine Hash do
4
+ def compact
5
+ h = {}
6
+ each do |key, value|
7
+ h[key] = value unless value == nil
8
+ end
9
+ h
10
+ end unless Hash.method_defined? :compact
11
+
12
+ def compact!
13
+ reject! {|_key, value| value == nil}
14
+ end unless Hash.method_defined? :compact!
15
+ end
16
+ end
17
+ end
@@ -5,12 +5,15 @@ require 'pact/errors'
5
5
  require 'pact/pact_broker/fetch_pacts'
6
6
  require 'pact/pact_broker/notices'
7
7
  require 'pact/pact_broker/pact_selection_description'
8
+ require "pact/hash_refinements"
8
9
 
9
10
  module Pact
10
11
  module PactBroker
11
12
  class FetchPactURIsForVerification
13
+ using Pact::HashRefinements
14
+
12
15
  include PactSelectionDescription
13
- attr_reader :provider, :consumer_version_selectors, :provider_version_tags, :broker_base_url, :http_client_options, :http_client, :options
16
+ attr_reader :provider, :consumer_version_selectors, :provider_version_branch, :provider_version_tags, :broker_base_url, :http_client_options, :http_client, :options
14
17
 
15
18
  PACTS_FOR_VERIFICATION_RELATION = 'pb:provider-pacts-for-verification'.freeze
16
19
  PACTS_FOR_VERIFICATION_RELATION_BETA = 'beta:provider-pacts-for-verification'.freeze
@@ -20,9 +23,10 @@ module Pact
20
23
  SELF = 'self'.freeze
21
24
  EMBEDDED = '_embedded'.freeze
22
25
 
23
- def initialize(provider, consumer_version_selectors, provider_version_tags, broker_base_url, http_client_options, options = {})
26
+ def initialize(provider, consumer_version_selectors, provider_version_branch, provider_version_tags, broker_base_url, http_client_options, options = {})
24
27
  @provider = provider
25
28
  @consumer_version_selectors = consumer_version_selectors || []
29
+ @provider_version_branch = provider_version_branch
26
30
  @provider_version_tags = [*provider_version_tags]
27
31
  @http_client_options = http_client_options
28
32
  @broker_base_url = broker_base_url
@@ -30,8 +34,8 @@ module Pact
30
34
  @options = options
31
35
  end
32
36
 
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
37
+ def self.call(provider, consumer_version_selectors, provider_version_branch, provider_version_tags, broker_base_url, http_client_options, options = {})
38
+ new(provider, consumer_version_selectors, provider_version_branch, provider_version_tags, broker_base_url, http_client_options, options).call
35
39
  end
36
40
 
37
41
  def call
@@ -73,11 +77,12 @@ module Pact
73
77
 
74
78
  def query
75
79
  q = {}
76
- q["includePendingStatus"] = true if options[:include_pending_status]
80
+ q["includePendingStatus"] = options[:include_pending_status]
77
81
  q["consumerVersionSelectors"] = consumer_version_selectors if consumer_version_selectors.any?
78
82
  q["providerVersionTags"] = provider_version_tags if provider_version_tags.any?
79
- q["includeWipPactsSince"] = options[:include_wip_pacts_since] if options[:include_wip_pacts_since]
80
- q
83
+ q["providerVersionBranch"] = provider_version_branch
84
+ q["includeWipPactsSince"] = options[:include_wip_pacts_since]
85
+ q.compact
81
86
  end
82
87
 
83
88
  def extract_notices(pact)
@@ -5,11 +5,54 @@ module Pact
5
5
  message = "Fetching pacts for #{provider} from #{broker_base_url} with the selection criteria: "
6
6
  if consumer_version_selectors.any?
7
7
  desc = consumer_version_selectors.collect do |selector|
8
- all_or_latest = !selector[:latest] ? "all for tag" : "latest for tag"
9
- consumer = selector[:consumer] ? "of consumer #{selector[:consumer]}" : nil
8
+ desc = nil
9
+ if selector[:tag]
10
+ desc = !selector[:latest] ? "all for tag #{selector[:tag]}" : "latest for tag #{selector[:tag]}"
11
+ desc = "#{desc} of #{selector[:consumer]}" if selector[:consumer]
12
+ elsif selector[:branch]
13
+ desc = "latest from branch #{selector[:branch]}"
14
+ desc = "#{desc} of #{selector[:consumer]}" if selector[:consumer]
15
+ elsif selector[:mainBranch]
16
+ desc = "latest from main branch"
17
+ desc = "#{desc} of #{selector[:consumer]}" if selector[:consumer]
18
+ elsif selector[:deployed]
19
+ if selector[:environment]
20
+ desc = "currently deployed to #{selector[:environment]}"
21
+ else
22
+ desc = "currently deployed"
23
+ end
24
+ desc = "#{selector[:consumer]} #{desc}" if selector[:consumer]
25
+ elsif selector[:released]
26
+ if selector[:environment]
27
+ desc = "currently released to #{selector[:environment]}"
28
+ else
29
+ desc = "currently released"
30
+ end
31
+ desc = "#{selector[:consumer]} #{desc}" if selector[:consumer]
32
+ elsif selector[:deployedOrReleased]
33
+ if selector[:environment]
34
+ desc = "currently deployed or released to #{selector[:environment]}"
35
+ else
36
+ desc = "currently deployed or released"
37
+ end
38
+ desc = "#{selector[:consumer]} #{desc}" if selector[:consumer]
39
+ elsif selector[:environment]
40
+ desc = "currently in #{selector[:environment]}"
41
+ desc = "#{selector[:consumer]} #{desc}" if selector[:consumer]
42
+ elsif selector[:matchingBranch]
43
+ desc = "matching current branch"
44
+ desc = "#{desc} for #{selector[:consumer]}" if selector[:consumer]
45
+ elsif selector[:matchingTag]
46
+ desc = "matching tag"
47
+ desc = "#{desc} for #{selector[:consumer]}" if selector[:consumer]
48
+ else
49
+ desc = selector.to_s
50
+ end
51
+
10
52
  fallback = selector[:fallback] || selector[:fallbackTag]
11
- name = fallback ? "#{selector[:tag]} (or #{fallback} if not found)" : selector[:tag]
12
- [all_or_latest, name, consumer].compact.join(" ")
53
+ desc = "#{desc} (or #{fallback} if not found)" if fallback
54
+
55
+ desc
13
56
  end.join(", ")
14
57
  if options[:include_wip_pacts_since]
15
58
  desc = "#{desc}, work in progress pacts created after #{options[:include_wip_pacts_since]}"
@@ -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.61.0"
4
4
  end
data/pact.gemspec CHANGED
@@ -32,7 +32,7 @@ Gem::Specification.new do |gem|
32
32
  gem.add_runtime_dependency 'webrick', '~> 1.3'
33
33
  gem.add_runtime_dependency 'term-ansicolor', '~> 1.0'
34
34
 
35
- gem.add_runtime_dependency 'pact-support', '~> 1.15'
35
+ gem.add_runtime_dependency 'pact-support', '~> 1.16', '>= 1.16.9'
36
36
  gem.add_runtime_dependency 'pact-mock_service', '~> 3.0', '>= 3.3.1'
37
37
 
38
38
  gem.add_development_dependency 'rake', '~> 13.0'
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.61.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-12-16 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: rspec
@@ -102,14 +102,20 @@ dependencies:
102
102
  requirements:
103
103
  - - "~>"
104
104
  - !ruby/object:Gem::Version
105
- version: '1.15'
105
+ version: '1.16'
106
+ - - ">="
107
+ - !ruby/object:Gem::Version
108
+ version: 1.16.9
106
109
  type: :runtime
107
110
  prerelease: false
108
111
  version_requirements: !ruby/object:Gem::Requirement
109
112
  requirements:
110
113
  - - "~>"
111
114
  - !ruby/object:Gem::Version
112
- version: '1.15'
115
+ version: '1.16'
116
+ - - ">="
117
+ - !ruby/object:Gem::Version
118
+ version: 1.16.9
113
119
  - !ruby/object:Gem::Dependency
114
120
  name: pact-mock_service
115
121
  requirement: !ruby/object:Gem::Requirement
@@ -321,6 +327,7 @@ files:
321
327
  - lib/pact/hal/http_client.rb
322
328
  - lib/pact/hal/link.rb
323
329
  - lib/pact/hal/non_json_entity.rb
330
+ - lib/pact/hash_refinements.rb
324
331
  - lib/pact/pact_broker.rb
325
332
  - lib/pact/pact_broker/fetch_pact_uris_for_verification.rb
326
333
  - lib/pact/pact_broker/fetch_pacts.rb
@@ -405,7 +412,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
405
412
  - !ruby/object:Gem::Version
406
413
  version: '0'
407
414
  requirements: []
408
- rubygems_version: 3.2.7
415
+ rubygems_version: 3.2.33
409
416
  signing_key:
410
417
  specification_version: 4
411
418
  summary: Enables consumer driven contract testing, providing a mock service and DSL