[tests] Add BadRequest test (and fix the bug), add "status" vhost
This commit is contained in:
parent
e87fc4007a
commit
688a17372f
|
@ -64,6 +64,7 @@ static void forward_response_body(liConnection *con) {
|
|||
li_connection_internal_error(con);
|
||||
return;
|
||||
}
|
||||
li_vrequest_joblist_append(vr);
|
||||
}
|
||||
|
||||
if (con->raw_out->is_closed) {
|
||||
|
|
|
@ -73,7 +73,7 @@ def load_test_file(name):
|
|||
return module
|
||||
|
||||
def vhostname(testname):
|
||||
return testname[1:-1].replace('/', '.').lower()
|
||||
return '.'.join(reversed(testname[1:-1].split('/'))).lower()
|
||||
|
||||
# basic interface
|
||||
class TestBase(object):
|
||||
|
@ -121,11 +121,18 @@ var.vhosts = var.vhosts + [ "%s" : ${
|
|||
try:
|
||||
if not self.Run():
|
||||
failed = True
|
||||
print >> sys.stderr, "Test %s failed" % (self.name)
|
||||
if self.todo:
|
||||
print >> Env.log, "Test %s failed" % (self.name)
|
||||
else:
|
||||
print >> sys.stderr, "Test %s failed" % (self.name)
|
||||
except Exception as e:
|
||||
failed = True
|
||||
print >> sys.stderr, "Test %s failed:" % (self.name)
|
||||
print >> sys.stderr, traceback.format_exc(10)
|
||||
if self.todo:
|
||||
print >> Env.log, "Test %s failed:" % (self.name)
|
||||
print >> Env.log, traceback.format_exc(10)
|
||||
else:
|
||||
print >> sys.stderr, "Test %s failed:" % (self.name)
|
||||
print >> sys.stderr, traceback.format_exc(10)
|
||||
print >> Env.log, "[Done] Running test %s [result=%s]" % (self.name, failed and "Failed" or "Succeeded")
|
||||
self._test_failed = failed and not self.todo
|
||||
return not failed
|
||||
|
@ -485,5 +492,8 @@ class Lighttpd(Service):
|
|||
|
||||
def Prepare(self):
|
||||
self.portfree(Env.port)
|
||||
self.fork(Env.angel, '-m', Env.plugindir, '-c', Env.angelconf)
|
||||
if Env.no_angel:
|
||||
self.fork(Env.worker, '-m', Env.plugindir, '-c', Env.lighttpdconf)
|
||||
else:
|
||||
self.fork(Env.angel, '-m', Env.plugindir, '-c', Env.angelconf)
|
||||
self.waitconnect(Env.port)
|
||||
|
|
|
@ -33,6 +33,7 @@ parser.add_option("-t", "--test", help = "Run specific test", action = "append",
|
|||
parser.add_option("-c", "--force-cleanup", help = "Keep no temporary files (overwrites -k)", action = "store_true", default = False)
|
||||
parser.add_option("-s", "--strace", help = "Strace services", action = "store_true", default = False)
|
||||
parser.add_option("--debug-requests", help = "Dump requests", action = "store_true", default = False)
|
||||
parser.add_option("--no-angel", help = "Spawn lighttpd worker directly", action = "store_true", default = False)
|
||||
|
||||
(options, args) = parser.parse_args()
|
||||
|
||||
|
@ -53,6 +54,7 @@ Env.luadir = os.path.join(os.path.dirname(Env.sourcedir), "doc")
|
|||
Env.debugRequests = options.debug_requests
|
||||
Env.strace = options.strace
|
||||
Env.color = sys.stdin.isatty()
|
||||
Env.no_angel = options.no_angel
|
||||
|
||||
Env.dir = mkdtemp(dir = os.getcwd())
|
||||
Env.defaultwww = os.path.join(Env.dir, "www", "default")
|
||||
|
|
|
@ -39,8 +39,21 @@ env.set "INFO" => "%{req.query}";
|
|||
show_env_info;
|
||||
"""
|
||||
|
||||
class TestBadRequest1(CurlRequest):
|
||||
# unencoded query
|
||||
URL = "/?complicated?query= $"
|
||||
EXPECT_RESPONSE_CODE = 400
|
||||
|
||||
class ProvideStatus(TestBase):
|
||||
runnable = False
|
||||
vhost = "status"
|
||||
config = """
|
||||
setup { module_load "mod_status"; }
|
||||
status.info;
|
||||
"""
|
||||
|
||||
class Test(GroupTest):
|
||||
group = [TestSimpleRequest,TestSimpleInfo]
|
||||
group = [TestSimpleRequest,TestSimpleInfo,TestBadRequest1,ProvideStatus]
|
||||
|
||||
def Prepare(self):
|
||||
self.PrepareFile("www/default/test.txt", TEST_TXT)
|
||||
|
|
Loading…
Reference in New Issue