pact-support 1.14.0 → 1.15.1
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 +5 -5
- data/CHANGELOG.md +36 -0
- data/lib/pact/consumer_contract/interaction_v3_parser.rb +15 -5
- data/lib/pact/consumer_contract/pact_file.rb +25 -0
- data/lib/pact/matchers/matchers.rb +5 -1
- data/lib/pact/matching_rules/v3/merge.rb +4 -2
- data/lib/pact/support/version.rb +1 -1
- data/lib/pact/term.rb +0 -1
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 7ccc117840bc0955cb8ffa7568bab96b94ec5d7d51b6bd5233a05b251373e221
|
4
|
+
data.tar.gz: 66218c13f81e23f76facec82ef95f64038376f3368ae02aa3ce16008288f35fe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4e16a0adf65d235937a123a5a1ee0043ded52ba0e4a2541f6b3a7a0e5e208a681cb405baee555b23c66d46a75dcb388999d1f424b0c7bb9c8055839cbf72f9ac
|
7
|
+
data.tar.gz: 0dc8fef0d02eaeb5976395c4a0eb33bdc01ac0ba954dad0eab3a7bc8b24d31625224e28c048d31b551ff1bc15a39ba41bd0f275a80f8d578f9077f0193fdfcb0
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,39 @@
|
|
1
|
+
<a name="v1.15.0"></a>
|
2
|
+
### v1.15.0 (2020-04-30)
|
3
|
+
|
4
|
+
|
5
|
+
#### Bug Fixes
|
6
|
+
|
7
|
+
* follow first redirect when fetching remote pact artifacts. (#80) ([c1df6dd](/../../commit/c1df6dd))
|
8
|
+
|
9
|
+
|
10
|
+
<a name="v1.14.3"></a>
|
11
|
+
### v1.14.3 (2020-04-06)
|
12
|
+
|
13
|
+
|
14
|
+
#### Bug Fixes
|
15
|
+
|
16
|
+
* do not blow up when there are no matchers ([ac70846](/../../commit/ac70846))
|
17
|
+
|
18
|
+
|
19
|
+
<a name="v1.14.2"></a>
|
20
|
+
### v1.14.2 (2020-03-25)
|
21
|
+
|
22
|
+
|
23
|
+
#### Bug Fixes
|
24
|
+
|
25
|
+
* don't blow up when there is a term inside an each like ([a565a56](/../../commit/a565a56))
|
26
|
+
|
27
|
+
|
28
|
+
<a name="v1.14.1"></a>
|
29
|
+
### v1.14.1 (2020-02-27)
|
30
|
+
|
31
|
+
|
32
|
+
#### Bug Fixes
|
33
|
+
|
34
|
+
* correctly parse matching rules for request paths ([cc15a72](/../../commit/cc15a72))
|
35
|
+
|
36
|
+
|
1
37
|
<a name="v1.14.0"></a>
|
2
38
|
### v1.14.0 (2020-02-13)
|
3
39
|
|
@@ -20,9 +20,9 @@ module Pact
|
|
20
20
|
Pact.configuration.error_stream.puts("WARN: Currently only 1 provider state is supported. Ignoring ")
|
21
21
|
end
|
22
22
|
metadata = parse_metadata(hash['metadata'])
|
23
|
-
Interaction.new(symbolize_keys(hash).merge(request: request,
|
24
|
-
response: response,
|
25
|
-
provider_states: provider_states,
|
23
|
+
Interaction.new(symbolize_keys(hash).merge(request: request,
|
24
|
+
response: response,
|
25
|
+
provider_states: provider_states,
|
26
26
|
provider_state: provider_state,
|
27
27
|
metadata: metadata))
|
28
28
|
end
|
@@ -47,14 +47,14 @@ module Pact
|
|
47
47
|
|
48
48
|
def self.parse_request_with_non_string_body request_hash, request_matching_rules, options
|
49
49
|
request_hash = request_hash.keys.each_with_object({}) do | key, new_hash |
|
50
|
-
new_hash[key] = Pact::MatchingRules.merge(request_hash[key],
|
50
|
+
new_hash[key] = Pact::MatchingRules.merge(request_hash[key], look_up_matching_rules(key, request_matching_rules), options)
|
51
51
|
end
|
52
52
|
Pact::Request::Expected.from_hash(request_hash)
|
53
53
|
end
|
54
54
|
|
55
55
|
def self.parse_response_with_non_string_body response_hash, response_matching_rules, options
|
56
56
|
response_hash = response_hash.keys.each_with_object({}) do | key, new_hash |
|
57
|
-
new_hash[key] = Pact::MatchingRules.merge(response_hash[key],
|
57
|
+
new_hash[key] = Pact::MatchingRules.merge(response_hash[key], look_up_matching_rules(key, response_matching_rules), options)
|
58
58
|
end
|
59
59
|
Pact::Response.from_hash(response_hash)
|
60
60
|
end
|
@@ -78,5 +78,15 @@ module Pact
|
|
78
78
|
def self.parse_metadata metadata_hash
|
79
79
|
symbolize_keys(metadata_hash)
|
80
80
|
end
|
81
|
+
|
82
|
+
def self.look_up_matching_rules(key, matching_rules)
|
83
|
+
# The matching rules for the path operate on the object itself and don't have sub paths
|
84
|
+
# Convert it into the format that Merge expects.
|
85
|
+
if key == 'path'
|
86
|
+
matching_rules[key] ? { '$.' => matching_rules[key] } : nil
|
87
|
+
else
|
88
|
+
matching_rules[key]
|
89
|
+
end
|
90
|
+
end
|
81
91
|
end
|
82
92
|
end
|
@@ -79,12 +79,37 @@ module Pact
|
|
79
79
|
|
80
80
|
def get_remote(uri, options)
|
81
81
|
request = Net::HTTP::Get.new(uri)
|
82
|
+
request = prepare_auth(request, options) if options[:username] || options[:token]
|
83
|
+
|
84
|
+
http = prepare_request(uri)
|
85
|
+
response = perform_http_request(http, request, options)
|
86
|
+
|
87
|
+
if response.is_a?(Net::HTTPRedirection)
|
88
|
+
uri = URI(response.header['location'])
|
89
|
+
req = Net::HTTP::Get.new(uri)
|
90
|
+
req = prepare_auth(req, options) if options[:username] || options[:token]
|
91
|
+
|
92
|
+
http = prepare_request(uri)
|
93
|
+
response = perform_http_request(http, req, options)
|
94
|
+
end
|
95
|
+
response
|
96
|
+
end
|
97
|
+
|
98
|
+
def prepare_auth(request, options)
|
82
99
|
request.basic_auth(options[:username], options[:password]) if options[:username]
|
83
100
|
request['Authorization'] = "Bearer #{options[:token]}" if options[:token]
|
101
|
+
request
|
102
|
+
end
|
103
|
+
|
104
|
+
def prepare_request(uri)
|
84
105
|
http = Net::HTTP.new(uri.host, uri.port, :ENV)
|
85
106
|
http.use_ssl = (uri.scheme == 'https')
|
86
107
|
http.ca_file = ENV['SSL_CERT_FILE'] if ENV['SSL_CERT_FILE'] && ENV['SSL_CERT_FILE'] != ''
|
87
108
|
http.ca_path = ENV['SSL_CERT_DIR'] if ENV['SSL_CERT_DIR'] && ENV['SSL_CERT_DIR'] != ''
|
109
|
+
http
|
110
|
+
end
|
111
|
+
|
112
|
+
def perform_http_request(http, request, options)
|
88
113
|
http.start do |http|
|
89
114
|
http.open_timeout = options[:open_timeout] || OPEN_TIMEOUT
|
90
115
|
http.read_timeout = options[:read_timeout] || READ_TIMEOUT
|
@@ -120,7 +120,11 @@ module Pact
|
|
120
120
|
def array_like_diff array_like, actual, options
|
121
121
|
if actual.is_a? Array
|
122
122
|
expected_size = [array_like.min, actual.size].max
|
123
|
-
|
123
|
+
# I know changing this is going to break something, but I don't know what it is, as there's no
|
124
|
+
# test that fails when I make this change. I know the unpack regexps was there for a reason however.
|
125
|
+
# Guess we'll have to change it and see!
|
126
|
+
# expected_array = expected_size.times.collect{ Pact::Term.unpack_regexps(array_like.contents) }
|
127
|
+
expected_array = expected_size.times.collect{ array_like.contents }
|
124
128
|
actual_array_diff expected_array, actual, options.merge(:type => true)
|
125
129
|
else
|
126
130
|
Difference.new array_like.generate, actual, type_difference_message(array_like.generate, actual)
|
@@ -108,8 +108,10 @@ module Pact
|
|
108
108
|
def log_ignored_rules
|
109
109
|
@matching_rules.each do | jsonpath, rules_hash |
|
110
110
|
rules_array = rules_hash["matchers"]
|
111
|
-
|
112
|
-
rules_array.
|
111
|
+
if rules_array
|
112
|
+
((rules_array.length - 1)..0).each do | index |
|
113
|
+
rules_array.delete_at(index) if rules_array[index].empty?
|
114
|
+
end
|
113
115
|
end
|
114
116
|
end
|
115
117
|
|
data/lib/pact/support/version.rb
CHANGED
data/lib/pact/term.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.
|
4
|
+
version: 1.15.1
|
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-
|
15
|
+
date: 2020-07-16 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: randexp
|
@@ -298,8 +298,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
298
298
|
- !ruby/object:Gem::Version
|
299
299
|
version: '0'
|
300
300
|
requirements: []
|
301
|
-
|
302
|
-
rubygems_version: 2.6.14.3
|
301
|
+
rubygems_version: 3.1.4
|
303
302
|
signing_key:
|
304
303
|
specification_version: 4
|
305
304
|
summary: Shared code for Pact gems
|