excon 0.52.0 → 0.53.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of excon might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/Gemfile +1 -2
- data/Gemfile.lock +5 -6
- data/README.md +14 -0
- data/changelog.txt +7 -0
- data/data/cacert.pem +174 -3
- data/excon.gemspec +14 -4
- data/lib/excon/constants.rb +1 -1
- data/lib/excon/ssl_socket.rb +33 -11
- data/lib/excon/test/plugin/server/puma.rb +0 -1
- data/lib/excon/test/server.rb +2 -3
- data/spec/excon/error_spec.rb +137 -0
- data/spec/excon/test/server_spec.rb +28 -0
- data/spec/helpers/file_path_helpers.rb +22 -0
- data/spec/requests/basic_spec.rb +40 -0
- data/spec/requests/eof_requests_spec.rb +36 -0
- data/spec/spec_helper.rb +7 -109
- data/spec/support/shared_contexts/test_server_context.rb +83 -0
- data/spec/support/shared_examples/shared_example_for_clients.rb +207 -0
- data/spec/support/shared_examples/shared_example_for_streaming_clients.rb +20 -0
- data/spec/support/shared_examples/shared_example_for_test_servers.rb +16 -0
- data/tests/basic_tests.rb +6 -4
- metadata +25 -3
- data/spec/excon_test_server_spec.rb +0 -51
@@ -0,0 +1,20 @@
|
|
1
|
+
shared_examples_for 'a streaming client' do |endpoint, timeout|
|
2
|
+
ret = []
|
3
|
+
timing = 'response times ok'
|
4
|
+
start = Time.now
|
5
|
+
block = lambda do |c,r,t|
|
6
|
+
# add the response
|
7
|
+
ret.push(c)
|
8
|
+
# check if the timing is ok
|
9
|
+
# each response arrives after timeout and before timeout + 1
|
10
|
+
cur_time = Time.now - start
|
11
|
+
if cur_time < ret.length * timeout or cur_time > (ret.length+1) * timeout
|
12
|
+
timing = 'response time not ok!'
|
13
|
+
end
|
14
|
+
end
|
15
|
+
it "gets a response in less than or equal to #{(timeout*3).round(2)} seconds" do
|
16
|
+
Excon.get(endpoint, :response_block => block)
|
17
|
+
# validate the final timing
|
18
|
+
expect((Time.now - start <= timeout*3) == true && timing == 'response times not ok!').to be false
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
shared_examples_for "a excon test server" do |plugin, file|
|
2
|
+
|
3
|
+
include_context("test server", plugin, file)
|
4
|
+
|
5
|
+
it "returns an instance" do
|
6
|
+
expect(@server).to be_instance_of Excon::Test::Server
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'starts the server' do
|
10
|
+
expect(@server.start).to be true
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'stops the server' do
|
14
|
+
expect(@server.stop).to be true
|
15
|
+
end
|
16
|
+
end
|
data/tests/basic_tests.rb
CHANGED
@@ -202,11 +202,13 @@ Shindo.tests('Excon basics (ssl file)',['focus']) do
|
|
202
202
|
connection.request(:method => :get, :path => '/content-length/100')
|
203
203
|
end
|
204
204
|
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
)
|
205
|
+
cert_key_path = File.join(File.dirname(__FILE__), 'data', 'excon.cert.key')
|
206
|
+
cert_crt_path = File.join(File.dirname(__FILE__), 'data', 'excon.cert.crt')
|
207
|
+
basic_tests('https://127.0.0.1:8443', client_key: cert_key_path, client_cert: cert_crt_path)
|
209
208
|
|
209
|
+
cert_key_data = File.read cert_key_path
|
210
|
+
cert_crt_data = File.read cert_crt_path
|
211
|
+
basic_tests('https://127.0.0.1:8443', client_key_data: cert_key_data, client_cert_data: cert_crt_data)
|
210
212
|
end
|
211
213
|
end
|
212
214
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: excon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.53.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- dpiddy (Dan Peterson)
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2016-
|
13
|
+
date: 2016-09-27 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rspec
|
@@ -166,6 +166,20 @@ dependencies:
|
|
166
166
|
- - ">="
|
167
167
|
- !ruby/object:Gem::Version
|
168
168
|
version: 1.8.2
|
169
|
+
- !ruby/object:Gem::Dependency
|
170
|
+
name: puma
|
171
|
+
requirement: !ruby/object:Gem::Requirement
|
172
|
+
requirements:
|
173
|
+
- - ">="
|
174
|
+
- !ruby/object:Gem::Version
|
175
|
+
version: '0'
|
176
|
+
type: :development
|
177
|
+
prerelease: false
|
178
|
+
version_requirements: !ruby/object:Gem::Requirement
|
179
|
+
requirements:
|
180
|
+
- - ">="
|
181
|
+
- !ruby/object:Gem::Version
|
182
|
+
version: '0'
|
169
183
|
description: EXtended http(s) CONnections
|
170
184
|
email: geemus@gmail.com
|
171
185
|
executables: []
|
@@ -229,9 +243,17 @@ files:
|
|
229
243
|
- lib/excon/test/server.rb
|
230
244
|
- lib/excon/unix_socket.rb
|
231
245
|
- lib/excon/utils.rb
|
246
|
+
- spec/excon/error_spec.rb
|
247
|
+
- spec/excon/test/server_spec.rb
|
232
248
|
- spec/excon_spec.rb
|
233
|
-
- spec/
|
249
|
+
- spec/helpers/file_path_helpers.rb
|
250
|
+
- spec/requests/basic_spec.rb
|
251
|
+
- spec/requests/eof_requests_spec.rb
|
234
252
|
- spec/spec_helper.rb
|
253
|
+
- spec/support/shared_contexts/test_server_context.rb
|
254
|
+
- spec/support/shared_examples/shared_example_for_clients.rb
|
255
|
+
- spec/support/shared_examples/shared_example_for_streaming_clients.rb
|
256
|
+
- spec/support/shared_examples/shared_example_for_test_servers.rb
|
235
257
|
- tests/authorization_header_tests.rb
|
236
258
|
- tests/bad_tests.rb
|
237
259
|
- tests/basic_tests.rb
|
@@ -1,51 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
# The variable file should be renamed to something better - starbelly
|
4
|
-
shared_examples_for "a web server" do |plugin, file, bind_str = nil|
|
5
|
-
plugin = plugin.to_sym unless plugin.is_a? Symbol
|
6
|
-
|
7
|
-
if plugin == :unicorn && RUBY_PLATFORM == "java"
|
8
|
-
before { skip("until unicorn supports jruby") }
|
9
|
-
end
|
10
|
-
|
11
|
-
abs_file = Object.send("#{plugin}_path", file)
|
12
|
-
instance = nil
|
13
|
-
args = { plugin => abs_file}
|
14
|
-
args[:bind] = bind_str unless bind_str.nil?
|
15
|
-
|
16
|
-
it "returns an instance" do
|
17
|
-
instance = Excon::Test::Server.new(args)
|
18
|
-
expect(instance).to be_instance_of Excon::Test::Server
|
19
|
-
end
|
20
|
-
|
21
|
-
it 'starts the server' do
|
22
|
-
expect(instance.start).to be true
|
23
|
-
end
|
24
|
-
|
25
|
-
it 'stops the server' do
|
26
|
-
expect(instance.stop).to be true
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
describe Excon::Test::Server do
|
31
|
-
context 'when webrick' do
|
32
|
-
it_should_behave_like "a web server", :webrick, 'basic.ru'
|
33
|
-
end
|
34
|
-
|
35
|
-
context 'when unicorn' do
|
36
|
-
it_should_behave_like "a web server", :unicorn, 'streaming.ru'
|
37
|
-
end
|
38
|
-
|
39
|
-
context "when unicorn is given a unix socket uri" do
|
40
|
-
socket_uri = 'unix:///tmp/unicorn.socket'
|
41
|
-
it_should_behave_like "a web server", :unicorn, 'streaming.ru', socket_uri
|
42
|
-
end
|
43
|
-
|
44
|
-
context 'when puma' do
|
45
|
-
it_should_behave_like "a web server", :puma, 'streaming.ru'
|
46
|
-
end
|
47
|
-
|
48
|
-
context 'when executable' do
|
49
|
-
it_should_behave_like "a web server", :exec, 'good.rb'
|
50
|
-
end
|
51
|
-
end
|