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.
Files changed (52) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +98 -0
  3. data/lib/rack/contrib.rb +3 -1
  4. data/lib/rack/contrib/enforce_valid_encoding.rb +23 -0
  5. data/lib/rack/contrib/jsonp.rb +5 -1
  6. data/lib/rack/contrib/locale.rb +1 -1
  7. data/lib/rack/contrib/mailexceptions.rb +41 -10
  8. data/lib/rack/contrib/post_body_content_type_parser.rb +1 -1
  9. data/lib/rack/contrib/relative_redirect.rb +1 -1
  10. data/lib/rack/contrib/try_static.rb +1 -1
  11. metadata +166 -113
  12. data/README.rdoc +0 -98
  13. data/Rakefile +0 -89
  14. data/rack-contrib.gemspec +0 -112
  15. data/test/404.html +0 -1
  16. data/test/Maintenance.html +0 -1
  17. data/test/documents/existing.html +0 -1
  18. data/test/documents/index.htm +0 -1
  19. data/test/documents/index.html +0 -1
  20. data/test/documents/test +0 -1
  21. data/test/mail_settings.rb +0 -20
  22. data/test/spec_rack_accept_format.rb +0 -72
  23. data/test/spec_rack_access.rb +0 -154
  24. data/test/spec_rack_backstage.rb +0 -26
  25. data/test/spec_rack_callbacks.rb +0 -65
  26. data/test/spec_rack_common_cookies.rb +0 -107
  27. data/test/spec_rack_config.rb +0 -22
  28. data/test/spec_rack_contrib.rb +0 -8
  29. data/test/spec_rack_cookies.rb +0 -56
  30. data/test/spec_rack_csshttprequest.rb +0 -66
  31. data/test/spec_rack_deflect.rb +0 -107
  32. data/test/spec_rack_evil.rb +0 -19
  33. data/test/spec_rack_expectation_cascade.rb +0 -72
  34. data/test/spec_rack_garbagecollector.rb +0 -13
  35. data/test/spec_rack_host_meta.rb +0 -50
  36. data/test/spec_rack_jsonp.rb +0 -188
  37. data/test/spec_rack_lighttpd_script_name_fix.rb +0 -16
  38. data/test/spec_rack_mailexceptions.rb +0 -169
  39. data/test/spec_rack_nested_params.rb +0 -46
  40. data/test/spec_rack_not_found.rb +0 -17
  41. data/test/spec_rack_post_body_content_type_parser.rb +0 -40
  42. data/test/spec_rack_proctitle.rb +0 -26
  43. data/test/spec_rack_profiler.rb +0 -42
  44. data/test/spec_rack_relative_redirect.rb +0 -78
  45. data/test/spec_rack_response_cache.rb +0 -137
  46. data/test/spec_rack_response_headers.rb +0 -35
  47. data/test/spec_rack_runtime.rb +0 -35
  48. data/test/spec_rack_sendfile.rb +0 -86
  49. data/test/spec_rack_simple_endpoint.rb +0 -95
  50. data/test/spec_rack_static_cache.rb +0 -104
  51. data/test/spec_rack_try_static.rb +0 -56
  52. data/test/statics/test +0 -1
@@ -1,98 +0,0 @@
1
- = Contributed Rack Middleware and Utilities
2
-
3
- This package includes a variety of add-on components for Rack, a Ruby web server
4
- interface:
5
-
6
- * Rack::JSONP - Adds JSON-P support by stripping out the callback param
7
- and padding the response with the appropriate callback format.
8
- * Rack::LighttpdScriptNameFix - Fixes how lighttpd sets the SCRIPT_NAME
9
- and PATH_INFO variables in certain configurations.
10
- * Rack::Locale - Detects the client locale using the Accept-Language request
11
- header and sets a rack.locale variable in the environment.
12
- * Rack::MailExceptions - Rescues exceptions raised from the app and
13
- sends a useful email with the exception, stacktrace, and contents of the
14
- environment.
15
- * Rack::NestedParams - parses form params with subscripts (e.g., * "post[title]=Hello")
16
- into a nested/recursive Hash structure (based on Rails' implementation).
17
- * Rack::PostBodyContentTypeParser - Adds support for JSON request bodies. The
18
- Rack parameter hash is populated by deserializing the JSON data provided in
19
- the request body when the Content-Type is application/json.
20
- * Rack::ProcTitle - Displays request information in process title ($0) for
21
- monitoring/inspection with ps(1).
22
- * Rack::Profiler - Uses ruby-prof to measure request time.
23
- * Rack::Sendfile - Enables X-Sendfile support for bodies that can be served
24
- from file.
25
- * Rack::Signals - Installs signal handlers that are safely processed after
26
- a request
27
- * Rack::StaticCache - Modifies the response headers to facilitiate client and proxy caching for
28
- static files that minimizes http requests and improves overall load times for second time visitors.
29
- * Rack::TimeZone - Detects the client's timezone using JavaScript and sets
30
- a variable in Rack's environment with the offset from UTC.
31
- * Rack::Evil - Lets the rack application return a response to the client from any place.
32
- * Rack::Callbacks - Implements DSL for pure before/after filter like Middlewares.
33
- * Rack::Config - Shared configuration for cooperative middleware.
34
- * Rack::NotFound - A default 404 application.
35
- * Rack::CSSHTTPRequest - Adds CSSHTTPRequest support by encoding responses as
36
- CSS for cross-site AJAX-style data loading
37
- * Rack::Deflect - Helps protect against DoS attacks.
38
- * Rack::ResponseCache - Caches responses to requests without query strings
39
- to Disk or a user provider Ruby object. Similar to Rails' page caching.
40
- * Rack::RelativeRedirect - Transforms relative paths in redirects to
41
- absolute URLs.
42
- * Rack::Backstage - Returns content of specified file if it exists, which makes
43
- it convenient for putting up maintenance pages.
44
- * Rack::AcceptFormat - Adds a format extension at the end of the URI when there is none, corresponding to the mime-type given in the Accept HTTP header.
45
- * Rack::HostMeta - Configures /host-meta using a block
46
- * Rack::Cookies - Adds simple cookie jar hash to env
47
- * Rack::Access - Limits access based on IP address
48
- * Rack::ResponseHeaders - Manipulates response headers object at runtime
49
- * Rack::SimpleEndpoint - Creates simple endpoints with routing rules, similar to Sinatra actions
50
- * Rack::TryStatic - Tries to match request to a static file
51
- * Rack::Printout - Prints the environment and the response per request
52
-
53
- === Use
54
-
55
- Git is the quickest way to the rack-contrib sources:
56
-
57
- git clone git://github.com/rack/rack-contrib.git
58
-
59
- Gems are available too:
60
-
61
- gem install rack-contrib
62
-
63
- Requiring 'rack/contrib' will add autoloads to the Rack modules for all of the
64
- components included. The following example shows what a simple rackup
65
- (+config.ru+) file might look like:
66
-
67
- require 'rack'
68
- require 'rack/contrib'
69
-
70
- use Rack::Profiler if ENV['RACK_ENV'] == 'development'
71
-
72
- use Rack::ETag
73
- use Rack::MailExceptions
74
-
75
- run theapp
76
-
77
- === Testing
78
-
79
- To contribute to the project, begin by cloning the repo and installing the necessary gems:
80
-
81
- gem install json rack ruby-prof test-spec test-unit
82
-
83
- To run the entire test suite, run
84
- rake test
85
-
86
- To run a specific component's tests run
87
- specrb -Ilib:test -w test/spec_rack_thecomponent.rb
88
-
89
- This works on ruby 1.8.7 but has problems under ruby 1.9.x.
90
-
91
- TODO: instructions for 1.9.x and include bundler
92
-
93
- === Links
94
-
95
- rack-contrib on GitHub:: <http://github.com/rack/rack-contrib>
96
- Rack:: <http://rack.rubyforge.org/>
97
- Rack On GitHub:: <http://github.com/rack/rack>
98
- rack-devel mailing list:: <http://groups.google.com/group/rack-devel>
data/Rakefile DELETED
@@ -1,89 +0,0 @@
1
- # Rakefile for Rack::Contrib. -*-ruby-*-
2
- require 'rake/rdoctask'
3
- require 'rake/testtask'
4
-
5
- desc "Run all the tests"
6
- task :default => [:test]
7
-
8
- desc "Generate RDox"
9
- task "RDOX" do
10
- sh "specrb -Ilib:test -a --rdox >RDOX"
11
- end
12
-
13
- desc "Run specs with test/unit style output"
14
- task :test do
15
- sh "specrb -Ilib:test -w #{ENV['TEST'] || '-a'} #{ENV['TESTOPTS']}"
16
- end
17
-
18
- desc "Run specs with specdoc style output"
19
- task :spec do
20
- sh "specrb -Ilib:test -s -w #{ENV['TEST'] || '-a'} #{ENV['TESTOPTS']}"
21
- end
22
-
23
- desc "Run all the tests"
24
- task :fulltest do
25
- sh "specrb -Ilib:test -w #{ENV['TEST'] || '-a'} #{ENV['TESTOPTS']}"
26
- end
27
-
28
- desc "Generate RDoc documentation"
29
- Rake::RDocTask.new(:rdoc) do |rdoc|
30
- rdoc.options << '--line-numbers' << '--inline-source' <<
31
- '--main' << 'README' <<
32
- '--title' << 'Rack Contrib Documentation' <<
33
- '--charset' << 'utf-8'
34
- rdoc.rdoc_dir = "doc"
35
- rdoc.rdoc_files.include 'README.rdoc'
36
- rdoc.rdoc_files.include 'RDOX'
37
- rdoc.rdoc_files.include('lib/rack/*.rb')
38
- rdoc.rdoc_files.include('lib/rack/*/*.rb')
39
- end
40
- task :rdoc => ["RDOX"]
41
-
42
-
43
- # PACKAGING =================================================================
44
-
45
- require 'rubygems'
46
- # load gemspec
47
- $spec = eval(File.read('rack-contrib.gemspec'))
48
-
49
- def package(ext='')
50
- "pkg/rack-contrib-#{$spec.version}" + ext
51
- end
52
-
53
- desc 'Build packages'
54
- task :package => %w[.gem .tar.gz].map {|e| package(e)}
55
-
56
- desc 'Build and install as local gem'
57
- task :install => package('.gem') do
58
- sh "gem install #{package('.gem')}"
59
- end
60
-
61
- directory 'pkg/'
62
-
63
- file package('.gem') => %w[pkg/ rack-contrib.gemspec] + $spec.files do |f|
64
- sh "gem build rack-contrib.gemspec"
65
- mv File.basename(f.name), f.name
66
- end
67
-
68
- file package('.tar.gz') => %w[pkg/] + $spec.files do |f|
69
- sh "git archive --format=tar HEAD | gzip > #{f.name}"
70
- end
71
-
72
- # GEMSPEC ===================================================================
73
-
74
- file 'rack-contrib.gemspec' => FileList['{lib,test}/**','Rakefile', 'README.rdoc'] do |f|
75
- # read spec file and split out manifest section
76
- spec = File.read(f.name)
77
- parts = spec.split(" # = MANIFEST =\n")
78
- fail 'bad spec' if parts.length != 3
79
- # determine file list from git ls-files
80
- files = `git ls-files`.
81
- split("\n").sort.reject{ |file| file =~ /^\./ }.
82
- map{ |file| " #{file}" }.join("\n")
83
- # piece file back together and write...
84
- parts[1] = " s.files = %w[\n#{files}\n ]\n"
85
- spec = parts.join(" # = MANIFEST =\n")
86
- spec.sub!(/s.date = '.*'/, "s.date = '#{Time.now.strftime("%Y-%m-%d")}'")
87
- File.open(f.name, 'w') { |io| io.write(spec) }
88
- puts "updated #{f.name}"
89
- end
@@ -1,112 +0,0 @@
1
- Gem::Specification.new do |s|
2
- s.specification_version = 2 if s.respond_to? :specification_version=
3
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
4
-
5
- s.name = 'rack-contrib'
6
- s.version = '1.2.0'
7
- s.licenses = ['MIT']
8
-
9
- s.description = "Contributed Rack Middleware and Utilities"
10
- s.summary = "Contributed Rack Middleware and Utilities"
11
-
12
- s.authors = ["rack-devel"]
13
- s.email = "rack-devel@googlegroups.com"
14
-
15
- # = MANIFEST =
16
- s.files = %w[
17
- AUTHORS
18
- COPYING
19
- README.rdoc
20
- Rakefile
21
- lib/rack/contrib.rb
22
- lib/rack/contrib/accept_format.rb
23
- lib/rack/contrib/access.rb
24
- lib/rack/contrib/backstage.rb
25
- lib/rack/contrib/bounce_favicon.rb
26
- lib/rack/contrib/callbacks.rb
27
- lib/rack/contrib/common_cookies.rb
28
- lib/rack/contrib/config.rb
29
- lib/rack/contrib/cookies.rb
30
- lib/rack/contrib/csshttprequest.rb
31
- lib/rack/contrib/deflect.rb
32
- lib/rack/contrib/evil.rb
33
- lib/rack/contrib/expectation_cascade.rb
34
- lib/rack/contrib/garbagecollector.rb
35
- lib/rack/contrib/host_meta.rb
36
- lib/rack/contrib/jsonp.rb
37
- lib/rack/contrib/lighttpd_script_name_fix.rb
38
- lib/rack/contrib/locale.rb
39
- lib/rack/contrib/mailexceptions.rb
40
- lib/rack/contrib/nested_params.rb
41
- lib/rack/contrib/not_found.rb
42
- lib/rack/contrib/post_body_content_type_parser.rb
43
- lib/rack/contrib/proctitle.rb
44
- lib/rack/contrib/printout.rb
45
- lib/rack/contrib/profiler.rb
46
- lib/rack/contrib/relative_redirect.rb
47
- lib/rack/contrib/response_cache.rb
48
- lib/rack/contrib/response_headers.rb
49
- lib/rack/contrib/route_exceptions.rb
50
- lib/rack/contrib/runtime.rb
51
- lib/rack/contrib/sendfile.rb
52
- lib/rack/contrib/signals.rb
53
- lib/rack/contrib/simple_endpoint.rb
54
- lib/rack/contrib/static_cache.rb
55
- lib/rack/contrib/time_zone.rb
56
- lib/rack/contrib/try_static.rb
57
- rack-contrib.gemspec
58
- test/404.html
59
- test/Maintenance.html
60
- test/documents/existing.html
61
- test/documents/index.htm
62
- test/documents/index.html
63
- test/documents/test
64
- test/mail_settings.rb
65
- test/spec_rack_accept_format.rb
66
- test/spec_rack_access.rb
67
- test/spec_rack_backstage.rb
68
- test/spec_rack_callbacks.rb
69
- test/spec_rack_common_cookies.rb
70
- test/spec_rack_config.rb
71
- test/spec_rack_contrib.rb
72
- test/spec_rack_cookies.rb
73
- test/spec_rack_csshttprequest.rb
74
- test/spec_rack_deflect.rb
75
- test/spec_rack_evil.rb
76
- test/spec_rack_expectation_cascade.rb
77
- test/spec_rack_garbagecollector.rb
78
- test/spec_rack_host_meta.rb
79
- test/spec_rack_jsonp.rb
80
- test/spec_rack_lighttpd_script_name_fix.rb
81
- test/spec_rack_mailexceptions.rb
82
- test/spec_rack_nested_params.rb
83
- test/spec_rack_not_found.rb
84
- test/spec_rack_post_body_content_type_parser.rb
85
- test/spec_rack_proctitle.rb
86
- test/spec_rack_profiler.rb
87
- test/spec_rack_relative_redirect.rb
88
- test/spec_rack_response_cache.rb
89
- test/spec_rack_response_headers.rb
90
- test/spec_rack_runtime.rb
91
- test/spec_rack_sendfile.rb
92
- test/spec_rack_simple_endpoint.rb
93
- test/spec_rack_static_cache.rb
94
- test/spec_rack_try_static.rb
95
- test/statics/test
96
- ]
97
- # = MANIFEST =
98
-
99
- s.test_files = s.files.select {|path| path =~ /^test\/spec_.*\.rb/}
100
-
101
- s.extra_rdoc_files = %w[README.rdoc COPYING]
102
- s.add_dependency 'rack', '>= 0.9.1'
103
- s.add_development_dependency 'test-spec', '>= 0.9.0'
104
- s.add_development_dependency 'tmail', '>= 1.2'
105
- s.add_development_dependency 'json', '>= 1.1'
106
-
107
- s.has_rdoc = true
108
- s.homepage = "http://github.com/rack/rack-contrib/"
109
- s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "rack-contrib", "--main", "README"]
110
- s.require_paths = %w[lib]
111
- s.rubygems_version = '1.1.1'
112
- end
@@ -1 +0,0 @@
1
- Not Found
@@ -1 +0,0 @@
1
- Under maintenance.
@@ -1 +0,0 @@
1
- existing.html
@@ -1 +0,0 @@
1
- index.htm
@@ -1 +0,0 @@
1
- index.html
@@ -1 +0,0 @@
1
- nocache
@@ -1,20 +0,0 @@
1
- TEST_SMTP = nil
2
-
3
- # Enable SMTP tests by providing the following for your SMTP server.
4
- #
5
- # TEST_SMTP = {
6
- # :server => 'localhost',
7
- # :domain => 'localhost',
8
- # :port => 25,
9
- # :authentication => :login,
10
- # :user_name => nil,
11
- # :password => nil
12
- # }
13
- #TEST_SMTP_TLS = {
14
- # :server => 'smtp.gmail.com',
15
- # :domain => 'gmail.com',
16
- # :port => 587,
17
- # :authentication => 'plain',
18
- # :user_name => nil,
19
- # :password => nil,
20
- #}
@@ -1,72 +0,0 @@
1
- require 'test/spec'
2
- require 'rack/mock'
3
- require 'rack/contrib/accept_format'
4
- require 'rack/mime'
5
-
6
- context "Rack::AcceptFormat" do
7
- app = lambda { |env| [200, {'Content-Type' => 'text/plain'}, env['PATH_INFO']] }
8
-
9
- specify "should do nothing when a format extension is already provided" do
10
- request = Rack::MockRequest.env_for("/resource.json")
11
- body = Rack::AcceptFormat.new(app).call(request).last
12
- body.should == "/resource.json"
13
- end
14
-
15
- context "default extention" do
16
- specify "should allow custom default" do
17
- request = Rack::MockRequest.env_for("/resource")
18
- body = Rack::AcceptFormat.new(app, '.xml').call(request).last
19
- body.should == "/resource.xml"
20
- end
21
-
22
- specify "should default to html" do
23
- request = Rack::MockRequest.env_for("/resource")
24
- body = Rack::AcceptFormat.new(app).call(request).last
25
- body.should == "/resource.html"
26
- end
27
-
28
- specify "should notmalize custom extention" do
29
- request = Rack::MockRequest.env_for("/resource")
30
-
31
- body = Rack::AcceptFormat.new(app,'xml').call(request).last #no dot prefix
32
- body.should == "/resource.xml"
33
-
34
- body = Rack::AcceptFormat.new(app, :xml).call(request).last
35
- body.should == "/resource.xml"
36
- end
37
- end
38
-
39
- context "there is no format extension" do
40
- Rack::Mime::MIME_TYPES.clear
41
-
42
- def mime(ext, type)
43
- ext = ".#{ext}" unless ext.to_s[0] == ?.
44
- Rack::Mime::MIME_TYPES[ext.to_s] = type
45
- end
46
-
47
- specify "should add the default extension if no Accept header" do
48
- request = Rack::MockRequest.env_for("/resource")
49
- body = Rack::AcceptFormat.new(app).call(request).last
50
- body.should == "/resource.html"
51
- end
52
-
53
- specify "should add the default extension if the Accept header is not registered in the Mime::Types" do
54
- request = Rack::MockRequest.env_for("/resource", 'HTTP_ACCEPT' => 'application/json;q=1.0, text/html;q=0.8, */*;q=0.1')
55
- body = Rack::AcceptFormat.new(app).call(request).last
56
- body.should == "/resource.html"
57
- end
58
-
59
- specify "should add the correct extension if the Accept header is registered in the Mime::Types" do
60
- mime :json, 'application/json'
61
- request = Rack::MockRequest.env_for("/resource", 'HTTP_ACCEPT' => 'application/json;q=1.0, text/html;q=0.8, */*;q=0.1')
62
- body = Rack::AcceptFormat.new(app).call(request).last
63
- body.should == "/resource.json"
64
- end
65
- end
66
-
67
- specify "shouldn't confuse extention when there are dots in path" do
68
- request = Rack::MockRequest.env_for("/parent.resource/resource")
69
- body = Rack::AcceptFormat.new(app, '.html').call(request).last
70
- body.should == "/parent.resource/resource.html"
71
- end
72
- end
@@ -1,154 +0,0 @@
1
- require 'test/spec'
2
- require 'rack/mock'
3
- require 'rack/contrib/access'
4
-
5
- context "Rack::Access" do
6
-
7
- setup do
8
- @app = lambda { |env| [200, { 'Content-Type' => 'text/plain' }, ['hello']] }
9
- @mock_addr_1 = '111.111.111.111'
10
- @mock_addr_2 = '192.168.1.222'
11
- @mock_addr_localhost = '127.0.0.1'
12
- @mock_addr_range = '192.168.1.0/24'
13
- end
14
-
15
- def mock_env(remote_addr, path = '/')
16
- Rack::MockRequest.env_for(path, { 'REMOTE_ADDR' => remote_addr })
17
- end
18
-
19
- def middleware(options = {})
20
- Rack::Access.new(@app, options)
21
- end
22
-
23
- specify "default configuration should deny non-local requests" do
24
- app = middleware
25
- status, headers, body = app.call(mock_env(@mock_addr_1))
26
- status.should.equal 403
27
- body.should.equal []
28
- end
29
-
30
- specify "default configuration should allow requests from 127.0.0.1" do
31
- app = middleware
32
- status, headers, body = app.call(mock_env(@mock_addr_localhost))
33
- status.should.equal 200
34
- body.should.equal ['hello']
35
- end
36
-
37
- specify "should allow remote addresses in allow_ipmasking" do
38
- app = middleware('/' => [@mock_addr_1])
39
- status, headers, body = app.call(mock_env(@mock_addr_1))
40
- status.should.equal 200
41
- body.should.equal ['hello']
42
- end
43
-
44
- specify "should deny remote addresses not in allow_ipmasks" do
45
- app = middleware('/' => [@mock_addr_1])
46
- status, headers, body = app.call(mock_env(@mock_addr_2))
47
- status.should.equal 403
48
- body.should.equal []
49
- end
50
-
51
- specify "should allow remote addresses in allow_ipmasks range" do
52
- app = middleware('/' => [@mock_addr_range])
53
- status, headers, body = app.call(mock_env(@mock_addr_2))
54
- status.should.equal 200
55
- body.should.equal ['hello']
56
- end
57
-
58
- specify "should deny remote addresses not in allow_ipmasks range" do
59
- app = middleware('/' => [@mock_addr_range])
60
- status, headers, body = app.call(mock_env(@mock_addr_1))
61
- status.should.equal 403
62
- body.should.equal []
63
- end
64
-
65
- specify "should allow remote addresses in one of allow_ipmasking" do
66
- app = middleware('/' => [@mock_addr_range, @mock_addr_localhost])
67
-
68
- status, headers, body = app.call(mock_env(@mock_addr_2))
69
- status.should.equal 200
70
- body.should.equal ['hello']
71
-
72
- status, headers, body = app.call(mock_env(@mock_addr_localhost))
73
- status.should.equal 200
74
- body.should.equal ['hello']
75
- end
76
-
77
- specify "should deny remote addresses not in one of allow_ipmasks" do
78
- app = middleware('/' => [@mock_addr_range, @mock_addr_localhost])
79
- status, headers, body = app.call(mock_env(@mock_addr_1))
80
- status.should.equal 403
81
- body.should.equal []
82
- end
83
-
84
- specify "handles paths correctly" do
85
- app = middleware({
86
- 'http://foo.org/bar' => [@mock_addr_localhost],
87
- '/foo' => [@mock_addr_localhost],
88
- '/foo/bar' => [@mock_addr_range, @mock_addr_localhost]
89
- })
90
-
91
- status, headers, body = app.call(mock_env(@mock_addr_1, "/"))
92
- status.should.equal 200
93
- body.should.equal ['hello']
94
-
95
- status, headers, body = app.call(mock_env(@mock_addr_1, "/qux"))
96
- status.should.equal 200
97
- body.should.equal ['hello']
98
-
99
- status, headers, body = app.call(mock_env(@mock_addr_1, "/foo"))
100
- status.should.equal 403
101
- body.should.equal []
102
- status, headers, body = app.call(mock_env(@mock_addr_localhost, "/foo"))
103
- status.should.equal 200
104
- body.should.equal ['hello']
105
-
106
- status, headers, body = app.call(mock_env(@mock_addr_1, "/foo/"))
107
- status.should.equal 403
108
- body.should.equal []
109
- status, headers, body = app.call(mock_env(@mock_addr_localhost, "/foo/"))
110
- status.should.equal 200
111
- body.should.equal ['hello']
112
-
113
- status, headers, body = app.call(mock_env(@mock_addr_1, "/foo/bar"))
114
- status.should.equal 403
115
- body.should.equal []
116
- status, headers, body = app.call(mock_env(@mock_addr_localhost, "/foo/bar"))
117
- status.should.equal 200
118
- body.should.equal ['hello']
119
- status, headers, body = app.call(mock_env(@mock_addr_2, "/foo/bar"))
120
- status.should.equal 200
121
- body.should.equal ['hello']
122
-
123
- status, headers, body = app.call(mock_env(@mock_addr_1, "/foo/bar/"))
124
- status.should.equal 403
125
- body.should.equal []
126
- status, headers, body = app.call(mock_env(@mock_addr_localhost, "/foo/bar/"))
127
- status.should.equal 200
128
- body.should.equal ['hello']
129
-
130
- status, headers, body = app.call(mock_env(@mock_addr_1, "/foo///bar//quux"))
131
- status.should.equal 403
132
- body.should.equal []
133
- status, headers, body = app.call(mock_env(@mock_addr_localhost, "/foo///bar//quux"))
134
- status.should.equal 200
135
- body.should.equal ['hello']
136
-
137
- status, headers, body = app.call(mock_env(@mock_addr_1, "/foo/quux"))
138
- status.should.equal 403
139
- body.should.equal []
140
- status, headers, body = app.call(mock_env(@mock_addr_localhost, "/foo/quux"))
141
- status.should.equal 200
142
- body.should.equal ['hello']
143
-
144
- status, headers, body = app.call(mock_env(@mock_addr_1, "/bar"))
145
- status.should.equal 200
146
- body.should.equal ['hello']
147
- status, headers, body = app.call(mock_env(@mock_addr_1, "/bar").merge('HTTP_HOST' => 'foo.org'))
148
- status.should.equal 403
149
- body.should.equal []
150
- status, headers, body = app.call(mock_env(@mock_addr_localhost, "/bar").merge('HTTP_HOST' => 'foo.org'))
151
- status.should.equal 200
152
- body.should.equal ['hello']
153
- end
154
- end