httpi 2.4.4 → 2.4.5

This diff has not been reviewed by any users.
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: a39851ef3ab42a8c7ff8ddda62256da8f5f42b34fe0df16910686e4c25bf4565
4
- data.tar.gz: 627e8c2ae552288e8066f3305d9cf245dcb3c51d7421ab5dee9e731cb85e6f68
3
+ metadata.gz: d4ef171693207d4179542cd91eb6de5c8a1dc4b30458fcb5e255098e60a6297e
4
+ data.tar.gz: fb6977168d9ad78ab44fdfcbce528145fbe4c43f433a195cd6cd1ca5e33f1f54
5
5
  SHA512:
6
- metadata.gz: f811738a0681dab582710c91b25c0210924bda41332413d50761ddb466121e7551a81f2bc9dcc3caba8bbe6bd5dbb9ec0dffa761e1e20aca4f28e9ffa02fa1f6
7
- data.tar.gz: 7a5f15293b034a71187dd5fbae304b763eca335dd20f05e1007f56c3770995c618446d4867d8b6dc8fa5e2f7b722abd490d2e71ca9a955e2470498f3fba76945
6
+ metadata.gz: fb1092a0fb53a39f2d7f327b0f7c02b914f8f1e1f80f20e64178592d81b98d414016a62310a532931c3ba0da969f9fde269da22ea62fb594220f111a351e64ba
7
+ data.tar.gz: 5ce7bd00cb3ed67cace0e21ca2a4b459f6da89d618da1857b641a37413a0da98b5619b617dd86fab0a68ba280713a24d4ab54ae6b44362b91c3bc04df43a9e3a
@@ -1,15 +1,6 @@
1
1
  language: "ruby"
2
2
  script: "bundle exec rake ci"
3
- sudo: false
4
3
  rvm:
5
- - 2.0.0
6
- - 2.1.8
7
- - 2.2.4
8
- - 2.3.0
9
- - 2.5.0
10
- - jruby-9.1.9.0
11
- env:
12
- global:
13
- - JRUBY_OPTS="--2.0"
14
- before_install:
15
- - "travis_retry gem install bundler"
4
+ - 2.5.8
5
+ - 2.6.6
6
+ - 2.7.1
@@ -1,3 +1,10 @@
1
+ ### 2.4.5
2
+
3
+ * Improvement: [#209](https://github.com/savonrb/httpi/pull/209) Drop Travis CI support for Ruby < 2.3.0 and jruby.
4
+ * Feature: [#208](https://github.com/savonrb/httpi/pull/208) Add SSL min/max_version configuration for supporting adapters
5
+ * Improvement: [#206](https://github.com/savonrb/httpi/pull/206) Support for net-http-persistent v3
6
+ * Improvement: [#204](https://github.com/savonrb/httpi/pull/204) Avoid excon warning
7
+
1
8
  ### 2.4.4
2
9
 
3
10
  * Improvement: [#197](https://github.com/savonrb/httpi/pull/197) Add support for new write timeout option to all adapters
data/README.md CHANGED
@@ -5,10 +5,10 @@ A common interface for Ruby's HTTP libraries.
5
5
  [Documentation](https://www.rubydoc.info/gems/httpi) |
6
6
  [Mailing list](https://groups.google.com/forum/#!forum/httpirb)
7
7
 
8
- [![Build Status](https://secure.travis-ci.org/savonrb/httpi.png?branch=master)](http://travis-ci.org/savonrb/httpi)
9
- [![Gem Version](https://badge.fury.io/rb/httpi.png)](http://badge.fury.io/rb/httpi)
10
- [![Code Climate](https://codeclimate.com/github/savonrb/httpi.png)](https://codeclimate.com/github/savonrb/httpi)
11
- [![Coverage Status](https://coveralls.io/repos/savonrb/httpi/badge.png?branch=master)](https://coveralls.io/r/savonrb/httpi)
8
+ [![Build Status](https://secure.travis-ci.org/savonrb/httpi.svg?branch=master)](http://travis-ci.org/savonrb/httpi)
9
+ [![Gem Version](https://badge.fury.io/rb/httpi.svg)](http://badge.fury.io/rb/httpi)
10
+ [![Code Climate](https://codeclimate.com/github/savonrb/httpi.svg)](https://codeclimate.com/github/savonrb/httpi)
11
+ [![Coverage Status](https://coveralls.io/repos/savonrb/httpi/badge.svg?branch=master)](https://coveralls.io/r/savonrb/httpi)
12
12
 
13
13
 
14
14
  ## Installation
@@ -13,7 +13,6 @@ Gem::Specification.new do |s|
13
13
  s.description = s.summary
14
14
  s.required_ruby_version = '>= 1.9.2'
15
15
 
16
- s.rubyforge_project = s.name
17
16
  s.license = 'MIT'
18
17
 
19
18
  s.add_dependency 'rack'
@@ -128,6 +128,9 @@ module HTTPI
128
128
  when :SSLv23 then 2
129
129
  when :SSLv3 then 3
130
130
  end
131
+ if ssl.min_version || ssl.max_version
132
+ raise NotSupportedError, 'Curb adapter does not support #min_version or #max_version. Please, use #ssl_version instead.'
133
+ end
131
134
  end
132
135
 
133
136
  def respond_with(client)
@@ -41,6 +41,7 @@ module HTTPI
41
41
 
42
42
  opts = {
43
43
  :host => url.host,
44
+ :hostname => url.hostname,
44
45
  :path => url.path,
45
46
  :port => url.port,
46
47
  :query => url.query,
@@ -73,6 +74,8 @@ module HTTPI
73
74
  end
74
75
 
75
76
  opts[:ssl_version] = ssl.ssl_version if ssl.ssl_version
77
+ opts[:ssl_min_version] = ssl.min_version if ssl.min_version
78
+ opts[:ssl_max_version] = ssl.max_version if ssl.max_version
76
79
 
77
80
  opts
78
81
  end
@@ -58,6 +58,8 @@ module HTTPI
58
58
  context.cert = @request.auth.ssl.cert
59
59
  context.key = @request.auth.ssl.cert_key
60
60
  context.ssl_version = @request.auth.ssl.ssl_version if @request.auth.ssl.ssl_version != nil
61
+ context.min_version = @request.auth.ssl.min_version if @request.auth.ssl.min_version != nil
62
+ context.max_version = @request.auth.ssl.max_version if @request.auth.ssl.max_version != nil
61
63
  context.verify_mode = @request.auth.ssl.openssl_verify_mode
62
64
 
63
65
  client = ::HTTP::Client.new(:ssl_context => context)
@@ -78,6 +78,9 @@ module HTTPI
78
78
  end
79
79
 
80
80
  @client.ssl_config.ssl_version = ssl.ssl_version.to_s if ssl.ssl_version
81
+ if ssl.min_version || ssl.max_version
82
+ raise NotSupportedError, 'Httpclient adapter does not support #min_version or #max_version. Please, use #ssl_version instead'
83
+ end
81
84
  end
82
85
 
83
86
  def respond_with(response)
@@ -182,6 +182,8 @@ module HTTPI
182
182
  end
183
183
 
184
184
  @client.ssl_version = ssl.ssl_version if ssl.ssl_version
185
+ @client.min_version = ssl.min_version if ssl.min_version
186
+ @client.max_version = ssl.max_version if ssl.max_version
185
187
  end
186
188
 
187
189
  def ssl_cert_store(ssl)
@@ -12,7 +12,11 @@ module HTTPI
12
12
  private
13
13
 
14
14
  def create_client
15
- Net::HTTP::Persistent.new thread_key
15
+ if is_v3
16
+ Net::HTTP::Persistent.new name: thread_key
17
+ else
18
+ Net::HTTP::Persistent.new thread_key
19
+ end
16
20
  end
17
21
 
18
22
  def perform(http, http_request, &on_body)
@@ -39,6 +43,10 @@ module HTTPI
39
43
  @request.url.host.split(/\W/).reject{|p|p == ""}.join('-')
40
44
  end
41
45
 
46
+ def is_v3
47
+ Net::HTTP::Persistent::VERSION.start_with? "3."
48
+ end
49
+
42
50
  end
43
51
  end
44
52
  end
@@ -20,6 +20,9 @@ module HTTPI
20
20
  ssl_context::METHODS.reject { |method| method.match(/server|client/) }
21
21
  end.sort.reverse
22
22
 
23
+ # Returns OpenSSL::SSL::*_VERSION values for min_version and max_version
24
+ MIN_MAX_VERSIONS = OpenSSL::SSL.constants.select{|constant| constant =~/_VERSION$/}.map{|version| version.to_s.gsub(/_VERSION$/,'').to_sym}.reverse
25
+
23
26
  # Returns whether SSL configuration is present.
24
27
  def present?
25
28
  (verify_mode == :none) || (cert && cert_key) || ca_cert_file
@@ -90,6 +93,36 @@ module HTTPI
90
93
  @ssl_version = version
91
94
  end
92
95
 
96
+ # Returns the SSL min_version number. Defaults to <tt>nil</tt> (auto-negotiate).
97
+ def min_version
98
+ @min_version ||= nil
99
+ end
100
+
101
+ # Sets the SSL min_version number. Expects one of <tt>HTTPI::Auth::SSL::MIN_MAX_VERSIONS</tt>.
102
+ def min_version=(version)
103
+ unless MIN_MAX_VERSIONS.include? version
104
+ raise ArgumentError, "Invalid SSL min_version #{version.inspect}\n" +
105
+ "Please specify one of #{MIN_MAX_VERSIONS.inspect}"
106
+ end
107
+
108
+ @min_version = version
109
+ end
110
+
111
+ # Returns the SSL min_version number. Defaults to <tt>nil</tt> (auto-negotiate).
112
+ def max_version
113
+ @max_version ||= nil
114
+ end
115
+
116
+ # Sets the SSL min_version number. Expects one of <tt>HTTPI::Auth::SSL::MIN_MAX_VERSIONS</tt>.
117
+ def max_version=(version)
118
+ unless MIN_MAX_VERSIONS.include? version
119
+ raise ArgumentError, "Invalid SSL max_version #{version.inspect}\n" +
120
+ "Please specify one of #{MIN_MAX_VERSIONS.inspect}"
121
+ end
122
+
123
+ @max_version = version
124
+ end
125
+
93
126
  # Returns an <tt>OpenSSL::X509::Certificate</tt> for the +cert_file+.
94
127
  def cert
95
128
  @cert ||= (OpenSSL::X509::Certificate.new File.read(cert_file) if cert_file)
@@ -1,3 +1,3 @@
1
1
  module HTTPI
2
- VERSION = '2.4.4'
2
+ VERSION = '2.4.5'
3
3
  end
@@ -278,6 +278,16 @@ unless RUBY_PLATFORM =~ /java/
278
278
  adapter.request(:get)
279
279
  end
280
280
  end
281
+ it 'raises error when min_version not nil' do
282
+ request.auth.ssl.min_version = :TLS1_2
283
+ expect{ adapter.request(:get) }.
284
+ to raise_error(HTTPI::NotSupportedError, 'Curb adapter does not support #min_version or #max_version. Please, use #ssl_version instead.')
285
+ end
286
+ it 'raises error when max_version not nil' do
287
+ request.auth.ssl.max_version = :TLS1_2
288
+ expect{ adapter.request(:get) }.
289
+ to raise_error(HTTPI::NotSupportedError, 'Curb adapter does not support #min_version or #max_version. Please, use #ssl_version instead.')
290
+ end
281
291
  end
282
292
 
283
293
  context "(for SSL client auth)" do
@@ -23,6 +23,12 @@ begin
23
23
  )
24
24
  end
25
25
  end
26
+ describe "host, hostname" do
27
+ it "both are set" do
28
+ Excon.expects(:display_warning).never
29
+ expect(adapter.client.data).to include(host: 'example.com', hostname: 'example.com')
30
+ end
31
+ end
26
32
  end
27
33
  end
28
34
  end
@@ -178,6 +178,17 @@ describe HTTPI::Adapter::HTTPClient do
178
178
 
179
179
  adapter.request(:get)
180
180
  end
181
+
182
+ it 'raises error when min_version not nil' do
183
+ request.auth.ssl.min_version = :TLS1_2
184
+ expect{ adapter.request(:get) }.
185
+ to raise_error(HTTPI::NotSupportedError, 'Httpclient adapter does not support #min_version or #max_version. Please, use #ssl_version instead')
186
+ end
187
+ it 'raises error when max_version not nil' do
188
+ request.auth.ssl.max_version = :TLS1_2
189
+ expect{ adapter.request(:get) }.
190
+ to raise_error(HTTPI::NotSupportedError, 'Httpclient adapter does not support #min_version or #max_version. Please, use #ssl_version instead')
191
+ end
181
192
  end
182
193
 
183
194
  context "(for SSL client auth with a verify mode of :none with no certs provided)" do
@@ -4,6 +4,7 @@ require "httpi/auth/ssl"
4
4
  describe HTTPI::Auth::SSL do
5
5
  before(:all) do
6
6
  @ssl_versions = HTTPI::Auth::SSL::SSL_VERSIONS
7
+ @min_max_versions = HTTPI::Auth::SSL::MIN_MAX_VERSIONS
7
8
  end
8
9
 
9
10
  describe "VERIFY_MODES" do
@@ -158,6 +159,36 @@ describe HTTPI::Auth::SSL do
158
159
  end
159
160
  end
160
161
 
162
+ describe "#min_version" do
163
+ subject { HTTPI::Auth::SSL.new }
164
+
165
+ it "returns the min_version" do
166
+ subject.min_version = @min_max_versions.first
167
+ expect(subject.min_version).to eq(@min_max_versions.first)
168
+ end
169
+
170
+ it 'raises ArgumentError if the version is unsupported' do
171
+ expect { ssl.min_version = :ssl_fail }.
172
+ to raise_error(ArgumentError, "Invalid SSL min_version :ssl_fail\n" +
173
+ "Please specify one of #{@min_max_versions}")
174
+ end
175
+ end
176
+
177
+ describe "#max_version" do
178
+ subject { HTTPI::Auth::SSL.new }
179
+
180
+ it "returns the SSL version" do
181
+ subject.max_version = @min_max_versions.first
182
+ expect(subject.max_version).to eq(@min_max_versions.first)
183
+ end
184
+
185
+ it 'raises ArgumentError if the version is unsupported' do
186
+ expect { ssl.max_version = :ssl_fail }.
187
+ to raise_error(ArgumentError, "Invalid SSL max_version :ssl_fail\n" +
188
+ "Please specify one of #{@min_max_versions}")
189
+ end
190
+ end
191
+
161
192
  def ssl
162
193
  ssl = HTTPI::Auth::SSL.new
163
194
  ssl.cert_key_file = "spec/fixtures/client_key.pem"
@@ -129,6 +129,16 @@ describe HTTPI::Adapter::HTTPClient do
129
129
  expect(response.body).to eq("get")
130
130
  end
131
131
 
132
+ it "works with min_version/max_version" do
133
+ request = HTTPI::Request.new(@server.url)
134
+ request.auth.ssl.ca_cert_file = IntegrationServer.ssl_ca_file
135
+ request.auth.ssl.min_version = :TLS1_2
136
+ request.auth.ssl.max_version = :TLS1_2
137
+
138
+ response = HTTPI.get(request, adapter)
139
+ expect(response.body).to eq("get")
140
+ end
141
+
132
142
  it "works with client cert and key provided as file path" do
133
143
  request = HTTPI::Request.new(@server.url)
134
144
  request.auth.ssl.ca_cert_file = IntegrationServer.ssl_ca_file
@@ -131,6 +131,16 @@ describe HTTPI::Adapter::HTTP do
131
131
  response = HTTPI.get(request, adapter)
132
132
  expect(response.body).to eq("get")
133
133
  end
134
+
135
+ it "works with min_version/max_version" do
136
+ request = HTTPI::Request.new(@server.url)
137
+ request.auth.ssl.ca_cert_file = IntegrationServer.ssl_ca_file
138
+ request.auth.ssl.min_version = :TLS1_2
139
+ request.auth.ssl.max_version = :TLS1_2
140
+
141
+ response = HTTPI.get(request, adapter)
142
+ expect(response.body).to eq("get")
143
+ end
134
144
  end
135
145
  end
136
146
 
@@ -217,6 +217,16 @@ describe HTTPI::Adapter::NetHTTP do
217
217
  response = HTTPI.get(request, adapter)
218
218
  expect(response.body).to eq("get")
219
219
  end
220
+
221
+ it "works with min_version/max_version" do
222
+ request = HTTPI::Request.new(@server.url)
223
+ request.auth.ssl.ca_cert_file = IntegrationServer.ssl_ca_file
224
+ request.auth.ssl.min_version = :TLS1_2
225
+ request.auth.ssl.max_version = :TLS1_2
226
+
227
+ response = HTTPI.get(request, adapter)
228
+ expect(response.body).to eq("get")
229
+ end
220
230
  end
221
231
  end
222
232
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: httpi
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.4
4
+ version: 2.4.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Harrington
@@ -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: 2020-07-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rack
@@ -219,8 +219,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
219
219
  - !ruby/object:Gem::Version
220
220
  version: '0'
221
221
  requirements: []
222
- rubyforge_project: httpi
223
- rubygems_version: 2.7.6
222
+ rubygems_version: 3.0.3
224
223
  signing_key:
225
224
  specification_version: 4
226
225
  summary: Common interface for Ruby's HTTP libraries