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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 92d18ca8bd1b86d4ae9c662ec2a44542527ea210
4
- data.tar.gz: 8c7fe0d434067f498247604d32e60d0fc464d59e
2
+ SHA256:
3
+ metadata.gz: 7ccc117840bc0955cb8ffa7568bab96b94ec5d7d51b6bd5233a05b251373e221
4
+ data.tar.gz: 66218c13f81e23f76facec82ef95f64038376f3368ae02aa3ce16008288f35fe
5
5
  SHA512:
6
- metadata.gz: 641f9838234b355e6e0fa3303a12cdad51479ad5ecffe2d5452a9e4e573929063bb2a6fffe4451a7e804a15e4b6613a82bd9c6a08225196cfe15732e07afddb1
7
- data.tar.gz: 90c860b8487295c6315b7d070b2df265d94da815eddbae30aab5c91f57a29396e4a0371d542815db00993437bde08ca95ee550e0836649a378e5a9764d05285b
6
+ metadata.gz: 4e16a0adf65d235937a123a5a1ee0043ded52ba0e4a2541f6b3a7a0e5e208a681cb405baee555b23c66d46a75dcb388999d1f424b0c7bb9c8055839cbf72f9ac
7
+ data.tar.gz: 0dc8fef0d02eaeb5976395c4a0eb33bdc01ac0ba954dad0eab3a7bc8b24d31625224e28c048d31b551ff1bc15a39ba41bd0f275a80f8d578f9077f0193fdfcb0
@@ -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], request_matching_rules[key], options)
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], response_matching_rules[key], options)
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
- expected_array = expected_size.times.collect{ Pact::Term.unpack_regexps(array_like.contents) }
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
- ((rules_array.length - 1)..0).each do | index |
112
- rules_array.delete_at(index) if rules_array[index].empty?
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
 
@@ -1,5 +1,5 @@
1
1
  module Pact
2
2
  module Support
3
- VERSION = "1.14.0"
3
+ VERSION = "1.15.1"
4
4
  end
5
5
  end
@@ -80,6 +80,5 @@ module Pact
80
80
  destination[key] = unpack_regexps source[key]
81
81
  end
82
82
  end
83
-
84
83
  end
85
84
  end
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.14.0
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-02-13 00:00:00.000000000 Z
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
- rubyforge_project:
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