diff options
author | mame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-10-29 11:48:35 +0000 |
---|---|---|
committer | mame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-10-29 11:48:35 +0000 |
commit | 3e056da13c08ff093ad311e24fbe1171d6e91282 (patch) | |
tree | 793ec3f9897d9b1df003221783b7f3125a6570c7 /test/webrick/test_filehandler.rb | |
parent | 19873d5cf91ffbef052a52b3c55fb170a72fd4b5 (diff) |
* test/webrick/utils.rb (start_server): provide a reference to log of
webrick.
* test/webrick/test_httpproxy.rb, test/webrick/test_httpauth.rb,
test/webrick/test_cgi.rb, test/webrick/test_httpserver.rb,
test/webrick/test_server.rb, test/webrick/test_filehandler.rb: use
webrick log as an assertion message.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@20023 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/webrick/test_filehandler.rb')
-rw-r--r-- | test/webrick/test_filehandler.rb | 62 |
1 files changed, 31 insertions, 31 deletions
diff --git a/test/webrick/test_filehandler.rb b/test/webrick/test_filehandler.rb index 371527e413..712ff7b1cd 100644 --- a/test/webrick/test_filehandler.rb +++ b/test/webrick/test_filehandler.rb @@ -75,19 +75,19 @@ class WEBrick::TestFileHandler < Test::Unit::TestCase def test_filehandler config = { :DocumentRoot => File.dirname(__FILE__), } this_file = File.basename(__FILE__) - TestWEBrick.start_httpserver(config) do |server, addr, port| + TestWEBrick.start_httpserver(config) do |server, addr, port, log| http = Net::HTTP.new(addr, port) req = Net::HTTP::Get.new("/") http.request(req){|res| - assert_equal("200", res.code) - assert_equal("text/html", res.content_type) - assert_match(/HREF="#{this_file}"/, res.body) + assert_equal("200", res.code, log.call) + assert_equal("text/html", res.content_type, log.call) + assert_match(/HREF="#{this_file}"/, res.body, log.call) } req = Net::HTTP::Get.new("/#{this_file}") http.request(req){|res| - assert_equal("200", res.code) - assert_equal("text/plain", res.content_type) - assert_equal(File.read(__FILE__), res.body) + assert_equal("200", res.code, log.call) + assert_equal("text/plain", res.content_type, log.call) + assert_equal(File.read(__FILE__), res.body, log.call) } end end @@ -95,23 +95,23 @@ class WEBrick::TestFileHandler < Test::Unit::TestCase def test_non_disclosure_name config = { :DocumentRoot => File.dirname(__FILE__), } this_file = File.basename(__FILE__) - TestWEBrick.start_httpserver(config) do |server, addr, port| + TestWEBrick.start_httpserver(config) do |server, addr, port, log| http = Net::HTTP.new(addr, port) doc_root_opts = server[:DocumentRootOptions] doc_root_opts[:NondisclosureName] = %w(.ht* *~ test_*) req = Net::HTTP::Get.new("/") http.request(req){|res| - assert_equal("200", res.code) - assert_equal("text/html", res.content_type) + assert_equal("200", res.code, log.call) + assert_equal("text/html", res.content_type, log.call) assert_no_match(/HREF="#{File.basename(__FILE__)}"/, res.body) } req = Net::HTTP::Get.new("/#{this_file}") http.request(req){|res| - assert_equal("404", res.code) + assert_equal("404", res.code, log.call) } doc_root_opts[:NondisclosureName] = %w(.ht* *~ TEST_*) http.request(req){|res| - assert_equal("404", res.code) + assert_equal("404", res.code, log.call) } end end @@ -119,14 +119,14 @@ class WEBrick::TestFileHandler < Test::Unit::TestCase def test_directory_traversal config = { :DocumentRoot => File.dirname(__FILE__), } this_file = File.basename(__FILE__) - TestWEBrick.start_httpserver(config) do |server, addr, port| + TestWEBrick.start_httpserver(config) do |server, addr, port, log| http = Net::HTTP.new(addr, port) req = Net::HTTP::Get.new("/../../") - http.request(req){|res| assert_equal("400", res.code) } + http.request(req){|res| assert_equal("400", res.code, log.call) } req = Net::HTTP::Get.new("/..%5c../#{File.basename(__FILE__)}") - http.request(req){|res| assert_equal(windows? ? "200" : "404", res.code) } + http.request(req){|res| assert_equal(windows? ? "200" : "404", res.code, log.call) } req = Net::HTTP::Get.new("/..%5c..%5cruby.c") - http.request(req){|res| assert_equal("404", res.code) } + http.request(req){|res| assert_equal("404", res.code, log.call) } end end @@ -134,10 +134,10 @@ class WEBrick::TestFileHandler < Test::Unit::TestCase if windows? config = { :DocumentRoot => File.dirname(__FILE__), } this_file = File.basename(__FILE__) - TestWEBrick.start_httpserver(config) do |server, addr, port| + TestWEBrick.start_httpserver(config) do |server, addr, port, log| http = Net::HTTP.new(addr, port) req = Net::HTTP::Get.new("/..%5c..") - http.request(req){|res| assert_equal("301", res.code) } + http.request(req){|res| assert_equal("301", res.code, log.call) } end end end @@ -148,25 +148,25 @@ class WEBrick::TestFileHandler < Test::Unit::TestCase :DocumentRoot => File.dirname(__FILE__), :CGIPathEnv => ENV['PATH'], } - TestWEBrick.start_httpserver(config) do |server, addr, port| + TestWEBrick.start_httpserver(config) do |server, addr, port, log| http = Net::HTTP.new(addr, port) req = Net::HTTP::Get.new("/webric~1.cgi/test") http.request(req) do |res| if windows? - assert_equal("200", res.code) - assert_equal("/test", res.body) + assert_equal("200", res.code, log.call) + assert_equal("/test", res.body, log.call) else - assert_equal("404", res.code) + assert_equal("404", res.code, log.call) end end req = Net::HTTP::Get.new("/.htaccess") - http.request(req) {|res| assert_equal("404", res.code) } + http.request(req) {|res| assert_equal("404", res.code, log.call) } req = Net::HTTP::Get.new("/htacce~1") - http.request(req) {|res| assert_equal("404", res.code) } + http.request(req) {|res| assert_equal("404", res.code, log.call) } req = Net::HTTP::Get.new("/HTACCE~1") - http.request(req) {|res| assert_equal("404", res.code) } + http.request(req) {|res| assert_equal("404", res.code, log.call) } end end @@ -176,21 +176,21 @@ class WEBrick::TestFileHandler < Test::Unit::TestCase :DocumentRoot => File.dirname(__FILE__), :CGIPathEnv => ENV['PATH'], } - TestWEBrick.start_httpserver(config) do |server, addr, port| + TestWEBrick.start_httpserver(config) do |server, addr, port, log| http = Net::HTTP.new(addr, port) req = Net::HTTP::Get.new("/webrick.cgi/test") http.request(req) do |res| - assert_equal("200", res.code) - assert_equal("/test", res.body) + assert_equal("200", res.code, log.call) + assert_equal("/test", res.body, log.call) end response_assertion = Proc.new do |res| if windows? - assert_equal("200", res.code) - assert_equal("/test", res.body) + assert_equal("200", res.code, log.call) + assert_equal("/test", res.body, log.call) else - assert_equal("404", res.code) + assert_equal("404", res.code, log.call) end end req = Net::HTTP::Get.new("/webrick.cgi%20/test") |