pact-support 1.16.6 → 1.16.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +28 -0
- data/lib/pact/consumer_contract/interaction_v2_parser.rb +1 -1
- data/lib/pact/consumer_contract/pact_file.rb +7 -4
- data/lib/pact/consumer_contract/query.rb +11 -5
- data/lib/pact/consumer_contract/query_hash.rb +18 -2
- data/lib/pact/http/authorization_header_redactor.rb +32 -0
- data/lib/pact/reification.rb +4 -2
- data/lib/pact/support/version.rb +1 -1
- metadata +16 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c09158af5f53a850b84bb939265b42de8dd5cb9d09f662004443a9d752268968
|
4
|
+
data.tar.gz: db8cc140cff9641ed1bb9540959b58beb1258d55112f8377a9751e0d4435e28b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9a2fd0c40074e31a07968fc4546868ef358c2179ed31adc3bba8dd6d438dd3a1b419f5a473af6c383b39a7ab81d40c8587ba2f1eba8ffae4df26d0db6581acaf
|
7
|
+
data.tar.gz: ef379ad7d79957f40bf6aa6c6acf7879d89a39bf722757faba5b64e323e94c821401baf9ee761da3c3b213ba40f58e64a3d1c98d17427ff985febfb59648ddaf
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,31 @@
|
|
1
|
+
<a name="v1.16.10"></a>
|
2
|
+
### v1.16.10 (2021-10-01)
|
3
|
+
|
4
|
+
#### Bug Fixes
|
5
|
+
|
6
|
+
* change expgen to a runtime dependency ([da81634](/../../commit/da81634))
|
7
|
+
|
8
|
+
<a name="v1.16.9"></a>
|
9
|
+
### v1.16.9 (2021-09-30)
|
10
|
+
|
11
|
+
#### Bug Fixes
|
12
|
+
|
13
|
+
* remove randexp dependency (#91) ([794fd4e](/../../commit/794fd4e))
|
14
|
+
|
15
|
+
<a name="v1.16.8"></a>
|
16
|
+
### v1.16.8 (2021-07-27)
|
17
|
+
|
18
|
+
#### Bug Fixes
|
19
|
+
|
20
|
+
* log HTTP request for pacts retrieved by URL when requested with verbose=true ([3288b81](/../../commit/3288b81))
|
21
|
+
|
22
|
+
<a name="v1.16.7"></a>
|
23
|
+
### v1.16.7 (2021-01-28)
|
24
|
+
|
25
|
+
#### Bug Fixes
|
26
|
+
|
27
|
+
* dynamically parse actual query to match expected format ([a86a3e3](/../../commit/a86a3e3))
|
28
|
+
|
1
29
|
<a name="v1.16.6"></a>
|
2
30
|
### v1.16.6 (2021-01-28)
|
3
31
|
|
@@ -36,7 +36,7 @@ module Pact
|
|
36
36
|
# in the translation between string => structured object, as we don't know/store which
|
37
37
|
# query string convention was used.
|
38
38
|
if query_is_string
|
39
|
-
request_hash['query'] = Pact::QueryHash.new(request_hash['query'], original_query_string)
|
39
|
+
request_hash['query'] = Pact::QueryHash.new(request_hash['query'], original_query_string, Pact::Query.parsed_as_nested?(request_hash['query']))
|
40
40
|
end
|
41
41
|
request = Pact::Request::Expected.from_hash(request_hash)
|
42
42
|
end
|
@@ -1,4 +1,6 @@
|
|
1
|
-
require
|
1
|
+
require "net/http"
|
2
|
+
require "pact/configuration"
|
3
|
+
require "pact/http/authorization_header_redactor"
|
2
4
|
|
3
5
|
module Pact
|
4
6
|
module PactFile
|
@@ -81,7 +83,7 @@ module Pact
|
|
81
83
|
request = Net::HTTP::Get.new(uri)
|
82
84
|
request = prepare_auth(request, options) if options[:username] || options[:token]
|
83
85
|
|
84
|
-
http = prepare_request(uri)
|
86
|
+
http = prepare_request(uri, options)
|
85
87
|
response = perform_http_request(http, request, options)
|
86
88
|
|
87
89
|
if response.is_a?(Net::HTTPRedirection)
|
@@ -89,7 +91,7 @@ module Pact
|
|
89
91
|
req = Net::HTTP::Get.new(uri)
|
90
92
|
req = prepare_auth(req, options) if options[:username] || options[:token]
|
91
93
|
|
92
|
-
http = prepare_request(uri)
|
94
|
+
http = prepare_request(uri, options)
|
93
95
|
response = perform_http_request(http, req, options)
|
94
96
|
end
|
95
97
|
response
|
@@ -101,11 +103,12 @@ module Pact
|
|
101
103
|
request
|
102
104
|
end
|
103
105
|
|
104
|
-
def prepare_request(uri)
|
106
|
+
def prepare_request(uri, options)
|
105
107
|
http = Net::HTTP.new(uri.host, uri.port, :ENV)
|
106
108
|
http.use_ssl = (uri.scheme == 'https')
|
107
109
|
http.ca_file = ENV['SSL_CERT_FILE'] if ENV['SSL_CERT_FILE'] && ENV['SSL_CERT_FILE'] != ''
|
108
110
|
http.ca_path = ENV['SSL_CERT_DIR'] if ENV['SSL_CERT_DIR'] && ENV['SSL_CERT_DIR'] != ''
|
111
|
+
http.set_debug_output(Pact::Http::AuthorizationHeaderRedactor.new(Pact.configuration.output_stream)) if options[:verbose]
|
109
112
|
http
|
110
113
|
end
|
111
114
|
|
@@ -6,6 +6,8 @@ module Pact
|
|
6
6
|
DEFAULT_SEP = /[&;] */n
|
7
7
|
COMMON_SEP = { ";" => /[;] */n, ";," => /[;,] */n, "&" => /[&] */n }
|
8
8
|
|
9
|
+
class NestedQuery < Hash; end
|
10
|
+
|
9
11
|
def self.create query
|
10
12
|
if query.is_a? Hash
|
11
13
|
Pact::QueryHash.new(query)
|
@@ -18,12 +20,16 @@ module Pact
|
|
18
20
|
object.is_a?(Pact::QueryHash) || object.is_a?(Pact::QueryString)
|
19
21
|
end
|
20
22
|
|
23
|
+
def self.parsed_as_nested?(object)
|
24
|
+
object.is_a?(NestedQuery)
|
25
|
+
end
|
26
|
+
|
21
27
|
def self.parse_string query_string
|
22
|
-
parsed_query =
|
28
|
+
parsed_query = parse_string_as_non_nested_query(query_string)
|
23
29
|
|
24
30
|
# If Rails nested params...
|
25
31
|
if parsed_query.keys.any?{ | key| key =~ /\[.*\]/ }
|
26
|
-
|
32
|
+
parse_string_as_nested_query(query_string)
|
27
33
|
else
|
28
34
|
parsed_query.each_with_object({}) do | (key, value), new_hash |
|
29
35
|
new_hash[key] = [*value]
|
@@ -33,7 +39,7 @@ module Pact
|
|
33
39
|
|
34
40
|
# Ripped from Rack to avoid adding an unnecessary dependency, thank you Rack
|
35
41
|
# https://github.com/rack/rack/blob/649c72bab9e7b50d657b5b432d0c205c95c2be07/lib/rack/utils.rb
|
36
|
-
def self.
|
42
|
+
def self.parse_string_as_non_nested_query(qs, d = nil, &unescaper)
|
37
43
|
unescaper ||= method(:unescape)
|
38
44
|
|
39
45
|
params = {}
|
@@ -56,7 +62,7 @@ module Pact
|
|
56
62
|
return params.to_h
|
57
63
|
end
|
58
64
|
|
59
|
-
def self.
|
65
|
+
def self.parse_string_as_nested_query(qs, d = nil)
|
60
66
|
params = {}
|
61
67
|
|
62
68
|
unless qs.nil? || qs.empty?
|
@@ -67,7 +73,7 @@ module Pact
|
|
67
73
|
end
|
68
74
|
end
|
69
75
|
|
70
|
-
return params.to_h
|
76
|
+
return NestedQuery[params.to_h]
|
71
77
|
end
|
72
78
|
|
73
79
|
def self.normalize_params(params, name, v)
|
@@ -10,9 +10,18 @@ module Pact
|
|
10
10
|
|
11
11
|
attr_reader :original_string
|
12
12
|
|
13
|
-
def initialize(query, original_string = nil)
|
13
|
+
def initialize(query, original_string = nil, nested = false)
|
14
14
|
@hash = query.nil? ? query : convert_to_hash_of_arrays(query)
|
15
15
|
@original_string = original_string
|
16
|
+
@nested = nested
|
17
|
+
end
|
18
|
+
|
19
|
+
def nested?
|
20
|
+
@nested
|
21
|
+
end
|
22
|
+
|
23
|
+
def any_key_contains_square_brackets?
|
24
|
+
query.keys.any?{ |key| key =~ /\[.*\]/ }
|
16
25
|
end
|
17
26
|
|
18
27
|
def as_json(opts = {})
|
@@ -35,7 +44,14 @@ module Pact
|
|
35
44
|
# from the actual query string.
|
36
45
|
def difference(other)
|
37
46
|
require 'pact/matchers' # avoid recursive loop between this file, pact/reification and pact/matchers
|
38
|
-
|
47
|
+
|
48
|
+
if any_key_contains_square_brackets?
|
49
|
+
other_query_hash_non_nested = Query.parse_string_as_non_nested_query(other.query)
|
50
|
+
Pact::Matchers.diff(query, convert_to_hash_of_arrays(other_query_hash_non_nested), allow_unexpected_keys: false)
|
51
|
+
else
|
52
|
+
other_query_hash = Query.parse_string(other.query)
|
53
|
+
Pact::Matchers.diff(query, symbolize_keys(convert_to_hash_of_arrays(other_query_hash)), allow_unexpected_keys: false)
|
54
|
+
end
|
39
55
|
end
|
40
56
|
|
41
57
|
def query
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require "delegate"
|
2
|
+
|
3
|
+
module Pact
|
4
|
+
module Http
|
5
|
+
class AuthorizationHeaderRedactor < SimpleDelegator
|
6
|
+
def puts(*args)
|
7
|
+
__getobj__().puts(*redact_args(args))
|
8
|
+
end
|
9
|
+
|
10
|
+
def print(*args)
|
11
|
+
__getobj__().puts(*redact_args(args))
|
12
|
+
end
|
13
|
+
|
14
|
+
def <<(*args)
|
15
|
+
__getobj__().send(:<<, *redact_args(args))
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
attr_reader :redactions
|
21
|
+
|
22
|
+
def redact_args(args)
|
23
|
+
args.collect{ | s| redact(s) }
|
24
|
+
end
|
25
|
+
|
26
|
+
def redact(string)
|
27
|
+
return string unless string.is_a?(String)
|
28
|
+
string.gsub(/Authorization: .*\\r\\n/, "Authorization: [redacted]\\r\\n")
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
data/lib/pact/reification.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'expgen'
|
2
2
|
require 'pact/term'
|
3
3
|
require 'pact/something_like'
|
4
4
|
require 'pact/array_like'
|
@@ -13,8 +13,10 @@ module Pact
|
|
13
13
|
|
14
14
|
def self.from_term(term)
|
15
15
|
case term
|
16
|
-
when Pact::Term,
|
16
|
+
when Pact::Term, Pact::SomethingLike, Pact::ArrayLike
|
17
17
|
from_term(term.generate)
|
18
|
+
when Regexp
|
19
|
+
from_term(Expgen.gen(term))
|
18
20
|
when Hash
|
19
21
|
term.inject({}) do |mem, (key,t)|
|
20
22
|
mem[key] = from_term(t)
|
data/lib/pact/support/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pact-support
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.16.
|
4
|
+
version: 1.16.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Fraser
|
@@ -12,64 +12,64 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date: 2021-
|
15
|
+
date: 2021-09-30 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
|
-
name:
|
18
|
+
name: term-ansicolor
|
19
19
|
requirement: !ruby/object:Gem::Requirement
|
20
20
|
requirements:
|
21
21
|
- - "~>"
|
22
22
|
- !ruby/object:Gem::Version
|
23
|
-
version:
|
23
|
+
version: '1.0'
|
24
24
|
type: :runtime
|
25
25
|
prerelease: false
|
26
26
|
version_requirements: !ruby/object:Gem::Requirement
|
27
27
|
requirements:
|
28
28
|
- - "~>"
|
29
29
|
- !ruby/object:Gem::Version
|
30
|
-
version:
|
30
|
+
version: '1.0'
|
31
31
|
- !ruby/object:Gem::Dependency
|
32
|
-
name:
|
32
|
+
name: awesome_print
|
33
33
|
requirement: !ruby/object:Gem::Requirement
|
34
34
|
requirements:
|
35
35
|
- - "~>"
|
36
36
|
- !ruby/object:Gem::Version
|
37
|
-
version: '1.
|
37
|
+
version: '1.9'
|
38
38
|
type: :runtime
|
39
39
|
prerelease: false
|
40
40
|
version_requirements: !ruby/object:Gem::Requirement
|
41
41
|
requirements:
|
42
42
|
- - "~>"
|
43
43
|
- !ruby/object:Gem::Version
|
44
|
-
version: '1.
|
44
|
+
version: '1.9'
|
45
45
|
- !ruby/object:Gem::Dependency
|
46
|
-
name:
|
46
|
+
name: diff-lcs
|
47
47
|
requirement: !ruby/object:Gem::Requirement
|
48
48
|
requirements:
|
49
49
|
- - "~>"
|
50
50
|
- !ruby/object:Gem::Version
|
51
|
-
version: '1.
|
51
|
+
version: '1.4'
|
52
52
|
type: :runtime
|
53
53
|
prerelease: false
|
54
54
|
version_requirements: !ruby/object:Gem::Requirement
|
55
55
|
requirements:
|
56
56
|
- - "~>"
|
57
57
|
- !ruby/object:Gem::Version
|
58
|
-
version: '1.
|
58
|
+
version: '1.4'
|
59
59
|
- !ruby/object:Gem::Dependency
|
60
|
-
name:
|
60
|
+
name: expgen
|
61
61
|
requirement: !ruby/object:Gem::Requirement
|
62
62
|
requirements:
|
63
63
|
- - "~>"
|
64
64
|
- !ruby/object:Gem::Version
|
65
|
-
version: '1
|
65
|
+
version: '0.1'
|
66
66
|
type: :runtime
|
67
67
|
prerelease: false
|
68
68
|
version_requirements: !ruby/object:Gem::Requirement
|
69
69
|
requirements:
|
70
70
|
- - "~>"
|
71
71
|
- !ruby/object:Gem::Version
|
72
|
-
version: '1
|
72
|
+
version: '0.1'
|
73
73
|
- !ruby/object:Gem::Dependency
|
74
74
|
name: rspec
|
75
75
|
requirement: !ruby/object:Gem::Requirement
|
@@ -254,6 +254,7 @@ files:
|
|
254
254
|
- lib/pact/consumer_contract/string_with_matching_rules.rb
|
255
255
|
- lib/pact/errors.rb
|
256
256
|
- lib/pact/helpers.rb
|
257
|
+
- lib/pact/http/authorization_header_redactor.rb
|
257
258
|
- lib/pact/logging.rb
|
258
259
|
- lib/pact/matchers.rb
|
259
260
|
- lib/pact/matchers/actual_type.rb
|
@@ -318,7 +319,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
318
319
|
- !ruby/object:Gem::Version
|
319
320
|
version: '0'
|
320
321
|
requirements: []
|
321
|
-
rubygems_version: 3.2.
|
322
|
+
rubygems_version: 3.2.28
|
322
323
|
signing_key:
|
323
324
|
specification_version: 4
|
324
325
|
summary: Shared code for Pact gems
|