diff options
author | Stefan Eissing <icing@apache.org> | 2021-11-08 13:33:46 +0100 |
---|---|---|
committer | Stefan Eissing <icing@apache.org> | 2021-11-08 13:33:46 +0100 |
commit | 0ecb9153ce1bb0159642efa70c9c3f80b5cd7d24 (patch) | |
tree | ddda6772774a90eeff55dad9177c954c499157ab /test/modules/md | |
parent | fr doc rebuild. (diff) | |
download | apache2-0ecb9153ce1bb0159642efa70c9c3f80b5cd7d24.tar.xz apache2-0ecb9153ce1bb0159642efa70c9c3f80b5cd7d24.zip |
* test: just general cleanup and separation
- base modules loaded minimized
- h2's htdocs/cgi setup now in test/modules/http2
- less args to constructors, more methods
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1894832 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'test/modules/md')
-rwxr-xr-x | test/modules/md/conftest.py | 3 | ||||
-rwxr-xr-x | test/modules/md/md_acme.py | 2 | ||||
-rwxr-xr-x | test/modules/md/md_env.py | 45 | ||||
-rw-r--r-- | test/modules/md/test_502_acmev2_drive.py | 2 |
4 files changed, 25 insertions, 27 deletions
diff --git a/test/modules/md/conftest.py b/test/modules/md/conftest.py index 8e5ede7d4e..63dab24c17 100755 --- a/test/modules/md/conftest.py +++ b/test/modules/md/conftest.py @@ -2,12 +2,10 @@ import logging import os import re import sys -from datetime import timedelta import pytest sys.path.append(os.path.join(os.path.dirname(__file__), '../..')) -from .md_certs import CertificateSpec, MDTestCA from .md_conf import HttpdConf from .md_env import MDTestEnv from .md_acme import MDPebbleRunner, MDBoulderRunner @@ -32,6 +30,7 @@ def env(pytestconfig) -> MDTestEnv: logging.getLogger('').addHandler(console) logging.getLogger('').setLevel(level=level) env = MDTestEnv(pytestconfig=pytestconfig) + env.setup_httpd() env.apache_access_log_clear() env.httpd_error_log.clear_log() return env diff --git a/test/modules/md/md_acme.py b/test/modules/md/md_acme.py index 9aae73a34a..36be3477a5 100755 --- a/test/modules/md/md_acme.py +++ b/test/modules/md/md_acme.py @@ -97,7 +97,7 @@ class MDPebbleRunner(ACMEServer): shutil.copyfile(self.env.ca.cert_file, dest) end = datetime.now() + timedelta(seconds=20) while datetime.now() < end: - r = self.env.curl_get('https://localhost:15000/roots/0', insecure=True, debug_log=False) + r = self.env.curl_get('https://localhost:15000/roots/0', insecure=True) if r.exit_code == 0: with open(dest, 'a') as fd: fd.write(r.stdout) diff --git a/test/modules/md/md_env.py b/test/modules/md/md_env.py index 47fecc56a4..718e5d1742 100755 --- a/test/modules/md/md_env.py +++ b/test/modules/md/md_env.py @@ -24,13 +24,16 @@ log = logging.getLogger(__name__) class MDTestSetup(HttpdTestSetup): - def __init__(self, env: 'HttpdTestEnv'): + def __init__(self, env: 'MDTestEnv'): super().__init__(env=env) + self.mdenv = env + self.add_modules(["watchdog", "proxy_connect", "md"]) def make(self): - super().make(add_modules=["proxy_connect", "md"]) - if "pebble" == self.env.acme_server: + super().make() + if "pebble" == self.mdenv.acme_server: self._make_pebble_conf() + self.mdenv.clear_store() def _make_pebble_conf(self): our_dir = os.path.dirname(inspect.getfile(MDTestSetup)) @@ -82,17 +85,16 @@ class MDTestEnv(HttpdTestEnv): @classmethod def has_a2md(cls): - dir = os.path.dirname(inspect.getfile(HttpdTestEnv)) + d = os.path.dirname(inspect.getfile(HttpdTestEnv)) config = ConfigParser(interpolation=ExtendedInterpolation()) - config.read(os.path.join(dir, 'config.ini')) + config.read(os.path.join(d, 'config.ini')) bin_dir = config.get('global', 'bindir') a2md_bin = os.path.join(bin_dir, 'a2md') return os.path.isfile(a2md_bin) - def __init__(self, pytestconfig=None, setup_dirs=True): - super().__init__(pytestconfig=pytestconfig, - local_dir=os.path.dirname(inspect.getfile(MDTestEnv)), - interesting_modules=["md"]) + def __init__(self, pytestconfig=None): + super().__init__(pytestconfig=pytestconfig) + self.add_httpd_log_modules(["md"]) self._acme_server = self.get_acme_server() self._acme_tos = "accepted" self._acme_ca_pemfile = os.path.join(self.gen_dir, "apache/acme-ca.pem") @@ -119,11 +121,8 @@ class MDTestEnv(HttpdTestEnv): CertificateSpec(domains=["localhost"], key_type='rsa2048'), ]) - if setup_dirs: - self._setup = MDTestSetup(env=self) - self._setup.make() - self.issue_certs() - self.clear_store() + def setup_httpd(self, setup: HttpdTestSetup = None): + super().setup_httpd(setup=MDTestSetup(env=self)) def set_store_dir_default(self): dirpath = "md" @@ -134,8 +133,10 @@ class MDTestEnv(HttpdTestEnv): def set_store_dir(self, dirpath): self._store_dir = os.path.join(self.server_dir, dirpath) if self.acme_url: - self.a2md_stdargs([self.a2md_bin, "-a", self.acme_url, "-d", self._store_dir, "-C", self.acme_ca_pemfile, "-j"]) - self.a2md_rawargs([self.a2md_bin, "-a", self.acme_url, "-d", self._store_dir, "-C", self.acme_ca_pemfile]) + self.a2md_stdargs([self.a2md_bin, "-a", self.acme_url, + "-d", self._store_dir, "-C", self.acme_ca_pemfile, "-j"]) + self.a2md_rawargs([self.a2md_bin, "-a", self.acme_url, + "-d", self._store_dir, "-C", self.acme_ca_pemfile]) def get_apxs_var(self, name: str) -> str: p = subprocess.run([self._apxs, "-q", name], capture_output=True, text=True) @@ -430,12 +431,11 @@ class MDTestEnv(HttpdTestEnv): assert r.exit_code == 0 return r.stdout - def get_json_content(self, domain, path, use_https=True, insecure=False, - debug_log=True): + def get_json_content(self, domain, path, use_https=True, insecure=False): schema = "https" if use_https else "http" port = self.https_port if use_https else self.http_port url = f"{schema}://{domain}:{port}{path}" - r = self.curl_get(url, insecure=insecure, debug_log=debug_log) + r = self.curl_get(url, insecure=insecure) if r.exit_code != 0: log.error(f"curl get on {url} returned {r.exit_code}" f"\nstdout: {r.stdout}" @@ -446,11 +446,11 @@ class MDTestEnv(HttpdTestEnv): def get_certificate_status(self, domain) -> Dict: return self.get_json_content(domain, "/.httpd/certificate-status", insecure=True) - def get_md_status(self, domain, via_domain=None, use_https=True, debug_log=False) -> Dict: + def get_md_status(self, domain, via_domain=None, use_https=True) -> Dict: if via_domain is None: via_domain = self._default_domain return self.get_json_content(via_domain, f"/md-status/{domain}", - use_https=use_https, debug_log=debug_log) + use_https=use_https) def get_server_status(self, query="/", via_domain=None, use_https=True): if via_domain is None: @@ -521,7 +521,6 @@ class MDTestEnv(HttpdTestEnv): and md['renewal']['errors'] >= errors: return md time.sleep(0.1) - return None def await_file(self, fpath, timeout=60): try_until = time.time() + timeout @@ -603,4 +602,4 @@ class MDTestEnv(HttpdTestEnv): dirpath = path if not path: dirpath = os.path.join(self.store_domains(), name_list[0]) - return MDCertUtil.create_self_signed_cert(dirpath, name_list, valid_days, serial)
\ No newline at end of file + return MDCertUtil.create_self_signed_cert(dirpath, name_list, valid_days, serial) diff --git a/test/modules/md/test_502_acmev2_drive.py b/test/modules/md/test_502_acmev2_drive.py index 05c7f73729..eb754f25ef 100644 --- a/test/modules/md/test_502_acmev2_drive.py +++ b/test/modules/md/test_502_acmev2_drive.py @@ -370,7 +370,7 @@ class TestDrivev2: env.run(["openssl", "s_client", f"-connect", "localhost:{env.https_port}", "-servername", "example.com", "-crlf" - ], input="GET https:// HTTP/1.1\nHost: example.com\n\n") + ], intext="GET https:// HTTP/1.1\nHost: example.com\n\n") assert env.apache_restart() == 0 # --------- critical state change -> drive again --------- |