diff --git a/Makefile.am b/Makefile.am index c0911b63..2b07b987 100644 --- a/Makefile.am +++ b/Makefile.am @@ -19,13 +19,8 @@ EXTRA_DIST = \ test/unit \ test/Makefile.in \ test/Makefile.am \ - test/mod_h2test/mod_h2test.c \ - test/mod_h2test/mod_h2test.h \ - test/conf \ - test/data \ - test/htdocs \ - test/*.py \ - test/*.ini.in + test/modules \ + test/pyhttpd dist_doc_DATA = README README.md LICENSE diff --git a/test/modules/http2/conftest.py b/test/modules/http2/conftest.py index 0cfa7cb4..80677743 100644 --- a/test/modules/http2/conftest.py +++ b/test/modules/http2/conftest.py @@ -10,7 +10,7 @@ def pytest_report_header(config, startdir): - env = H2TestEnv(setup_dirs=False) + env = H2TestEnv() return f"mod_h2 [apache: {env.get_httpd_version()}, mpm: {env.mpm_module}, {env.prefix}]" @@ -36,6 +36,7 @@ def env(pytestconfig) -> H2TestEnv: logging.getLogger('').addHandler(console) logging.getLogger('').setLevel(level=level) env = H2TestEnv(pytestconfig=pytestconfig) + env.setup_httpd() env.apache_access_log_clear() env.httpd_error_log.clear_log() return env diff --git a/test/modules/http2/env.py b/test/modules/http2/env.py index d3d0cafb..dae91657 100644 --- a/test/modules/http2/env.py +++ b/test/modules/http2/env.py @@ -16,15 +16,19 @@ class H2TestSetup(HttpdTestSetup): def __init__(self, env: 'HttpdTestEnv'): super().__init__(env=env) + self.add_source_dir(os.path.dirname(inspect.getfile(H2TestSetup))) + self.add_modules(["http2", "proxy_http2", "cgid", "autoindex"]) def make(self): - super().make(add_modules=["http2", "proxy_http2"]) + super().make() self._add_h2test() + self._setup_data_1k_1m() def _add_h2test(self): + local_dir = os.path.dirname(inspect.getfile(H2TestSetup)) p = subprocess.run([self.env.apxs, '-c', 'mod_h2test.c'], capture_output=True, - cwd=os.path.join(self.env.local_dir, 'mod_h2test')) + cwd=os.path.join(local_dir, 'mod_h2test')) rv = p.returncode if rv != 0: log.error(f"compiling md_h2test failed: {p.stderr}") @@ -33,20 +37,34 @@ def _add_h2test(self): modules_conf = os.path.join(self.env.server_dir, 'conf/modules.conf') with open(modules_conf, 'a') as fd: # load our test module which is not installed - fd.write(f"LoadModule h2test_module \"{self.env.local_dir}/mod_h2test/.libs/mod_h2test.so\"\n") + fd.write(f"LoadModule h2test_module \"{local_dir}/mod_h2test/.libs/mod_h2test.so\"\n") + + def _setup_data_1k_1m(self): + s90 = "01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678\n" + with open(os.path.join(self.env.gen_dir, "data-1k"), 'w') as f: + for i in range(10): + f.write(f"{i:09d}-{s90}") + with open(os.path.join(self.env.gen_dir, "data-10k"), 'w') as f: + for i in range(100): + f.write(f"{i:09d}-{s90}") + with open(os.path.join(self.env.gen_dir, "data-100k"), 'w') as f: + for i in range(1000): + f.write(f"{i:09d}-{s90}") + with open(os.path.join(self.env.gen_dir, "data-1m"), 'w') as f: + for i in range(10000): + f.write(f"{i:09d}-{s90}") class H2TestEnv(HttpdTestEnv): - def __init__(self, pytestconfig=None, setup_dirs=True): - super().__init__(pytestconfig=pytestconfig, - local_dir=os.path.dirname(inspect.getfile(H2TestEnv)), - add_base_conf=[ + def __init__(self, pytestconfig=None): + super().__init__(pytestconfig=pytestconfig) + self.add_httpd_conf([ "H2MinWorkers 1", "H2MaxWorkers 64", "Protocols h2 http/1.1 h2c", - ], - interesting_modules=["http2", "proxy_http2", "h2test"]) + ]) + self.add_httpd_log_modules(["http2", "proxy_http2", "h2test"]) self.add_cert_specs([ CertificateSpec(domains=[ f"push.{self._http_tld}", @@ -70,29 +88,12 @@ def __init__(self, pytestconfig=None, setup_dirs=True): ]) self.httpd_error_log.add_ignored_patterns([ re.compile(r'.*malformed header from script \'hecho.py\': Bad header: x.*'), + re.compile(r'.*:tls_post_process_client_hello:.*'), + re.compile(r'.*:tls_process_client_certificate:.*'), ]) - if setup_dirs: - self._setup = H2TestSetup(env=self) - self._setup.make() - self.issue_certs() - self.setup_data_1k_1m() - - - def setup_data_1k_1m(self): - s90 = "01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678\n" - with open(os.path.join(self.gen_dir, "data-1k"), 'w') as f: - for i in range(10): - f.write(f"{i:09d}-{s90}") - with open(os.path.join(self.gen_dir, "data-10k"), 'w') as f: - for i in range(100): - f.write(f"{i:09d}-{s90}") - with open(os.path.join(self.gen_dir, "data-100k"), 'w') as f: - for i in range(1000): - f.write(f"{i:09d}-{s90}") - with open(os.path.join(self.gen_dir, "data-1m"), 'w') as f: - for i in range(10000): - f.write(f"{i:09d}-{s90}") + def setup_httpd(self, setup: HttpdTestSetup = None): + super().setup_httpd(setup=H2TestSetup(env=self)) class H2Conf(HttpdConf): @@ -105,7 +106,7 @@ def __init__(self, env: HttpdTestEnv, extras: Dict[str, Any] = None): ] })) - def start_vhost(self, domains, port=None, doc_root="htdocs", with_ssl=False): + def start_vhost(self, domains, port=None, doc_root="htdocs", with_ssl=None): super().start_vhost(domains=domains, port=port, doc_root=doc_root, with_ssl=with_ssl) if f"noh2.{self.env.http_tld}" in domains: protos = ["http/1.1"] @@ -133,4 +134,3 @@ def add_vhost_test1(self, proxy_self=False, h2proxy_self=False): def add_vhost_test2(self): return super().add_vhost_test2() - diff --git a/test/modules/http2/test_001_httpd_alive.py b/test/modules/http2/test_001_httpd_alive.py index d922b440..557d17a4 100644 --- a/test/modules/http2/test_001_httpd_alive.py +++ b/test/modules/http2/test_001_httpd_alive.py @@ -3,7 +3,7 @@ from .env import H2Conf -class TestStore: +class TestBasicAlive: @pytest.fixture(autouse=True, scope='class') def _class_scope(self, env): diff --git a/test/modules/http2/test_002_curl_basics.py b/test/modules/http2/test_002_curl_basics.py index dfe39c53..bb03bd84 100644 --- a/test/modules/http2/test_002_curl_basics.py +++ b/test/modules/http2/test_002_curl_basics.py @@ -3,7 +3,7 @@ from .env import H2Conf -class TestStore: +class TestCurlBasics: @pytest.fixture(autouse=True, scope='class') def _class_scope(self, env): diff --git a/test/modules/http2/test_003_get.py b/test/modules/http2/test_003_get.py index a62da2ac..3fbaa081 100644 --- a/test/modules/http2/test_003_get.py +++ b/test/modules/http2/test_003_get.py @@ -4,7 +4,7 @@ from .env import H2Conf -class TestStore: +class TestGet: @pytest.fixture(autouse=True, scope='class') def _class_scope(self, env): @@ -92,7 +92,7 @@ def test_h2_003_20(self, env): Index of /006 -My Header Title +

Index of /006