pact-provider-verifier 1.14.0 → 1.14.3

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: 91e57d1d70bc73bb118c32c1751add6a86b5bed6a7473a1f127edab30729e329
4
- data.tar.gz: 3507befee7fce08b019cc7dfbe834a871f4f3f66d4ccf7a21a9cb40f8815a7c6
3
+ metadata.gz: ee26873b6d4026f5e77d867508a23c823c580e60e34ed23b8aa7cb9f31a9f6f8
4
+ data.tar.gz: 29a26e0a4648253c240bff44855e013ee8e201fe04e9d2411e1711a2b2455455
5
5
  SHA512:
6
- metadata.gz: 57878d218ad9d4cd506c88202e1404c5f012c99068e729c90d73b2c137ba8a7768638d2a2455f0d79b7f5251fd8f7c745f8e01a1eece8ab0bc97108bbba78d59
7
- data.tar.gz: 73980447db71db302c20d04e56553f728c77a0782d2e6bdef48252bd84e6f1ba5940d03eb944f0a3dd82832afe3ab11e268db5add12bbd5af1a92dc7ab808f75
6
+ metadata.gz: 082de71a324d991ecf66957ae3b6d498acaf031cba0924bdf44aeaee525f6151ccc7b8e1debf6399a6a9f26a824ee0273bc34abaf608142772e16b32be6e3e21
7
+ data.tar.gz: 96a7dbceb37c46dac5b2fb2193addcd0fd91d64cfccac93c2278c9072077a918fed18d60c9f1fead3bdf490d89b128d80f32d983051977ddf84811e7d817354a
@@ -1,3 +1,12 @@
1
+ <a name="v1.14.1-1"></a>
2
+ ### v1.14.1-1 (2018-05-08)
3
+
4
+
5
+ #### Bug Fixes
6
+
7
+ * ensure headers with underscores are correctly replayed ([abb4b4a](/../../commit/abb4b4a))
8
+
9
+
1
10
  <a name="v1.14.0-1"></a>
2
11
  ### v1.14.0-1 (2018-04-16)
3
12
 
data/README.md CHANGED
@@ -109,6 +109,8 @@ Rather than tearing down the specific test data created after each interaction,
109
109
 
110
110
  Note that the HTTP endpoint does not have to actually be within your application - it just has to have access to the same data store. So if you cannot add "test only" endpoints during your verification, consider making a separate app which shares credentials to your app's datastore. It is highly recommended that you run your verifications against a locally running provider, rather than a deployed one, as this will make it much easier to stub any downstream calls, debug issues, and it will make your tests run as fast as possible.
111
111
 
112
+ Ignore the `states` array that you will see if you happen to print out the live provider state set up request body - that was an attempt to make the set up call forwards compatible with the v3 pact specification, which allows multiple provider states. Unfortunately, this forwards compatibilty attempt failed, because the v3 provider states support a map of params, not just a name, so it should have been `{ "state": { "name": "PROVIDER_STATE, "params": {...} } }`.
113
+
112
114
  ### Using the Pact Broker with Basic authentication
113
115
 
114
116
  The following flags are required to use basic authentication with a Pact Broker:
@@ -80,7 +80,7 @@ module Pact
80
80
  preserve_host: true,
81
81
  x_forwarded_headers: false
82
82
  )
83
- reverse_proxy /(.*)/, "#{provider_base_url}$1"
83
+ reverse_proxy %r{(.*)}, "#{provider_base_url}$1"
84
84
  end
85
85
  end
86
86
 
@@ -4,6 +4,7 @@ require 'json'
4
4
  require_relative './app'
5
5
  require_relative 'set_up_provider_state'
6
6
  require 'pact/provider/configuration'
7
+ require 'pact/provider_verifier/underscored_headers_monkeypatch.rb'
7
8
 
8
9
  # Responsible for making the call to the provider state server to set up the state
9
10
 
@@ -0,0 +1,96 @@
1
+ # Ok, this doesn't make me feel good about myself, but it's the best way I've found
2
+ # to ensure that any underscored headers (eg "access_token") are not turned into dasherized
3
+ # headers by the Rack code that converts capitalized, dasherized headers into uppercase,
4
+ # underscored headers, and then back again.
5
+ # eg. access_token => HTTP_ACCESS_TOKEN => ACCESS-TOKEN
6
+ # To ensure the original header format is kept, an extra header, HTTP_X_PACT_ORIGINAL_HEADER_NAMES
7
+ # is added to the Rack Request when it is created from the request in the pact file, which contains
8
+ # a comma separated list of the original header names.
9
+ # This header is then removed by the modified Rack Reverse Proxy code, and used to restore
10
+ # the original header names if they have been transformed "incorrectly".
11
+ require 'pact/configuration'
12
+
13
+ def rack_reverse_proxy_headers_method_found
14
+ begin
15
+ RackReverseProxy::RoundTrip.instance_method(:headers)
16
+ true
17
+ rescue NameError
18
+ Pact.configuration.error_stream.puts "WARN: Could not find the RackReverseProxy::RoundTrip#headers method. The implementation must have changed. Cannot monkey patch the aforementioned method to ensure any underscores are retained in header names. You can ignore this warning if you use normal dasherized headers."
19
+ false
20
+ end
21
+ end
22
+
23
+ def pact_provider_request_headers_method_found
24
+ begin
25
+ Pact::Provider::Request::Replayable.instance_method(:headers)
26
+ true
27
+ rescue NameError
28
+ Pact.configuration.error_stream.puts "WARN: Could not find the Pact::Provider::Request::Replayable#headers method. The implementation must have changed. Cannot monkey patch the aforementioned method to ensure any underscores are retained in header names. You can ignore this warning if you use normal dasherized headers."
29
+ false
30
+ end
31
+ end
32
+
33
+ module Pact
34
+ module ProviderVerifier
35
+ module UnderscoredHeadersMonkeyPatch
36
+ extend self
37
+
38
+ def save_original_header_names rack_headers, expected_request_headers
39
+ # expected_request_headers may be a Pact::NullExpectation
40
+ if rack_headers.any?
41
+ rack_headers['HTTP_X_PACT_ORIGINAL_HEADER_NAMES'] = expected_request_headers.keys.join(",")
42
+ end
43
+ rack_headers
44
+ end
45
+
46
+ def restore_original_header_names dasherized_headers
47
+ original_header_names_value = dasherized_headers.delete("X-PACT-ORIGINAL-HEADER-NAMES")
48
+ if original_header_names_value && original_header_names_value.size > 0
49
+ replace_header_names(dasherized_headers, original_header_names_value.split(","))
50
+ else
51
+ dasherized_headers
52
+ end
53
+ end
54
+
55
+ private
56
+
57
+ def replace_header_names dasherized_headers, original_header_names
58
+ original_header_names.each_with_object(dasherized_headers) do | original_header_name, headers |
59
+ if headers.key?(pact_uppercase_and_dasherize(original_header_name))
60
+ headers[original_header_name] = headers.delete(pact_uppercase_and_dasherize(original_header_name))
61
+ end
62
+ end
63
+ end
64
+
65
+ def pact_uppercase_and_dasherize header_name
66
+ header_name.upcase.split("_").join("-")
67
+ end
68
+ end
69
+ end
70
+ end
71
+
72
+ if pact_provider_request_headers_method_found && rack_reverse_proxy_headers_method_found
73
+ module Pact
74
+ module Provider
75
+ module Request
76
+ class Replayable
77
+ alias_method :pact_old_headers, :headers
78
+
79
+ def headers
80
+ Pact::ProviderVerifier::UnderscoredHeadersMonkeyPatch.save_original_header_names(pact_old_headers, expected_request.headers)
81
+ end
82
+ end
83
+ end
84
+ end
85
+ end
86
+
87
+ module RackReverseProxy
88
+ class RoundTrip
89
+ alias_method :pact_old_headers, :headers
90
+
91
+ def headers
92
+ Pact::ProviderVerifier::UnderscoredHeadersMonkeyPatch.restore_original_header_names(pact_old_headers)
93
+ end
94
+ end
95
+ end
96
+ end
@@ -1,5 +1,5 @@
1
1
  module Pact
2
2
  module ProviderVerifier
3
- VERSION = "1.14.0"
3
+ VERSION = "1.14.3"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pact-provider-verifier
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.14.0
4
+ version: 1.14.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Fellows
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-04-15 00:00:00.000000000 Z
11
+ date: 2018-05-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -302,6 +302,7 @@ files:
302
302
  - lib/pact/provider_verifier/cli/verify.rb
303
303
  - lib/pact/provider_verifier/pact_helper.rb
304
304
  - lib/pact/provider_verifier/set_up_provider_state.rb
305
+ - lib/pact/provider_verifier/underscored_headers_monkeypatch.rb
305
306
  - lib/pact/provider_verifier/version.rb
306
307
  homepage: https://github.com/pact-foundation/pact-provider-verifier
307
308
  licenses: