pact 1.55.0 → 1.55.5

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: 54f6d8684eb57457977a86f79a9e2aace62f2fe63ef1e3896e8beee31586b0fe
4
- data.tar.gz: 292f5bdfe8cf126faaaab4a1792b1e68a21484f32a311fc9a5053f9a64f00f04
3
+ metadata.gz: b10e91c9004cfc9ac062f5a7f8af29366d1cfa38e7f763f649a78bb098355b5f
4
+ data.tar.gz: 272b6a356bdeabc2250a4190ee33c37dd38f814b07a4db3d041cdba18ab4e387
5
5
  SHA512:
6
- metadata.gz: 2501e2bb9ea36e185d45816d1944718fca0b0ebab315f7c51557553f85c809c96cb2a20d09096a326be108eafef352e6d41d2cc018369b3422f162bcc8fe7696
7
- data.tar.gz: d08e959aa8220f31b0fc8e60b82e9dda9f367f04604db7d26bdef16304b8862f45679e9333e49646d157e292ca03ef98fd94cb221723c7aee988539d0cc8540d
6
+ metadata.gz: fbaae4a4c078612e0441f8143f60cdbed8708da63eaaeff20e5f6677f10e499ff21a24b814459b0da60f534df6c3b95ce34827e3d9cc183f7d1676ae9615d614
7
+ data.tar.gz: f862fdfee39090335099e2584a4431441b2c564a198fb4516622d71502730ca35fd315181a720d4b7b7838ba8ba03f93096815f923deca41c17e1ef9b66c199f
@@ -1,3 +1,40 @@
1
+ <a name="v1.55.5"></a>
2
+ ### v1.55.5 (2020-10-12)
3
+
4
+ #### Bug Fixes
5
+
6
+ * **security**
7
+ * hide personal access token given in uri (#225) ([f6db12d](/../../commit/f6db12d))
8
+
9
+ <a name="v1.55.4"></a>
10
+ ### v1.55.4 (2020-10-09)
11
+
12
+ #### Bug Fixes
13
+
14
+ * add back missing output describing the interactions filter ([1a2d7c1](/../../commit/1a2d7c1))
15
+
16
+ <a name="v1.55.3"></a>
17
+ ### v1.55.3 (2020-09-28)
18
+
19
+ #### Bug Fixes
20
+
21
+ * correct logic for determining if all interactions for a pact have been verified ([c4f968e](/../../commit/c4f968e))
22
+ * de-duplicate re-run commands ([0813498](/../../commit/0813498))
23
+
24
+ <a name="v1.55.2"></a>
25
+ ### v1.55.2 (2020-09-26)
26
+
27
+ #### Bug Fixes
28
+
29
+ * correctly calculate exit code when a mix of pending and non pending pacts are verified ([533faa1](/../../commit/533faa1))
30
+
31
+ <a name="v1.55.1"></a>
32
+ ### v1.55.1 (2020-09-26)
33
+
34
+ #### Bug Fixes
35
+
36
+ * remove accidentally committed debug logging ([081423e](/../../commit/081423e))
37
+
1
38
  <a name="v1.55.0"></a>
2
39
  ### v1.55.0 (2020-09-26)
3
40
 
@@ -1,6 +1,7 @@
1
1
  require 'pact/consumer_contract/pact_file'
2
2
  require 'pact/hal/http_client'
3
3
  require 'pact/hal/entity'
4
+ require 'pact/consumer_contract'
4
5
 
5
6
  module Pact
6
7
  module Provider
@@ -20,6 +21,14 @@ module Pact
20
21
  @pact_hash ||= JSON.load(pact_json, nil, { max_nesting: 50 })
21
22
  end
22
23
 
24
+ def pending?
25
+ uri.metadata[:pending]
26
+ end
27
+
28
+ def consumer_contract
29
+ @consumer_contract ||= Pact::ConsumerContract.from_json(pact_json)
30
+ end
31
+
23
32
  def hal_entity
24
33
  http_client_keys = [:username, :password, :token]
25
34
  http_client_options = uri.options.reject{ |k, _| !http_client_keys.include?(k) }
@@ -11,6 +11,7 @@ require 'pact/provider/verification_results/publish_all'
11
11
  require 'pact/provider/rspec/pact_broker_formatter'
12
12
  require 'pact/provider/rspec/json_formatter'
13
13
  require 'pact/provider/rspec'
14
+ require 'pact/provider/rspec/calculate_exit_code'
14
15
 
15
16
  module Pact
16
17
  module Provider
@@ -79,6 +80,7 @@ module Pact
79
80
  executing_with_ruby = executing_with_ruby?
80
81
 
81
82
  config.after(:suite) do | suite |
83
+ Pact.provider_world.failed_examples = suite.reporter.failed_examples
82
84
  Pact::Provider::Help::Write.call(Pact.provider_world.pact_sources) if executing_with_ruby
83
85
  end
84
86
  end
@@ -90,7 +92,12 @@ module Pact
90
92
  ::RSpec::Core::CommandLine.new(NoConfigurationOptions.new)
91
93
  .run(::RSpec.configuration.output_stream, ::RSpec.configuration.error_stream)
92
94
  end
93
- pending_mode? ? 0 : exit_code
95
+
96
+ if options[:ignore_failures]
97
+ 0
98
+ else
99
+ Pact::Provider::RSpec::CalculateExitCode.call(pact_sources, Pact.provider_world.failed_examples)
100
+ end
94
101
  end
95
102
 
96
103
  def rspec_runner_options
@@ -147,8 +154,6 @@ module Pact
147
154
  end
148
155
 
149
156
  ::RSpec.configuration.full_backtrace = @options[:full_backtrace]
150
-
151
- ::RSpec.configuration.failure_color = :yellow if pending_mode?
152
157
  end
153
158
 
154
159
  def ordered_pact_json(pact_json)
@@ -159,20 +164,12 @@ module Pact
159
164
  consumer_contract.to_json
160
165
  end
161
166
 
162
- def all_pacts_pending?
163
- pact_urls.all?{ | pact_url| pact_url.metadata[:pending] }
164
- end
165
-
166
167
  def class_exists? name
167
168
  Kernel.const_get name
168
169
  rescue NameError
169
170
  false
170
171
  end
171
172
 
172
- def pending_mode?
173
- (all_pacts_pending? || options[:ignore_failures])
174
- end
175
-
176
173
  def executing_with_ruby?
177
174
  ENV['PACT_EXECUTING_LANGUAGE'] == 'ruby'
178
175
  end
@@ -17,7 +17,7 @@ module Pact
17
17
  end
18
18
 
19
19
  def basic_auth?
20
- !!username
20
+ !!username && !!password
21
21
  end
22
22
 
23
23
  def username
@@ -29,12 +29,23 @@ module Pact
29
29
  end
30
30
 
31
31
  def to_s
32
- if basic_auth? && uri.start_with?('http://', 'https://')
32
+ if basic_auth? && http_or_https_uri?
33
33
  URI(@uri).tap { |x| x.userinfo="#{username}:*****"}.to_s
34
+ elsif personal_access_token? && http_or_https_uri?
35
+ URI(@uri).tap { |x| x.userinfo="*****"}.to_s
34
36
  else
35
37
  uri
36
38
  end
37
39
  end
40
+
41
+ private def personal_access_token?
42
+ !!username && !password
43
+ end
44
+
45
+ private def http_or_https_uri?
46
+ uri.start_with?('http://', 'https://')
47
+ end
48
+
38
49
  end
39
50
  end
40
51
  end
@@ -26,8 +26,10 @@ module Pact
26
26
  Pact.configuration.output_stream.puts "INFO: Reading pact at #{pact_uri}"
27
27
  consumer_contract = Pact::ConsumerContract.from_json(pact_json)
28
28
  suffix = pact_uri.metadata[:pending] ? " [PENDING]": ""
29
+ example_group_description = "Verifying a pact between #{consumer_contract.consumer.name} and #{consumer_contract.provider.name}#{suffix}"
30
+ example_group_metadata = { pactfile_uri: pact_uri, pact_criteria: options[:criteria] }
29
31
 
30
- ::RSpec.describe "Verifying a pact between #{consumer_contract.consumer.name} and #{consumer_contract.provider.name}#{suffix}", pactfile_uri: pact_uri do
32
+ ::RSpec.describe example_group_description, example_group_metadata do
31
33
  honour_consumer_contract consumer_contract, options.merge(
32
34
  pact_json: pact_json,
33
35
  pact_uri: pact_uri,
@@ -89,9 +91,8 @@ module Pact
89
91
  pact_interaction_example_description: interaction_description_for_rerun_command(interaction),
90
92
  pact_uri: options[:pact_uri],
91
93
  pact_source: options[:pact_source],
92
- pact_ignore_failures: options[:pact_uri].metadata[:pending] || options[:ignore_failures],
93
- pact_consumer_contract: options[:consumer_contract],
94
- pact_criteria: options[:criteria]
94
+ pact_ignore_failures: options[:pact_source].pending? || options[:ignore_failures],
95
+ pact_consumer_contract: options[:consumer_contract]
95
96
  }
96
97
 
97
98
  describe description_for(interaction), metadata do
@@ -100,9 +101,6 @@ module Pact
100
101
  pact_context = options[:pact_context]
101
102
 
102
103
  before do | example |
103
- pact_context.run_once :before do
104
- ::RSpec.configuration.reporter.message "THIS IS A PACT"
105
- end
106
104
  interaction_context.run_once :before do
107
105
  Pact.configuration.logger.info "Running example '#{Pact::RSpec.full_description(example)}'"
108
106
  set_up_provider_states interaction.provider_states, options[:consumer]
@@ -0,0 +1,18 @@
1
+ module Pact
2
+ module Provider
3
+ module RSpec
4
+ module CalculateExitCode
5
+ def self.call(pact_sources, failed_examples)
6
+ any_non_pending_failures = pact_sources.any? do |pact_source|
7
+ if pact_source.pending?
8
+ nil
9
+ else
10
+ failed_examples.select { |e| e.metadata[:pact_source] == pact_source }.any?
11
+ end
12
+ end
13
+ any_non_pending_failures ? 1 : 0
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -25,6 +25,7 @@ module Pact
25
25
  C = ::Term::ANSIColor
26
26
 
27
27
  def example_group_started(notification)
28
+ # This is the metadata on the top level "Verifying a pact between X and Y" describe block
28
29
  if @group_level == 0
29
30
  Pact.configuration.output_stream.puts
30
31
  pact_uri = notification.group.metadata[:pactfile_uri]
@@ -65,10 +66,6 @@ module Pact
65
66
  pending_interaction_examples(summary).size
66
67
  end
67
68
 
68
- def ignore_failures?(summary)
69
- summary.failed_examples.any?{ |e| e.metadata[:pact_ignore_failures] }
70
- end
71
-
72
69
  def failure_title summary
73
70
  ::RSpec::Core::Formatters::Helpers.pluralize(failed_interactions_count(summary), "failure")
74
71
  end
@@ -96,12 +93,14 @@ module Pact
96
93
  interaction_rerun_commands(pending_interaction_examples(summary)).each do | message |
97
94
  output.puts(message)
98
95
  end
96
+ set_rspec_failure_color(:red)
99
97
  end
100
98
 
101
- set_rspec_failure_color(:red)
102
- output.puts("\nFailed interactions:\n\n")
103
- interaction_rerun_commands(failed_interaction_examples(summary)).each do | message |
104
- output.puts(message)
99
+ if failed_interactions_count(summary) > 0
100
+ output.puts("\nFailed interactions:\n\n")
101
+ interaction_rerun_commands(failed_interaction_examples(summary)).each do | message |
102
+ output.puts(message)
103
+ end
105
104
  end
106
105
  end
107
106
 
@@ -130,7 +129,7 @@ module Pact
130
129
  def interaction_rerun_commands examples
131
130
  examples.collect do |example|
132
131
  interaction_rerun_command_for example
133
- end.compact
132
+ end.compact.uniq
134
133
  end
135
134
 
136
135
  def interaction_unique_key(example)
@@ -28,7 +28,23 @@ module Pact
28
28
  end
29
29
 
30
30
  def publishable?
31
- executed_interactions_count == all_interactions_count && all_interactions_count > 0
31
+ if defined?(@publishable)
32
+ @publishable
33
+ else
34
+ @publishable = pact_source.consumer_contract.interactions.all? do | interaction |
35
+ examples_for_pact_uri.any?{ |e| example_is_for_interaction?(e, interaction) }
36
+ end && examples_for_pact_uri.count > 0
37
+ end
38
+ end
39
+
40
+ def example_is_for_interaction?(example, interaction)
41
+ # Use the Pact Broker id if supported
42
+ if interaction._id
43
+ example[:pact_interaction]._id == interaction._id
44
+ else
45
+ # fall back to object equality (based on the field values of the interaction)
46
+ example[:pact_interaction] == interaction
47
+ end
32
48
  end
33
49
 
34
50
  def examples_for_pact_uri
@@ -39,18 +55,6 @@ module Pact
39
55
  examples_for_pact_uri.count{ |e| e[:status] != 'passed' }
40
56
  end
41
57
 
42
- def executed_interactions_count
43
- examples_for_pact_uri
44
- .collect { |e| e[:pact_interaction].object_id }
45
- .uniq
46
- .count
47
- end
48
-
49
- def all_interactions_count
50
- interactions = (pact_source.pact_hash['interactions'] || pact_source.pact_hash['messages'])
51
- interactions ? interactions.count : 0
52
- end
53
-
54
58
  def test_results_hash_for_pact_uri
55
59
  {
56
60
  tests: examples_for_pact_uri.collect{ |e| clean_example(e) },
@@ -81,7 +81,7 @@ module Pact
81
81
  Pact.configuration.output_stream.puts "INFO: Tagging version #{provider_application_version} of #{provider_name} as #{tag.inspect}"
82
82
  tag_entity = tag_link.expand(version: provider_application_version, tag: tag).put
83
83
  unless tag_entity.success?
84
- raise PublicationError.new("Error returned from tagging request #{tag_entity.response.code} #{tag_entity.response.body}")
84
+ raise PublicationError.new("Error returned from tagging request: status=#{tag_entity.response.code} body=#{tag_entity.response.body}")
85
85
  end
86
86
  end
87
87
  end
@@ -14,7 +14,7 @@ module Pact
14
14
  module Provider
15
15
  class World
16
16
 
17
- attr_accessor :pact_sources
17
+ attr_accessor :pact_sources, :failed_examples
18
18
 
19
19
  def provider_states
20
20
  @provider_states_proxy ||= Pact::Provider::State::ProviderStateProxy.new
@@ -1,4 +1,4 @@
1
1
  # Remember to bump pact-provider-proxy when this changes major version
2
2
  module Pact
3
- VERSION = "1.55.0"
3
+ VERSION = "1.55.5"
4
4
  end
@@ -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.9'
35
+ gem.add_runtime_dependency 'pact-support', '~> 1.15'
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'
@@ -43,6 +43,6 @@ Gem::Specification.new do |gem|
43
43
  gem.add_development_dependency 'faraday', '~> 0.13'
44
44
  gem.add_development_dependency 'conventional-changelog', '~> 1.3'
45
45
  gem.add_development_dependency 'bump', '~> 0.5'
46
- gem.add_development_dependency 'pact-message', '~> 0.6'
46
+ gem.add_development_dependency 'pact-message', '~> 0.8'
47
47
  gem.add_development_dependency 'rspec-its', '~> 1.3'
48
48
  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.55.0
4
+ version: 1.55.5
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: 2020-09-26 00:00:00.000000000 Z
15
+ date: 2020-10-11 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: rspec
@@ -102,14 +102,14 @@ dependencies:
102
102
  requirements:
103
103
  - - "~>"
104
104
  - !ruby/object:Gem::Version
105
- version: '1.9'
105
+ version: '1.15'
106
106
  type: :runtime
107
107
  prerelease: false
108
108
  version_requirements: !ruby/object:Gem::Requirement
109
109
  requirements:
110
110
  - - "~>"
111
111
  - !ruby/object:Gem::Version
112
- version: '1.9'
112
+ version: '1.15'
113
113
  - !ruby/object:Gem::Dependency
114
114
  name: pact-mock_service
115
115
  requirement: !ruby/object:Gem::Requirement
@@ -248,14 +248,14 @@ dependencies:
248
248
  requirements:
249
249
  - - "~>"
250
250
  - !ruby/object:Gem::Version
251
- version: '0.6'
251
+ version: '0.8'
252
252
  type: :development
253
253
  prerelease: false
254
254
  version_requirements: !ruby/object:Gem::Requirement
255
255
  requirements:
256
256
  - - "~>"
257
257
  - !ruby/object:Gem::Version
258
- version: '0.6'
258
+ version: '0.8'
259
259
  - !ruby/object:Gem::Dependency
260
260
  name: rspec-its
261
261
  requirement: !ruby/object:Gem::Requirement
@@ -352,6 +352,7 @@ files:
352
352
  - lib/pact/provider/request.rb
353
353
  - lib/pact/provider/rspec.rb
354
354
  - lib/pact/provider/rspec/backtrace_formatter.rb
355
+ - lib/pact/provider/rspec/calculate_exit_code.rb
355
356
  - lib/pact/provider/rspec/custom_options_file
356
357
  - lib/pact/provider/rspec/formatter_rspec_2.rb
357
358
  - lib/pact/provider/rspec/formatter_rspec_3.rb