rack-contrib 1.2.0 → 1.2.0.39.g17d21b4
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of rack-contrib might be problematic. Click here for more details.
- checksums.yaml +7 -0
- data/README.md +98 -0
- data/lib/rack/contrib.rb +3 -1
- data/lib/rack/contrib/enforce_valid_encoding.rb +23 -0
- data/lib/rack/contrib/jsonp.rb +5 -1
- data/lib/rack/contrib/locale.rb +1 -1
- data/lib/rack/contrib/mailexceptions.rb +41 -10
- data/lib/rack/contrib/post_body_content_type_parser.rb +1 -1
- data/lib/rack/contrib/relative_redirect.rb +1 -1
- data/lib/rack/contrib/try_static.rb +1 -1
- metadata +166 -113
- data/README.rdoc +0 -98
- data/Rakefile +0 -89
- data/rack-contrib.gemspec +0 -112
- data/test/404.html +0 -1
- data/test/Maintenance.html +0 -1
- data/test/documents/existing.html +0 -1
- data/test/documents/index.htm +0 -1
- data/test/documents/index.html +0 -1
- data/test/documents/test +0 -1
- data/test/mail_settings.rb +0 -20
- data/test/spec_rack_accept_format.rb +0 -72
- data/test/spec_rack_access.rb +0 -154
- data/test/spec_rack_backstage.rb +0 -26
- data/test/spec_rack_callbacks.rb +0 -65
- data/test/spec_rack_common_cookies.rb +0 -107
- data/test/spec_rack_config.rb +0 -22
- data/test/spec_rack_contrib.rb +0 -8
- data/test/spec_rack_cookies.rb +0 -56
- data/test/spec_rack_csshttprequest.rb +0 -66
- data/test/spec_rack_deflect.rb +0 -107
- data/test/spec_rack_evil.rb +0 -19
- data/test/spec_rack_expectation_cascade.rb +0 -72
- data/test/spec_rack_garbagecollector.rb +0 -13
- data/test/spec_rack_host_meta.rb +0 -50
- data/test/spec_rack_jsonp.rb +0 -188
- data/test/spec_rack_lighttpd_script_name_fix.rb +0 -16
- data/test/spec_rack_mailexceptions.rb +0 -169
- data/test/spec_rack_nested_params.rb +0 -46
- data/test/spec_rack_not_found.rb +0 -17
- data/test/spec_rack_post_body_content_type_parser.rb +0 -40
- data/test/spec_rack_proctitle.rb +0 -26
- data/test/spec_rack_profiler.rb +0 -42
- data/test/spec_rack_relative_redirect.rb +0 -78
- data/test/spec_rack_response_cache.rb +0 -137
- data/test/spec_rack_response_headers.rb +0 -35
- data/test/spec_rack_runtime.rb +0 -35
- data/test/spec_rack_sendfile.rb +0 -86
- data/test/spec_rack_simple_endpoint.rb +0 -95
- data/test/spec_rack_static_cache.rb +0 -104
- data/test/spec_rack_try_static.rb +0 -56
- data/test/statics/test +0 -1
data/test/spec_rack_backstage.rb
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
require 'test/spec'
|
2
|
-
require 'rack/builder'
|
3
|
-
require 'rack/mock'
|
4
|
-
require 'rack/contrib/backstage'
|
5
|
-
|
6
|
-
context "Rack::Backstage" do
|
7
|
-
specify "shows maintenances page if present" do
|
8
|
-
app = Rack::Builder.new do
|
9
|
-
use Rack::Backstage, 'test/Maintenance.html'
|
10
|
-
run lambda { |env| [200, {'Content-Type' => 'text/plain'}, ["Hello, World!"]] }
|
11
|
-
end
|
12
|
-
response = Rack::MockRequest.new(app).get('/')
|
13
|
-
response.body.should.equal('Under maintenance.')
|
14
|
-
response.status.should.equal(503)
|
15
|
-
end
|
16
|
-
|
17
|
-
specify "passes on request if page is not present" do
|
18
|
-
app = Rack::Builder.new do
|
19
|
-
use Rack::Backstage, 'test/Nonsense.html'
|
20
|
-
run lambda { |env| [200, {'Content-Type' => 'text/plain'}, ["Hello, World!"]] }
|
21
|
-
end
|
22
|
-
response = Rack::MockRequest.new(app).get('/')
|
23
|
-
response.body.should.equal('Hello, World!')
|
24
|
-
response.status.should.equal(200)
|
25
|
-
end
|
26
|
-
end
|
data/test/spec_rack_callbacks.rb
DELETED
@@ -1,65 +0,0 @@
|
|
1
|
-
require 'test/spec'
|
2
|
-
require 'rack/mock'
|
3
|
-
|
4
|
-
class Flame
|
5
|
-
def call(env)
|
6
|
-
env['flame'] = 'F Lifo..'
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
|
-
class Pacify
|
11
|
-
def initialize(with)
|
12
|
-
@with = with
|
13
|
-
end
|
14
|
-
|
15
|
-
def call(env)
|
16
|
-
env['peace'] = @with
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
class Finale
|
21
|
-
def call(response)
|
22
|
-
status, headers, body = response
|
23
|
-
|
24
|
-
headers['last'] = 'Finale'
|
25
|
-
$old_status = status
|
26
|
-
|
27
|
-
[201, headers, body]
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
class TheEnd
|
32
|
-
def call(response)
|
33
|
-
status, headers, body = response
|
34
|
-
|
35
|
-
headers['last'] = 'TheEnd'
|
36
|
-
[201, headers, body]
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
context "Rack::Callbacks" do
|
41
|
-
specify "works for love and small stack trace" do
|
42
|
-
callback_app = Rack::Callbacks.new do
|
43
|
-
before Flame
|
44
|
-
before Pacify, "with love"
|
45
|
-
|
46
|
-
run lambda {|env| [200, {}, [env['flame'], env['peace']]] }
|
47
|
-
|
48
|
-
after Finale
|
49
|
-
after TheEnd
|
50
|
-
end
|
51
|
-
|
52
|
-
app = Rack::Builder.new do
|
53
|
-
run callback_app
|
54
|
-
end.to_app
|
55
|
-
|
56
|
-
response = Rack::MockRequest.new(app).get("/")
|
57
|
-
|
58
|
-
response.body.should.equal 'F Lifo..with love'
|
59
|
-
|
60
|
-
$old_status.should.equal 200
|
61
|
-
response.status.should.equal 201
|
62
|
-
|
63
|
-
response.headers['last'].should.equal 'TheEnd'
|
64
|
-
end
|
65
|
-
end
|
@@ -1,107 +0,0 @@
|
|
1
|
-
require 'test/spec'
|
2
|
-
require 'rack/mock'
|
3
|
-
require 'rack/builder'
|
4
|
-
require 'rack/contrib/common_cookies'
|
5
|
-
|
6
|
-
context Rack::CommonCookies do
|
7
|
-
|
8
|
-
setup do
|
9
|
-
@app = Rack::Builder.new do
|
10
|
-
use Rack::CommonCookies
|
11
|
-
run lambda {|env| [200, {'Set-Cookie' => env['HTTP_COOKIE']}, []] }
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
def request
|
16
|
-
Rack::MockRequest.new(@app)
|
17
|
-
end
|
18
|
-
|
19
|
-
def make_request(domain, cookies='key=value')
|
20
|
-
request.get '/', 'HTTP_COOKIE' => cookies, 'HTTP_HOST' => domain
|
21
|
-
end
|
22
|
-
|
23
|
-
specify 'should use .domain.com for cookies from domain.com' do
|
24
|
-
response = make_request 'domain.com'
|
25
|
-
response.headers['Set-Cookie'].should == 'key=value; domain=.domain.com'
|
26
|
-
end
|
27
|
-
|
28
|
-
specify 'should use .domain.com for cookies from www.domain.com' do
|
29
|
-
response = make_request 'www.domain.com'
|
30
|
-
response.headers['Set-Cookie'].should == 'key=value; domain=.domain.com'
|
31
|
-
end
|
32
|
-
|
33
|
-
specify 'should use .domain.com for cookies from subdomain.domain.com' do
|
34
|
-
response = make_request 'subdomain.domain.com'
|
35
|
-
response.headers['Set-Cookie'].should == 'key=value; domain=.domain.com'
|
36
|
-
end
|
37
|
-
|
38
|
-
specify 'should use .domain.com for cookies from 0.subdomain1.subdomain2.domain.com' do
|
39
|
-
response = make_request '0.subdomain1.subdomain2.domain.com'
|
40
|
-
response.headers['Set-Cookie'].should == 'key=value; domain=.domain.com'
|
41
|
-
end
|
42
|
-
|
43
|
-
specify 'should use .domain.local for cookies from domain.local' do
|
44
|
-
response = make_request '0.subdomain1.subdomain2.domain.com'
|
45
|
-
response.headers['Set-Cookie'].should == 'key=value; domain=.domain.com'
|
46
|
-
end
|
47
|
-
|
48
|
-
specify 'should use .domain.local for cookies from subdomain.domain.local' do
|
49
|
-
response = make_request 'subdomain.domain.local'
|
50
|
-
response.headers['Set-Cookie'].should == 'key=value; domain=.domain.local'
|
51
|
-
end
|
52
|
-
|
53
|
-
specify 'should use .domain.com.ua for cookies from domain.com.ua' do
|
54
|
-
response = make_request 'domain.com.ua'
|
55
|
-
response.headers['Set-Cookie'].should == 'key=value; domain=.domain.com.ua'
|
56
|
-
end
|
57
|
-
|
58
|
-
specify 'should use .domain.com.ua for cookies from subdomain.domain.com.ua' do
|
59
|
-
response = make_request 'subdomain.domain.com.ua'
|
60
|
-
response.headers['Set-Cookie'].should == 'key=value; domain=.domain.com.ua'
|
61
|
-
end
|
62
|
-
|
63
|
-
specify 'should use .domain.co.uk for cookies from domain.co.uk' do
|
64
|
-
response = make_request 'domain.co.uk'
|
65
|
-
response.headers['Set-Cookie'].should == 'key=value; domain=.domain.co.uk'
|
66
|
-
end
|
67
|
-
|
68
|
-
specify 'should use .domain.co.uk for cookies from subdomain.domain.co.uk' do
|
69
|
-
response = make_request 'subdomain.domain.co.uk'
|
70
|
-
response.headers['Set-Cookie'].should == 'key=value; domain=.domain.co.uk'
|
71
|
-
end
|
72
|
-
|
73
|
-
specify 'should use .domain.eu.com for cookies from domain.eu.com' do
|
74
|
-
response = make_request 'domain.eu.com'
|
75
|
-
response.headers['Set-Cookie'].should == 'key=value; domain=.domain.eu.com'
|
76
|
-
end
|
77
|
-
|
78
|
-
specify 'should use .domain.eu.com for cookies from subdomain.domain.eu.com' do
|
79
|
-
response = make_request 'subdomain.domain.eu.com'
|
80
|
-
response.headers['Set-Cookie'].should == 'key=value; domain=.domain.eu.com'
|
81
|
-
end
|
82
|
-
|
83
|
-
specify 'should work with multiple cookies' do
|
84
|
-
response = make_request 'sub.domain.bz', "key=value\nkey1=value2"
|
85
|
-
response.headers['Set-Cookie'].should == "key=value; domain=.domain.bz\nkey1=value2; domain=.domain.bz"
|
86
|
-
end
|
87
|
-
|
88
|
-
specify 'should work with cookies which have explicit domain' do
|
89
|
-
response = make_request 'sub.domain.bz', "key=value; domain=domain.bz"
|
90
|
-
response.headers['Set-Cookie'].should == "key=value; domain=.domain.bz"
|
91
|
-
end
|
92
|
-
|
93
|
-
specify 'should not touch cookies if domain is localhost' do
|
94
|
-
response = make_request 'localhost'
|
95
|
-
response.headers['Set-Cookie'].should == "key=value"
|
96
|
-
end
|
97
|
-
|
98
|
-
specify 'should not touch cookies if domain is ip address' do
|
99
|
-
response = make_request '127.0.0.1'
|
100
|
-
response.headers['Set-Cookie'].should == "key=value"
|
101
|
-
end
|
102
|
-
|
103
|
-
specify 'should use .domain.com for cookies from subdomain.domain.com:3000' do
|
104
|
-
response = make_request 'subdomain.domain.com:3000'
|
105
|
-
response.headers['Set-Cookie'].should == "key=value; domain=.domain.com"
|
106
|
-
end
|
107
|
-
end
|
data/test/spec_rack_config.rb
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
require 'test/spec'
|
2
|
-
require 'rack/mock'
|
3
|
-
require 'rack/contrib/config'
|
4
|
-
|
5
|
-
context "Rack::Config" do
|
6
|
-
|
7
|
-
specify "should accept a block that modifies the environment" do
|
8
|
-
app = Rack::Builder.new do
|
9
|
-
use Rack::Lint
|
10
|
-
use Rack::ContentLength
|
11
|
-
use Rack::Config do |env|
|
12
|
-
env['greeting'] = 'hello'
|
13
|
-
end
|
14
|
-
run lambda { |env|
|
15
|
-
[200, {'Content-Type' => 'text/plain'}, [env['greeting'] || '']]
|
16
|
-
}
|
17
|
-
end
|
18
|
-
response = Rack::MockRequest.new(app).get('/')
|
19
|
-
response.body.should.equal('hello')
|
20
|
-
end
|
21
|
-
|
22
|
-
end
|
data/test/spec_rack_contrib.rb
DELETED
data/test/spec_rack_cookies.rb
DELETED
@@ -1,56 +0,0 @@
|
|
1
|
-
require 'test/spec'
|
2
|
-
require 'rack/mock'
|
3
|
-
require 'rack/contrib/cookies'
|
4
|
-
|
5
|
-
context "Rack::Cookies" do
|
6
|
-
specify "should be able to read received cookies" do
|
7
|
-
app = lambda { |env|
|
8
|
-
cookies = env['rack.cookies']
|
9
|
-
foo, quux = cookies[:foo], cookies['quux']
|
10
|
-
[200, {'Content-Type' => 'text/plain'}, ["foo: #{foo}, quux: #{quux}"]]
|
11
|
-
}
|
12
|
-
app = Rack::Cookies.new(app)
|
13
|
-
|
14
|
-
response = Rack::MockRequest.new(app).get('/', 'HTTP_COOKIE' => 'foo=bar;quux=h&m')
|
15
|
-
response.body.should.equal('foo: bar, quux: h&m')
|
16
|
-
end
|
17
|
-
|
18
|
-
specify "should be able to set new cookies" do
|
19
|
-
app = lambda { |env|
|
20
|
-
cookies = env['rack.cookies']
|
21
|
-
cookies[:foo] = 'bar'
|
22
|
-
cookies['quux'] = 'h&m'
|
23
|
-
[200, {'Content-Type' => 'text/plain'}, []]
|
24
|
-
}
|
25
|
-
app = Rack::Cookies.new(app)
|
26
|
-
|
27
|
-
response = Rack::MockRequest.new(app).get('/')
|
28
|
-
response.headers['Set-Cookie'].should.equal("quux=h%26m; path=/\nfoo=bar; path=/")
|
29
|
-
end
|
30
|
-
|
31
|
-
specify "should be able to set cookie with options" do
|
32
|
-
app = lambda { |env|
|
33
|
-
cookies = env['rack.cookies']
|
34
|
-
cookies['foo'] = { :value => 'bar', :path => '/login', :secure => true }
|
35
|
-
[200, {'Content-Type' => 'text/plain'}, []]
|
36
|
-
}
|
37
|
-
app = Rack::Cookies.new(app)
|
38
|
-
|
39
|
-
response = Rack::MockRequest.new(app).get('/')
|
40
|
-
response.headers['Set-Cookie'].should.equal('foo=bar; path=/login; secure')
|
41
|
-
end
|
42
|
-
|
43
|
-
specify "should be able to delete received cookies" do
|
44
|
-
app = lambda { |env|
|
45
|
-
cookies = env['rack.cookies']
|
46
|
-
cookies.delete(:foo)
|
47
|
-
foo, quux = cookies['foo'], cookies[:quux]
|
48
|
-
[200, {'Content-Type' => 'text/plain'}, ["foo: #{foo}, quux: #{quux}"]]
|
49
|
-
}
|
50
|
-
app = Rack::Cookies.new(app)
|
51
|
-
|
52
|
-
response = Rack::MockRequest.new(app).get('/', 'HTTP_COOKIE' => 'foo=bar;quux=h&m')
|
53
|
-
response.body.should.equal('foo: , quux: h&m')
|
54
|
-
response.headers['Set-Cookie'].should.equal('foo=; path=/; expires=Thu, 01-Jan-1970 00:00:00 GMT')
|
55
|
-
end
|
56
|
-
end
|
@@ -1,66 +0,0 @@
|
|
1
|
-
require 'test/spec'
|
2
|
-
require 'rack/mock'
|
3
|
-
|
4
|
-
begin
|
5
|
-
require 'csshttprequest'
|
6
|
-
require 'rack/contrib/csshttprequest'
|
7
|
-
|
8
|
-
context "Rack::CSSHTTPRequest" do
|
9
|
-
|
10
|
-
before(:each) do
|
11
|
-
@test_body = '{"bar":"foo"}'
|
12
|
-
@test_headers = {'Content-Type' => 'text/plain'}
|
13
|
-
@encoded_body = CSSHTTPRequest.encode(@test_body)
|
14
|
-
@app = lambda { |env| [200, @test_headers, [@test_body]] }
|
15
|
-
end
|
16
|
-
|
17
|
-
specify "env['csshttprequest.chr'] should be set to true when \
|
18
|
-
PATH_INFO ends with '.chr'" do
|
19
|
-
request = Rack::MockRequest.env_for("/blah.chr", :lint => true, :fatal => true)
|
20
|
-
Rack::CSSHTTPRequest.new(@app).call(request)
|
21
|
-
request['csshttprequest.chr'].should.equal true
|
22
|
-
end
|
23
|
-
|
24
|
-
specify "env['csshttprequest.chr'] should be set to true when \
|
25
|
-
request parameter _format == 'chr'" do
|
26
|
-
request = Rack::MockRequest.env_for("/?_format=chr", :lint => true, :fatal => true)
|
27
|
-
Rack::CSSHTTPRequest.new(@app).call(request)
|
28
|
-
request['csshttprequest.chr'].should.equal true
|
29
|
-
end
|
30
|
-
|
31
|
-
specify "should not change the headers or response when !env['csshttprequest.chr']" do
|
32
|
-
request = Rack::MockRequest.env_for("/", :lint => true, :fatal => true)
|
33
|
-
status, headers, response = Rack::CSSHTTPRequest.new(@app).call(request)
|
34
|
-
headers.should.equal @test_headers
|
35
|
-
response.join.should.equal @test_body
|
36
|
-
end
|
37
|
-
|
38
|
-
context "when env['csshttprequest.chr']" do
|
39
|
-
before(:each) do
|
40
|
-
@request = Rack::MockRequest.env_for("/",
|
41
|
-
'csshttprequest.chr' => true, :lint => true, :fatal => true)
|
42
|
-
end
|
43
|
-
|
44
|
-
specify "should modify the content length to the correct value" do
|
45
|
-
headers = Rack::CSSHTTPRequest.new(@app).call(@request)[1]
|
46
|
-
headers['Content-Length'].should.equal @encoded_body.length.to_s
|
47
|
-
end
|
48
|
-
|
49
|
-
specify "should modify the content type to the correct value" do
|
50
|
-
headers = Rack::CSSHTTPRequest.new(@app).call(@request)[1]
|
51
|
-
headers['Content-Type'].should.equal 'text/css'
|
52
|
-
end
|
53
|
-
|
54
|
-
specify "should not modify any other headers" do
|
55
|
-
headers = Rack::CSSHTTPRequest.new(@app).call(@request)[1]
|
56
|
-
headers.should.equal @test_headers.merge({
|
57
|
-
'Content-Type' => 'text/css',
|
58
|
-
'Content-Length' => @encoded_body.length.to_s
|
59
|
-
})
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
end
|
64
|
-
rescue LoadError => boom
|
65
|
-
STDERR.puts "WARN: Skipping Rack::CSSHTTPRequest tests (nbio-csshttprequest not installed)"
|
66
|
-
end
|
data/test/spec_rack_deflect.rb
DELETED
@@ -1,107 +0,0 @@
|
|
1
|
-
require 'test/spec'
|
2
|
-
require 'rack/mock'
|
3
|
-
require 'rack/contrib/deflect'
|
4
|
-
|
5
|
-
context "Rack::Deflect" do
|
6
|
-
|
7
|
-
setup do
|
8
|
-
@app = lambda { |env| [200, { 'Content-Type' => 'text/plain' }, ['cookies']] }
|
9
|
-
@mock_addr_1 = '111.111.111.111'
|
10
|
-
@mock_addr_2 = '222.222.222.222'
|
11
|
-
@mock_addr_3 = '333.333.333.333'
|
12
|
-
end
|
13
|
-
|
14
|
-
def mock_env remote_addr, path = '/'
|
15
|
-
Rack::MockRequest.env_for path, { 'REMOTE_ADDR' => remote_addr }
|
16
|
-
end
|
17
|
-
|
18
|
-
def mock_deflect options = {}
|
19
|
-
Rack::Deflect.new @app, options
|
20
|
-
end
|
21
|
-
|
22
|
-
specify "should allow regular requests to follow through" do
|
23
|
-
app = mock_deflect
|
24
|
-
status, headers, body = app.call mock_env(@mock_addr_1)
|
25
|
-
status.should.equal 200
|
26
|
-
body.should.equal ['cookies']
|
27
|
-
end
|
28
|
-
|
29
|
-
specify "should deflect requests exceeding the request threshold" do
|
30
|
-
log = StringIO.new
|
31
|
-
app = mock_deflect :request_threshold => 5, :interval => 10, :block_duration => 10, :log => log
|
32
|
-
env = mock_env @mock_addr_1
|
33
|
-
|
34
|
-
# First 5 should be fine
|
35
|
-
5.times do
|
36
|
-
status, headers, body = app.call env
|
37
|
-
status.should.equal 200
|
38
|
-
body.should.equal ['cookies']
|
39
|
-
end
|
40
|
-
|
41
|
-
# Remaining requests should fail for 10 seconds
|
42
|
-
10.times do
|
43
|
-
status, headers, body = app.call env
|
44
|
-
status.should.equal 403
|
45
|
-
body.should.equal []
|
46
|
-
end
|
47
|
-
|
48
|
-
# Log should reflect that we have blocked an address
|
49
|
-
log.string.should.match(/^deflect\(\d+\/\d+\/\d+\): blocked 111.111.111.111\n/)
|
50
|
-
end
|
51
|
-
|
52
|
-
specify "should expire blocking" do
|
53
|
-
log = StringIO.new
|
54
|
-
app = mock_deflect :request_threshold => 5, :interval => 2, :block_duration => 2, :log => log
|
55
|
-
env = mock_env @mock_addr_1
|
56
|
-
|
57
|
-
# First 5 should be fine
|
58
|
-
5.times do
|
59
|
-
status, headers, body = app.call env
|
60
|
-
status.should.equal 200
|
61
|
-
body.should.equal ['cookies']
|
62
|
-
end
|
63
|
-
|
64
|
-
# Exceeds request threshold
|
65
|
-
status, headers, body = app.call env
|
66
|
-
status.should.equal 403
|
67
|
-
body.should.equal []
|
68
|
-
|
69
|
-
# Allow block to expire
|
70
|
-
sleep 3
|
71
|
-
|
72
|
-
# Another 5 is fine now
|
73
|
-
5.times do
|
74
|
-
status, headers, body = app.call env
|
75
|
-
status.should.equal 200
|
76
|
-
body.should.equal ['cookies']
|
77
|
-
end
|
78
|
-
|
79
|
-
# Log should reflect block and release
|
80
|
-
log.string.should.match(/deflect.*: blocked 111\.111\.111\.111\ndeflect.*: released 111\.111\.111\.111\n/)
|
81
|
-
end
|
82
|
-
|
83
|
-
specify "should allow whitelisting of remote addresses" do
|
84
|
-
app = mock_deflect :whitelist => [@mock_addr_1], :request_threshold => 5, :interval => 2
|
85
|
-
env = mock_env @mock_addr_1
|
86
|
-
|
87
|
-
# Whitelisted addresses are always fine
|
88
|
-
10.times do
|
89
|
-
status, headers, body = app.call env
|
90
|
-
status.should.equal 200
|
91
|
-
body.should.equal ['cookies']
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
specify "should allow blacklisting of remote addresses" do
|
96
|
-
app = mock_deflect :blacklist => [@mock_addr_2]
|
97
|
-
|
98
|
-
status, headers, body = app.call mock_env(@mock_addr_1)
|
99
|
-
status.should.equal 200
|
100
|
-
body.should.equal ['cookies']
|
101
|
-
|
102
|
-
status, headers, body = app.call mock_env(@mock_addr_2)
|
103
|
-
status.should.equal 403
|
104
|
-
body.should.equal []
|
105
|
-
end
|
106
|
-
|
107
|
-
end
|