httpi 2.4.2 → 2.5.0
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/.github/workflows/development.yml +48 -0
- data/CHANGELOG.md +27 -0
- data/Gemfile +9 -4
- data/README.md +4 -9
- data/Rakefile +5 -3
- data/httpi.gemspec +5 -5
- data/lib/httpi/adapter/curb.rb +7 -2
- data/lib/httpi/adapter/em_http.rb +5 -4
- data/lib/httpi/adapter/excon.rb +11 -2
- data/lib/httpi/adapter/http.rb +15 -2
- data/lib/httpi/adapter/httpclient.rb +5 -0
- data/lib/httpi/adapter/net_http.rb +17 -3
- data/lib/httpi/adapter/net_http_persistent.rb +6 -2
- data/lib/httpi/auth/ssl.rb +62 -3
- data/lib/httpi/logger.rb +6 -1
- data/lib/httpi/request.rb +2 -2
- data/lib/httpi/version.rb +1 -1
- data/spec/fixtures/client_cert.pem +18 -14
- data/spec/fixtures/client_key.pem +25 -13
- data/spec/httpi/adapter/curb_spec.rb +32 -9
- data/spec/httpi/adapter/em_http_spec.rb +23 -21
- data/spec/httpi/adapter/excon_spec.rb +28 -118
- data/spec/httpi/adapter/http_spec.rb +23 -96
- data/spec/httpi/adapter/httpclient_spec.rb +32 -0
- data/spec/httpi/adapter/net_http_persistent_spec.rb +31 -81
- data/spec/httpi/adapter/net_http_spec.rb +37 -154
- data/spec/httpi/auth/ssl_spec.rb +49 -1
- data/spec/httpi/httpi_spec.rb +2 -4
- data/spec/integration/curb_spec.rb +20 -0
- data/spec/integration/em_http_spec.rb +19 -2
- data/spec/integration/excon_spec.rb +174 -0
- data/spec/integration/fixtures/ca_all.pem +17 -42
- data/spec/integration/fixtures/server.cert +17 -17
- data/spec/integration/fixtures/server.key +25 -13
- data/spec/integration/http_spec.rb +156 -0
- data/spec/integration/httpclient_spec.rb +20 -0
- data/spec/integration/net_http_persistent_spec.rb +34 -2
- data/spec/integration/net_http_spec.rb +136 -1
- data/spec/integration/support/application.rb +3 -2
- data/spec/integration/support/server.rb +1 -2
- data/spec/spec_helper.rb +0 -2
- metadata +16 -15
- data/.travis.yml +0 -9
@@ -1,171 +1,54 @@
|
|
1
1
|
require "spec_helper"
|
2
|
-
require "
|
2
|
+
require "httpi/adapter/net_http"
|
3
|
+
require "httpi/request"
|
3
4
|
|
4
|
-
|
5
|
+
begin
|
6
|
+
HTTPI::Adapter.load_adapter(:net_http)
|
5
7
|
|
6
|
-
|
8
|
+
describe HTTPI::Adapter::NetHTTP do
|
9
|
+
let(:adapter) { HTTPI::Adapter::NetHTTP.new(request) }
|
10
|
+
let(:request) { HTTPI::Request.new("http://example.com") }
|
7
11
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
after :all do
|
14
|
-
@server.stop
|
15
|
-
end
|
16
|
-
|
17
|
-
context 'when socks is specified' do
|
18
|
-
|
19
|
-
let(:socks_client) { mock('socks_client') }
|
20
|
-
let(:request){HTTPI::Request.new(@server.url)}
|
21
|
-
|
22
|
-
it 'uses Net::HTTP.SOCKSProxy as client' do
|
23
|
-
socks_client.expects(:new).with(URI(@server.url).host, URI(@server.url).port).returns(:socks_client_instance)
|
24
|
-
Net::HTTP.expects(:SOCKSProxy).with('localhost', 8080).returns socks_client
|
25
|
-
|
26
|
-
request.proxy = 'socks://localhost:8080'
|
27
|
-
adapter = HTTPI::Adapter::NetHTTP.new(request)
|
28
|
-
|
29
|
-
expect(adapter.client).to eq(:socks_client_instance)
|
12
|
+
let(:response) {
|
13
|
+
Object.new.tap do |r|
|
14
|
+
r.stubs(:code).returns(200)
|
15
|
+
r.stubs(:body).returns("abc")
|
16
|
+
r.stubs(:to_hash).returns({"Content-Length" => "3"})
|
30
17
|
end
|
31
|
-
|
18
|
+
}
|
32
19
|
|
33
|
-
|
34
|
-
|
35
|
-
request.headers["X-Header"] = "HTTPI"
|
36
|
-
|
37
|
-
response = HTTPI.get(request, adapter)
|
38
|
-
expect(response.body).to include("HTTPI")
|
20
|
+
before do
|
21
|
+
Net::HTTP.any_instance.stubs(:start).returns(response)
|
39
22
|
end
|
40
23
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
24
|
+
describe "settings" do
|
25
|
+
describe "open_timeout, read_timeout" do
|
26
|
+
it "are being set on the client" do
|
27
|
+
request.open_timeout = 30
|
28
|
+
request.read_timeout = 40
|
46
29
|
|
47
|
-
|
48
|
-
|
49
|
-
expect(response.body).to eq("post")
|
50
|
-
expect(response.headers["Content-Type"]).to eq("text/plain")
|
51
|
-
end
|
52
|
-
|
53
|
-
it "executes HEAD requests" do
|
54
|
-
response = HTTPI.head(@server.url, adapter)
|
55
|
-
expect(response.code).to eq(200)
|
56
|
-
expect(response.headers["Content-Type"]).to eq("text/plain")
|
57
|
-
end
|
30
|
+
adapter.client.expects(:open_timeout=).with(30)
|
31
|
+
adapter.client.expects(:read_timeout=).with(40)
|
58
32
|
|
59
|
-
|
60
|
-
response = HTTPI.put(@server.url, "<some>xml</some>", adapter)
|
61
|
-
expect(response.body).to eq("put")
|
62
|
-
expect(response.headers["Content-Type"]).to eq("text/plain")
|
63
|
-
end
|
64
|
-
|
65
|
-
it "executes DELETE requests" do
|
66
|
-
response = HTTPI.delete(@server.url, adapter)
|
67
|
-
expect(response.body).to eq("delete")
|
68
|
-
expect(response.headers["Content-Type"]).to eq("text/plain")
|
69
|
-
end
|
70
|
-
|
71
|
-
context "supports custom methods supported by Net::HTTP" do
|
72
|
-
let(:request) do
|
73
|
-
HTTPI::Request.new(@server.url).tap do|r|
|
74
|
-
r.body = request_body if request_body
|
33
|
+
adapter.request(:get)
|
75
34
|
end
|
76
35
|
end
|
77
36
|
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
end
|
93
|
-
|
94
|
-
context 'UNSUPPORTED method' do
|
95
|
-
let(:http_method) { :unsupported }
|
96
|
-
|
97
|
-
specify { expect { response }.to raise_error HTTPI::NotSupportedError }
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
it "supports basic authentication" do
|
102
|
-
request = HTTPI::Request.new(@server.url + "basic-auth")
|
103
|
-
request.auth.basic("admin", "secret")
|
104
|
-
|
105
|
-
response = HTTPI.get(request, adapter)
|
106
|
-
expect(response.body).to eq("basic-auth")
|
107
|
-
end
|
108
|
-
|
109
|
-
it "does not support digest authentication" do
|
110
|
-
request = HTTPI::Request.new(@server.url + "digest-auth")
|
111
|
-
request.auth.digest("admin", "secret")
|
112
|
-
|
113
|
-
expect { HTTPI.get(request, adapter) }.
|
114
|
-
to raise_error(HTTPI::NotSupportedError, /does not support HTTP digest authentication/)
|
115
|
-
end
|
116
|
-
|
117
|
-
it "supports ntlm authentication" do
|
118
|
-
request = HTTPI::Request.new(@server.url + "ntlm-auth")
|
119
|
-
request.auth.ntlm("tester", "vReqSoafRe5O")
|
120
|
-
|
121
|
-
response = HTTPI.get(request, adapter)
|
122
|
-
expect(response.body).to eq("ntlm-auth")
|
123
|
-
end
|
124
|
-
|
125
|
-
it 'does not support ntlm authentication when Net::NTLM is not available' do
|
126
|
-
Net.expects(:const_defined?).with(:NTLM).returns false
|
127
|
-
|
128
|
-
request = HTTPI::Request.new(@server.url + 'ntlm-auth')
|
129
|
-
request.auth.ntlm("testing", "failures")
|
130
|
-
|
131
|
-
expect { HTTPI.get(request, adapter) }.
|
132
|
-
to raise_error(HTTPI::NotSupportedError, /Net::NTLM is not available/)
|
133
|
-
end
|
134
|
-
|
135
|
-
it "does not crash when authenticate header is missing (on second request)" do
|
136
|
-
request = HTTPI::Request.new(@server.url + 'ntlm-auth')
|
137
|
-
request.auth.ntlm("tester", "vReqSoafRe5O")
|
138
|
-
|
139
|
-
expect { HTTPI.get(request, adapter) }.
|
140
|
-
to_not raise_error
|
141
|
-
|
142
|
-
expect { HTTPI.get(request, adapter) }.
|
143
|
-
to_not raise_error
|
144
|
-
end
|
145
|
-
end
|
146
|
-
|
147
|
-
# it does not support digest auth
|
148
|
-
|
149
|
-
if RUBY_PLATFORM =~ /java/
|
150
|
-
pending "Puma Server complains: SSL not supported on JRuby"
|
151
|
-
else
|
152
|
-
context "https requests" do
|
153
|
-
before :all do
|
154
|
-
@server = IntegrationServer.run(:ssl => true)
|
155
|
-
end
|
156
|
-
after :all do
|
157
|
-
@server.stop
|
158
|
-
end
|
159
|
-
|
160
|
-
# it does not raise when no certificate was set up
|
161
|
-
it "works when set up properly" do
|
162
|
-
request = HTTPI::Request.new(@server.url)
|
163
|
-
request.auth.ssl.ca_cert_file = IntegrationServer.ssl_ca_file
|
164
|
-
|
165
|
-
response = HTTPI.get(request, adapter)
|
166
|
-
expect(response.body).to eq("get")
|
37
|
+
describe "write_timeout" do
|
38
|
+
if Net::HTTP.method_defined?(:write_timeout=)
|
39
|
+
it "is being set on the client" do
|
40
|
+
request.write_timeout = 50
|
41
|
+
adapter.client.expects(:write_timeout=).with(50)
|
42
|
+
adapter.request(:get)
|
43
|
+
end
|
44
|
+
else
|
45
|
+
it "can not be set on the client" do
|
46
|
+
request.write_timeout = 50
|
47
|
+
expect { adapter.request(:get) }
|
48
|
+
.to raise_error(HTTPI::NotSupportedError, /write_timeout/)
|
49
|
+
end
|
50
|
+
end
|
167
51
|
end
|
168
52
|
end
|
169
53
|
end
|
170
|
-
|
171
54
|
end
|
data/spec/httpi/auth/ssl_spec.rb
CHANGED
@@ -3,7 +3,8 @@ require "httpi/auth/ssl"
|
|
3
3
|
|
4
4
|
describe HTTPI::Auth::SSL do
|
5
5
|
before(:all) do
|
6
|
-
@ssl_versions =
|
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,53 @@ 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
|
+
|
192
|
+
describe '#ciphers' do
|
193
|
+
subject { ssl.ciphers }
|
194
|
+
let(:ssl) { HTTPI::Auth::SSL.new }
|
195
|
+
|
196
|
+
context 'without ciphers' do
|
197
|
+
before { ssl.ciphers = nil }
|
198
|
+
|
199
|
+
it { is_expected.to eq(nil) }
|
200
|
+
end
|
201
|
+
|
202
|
+
context 'with ciphers' do
|
203
|
+
before { ssl.ciphers = OpenSSL::SSL::SSLContext.new.ciphers }
|
204
|
+
|
205
|
+
it { is_expected.to be_any.and(all(be_an_instance_of(String))) }
|
206
|
+
end
|
207
|
+
end
|
208
|
+
|
161
209
|
def ssl
|
162
210
|
ssl = HTTPI::Auth::SSL.new
|
163
211
|
ssl.cert_key_file = "spec/fixtures/client_key.pem"
|
data/spec/httpi/httpi_spec.rb
CHANGED
@@ -6,11 +6,9 @@ require "excon"
|
|
6
6
|
require "net/http/persistent"
|
7
7
|
require "http"
|
8
8
|
|
9
|
-
unless
|
9
|
+
unless RUBY_PLATFORM =~ /java/
|
10
10
|
require "em-synchrony"
|
11
11
|
require "em-http-request"
|
12
|
-
end
|
13
|
-
unless RUBY_PLATFORM =~ /java/
|
14
12
|
require "curb"
|
15
13
|
end
|
16
14
|
|
@@ -294,7 +292,7 @@ describe HTTPI do
|
|
294
292
|
end
|
295
293
|
|
296
294
|
HTTPI::Adapter::ADAPTERS.each do |adapter, opts|
|
297
|
-
unless (adapter == :em_http
|
295
|
+
unless (adapter == :em_http || adapter == :curb) && RUBY_PLATFORM =~ /java/
|
298
296
|
client_class = {
|
299
297
|
:httpclient => lambda { HTTPClient },
|
300
298
|
:curb => lambda { Curl::Easy },
|
@@ -33,6 +33,17 @@ describe HTTPI::Adapter::Curb do
|
|
33
33
|
expect(response.headers["Set-Cookie"]).to eq(cookies)
|
34
34
|
end
|
35
35
|
|
36
|
+
it "it supports read timeout" do
|
37
|
+
require "curb"
|
38
|
+
|
39
|
+
request = HTTPI::Request.new(@server.url + "timeout")
|
40
|
+
request.read_timeout = 0.5 # seconds
|
41
|
+
|
42
|
+
expect do
|
43
|
+
HTTPI.get(request, adapter)
|
44
|
+
end.to raise_exception(Curl::Err::TimeoutError)
|
45
|
+
end
|
46
|
+
|
36
47
|
it "executes GET requests" do
|
37
48
|
response = HTTPI.get(@server.url, adapter)
|
38
49
|
expect(response.body).to eq("get")
|
@@ -112,6 +123,15 @@ describe HTTPI::Adapter::Curb do
|
|
112
123
|
response = HTTPI.get(request, adapter)
|
113
124
|
expect(response.body).to eq("get")
|
114
125
|
end
|
126
|
+
|
127
|
+
it "works with ciphers" do
|
128
|
+
request = HTTPI::Request.new(@server.url)
|
129
|
+
request.auth.ssl.ca_cert_file = IntegrationServer.ssl_ca_file
|
130
|
+
request.auth.ssl.ciphers = OpenSSL::SSL::SSLContext.new.ciphers
|
131
|
+
|
132
|
+
response = HTTPI.get(request, adapter)
|
133
|
+
expect(response.body).to eq("get")
|
134
|
+
end
|
115
135
|
end
|
116
136
|
|
117
137
|
end
|
@@ -3,8 +3,8 @@ require "integration/support/server"
|
|
3
3
|
|
4
4
|
describe HTTPI::Adapter::EmHttpRequest do
|
5
5
|
|
6
|
-
# em_http is not supported on
|
7
|
-
unless
|
6
|
+
# em_http is not supported on java
|
7
|
+
unless RUBY_PLATFORM =~ /java/
|
8
8
|
require "em-synchrony"
|
9
9
|
|
10
10
|
subject(:adapter) { :em_http }
|
@@ -42,6 +42,23 @@ describe HTTPI::Adapter::EmHttpRequest do
|
|
42
42
|
expect(response.headers["Set-Cookie"]).to eq(cookies)
|
43
43
|
end
|
44
44
|
|
45
|
+
if RUBY_PLATFORM =~ /java/
|
46
|
+
pending <<-MSG
|
47
|
+
It seems like JRuby is missing support for inactivity timeout! See related issues on GitHub:
|
48
|
+
- https://github.com/eventmachine/eventmachine/issues/155
|
49
|
+
- https://github.com/eventmachine/eventmachine/pull/312
|
50
|
+
MSG
|
51
|
+
else
|
52
|
+
it "it supports read timeout" do
|
53
|
+
request = HTTPI::Request.new(@server.url + "timeout")
|
54
|
+
request.read_timeout = 0.5 # seconds
|
55
|
+
|
56
|
+
expect do
|
57
|
+
HTTPI.get(request, adapter)
|
58
|
+
end.to raise_exception(HTTPI::TimeoutError)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
45
62
|
it "executes GET requests" do
|
46
63
|
response = HTTPI.get(@server.url, adapter)
|
47
64
|
expect(response.body).to eq("get")
|
@@ -0,0 +1,174 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "integration/support/server"
|
3
|
+
|
4
|
+
describe HTTPI::Adapter::Excon do
|
5
|
+
|
6
|
+
subject(:adapter) { :excon }
|
7
|
+
|
8
|
+
context "http requests" do
|
9
|
+
before :all do
|
10
|
+
@server = IntegrationServer.run
|
11
|
+
end
|
12
|
+
|
13
|
+
after :all do
|
14
|
+
@server.stop
|
15
|
+
end
|
16
|
+
|
17
|
+
it "sends and receives HTTP headers" do
|
18
|
+
request = HTTPI::Request.new(@server.url + "x-header")
|
19
|
+
request.headers["X-Header"] = "HTTPI"
|
20
|
+
|
21
|
+
response = HTTPI.get(request, adapter)
|
22
|
+
expect(response.body).to include("HTTPI")
|
23
|
+
end
|
24
|
+
|
25
|
+
it "it supports headers with multiple values" do
|
26
|
+
request = HTTPI::Request.new(@server.url + "cookies")
|
27
|
+
|
28
|
+
response = HTTPI.get(request, adapter)
|
29
|
+
cookies = ["cookie1=chip1; path=/", "cookie2=chip2; path=/"]
|
30
|
+
expect(response.headers["Set-Cookie"]).to eq(cookies)
|
31
|
+
end
|
32
|
+
|
33
|
+
it "it supports read timeout" do
|
34
|
+
require "excon"
|
35
|
+
|
36
|
+
request = HTTPI::Request.new(@server.url + "timeout")
|
37
|
+
request.read_timeout = 0.5 # seconds
|
38
|
+
|
39
|
+
expect do
|
40
|
+
HTTPI.get(request, adapter)
|
41
|
+
end.to raise_exception(Excon::Error::Timeout)
|
42
|
+
end
|
43
|
+
|
44
|
+
it "executes GET requests" do
|
45
|
+
response = HTTPI.get(@server.url, adapter)
|
46
|
+
expect(response.body).to eq("get")
|
47
|
+
expect(response.headers["Content-Type"]).to eq("text/plain")
|
48
|
+
end
|
49
|
+
|
50
|
+
it "executes POST requests" do
|
51
|
+
response = HTTPI.post(@server.url, "<some>xml</some>", adapter)
|
52
|
+
expect(response.body).to eq("post")
|
53
|
+
expect(response.headers["Content-Type"]).to eq("text/plain")
|
54
|
+
end
|
55
|
+
|
56
|
+
it "executes HEAD requests" do
|
57
|
+
response = HTTPI.head(@server.url, adapter)
|
58
|
+
expect(response.code).to eq(200)
|
59
|
+
expect(response.headers["Content-Type"]).to eq("text/plain")
|
60
|
+
end
|
61
|
+
|
62
|
+
it "executes PUT requests" do
|
63
|
+
response = HTTPI.put(@server.url, "<some>xml</some>", adapter)
|
64
|
+
expect(response.body).to eq("put")
|
65
|
+
expect(response.headers["Content-Type"]).to eq("text/plain")
|
66
|
+
end
|
67
|
+
|
68
|
+
it "executes DELETE requests" do
|
69
|
+
response = HTTPI.delete(@server.url, adapter)
|
70
|
+
expect(response.body).to eq("delete")
|
71
|
+
expect(response.headers["Content-Type"]).to eq("text/plain")
|
72
|
+
end
|
73
|
+
|
74
|
+
it "supports basic authentication" do
|
75
|
+
request = HTTPI::Request.new(@server.url + "basic-auth")
|
76
|
+
request.auth.basic("admin", "secret")
|
77
|
+
|
78
|
+
response = HTTPI.get(request, adapter)
|
79
|
+
expect(response.body).to eq("basic-auth")
|
80
|
+
end
|
81
|
+
|
82
|
+
it "does not support ntlm authentication" do
|
83
|
+
request = HTTPI::Request.new(@server.url + "ntlm-auth")
|
84
|
+
request.auth.ntlm("tester", "vReqSoafRe5O")
|
85
|
+
|
86
|
+
expect { HTTPI.get(request, adapter) }.
|
87
|
+
to raise_error(HTTPI::NotSupportedError, /does not support NTLM authentication/)
|
88
|
+
end
|
89
|
+
|
90
|
+
it "supports disabling verify mode" do
|
91
|
+
request = HTTPI::Request.new(@server.url)
|
92
|
+
request.auth.ssl.verify_mode = :none
|
93
|
+
adapter_class = HTTPI::Adapter.load(adapter).new(request)
|
94
|
+
expect(adapter_class.client.data[:ssl_verify_peer]).to eq(false)
|
95
|
+
end
|
96
|
+
|
97
|
+
it "supports chunked response" do
|
98
|
+
request = HTTPI::Request.new(@server.url)
|
99
|
+
res = ""
|
100
|
+
request.on_body do |body|
|
101
|
+
res += body
|
102
|
+
end
|
103
|
+
response = HTTPI.post(request, adapter)
|
104
|
+
expect(res).to eq("post")
|
105
|
+
expect(response.body).to eq("")
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
if RUBY_PLATFORM =~ /java/
|
110
|
+
pending "Puma Server complains: SSL not supported on JRuby"
|
111
|
+
else
|
112
|
+
context "https requests" do
|
113
|
+
before :all do
|
114
|
+
@server = IntegrationServer.run(:ssl => true)
|
115
|
+
end
|
116
|
+
after :all do
|
117
|
+
@server.stop
|
118
|
+
end
|
119
|
+
|
120
|
+
it "raises when no certificate was set up" do
|
121
|
+
expect { HTTPI.post(@server.url, "", adapter) }.to raise_error(HTTPI::SSLError)
|
122
|
+
end
|
123
|
+
|
124
|
+
it "works when set up properly" do
|
125
|
+
request = HTTPI::Request.new(@server.url)
|
126
|
+
request.auth.ssl.ca_cert_file = IntegrationServer.ssl_ca_file
|
127
|
+
|
128
|
+
response = HTTPI.get(request, adapter)
|
129
|
+
expect(response.body).to eq("get")
|
130
|
+
end
|
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
|
+
|
142
|
+
it "works with client cert and key provided as file path" do
|
143
|
+
request = HTTPI::Request.new(@server.url)
|
144
|
+
request.auth.ssl.ca_cert_file = IntegrationServer.ssl_ca_file
|
145
|
+
request.auth.ssl.cert_file = "spec/fixtures/client_cert.pem"
|
146
|
+
request.auth.ssl.cert_key_file = "spec/fixtures/client_key.pem"
|
147
|
+
|
148
|
+
response = HTTPI.get(request, adapter)
|
149
|
+
expect(response.body).to eq("get")
|
150
|
+
end
|
151
|
+
|
152
|
+
it "works with client cert and key set directly" do
|
153
|
+
request = HTTPI::Request.new(@server.url)
|
154
|
+
|
155
|
+
request.auth.ssl.ca_cert_file = IntegrationServer.ssl_ca_file
|
156
|
+
request.auth.ssl.cert = OpenSSL::X509::Certificate.new File.open("spec/fixtures/client_cert.pem").read
|
157
|
+
request.auth.ssl.cert_key = OpenSSL::PKey.read File.open("spec/fixtures/client_key.pem").read
|
158
|
+
|
159
|
+
response = HTTPI.get(request, adapter)
|
160
|
+
expect(response.body).to eq("get")
|
161
|
+
end
|
162
|
+
|
163
|
+
it "works with ciphers" do
|
164
|
+
request = HTTPI::Request.new(@server.url)
|
165
|
+
request.auth.ssl.ca_cert_file = IntegrationServer.ssl_ca_file
|
166
|
+
request.auth.ssl.ciphers = OpenSSL::SSL::SSLContext.new.ciphers
|
167
|
+
|
168
|
+
response = HTTPI.get(request, adapter)
|
169
|
+
expect(response.body).to eq("get")
|
170
|
+
end
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
174
|
+
end
|
@@ -1,44 +1,19 @@
|
|
1
1
|
-----BEGIN CERTIFICATE-----
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
MJJFRkSu6d/Ph5ypzBVw2YMT/nsOo5VwMUGLgS7YVjU+u/HNWz80J3oO17mNZllj
|
20
|
-
PvORJcnjwlroDnS58KoJ7GDgejv3ESWADvX1OHLE4cRkiQGeLoEU4pxdCxXRqX0U
|
21
|
-
PbwIkZN9mXVcrmPHq8MWi4eC/V7hnbZETMHuWhUoiNdOEfsAXr3iP4KjyyRdwc7a
|
22
|
-
d/xgcK06UVQRL/HbEYGiQL056mc=
|
23
|
-
-----END CERTIFICATE-----
|
24
|
-
-----BEGIN CERTIFICATE-----
|
25
|
-
MIIDaDCCAlCgAwIBAgIBATANBgkqhkiG9w0BAQUFADA8MQswCQYDVQQGDAJKUDES
|
26
|
-
MBAGA1UECgwJSklOLkdSLkpQMQwwCgYDVQQLDANSUlIxCzAJBgNVBAMMAkNBMB4X
|
27
|
-
DTA0MDEzMDAwNDMyN1oXDTM1MDEyMjAwNDMyN1owPzELMAkGA1UEBgwCSlAxEjAQ
|
28
|
-
BgNVBAoMCUpJTi5HUi5KUDEMMAoGA1UECwwDUlJSMQ4wDA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