pact 1.56.0 → 1.60.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: '07691380e13b6856eb1c2df42bf7ce5f360ed46b8e75aff4e122c22f685e45b5'
4
- data.tar.gz: f2ce2cf40b492b0f163fe27732ef09f37c5b1a5061a05e07427807343cfee431
3
+ metadata.gz: 2c47a890620bb658d731e15874d9a2921bdc0b349c0f4c7b5a5cab6f4d4938ee
4
+ data.tar.gz: 133ccad2b3905c2cff2cee872c790bc11334a155a799b92824f0a669a2f1538e
5
5
  SHA512:
6
- metadata.gz: cf78bed99d4180a145ae7edf411a8d6840e622e315f2b1173294ded82288b87d404ef23796e38bb025fea51f8e437a09fc7d5e643835156400bda73cafc64ebe
7
- data.tar.gz: a69c674a42bab959fe7483ac568a2e7102d141f3d861327c1b4f64c4d7e22864f298385917fbbb0b93bcc205565c4233d4a455423885d91a86b315796063c2b4
6
+ metadata.gz: 2b655070423818845c7ba052ca1ce81a9e73c3066c4f1b5c915169ef8d3c810696bc84cb773c4b10993a471e9428ad93021480fda51cc26d949568ecc1ecca73
7
+ data.tar.gz: 9f7e7d365fc7326e9714120bfaa4c0cfd4df27c29d44deb213310ed5cc9374e44e462f311e57fe3e7181ade321a0f1543202da24267da10eb78ced5cc872865c
data/CHANGELOG.md CHANGED
@@ -1,3 +1,35 @@
1
+ <a name="v1.60.0"></a>
2
+ ### v1.60.0 (2021-10-01)
3
+
4
+ #### Features
5
+
6
+ * allow SSL verification to be disabled in the HAL client by setting the environment variable PACT_DISABLE_SSL_VERIFICATION=true ([ce07d32](/../../commit/ce07d32))
7
+
8
+ <a name="v1.59.0"></a>
9
+ ### v1.59.0 (2021-09-07)
10
+
11
+ #### Features
12
+
13
+ * update descriptions for new consumer version selectors ([0471397](/../../commit/0471397))
14
+
15
+ <a name="v1.58.0"></a>
16
+ ### v1.58.0 (2021-09-01)
17
+
18
+ #### Features
19
+
20
+ * support publishing verification results with a version branch ([da2facf](/../../commit/da2facf))
21
+
22
+ #### Bug Fixes
23
+
24
+ * gracefully handle display of username that causes InvalidComponentError to be raised when composing a URI ([cecb98f](/../../commit/cecb98f))
25
+
26
+ <a name="v1.57.0"></a>
27
+ ### v1.57.0 (2021-01-27)
28
+
29
+ #### Features
30
+
31
+ * allow verbose flag to be set when publishing verifications ([9238e4c](/../../commit/9238e4c))
32
+
1
33
  <a name="v1.56.0"></a>
2
34
  ### v1.56.0 (2021-01-22)
3
35
 
@@ -79,6 +79,7 @@ module Pact
79
79
  def pact_spec_options
80
80
  {
81
81
  full_backtrace: options[:backtrace],
82
+ verbose: options[:verbose] || ENV['VERBOSE'] == 'true',
82
83
  criteria: SpecCriteria.call(options),
83
84
  format: options[:format],
84
85
  out: options[:out],
data/lib/pact/cli.rb CHANGED
@@ -16,6 +16,7 @@ module Pact
16
16
  method_option :pact_broker_password, aliases: "-w", desc: "Pact broker password"
17
17
  method_option :pact_broker_token, aliases: "-k", desc: "Pact broker token"
18
18
  method_option :backtrace, aliases: "-b", desc: "Show full backtrace", :default => false, :type => :boolean
19
+ method_option :verbose, aliases: "-v", desc: "Show verbose HTTP logging", :default => false, :type => :boolean
19
20
  method_option :interactions_replay_order, aliases: "-o",
20
21
  desc: "Interactions replay order: randomised or recorded (default)",
21
22
  default: Pact.configuration.interactions_replay_order
@@ -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
@@ -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
@@ -5,11 +5,48 @@ 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
+ else
43
+ desc = selector.to_s
44
+ end
45
+
10
46
  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(" ")
47
+ desc = "#{desc} (or #{fallback} if not found)" if fallback
48
+
49
+ desc
13
50
  end.join(", ")
14
51
  if options[:include_wip_pacts_since]
15
52
  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
@@ -75,6 +75,7 @@ module Pact
75
75
  end
76
76
 
77
77
  # For the Pact::Provider::RSpec::PactBrokerFormatter
78
+ Pact.provider_world.verbose = options[:verbose]
78
79
  Pact.provider_world.pact_sources = pact_sources
79
80
  jsons = pact_jsons
80
81
  executing_with_ruby = executing_with_ruby?
@@ -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
@@ -25,7 +25,7 @@ module Pact
25
25
  end
26
26
 
27
27
  def close(_notification)
28
- Pact::Provider::VerificationResults::PublishAll.call(Pact.provider_world.pact_sources, output_hash)
28
+ Pact::Provider::VerificationResults::PublishAll.call(Pact.provider_world.pact_sources, output_hash, { verbose: Pact.provider_world.verbose })
29
29
  end
30
30
 
31
31
  private
@@ -36,7 +36,7 @@ module Pact
36
36
  pact_source: pact_source,
37
37
  consumer_contract: consumer_contract,
38
38
  criteria: options[:criteria]
39
- )
39
+ )
40
40
  end
41
41
  end
42
42
 
@@ -16,21 +16,23 @@ 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
- def self.call pact_source, verification_result
21
- new(pact_source, verification_result).call
21
+ def self.call pact_source, verification_result, options = {}
22
+ new(pact_source, verification_result, options).call
22
23
  end
23
24
 
24
- def initialize pact_source, verification_result
25
+ def initialize pact_source, verification_result, options = {}
25
26
  @pact_source = pact_source
26
27
  @verification_result = verification_result
27
28
  http_client_options = pact_source.uri.options.reject{ |k, v| ![:username, :password, :token].include?(k) }
28
- @http_client = Pact::Hal::HttpClient.new(http_client_options)
29
+ @http_client = Pact::Hal::HttpClient.new(http_client_options.merge(verbose: options[:verbose]))
29
30
  @pact_entity = Pact::Hal::Entity.new(pact_source.uri, pact_source.pact_hash, http_client)
30
31
  end
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
@@ -6,20 +6,21 @@ module Pact
6
6
  module VerificationResults
7
7
  class PublishAll
8
8
 
9
- def self.call pact_sources, test_results_hash
10
- new(pact_sources, test_results_hash).call
9
+ def self.call pact_sources, test_results_hash, options = {}
10
+ new(pact_sources, test_results_hash, options).call
11
11
  end
12
12
 
13
- def initialize pact_sources, test_results_hash
13
+ def initialize pact_sources, test_results_hash, options = {}
14
14
  @pact_sources = pact_sources
15
15
  @test_results_hash = test_results_hash
16
+ @options = options
16
17
  end
17
18
 
18
19
  def call
19
20
  verification_results.collect do | (pact_source, verification_result) |
20
21
  published = false
21
22
  begin
22
- published = Publish.call(pact_source, verification_result)
23
+ published = Publish.call(pact_source, verification_result, { verbose: options[:verbose] })
23
24
  ensure
24
25
  print_after_verification_notices(pact_source, verification_result, published)
25
26
  end
@@ -42,7 +43,7 @@ module Pact
42
43
  end
43
44
  end
44
45
 
45
- attr_reader :pact_sources, :test_results_hash
46
+ attr_reader :pact_sources, :test_results_hash, :options
46
47
  end
47
48
  end
48
49
  end
@@ -14,7 +14,7 @@ module Pact
14
14
  module Provider
15
15
  class World
16
16
 
17
- attr_accessor :pact_sources, :failed_examples
17
+ attr_accessor :pact_sources, :failed_examples, :verbose
18
18
 
19
19
  def provider_states
20
20
  @provider_states_proxy ||= Pact::Provider::State::ProviderStateProxy.new
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.56.0"
3
+ VERSION = "1.60.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.56.0
4
+ version: 1.60.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-21 00:00:00.000000000 Z
15
+ date: 2021-10-01 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
@@ -405,7 +411,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
405
411
  - !ruby/object:Gem::Version
406
412
  version: '0'
407
413
  requirements: []
408
- rubygems_version: 3.2.6
414
+ rubygems_version: 3.2.28
409
415
  signing_key:
410
416
  specification_version: 4
411
417
  summary: Enables consumer driven contract testing, providing a mock service and DSL