[tests] small cleanups: use req_header.overwrite, no_docroot option

personal/stbuehler/wip
Stefan Bühler 8 years ago
parent 76c12e4077
commit 6e2ca4b80c
  1. 10
      tests/base.py
  2. 32
      tests/t-mod-proxy.py
  3. 4
      tests/t-secdownload.py

@ -92,6 +92,7 @@ class TestBase(object):
todo = False
subdomains = False # set to true to match all subdomains too
inherit_docroot = False
no_docroot = False
def __init__(self, parent = None):
self._test_cleanup_files = []
@ -103,10 +104,13 @@ class TestBase(object):
def _register(self, tests):
self.tests = tests
if not self.vhost: self.vhost = vhostname(self.name)
if self.inherit_docroot:
self.vhostdir = self._parent.vhostdir
if not self.no_docroot:
if self.inherit_docroot:
self.vhostdir = self._parent.vhostdir
else:
self.vhostdir = os.path.join(Env.dir, 'www', 'vhosts', self.vhost)
else:
self.vhostdir = os.path.join(Env.dir, 'www', 'vhosts', self.vhost)
self.vhostdir = None
if self.FeatureCheck():
tests.add_test(self)
return True

@ -3,39 +3,25 @@
from base import *
from requests import *
LUA_SET_HOST_HEADER="""
function set_host_header(vr)
vr.req.headers["Host"] = "basic-gets";
end
actions = set_host_header
"""
class TestSimple(CurlRequest):
URL = "/test.txt"
EXPECT_RESPONSE_CODE = 200
def Prepare(self):
# we don't want a docroot action this time
self.vhostdir = None
self.config = """
set_host_header_basic_gets_lua;
proxy "127.0.0.2:%i";
""" % (Env.port + self.PORT)
config = """
req_header.overwrite "Host" => "basic-gets";
self_proxy;
"""
no_docroot = True
class Test(GroupTest):
group = [
TestSimple,
]
def Prepare(self):
set_host_header_lua = self.PrepareFile("lua/set_host_header.lua", LUA_SET_HOST_HEADER)
self.plain_config = """
setup {{ module_load "mod_proxy"; }}
set_host_header_basic_gets_lua = {{
lua.handler "{set_host_header_lua}";
self_proxy = {{
proxy "127.0.0.2:{self_port}";
}};
""".format(set_host_header_lua = set_host_header_lua)
""".format(self_port = Env.port)

@ -36,6 +36,4 @@ class Test(GroupTest):
config = """
secdownload ( "prefix" => "/", "document-root" => var.default_docroot, "secret" => "abc", "timeout" => 600 );
"""
def Prepare(self):
self.vhostdir = None
no_docroot = True

Loading…
Cancel
Save