2
0
Fork 0
lighttpd2/tests/t-basic-gets.py

66 lines
1.6 KiB
Python
Raw Normal View History

2010-10-02 20:45:29 +00:00
# -*- coding: utf-8 -*-
from base import *
from requests import *
TEST_TXT="""Hi!
0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef
0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef
0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef
0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef
"""
2010-10-05 09:54:13 +00:00
LUA_SHOW_ENV_INFO="""
function show_env_info(vr)
if vr:handle_direct() then
vr.resp.status = 200
vr.resp.headers["Content-Type"] = "text/plain"
vr.out:add(vr.env["INFO"])
end
end
actions = show_env_info
"""
class TestSimpleRequest(CurlRequest):
2010-10-02 20:45:29 +00:00
URL = "/test.txt"
EXPECT_RESPONSE_BODY = TEST_TXT
EXPECT_RESPONSE_CODE = 200
2010-10-05 09:54:13 +00:00
class TestSimpleInfo(CurlRequest):
URL = "/?a_simple_query"
EXPECT_RESPONSE_BODY = "a_simple_query"
EXPECT_RESPONSE_CODE = 200
config = """
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;
"""
2010-10-05 09:54:13 +00:00
class Test(GroupTest):
group = [TestSimpleRequest,TestSimpleInfo,TestBadRequest1,ProvideStatus]
2010-10-05 09:54:13 +00:00
2010-10-02 20:45:29 +00:00
def Prepare(self):
self.PrepareFile("www/default/test.txt", TEST_TXT)
2010-10-05 09:54:13 +00:00
show_env_info_lua = self.PrepareFile("lua/show_env_info.lua", LUA_SHOW_ENV_INFO)
self.plain_config = """
show_env_info = {{
2010-10-05 09:54:13 +00:00
lua.handler "{show_env_info_lua}";
}};
2010-10-05 09:54:13 +00:00
""".format(show_env_info_lua = show_env_info_lua)