mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* test/open-uri: Test server log in server thread.
* test/webrick: Ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48347 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
0d07bc203c
commit
ad58f04833
8 changed files with 203 additions and 169 deletions
|
@ -6,7 +6,7 @@ require "test/unit"
|
|||
class TestWEBrickCGI < Test::Unit::TestCase
|
||||
CRLF = "\r\n"
|
||||
|
||||
def start_cgi_server(&block)
|
||||
def start_cgi_server(log_tester=TestWEBrick::DefaultLogTester, &block)
|
||||
config = {
|
||||
:CGIInterpreter => TestWEBrick::RubyBin,
|
||||
:DocumentRoot => File.dirname(__FILE__),
|
||||
|
@ -23,7 +23,7 @@ class TestWEBrickCGI < Test::Unit::TestCase
|
|||
if RUBY_PLATFORM =~ /mswin|mingw|cygwin|bccwin32/
|
||||
config[:CGIPathEnv] = ENV['PATH'] # runtime dll may not be in system dir.
|
||||
end
|
||||
TestWEBrick.start_httpserver(config){|server, addr, port, log|
|
||||
TestWEBrick.start_httpserver(config, log_tester){|server, addr, port, log|
|
||||
block.call(server, addr, port, log)
|
||||
}
|
||||
end
|
||||
|
@ -90,7 +90,10 @@ class TestWEBrickCGI < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
def test_bad_request
|
||||
start_cgi_server{|server, addr, port, log|
|
||||
log_tester = lambda {|log, access_log|
|
||||
assert_match(/BadRequest/, log.join)
|
||||
}
|
||||
start_cgi_server(log_tester) {|server, addr, port, log|
|
||||
sock = TCPSocket.new(addr, port)
|
||||
begin
|
||||
sock << "POST /webrick.cgi HTTP/1.0" << CRLF
|
||||
|
@ -111,7 +114,11 @@ class TestWEBrickCGI < Test::Unit::TestCase
|
|||
DumpPat = /#{Regexp.quote(CtrlSeq.dump[1...-1])}/o
|
||||
|
||||
def test_bad_uri
|
||||
start_cgi_server{|server, addr, port, log|
|
||||
log_tester = lambda {|log, access_log|
|
||||
assert_equal(1, log.length)
|
||||
assert_match(/ERROR bad URI/, log[0])
|
||||
}
|
||||
start_cgi_server(log_tester) {|server, addr, port, log|
|
||||
res = TCPSocket.open(addr, port) {|sock|
|
||||
sock << "GET /#{CtrlSeq}#{CRLF}#{CRLF}"
|
||||
sock.close_write
|
||||
|
@ -125,7 +132,11 @@ class TestWEBrickCGI < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
def test_bad_header
|
||||
start_cgi_server{|server, addr, port, log|
|
||||
log_tester = lambda {|log, access_log|
|
||||
assert_equal(1, log.length)
|
||||
assert_match(/ERROR bad header/, log[0])
|
||||
}
|
||||
start_cgi_server(log_tester) {|server, addr, port, log|
|
||||
res = TCPSocket.open(addr, port) {|sock|
|
||||
sock << "GET / HTTP/1.0#{CRLF}#{CtrlSeq}#{CRLF}#{CRLF}"
|
||||
sock.close_write
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue