pact-provider-verifier 1.17.0 → 1.19.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: f9a81a012908b0e5c40d70fc383041979cbe9e788d70e50b7ff88125264897eb
4
- data.tar.gz: 8b6017a1b1b8be59aaecfb3a9cbe672994747859c4e423c280cb57541b77c465
3
+ metadata.gz: 4816191834c42acad2eb1b2d1c23ad3080946f7d38304cccd2773aba2fc224c8
4
+ data.tar.gz: aa706e5dcf1069847773c7d547ee8d19d0f22020ccea133c77861052e33bf63c
5
5
  SHA512:
6
- metadata.gz: 85855c162d8798e1e2d36b80c2ca773908b25135cc35115239f43987fd87aaa243732fce1a5ddb12d74b0ffbd54eab7b5cf0dbb918f67973733724aa532f437d
7
- data.tar.gz: e14d6f338fe7d324642260e1aedbb3dd5a2d1d6e9c4093db433b7d80a66d7fe83530715bb458c17bb7111cc271ad951dd0ec51817cb7851fc6f82c56f5a14cb6
6
+ metadata.gz: 800639f786836a31e616b9455fdf2b046d244345a1ad0f81e0de416ad59238afebf794f8bc05bab11ad625dbe1b8e8da696b12d5ebeca307cd36c34fb0241e67
7
+ data.tar.gz: 2291ff8495f596a5bb15eded82328fabddf58065a6626881efbbe44c8de264ca35ba30628375410ce283bac88e38166b5485917946267090202885cf2e17183d
data/CHANGELOG.md CHANGED
@@ -1,3 +1,18 @@
1
+ <a name="v1.18.0-1"></a>
2
+ ### v1.18.0-1 (2018-09-11)
3
+
4
+
5
+ #### Features
6
+
7
+ * **pending pacts**
8
+ * allow pending pacts to be feature toggled ([5e8e15f](/../../commit/5e8e15f))
9
+
10
+ * allow custom rack middleware to be specified ([ef857d4](/../../commit/ef857d4))
11
+
12
+ * **custom-middleware**
13
+ * allow custom middleware to be configured via the command line ([217136d](/../../commit/217136d))
14
+
15
+
1
16
  <a name="v1.17.0-1"></a>
2
17
  ### v1.17.0-1 (2018-09-06)
3
18
 
@@ -43,8 +43,12 @@ module Pact
43
43
  end
44
44
 
45
45
  def net_pending_pact_uris
46
- pending_pact_uris - non_pending_pact_uris
46
+ if ENV['PACT_INCLUDE_PENDING'] == 'true'
47
+ pending_pact_uris - non_pending_pact_uris
48
+ else
49
+ []
50
+ end
47
51
  end
48
52
  end
49
53
  end
50
- end
54
+ end
@@ -1,4 +1,7 @@
1
1
  require 'pact/provider_verifier/add_header_middlware'
2
+ require 'pact/provider_verifier/provider_states/add_provider_states_header'
3
+ require 'pact/provider_verifier/provider_states/remove_provider_states_header_middleware'
4
+ require 'pact/provider_verifier/custom_middleware'
2
5
  require 'pact/provider/rspec'
3
6
  require 'pact/message'
4
7
  require 'pact/cli/run_pact_verification'
@@ -53,15 +56,17 @@ module Pact
53
56
 
54
57
  def configure_service_provider
55
58
  # Have to declare these locally as the class scope gets lost within the block
56
- rack_reverse_proxy = configure_reverse_proxy
57
- rack_reverse_proxy = configure_custom_header_middleware(rack_reverse_proxy)
59
+ application = configure_reverse_proxy
60
+ application = configure_provider_states_header_removal_middleware(application)
61
+ application = configure_custom_middleware(application)
62
+ application = configure_custom_header_middleware(application)
58
63
 
59
64
  provider_application_version = options.provider_app_version
60
65
  publish_results = options.publish_verification_results
61
66
 
62
67
  Pact.service_provider "Running Provider Application" do
63
68
  app do
64
- rack_reverse_proxy
69
+ application
65
70
  end
66
71
 
67
72
  if provider_application_version
@@ -92,7 +97,39 @@ module Pact
92
97
  end
93
98
  end
94
99
 
95
- def verify_pact config
100
+ def configure_custom_middleware app
101
+ if options.custom_middleware && options.custom_middleware.any?
102
+ require_custom_middlware
103
+ apply_custom_middleware(app)
104
+ else
105
+ app
106
+ end
107
+ end
108
+
109
+ def configure_provider_states_header_removal_middleware app
110
+ ProviderStates::RemoveProviderStatesHeaderMiddleware.new(app)
111
+ end
112
+
113
+ def require_custom_middlware
114
+ options.custom_middleware.each do |file|
115
+ $stdout.puts "DEBUG: Requiring custom middleware file #{file}" if options.verbose
116
+ begin
117
+ require file
118
+ rescue LoadError => e
119
+ $stderr.puts "ERROR: #{e.class} - #{e.message}. Please specify an absolute path."
120
+ exit(1)
121
+ end
122
+ end
123
+ end
124
+
125
+ def apply_custom_middleware app
126
+ CustomMiddleware.descendants.inject(app) do | app, clazz |
127
+ Pact.configuration.output_stream.puts "INFO: Adding custom middleware #{clazz}"
128
+ clazz.new(app)
129
+ end
130
+ end
131
+
132
+ def verify_pact(config)
96
133
  begin
97
134
  verify_options = {
98
135
  pact_helper: PROXY_PACT_HELPER,
@@ -102,7 +139,8 @@ module Pact
102
139
  pact_broker_password: options.broker_password,
103
140
  format: options.format,
104
141
  out: options.out,
105
- ignore_failures: config.pending
142
+ ignore_failures: config.pending,
143
+ request_customizer: ProviderStates::AddProviderStatesHeader
106
144
  }
107
145
  verify_options[:description] = ENV['PACT_DESCRIPTION'] if ENV['PACT_DESCRIPTION']
108
146
  verify_options[:provider_state] = ENV['PACT_PROVIDER_STATE'] if ENV['PACT_PROVIDER_STATE']
@@ -161,3 +199,5 @@ module Pact
161
199
  end
162
200
  end
163
201
  end
202
+
203
+
@@ -17,10 +17,11 @@ module Pact
17
17
  method_option :broker_username, aliases: "-n", desc: "Pact Broker basic auth username", :required => false
18
18
  method_option :broker_password, aliases: "-p", desc: "Pact Broker basic auth password", :required => false
19
19
  method_option :provider, required: false
20
- method_option :consumer_version_tag, type: :array, banner: "TAG", desc: "Retrieve the latest pacts with this consumer version tag. Used in conjuction with --provider. May be specified multiple times.", :required => false
20
+ method_option :consumer_version_tag, type: :array, banner: "TAG", desc: "Retrieve the latest pacts with this consumer version tag. Used in conjunction with --provider. May be specified multiple times.", :required => false
21
21
  method_option :provider_app_version, aliases: "-a", desc: "Provider application version, required when publishing verification results", :required => false
22
22
  method_option :publish_verification_results, aliases: "-r", desc: "Publish verification results to the broker", required: false
23
23
  method_option :custom_provider_header, type: :array, banner: 'CUSTOM_PROVIDER_HEADER', desc: "Header to add to provider state set up and pact verification requests. eg 'Authorization: Basic cGFjdDpwYWN0'. May be specified multiple times.", :required => false
24
+ method_option :custom_middleware, type: :array, banner: 'FILE', desc: "Ruby file containing a class implementing Pact::ProviderVerifier::CustomMiddleware. This allows the response to be modified before replaying. Use with caution!", :required => false
24
25
  method_option :monkeypatch, hide: true, type: :array, :required => false
25
26
  method_option :verbose, aliases: "-v", desc: "Verbose output", :required => false
26
27
  method_option :provider_states_url, aliases: "-s", :required => false, hide: true
@@ -0,0 +1,33 @@
1
+ require 'ostruct'
2
+
3
+ module Pact
4
+ module ProviderVerifier
5
+ class CustomMiddleware
6
+ def self.descendants
7
+ descendants = []
8
+ ObjectSpace.each_object(singleton_class) do |k|
9
+ descendants.unshift k unless k == self
10
+ end
11
+ descendants
12
+ end
13
+
14
+ attr_accessor :app
15
+
16
+ def initialize app
17
+ @app = app
18
+ end
19
+
20
+ def call env
21
+ raise NotImplementedError
22
+ end
23
+
24
+ def provider_states_from(env)
25
+ if env["X_PACT_PROVIDER_STATES"]
26
+ env["X_PACT_PROVIDER_STATES"].collect{ | provider_state| OpenStruct.new(provider_state) }
27
+ else
28
+ []
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,36 @@
1
+ require 'delegate'
2
+
3
+ module Pact
4
+ module ProviderVerifier
5
+ module ProviderStates
6
+ class RequestDelegate < SimpleDelegator
7
+ def initialize request, extra_rack_headers
8
+ super(request)
9
+ @extra_rack_headers = extra_rack_headers
10
+ end
11
+
12
+ def headers
13
+ __getobj__().headers.merge(@extra_rack_headers)
14
+ end
15
+
16
+ def method
17
+ __getobj__().method
18
+ end
19
+ end
20
+
21
+ class AddProviderStatesHeader
22
+
23
+ def self.call(request, interaction)
24
+ if interaction.provider_state
25
+ extra_rack_headers = {
26
+ "X_PACT_PROVIDER_STATES" => [{ "name" => interaction.provider_state }]
27
+ }
28
+ RequestDelegate.new(request, extra_rack_headers)
29
+ else
30
+ request
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,19 @@
1
+ module Pact
2
+ module ProviderVerifier
3
+ module ProviderStates
4
+ class RemoveProviderStatesHeaderMiddleware
5
+ def initialize app
6
+ @app = app
7
+ end
8
+
9
+ def call env
10
+ @app.call(remove_header(env))
11
+ end
12
+
13
+ def remove_header env
14
+ env.reject { | key, value | key == "X_PACT_PROVIDER_STATES" }
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -1,5 +1,5 @@
1
1
  module Pact
2
2
  module ProviderVerifier
3
- VERSION = "1.17.0"
3
+ VERSION = "1.19.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pact-provider-verifier
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.17.0
4
+ version: 1.19.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Fellows
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2018-09-05 00:00:00.000000000 Z
12
+ date: 2018-09-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
@@ -31,20 +31,14 @@ dependencies:
31
31
  requirements:
32
32
  - - "~>"
33
33
  - !ruby/object:Gem::Version
34
- version: '1.33'
35
- - - ">="
36
- - !ruby/object:Gem::Version
37
- version: 1.33.2
34
+ version: '1.34'
38
35
  type: :runtime
39
36
  prerelease: false
40
37
  version_requirements: !ruby/object:Gem::Requirement
41
38
  requirements:
42
39
  - - "~>"
43
40
  - !ruby/object:Gem::Version
44
- version: '1.33'
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- version: 1.33.2
41
+ version: '1.34'
48
42
  - !ruby/object:Gem::Dependency
49
43
  name: pact-message
50
44
  requirement: !ruby/object:Gem::Requirement
@@ -309,7 +303,10 @@ files:
309
303
  - lib/pact/provider_verifier/app.rb
310
304
  - lib/pact/provider_verifier/cli/custom_thor.rb
311
305
  - lib/pact/provider_verifier/cli/verify.rb
306
+ - lib/pact/provider_verifier/custom_middleware.rb
312
307
  - lib/pact/provider_verifier/pact_helper.rb
308
+ - lib/pact/provider_verifier/provider_states/add_provider_states_header.rb
309
+ - lib/pact/provider_verifier/provider_states/remove_provider_states_header_middleware.rb
313
310
  - lib/pact/provider_verifier/rspec_json_formatter_monkeypatch.rb
314
311
  - lib/pact/provider_verifier/set_up_provider_state.rb
315
312
  - lib/pact/provider_verifier/underscored_headers_monkeypatch.rb