From e9eba3484af1b891012247fd6a88b718b13f4ead Mon Sep 17 00:00:00 2001 From: Stefan Eissing Date: Mon, 13 Jan 2025 17:48:07 +0100 Subject: [PATCH] add github workflow for linux with pytest and pebble Adds a workflow on ubuntu-latest. Required some adjustements: - no longer use `apachectl` and call `httpd/apache2` directly - add some more debuging when apache start/restart/stop fails --- .github/workflows/linux.yml | 67 ++++++--- configure.ac | 46 +++--- test/modules/md/conftest.py | 3 +- test/modules/md/md_env.py | 29 ++-- test/modules/md/test_010_store_migrate.py | 2 +- test/modules/md/test_202_acmev2_regs.py | 2 +- test/modules/md/test_300_conf_validate.py | 32 ++--- test/modules/md/test_310_conf_store.py | 162 +++++++++++----------- test/modules/md/test_502_acmev2_drive.py | 50 +++---- test/modules/md/test_602_roundtrip.py | 18 +-- test/modules/md/test_702_auto.py | 76 +++++----- test/modules/md/test_720_wildcard.py | 22 +-- test/modules/md/test_730_static.py | 6 +- test/modules/md/test_740_acme_errors.py | 6 +- test/modules/md/test_741_setup_errors.py | 8 +- test/modules/md/test_750_eab.py | 36 ++--- test/modules/md/test_751_sectigo.py | 14 +- test/modules/md/test_752_zerossl.py | 14 +- test/modules/md/test_780_tailscale.py | 10 +- test/modules/md/test_790_failover.py | 8 +- test/modules/md/test_800_must_staple.py | 12 +- test/modules/md/test_801_stapling.py | 52 +++---- test/modules/md/test_810_ec.py | 10 +- test/modules/md/test_820_locks.py | 10 +- test/modules/md/test_900_notify.py | 10 +- test/modules/md/test_901_message.py | 28 ++-- test/modules/md/test_910_cleanups.py | 4 +- test/modules/md/test_920_status.py | 18 +-- test/pyhttpd/conf/httpd.conf.template | 2 +- test/pyhttpd/conf/stop.conf.template | 4 + test/pyhttpd/config.ini.in | 3 +- test/pyhttpd/env.py | 88 +++++++++--- test/pyhttpd/log.py | 4 + test/requirements.txt | 20 +++ 34 files changed, 501 insertions(+), 375 deletions(-) create mode 100644 test/requirements.txt diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index bd0ffd1..c46118e 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -39,33 +39,62 @@ env: CFLAGS: "-g" jobs: - build: + linux: name: ${{ matrix.name }} runs-on: ubuntu-latest timeout-minutes: 30 strategy: fail-fast: false matrix: - include: + build: - name: Default install_packages: - install_steps: pytest + install_steps: pytest pebble - steps: - - name: 'install prereqs' - run: | - sudo apt-get update -y - sudo apt-get install -y --no-install-suggests --no-install-recommends \ - libtool autoconf automake pkgconf apache2 apache2-dev openssl \ - libssl-dev libjansson-dev libcurl4-openssl-dev \ - ${{ matrix.build.install_packages }} - python3 -m venv $HOME/venv + steps: + - name: 'install prereqs' + run: | + sudo apt-get update -y + sudo apt-get install -y --no-install-suggests --no-install-recommends \ + libtool autoconf automake pkgconf apache2 apache2-dev openssl \ + curl nghttp2-client libssl-dev libjansson-dev libcurl4-openssl-dev \ + ${{ matrix.build.install_packages }} + python3 -m venv $HOME/venv - - name: 'configure' - run: | - autoreconf -fi - ./configure --enable-werror + - uses: actions/checkout@v4 - - name: 'build' - run: | - make V=1 + - name: 'install test prereqs' + run: | + [ -x "$HOME/venv/bin/activate" ] && source $HOME/venv/bin/activate + python3 -m pip install -r test/requirements.txt + + - name: setup Go + if: contains(matrix.build.install_steps, 'pebble') + uses: actions/setup-go@v5 + + - name: install pebble + if: contains(matrix.build.install_steps, 'pebble') + run: | + export PATH=$PATH:$HOME/go/bin + git clone --quiet --depth=1 https://github.com/letsencrypt/pebble/ + cd pebble + go install ./cmd/pebble + go install ./cmd/pebble-challtestsrv + + - name: 'configure' + run: | + export PATH=$PATH:$HOME/go/bin + autoreconf -fi + ./configure --enable-werror + + - name: 'build' + run: make V=1 + + - name: pytest + if: contains(matrix.build.install_steps, 'pytest') + env: + PYTEST_ADDOPTS: "--color=yes" + run: | + export PATH=$PATH:$HOME/go/bin + [ -x "$HOME/venv/bin/activate" ] && source $HOME/venv/bin/activate + pytest -v diff --git a/configure.ac b/configure.ac index c4569f4..44e7edb 100644 --- a/configure.ac +++ b/configure.ac @@ -117,24 +117,37 @@ CPPFLAGS="-I$($APXS -q includedir) -I$($APXS -q APR_INCLUDEDIR) $($APXS -q EXTRA HTTPD_VERSION="$($APXS -q HTTPD_VERSION)" AC_SUBST(HTTPD_VERSION) -APACHECTL="$sbindir/apachectl" -if test ! -x "$APACHECTL"; then - # rogue distros rename things! =) - APACHECTL="$sbindir/apache2ctl" -fi -AC_SUBST(APACHECTL) - -if test -x "$APACHECTL"; then - DSO_MODULES="$($APACHECTL -t -D DUMP_MODULES | fgrep '(shared)'| sed 's/_module.*//g'|tr -d \\n)" - AC_SUBST(DSO_MODULES) - STATIC_MODULES="$($APACHECTL -t -D DUMP_MODULES | fgrep '(static)'| sed 's/_module.*//g'|tr -d \\n)" - AC_SUBST(STATIC_MODULES) - MPM_MODULES="mpm_event mpm_worker" - AC_SUBST(MPM_MODULES) +HTTPD="$sbindir/httpd" +if test -x "$HTTPD"; then + : # all fine else - AC_MSG_WARN("apachectl not found in '$BINDIR', test suite will not work!") - APACHECTL="" + HTTPD="$sbindir/apache2" + if test -x "$HTTPD"; then + : # all fine + else + HTTPD="" + AC_PATH_PROG([HTTPD], [httpd]) + if test -x "$HTTPD"; then + : # ok + else + HTTPD="" + AC_PATH_PROG([HTTPD], [apache2]) + if test -x "$HTTPD"; then + : # ok + else + AC_MSG_ERROR([httpd/apache2 not in PATH]) + fi + fi + fi fi +AC_SUBST(HTTPD) + +DSO_MODULES="$($HTTPD -t -D DUMP_MODULES | fgrep '(shared)'| sed 's/_module.*//g'|tr -d \\n)" +AC_SUBST(DSO_MODULES) +STATIC_MODULES="$($HTTPD -t -D DUMP_MODULES | fgrep '(static)'| sed 's/_module.*//g'|tr -d \\n)" +AC_SUBST(STATIC_MODULES) +MPM_MODULES="mpm_event mpm_worker" +AC_SUBST(MPM_MODULES) # We need a JSON lib, like jansson # @@ -459,6 +472,7 @@ AC_MSG_NOTICE([summary of build options: Install prefix: ${prefix} APXS: ${APXS} HTTPD-VERSION: ${HTTPD_VERSION} + HTTPD: ${HTTPD} C compiler: ${CC} ${COMPILER_VERSION} CFLAGS: ${CFLAGS} WARNCFLAGS: ${WERROR_CFLAGS} diff --git a/test/modules/md/conftest.py b/test/modules/md/conftest.py index 0118de5..defa649 100644 --- a/test/modules/md/conftest.py +++ b/test/modules/md/conftest.py @@ -5,12 +5,11 @@ sys.path.append(os.path.join(os.path.dirname(__file__), '../..')) -from .md_conf import HttpdConf from .md_env import MDTestEnv from .md_acme import MDPebbleRunner, MDBoulderRunner -def pytest_report_header(config, startdir): +def pytest_report_header(config): env = MDTestEnv() return "mod_md: [apache: {aversion}({prefix}), mod_{ssl}, ACME server: {acme}]".format( prefix=env.prefix, diff --git a/test/modules/md/md_env.py b/test/modules/md/md_env.py index acc8417..703ae84 100644 --- a/test/modules/md/md_env.py +++ b/test/modules/md/md_env.py @@ -27,7 +27,8 @@ class MDTestSetup(HttpdTestSetup): def __init__(self, env: 'MDTestEnv'): super().__init__(env=env) self.mdenv = env - self.add_modules(["watchdog", "proxy_connect", "md"]) + self.add_modules(["watchdog", "proxy_connect"]) + self.add_local_module("md", "src/.libs/mod_md.so") def make(self): super().make() @@ -87,13 +88,16 @@ def is_pebble(cls) -> bool: def lacks_ocsp(cls): return cls.is_pebble() + A2MD_BIN = None + @classmethod def has_a2md(cls): - d = os.path.dirname(inspect.getfile(HttpdTestEnv)) - config = ConfigParser(interpolation=ExtendedInterpolation()) - config.read(os.path.join(d, 'config.ini')) - bin_dir = config.get('global', 'bindir') - a2md_bin = os.path.join(bin_dir, 'a2md') + if cls.A2MD_BIN is None: + d = os.path.dirname(inspect.getfile(HttpdTestEnv)) + config = ConfigParser(interpolation=ExtendedInterpolation()) + config.read(os.path.join(d, 'config.ini')) + src_dir = config.get('test', 'src_dir') + a2md_bin = os.path.join(src_dir, 'src/a2md') return os.path.isfile(a2md_bin) def __init__(self, pytestconfig=None): @@ -113,7 +117,7 @@ def __init__(self, pytestconfig=None): self._acme_server_down = False self._acme_server_ok = False - self._a2md_bin = os.path.join(self.bin_dir, 'a2md') + self._a2md_bin = os.path.join(self.src_dir, 'src/a2md') self._default_domain = f"test1.{self.http_tld}" self._tailscale_domain = "test.headless-chicken.ts.net" self._store_dir = "./md" @@ -309,8 +313,15 @@ def check_md(self, domain, md=None, state=-1, ca=None, protocol=None, agreement= if md: domain = md path = self.store_domain_file(domain, 'md.json') - with open(path) as f: - md = json.load(f) + try: + with open(path) as f: + md = json.load(f) + except FileNotFoundError: + log.error(f"not found: {path}") + if not os.path.exists(self._store_dir): + log.error(f"md store dir not found: {self._store_dir}") + self.httpd_error_log.dump(log) + assert False assert md if domains: assert md['domains'] == domains diff --git a/test/modules/md/test_010_store_migrate.py b/test/modules/md/test_010_store_migrate.py index d734b29..1872f47 100644 --- a/test/modules/md/test_010_store_migrate.py +++ b/test/modules/md/test_010_store_migrate.py @@ -13,7 +13,7 @@ class TestStoreMigrate: @pytest.fixture(autouse=True, scope='class') def _class_scope(self, env): MDConf(env).install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' # install old store, start a2md list, check files afterwards def test_md_010_000(self, env): diff --git a/test/modules/md/test_202_acmev2_regs.py b/test/modules/md/test_202_acmev2_regs.py index 97f093e..b99c745 100644 --- a/test/modules/md/test_202_acmev2_regs.py +++ b/test/modules/md/test_202_acmev2_regs.py @@ -19,7 +19,7 @@ def _class_scope(self, env, acme): env.check_acme() env.APACHE_CONF_SRC = "data/test_drive" MDConf(env).install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' @pytest.fixture(autouse=True, scope='function') def _method_scope(self, env): diff --git a/test/modules/md/test_300_conf_validate.py b/test/modules/md/test_300_conf_validate.py index 88df168..c863010 100644 --- a/test/modules/md/test_300_conf_validate.py +++ b/test/modules/md/test_300_conf_validate.py @@ -24,7 +24,7 @@ def test_md_300_001(self, env): MDConf(env, text=""" MDomain not-forbidden.org www.not-forbidden.org mail.not-forbidden.org """).install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' # env.httpd_error_log.ignore_recent( lognos = [ @@ -38,7 +38,7 @@ def test_md_300_002(self, env): MDomain not-forbidden.org www.not-forbidden.org mail.not-forbidden.org MDomain example2.org www.example2.org mail.example2.org """).install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' # env.httpd_error_log.ignore_recent( lognos = [ @@ -84,7 +84,7 @@ def test_md_300_005(self, env): MDomain example2.org www.example2.org www.example3.org """).install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' # env.httpd_error_log.ignore_recent( lognos = [ @@ -101,7 +101,7 @@ def test_md_300_006(self, env): MDomain example2.org www.example2.org www.example3.org """).install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' # env.httpd_error_log.ignore_recent( lognos = [ @@ -121,7 +121,7 @@ def test_md_300_007(self, env): ServerName www.example2.org """).install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' # env.httpd_error_log.ignore_recent( lognos = [ @@ -144,7 +144,7 @@ def test_md_300_008(self, env): ServerAlias example2.org """).install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' # env.httpd_error_log.ignore_recent( lognos = [ @@ -186,7 +186,7 @@ def test_md_300_010(self, env): """) conf.install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' # test case: MDomain, misses one ServerAlias def test_md_300_011a(self, env): @@ -216,7 +216,7 @@ def test_md_300_011b(self, env): ServerAlias test4.not-forbidden.org """ % env.https_port).install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' # test case: MDomain does not match any vhost def test_md_300_012(self, env): @@ -227,7 +227,7 @@ def test_md_300_012(self, env): ServerAlias test3.not-forbidden.org """).install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' # env.httpd_error_log.ignore_recent( lognos = [ @@ -246,7 +246,7 @@ def test_md_300_013(self, env): ServerName test-b.example2.org """).install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' # test case: global server name as managed domain name def test_md_300_014(self, env): @@ -257,7 +257,7 @@ def test_md_300_014(self, env): ServerName www.example2.org """).install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' # test case: valid pkey specification def test_md_300_015(self, env): @@ -268,7 +268,7 @@ def test_md_300_015(self, env): MDPrivateKeys RSA 3072 MDPrivateKeys RSA 4096 """).install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' # test case: invalid pkey specification @pytest.mark.parametrize("line,exp_err_msg", [ @@ -355,7 +355,7 @@ def test_md_300_022(self, env): ServerName secret.com """).install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' # env.httpd_error_log.ignore_recent( lognos = [ @@ -431,7 +431,7 @@ def test_md_300_026(self, env): """) conf.install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' # test case: configure more than 1 CA @pytest.mark.parametrize("cas, should_work", [ @@ -493,7 +493,7 @@ def test_md_300_028(self, env): # It works, if we only match on ServerNames conf.add("MDMatchNames servernames") conf.install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' env.httpd_error_log.ignore_recent( lognos=[ "AH10040", # ServerAlias not covered @@ -537,7 +537,7 @@ def test_md_300_029(self, env): # It works, if we only match on ServerNames conf.add("MDMatchNames servernames") conf.install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' time.sleep(2) assert env.apache_stop() == 0 # we need dns-01 challenge for the wildcard, which is not configured diff --git a/test/modules/md/test_310_conf_store.py b/test/modules/md/test_310_conf_store.py index f2bb9c7..992a630 100644 --- a/test/modules/md/test_310_conf_store.py +++ b/test/modules/md/test_310_conf_store.py @@ -30,7 +30,7 @@ def _method_scope(self, env, request): # test case: no md definitions in config def test_md_310_001(self, env): MDConf(env, text="").install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' r = env.a2md(["list"]) assert 0 == len(r.json["output"]) @@ -45,7 +45,7 @@ def test_md_310_001(self, env): ]) def test_md_310_100(self, env, confline, dns_lists, md_count): MDConf(env, text=confline).install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' for i in range(0, len(dns_lists)): env.check_md(dns_lists[i], state=1) @@ -54,13 +54,13 @@ def test_md_310_101(self, env): MDConf(env, text=""" MDomain testdomain.org www.testdomain.org mail.testdomain.org """).install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' env.check_md(["testdomain.org", "www.testdomain.org", "mail.testdomain.org"], state=1) MDConf(env, text=""" MDomain testdomain.org www.testdomain.org mail.testdomain.org MDomain testdomain2.org www.testdomain2.org mail.testdomain2.org """).install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' env.check_md(["testdomain.org", "www.testdomain.org", "mail.testdomain.org"], state=1) env.check_md(["testdomain2.org", "www.testdomain2.org", "mail.testdomain2.org"], state=1) @@ -70,7 +70,7 @@ def test_md_310_102(self, env): MDConf(env, text=""" MDomain testdomain.org www.testdomain.org mail.testdomain.org """).install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' env.check_md(["testdomain.org", "www.testdomain.org", "mail.testdomain.org"], state=1) # test case: add new md definition with acme url, acme protocol, acme agreement @@ -82,7 +82,7 @@ def test_md_310_103(self, env): MDomain testdomain.org www.testdomain.org mail.testdomain.org """, local_ca=False).install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' name = "testdomain.org" env.check_md([name, "www.testdomain.org", "mail.testdomain.org"], state=1, ca="http://acme.test.org:4000/directory", protocol="ACME", @@ -94,7 +94,7 @@ def test_md_310_104(self, env): MDConf(env, local_ca=False, text=""" MDomain testdomain.org www.testdomain.org mail.testdomain.org """).install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' env.check_md([name, "www.testdomain.org", "mail.testdomain.org"], state=1, ca="https://acme-v02.api.letsencrypt.org/directory", protocol="ACME") MDConf(env, local_ca=False, text=""" @@ -104,7 +104,7 @@ def test_md_310_104(self, env): MDomain testdomain.org www.testdomain.org mail.testdomain.org """).install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' env.check_md([name, "www.testdomain.org", "mail.testdomain.org"], state=1, ca="http://acme.test.org:4000/directory", protocol="ACME", agreement="http://acme.test.org:4000/terms/v1") @@ -114,7 +114,7 @@ def test_md_310_105(self, env): MDConf(env, admin="admin@testdomain.org", text=""" MDomain testdomain.org www.testdomain.org mail.testdomain.org """).install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' name = "testdomain.org" env.check_md([name, "www.testdomain.org", "mail.testdomain.org"], state=1, contacts=["mailto:admin@testdomain.org"]) @@ -126,7 +126,7 @@ def test_md_310_106(self, env): MDConf(env, admin="admin@testdomain.org", text=""" MDomain testdomain.org www.testdomain.org mail.testdomain.org """).install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' env.check_md([name, "www.testdomain.org", "mail.testdomain.org"], state=1, contacts=["mailto:admin@testdomain.org"]) @@ -148,7 +148,7 @@ def test_md_310_107(self, env): ServerAdmin mailto:admin@testdomain2.org """).install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' name1 = "testdomain.org" name2 = "testdomain2.org" env.check_md([name1, "www." + name1, "mail." + name1], state=1, contacts=["mailto:admin@" + name1]) @@ -159,7 +159,7 @@ def test_md_310_108(self, env): MDConf(env, text=""" MDomain testdomain.org WWW.testdomain.org MAIL.testdomain.org """).install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' env.check_md(["testdomain.org", "www.testdomain.org", "mail.testdomain.org"], state=1) # test case: default drive mode - auto @@ -167,7 +167,7 @@ def test_md_310_109(self, env): MDConf(env, text=""" MDomain testdomain.org www.testdomain.org mail.testdomain.org """).install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' assert env.a2md(["list"]).json['output'][0]['renew-mode'] == 1 # test case: drive mode manual @@ -176,7 +176,7 @@ def test_md_310_110(self, env): MDRenewMode manual MDomain testdomain.org www.testdomain.org mail.testdomain.org """).install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' assert env.a2md(["list"]).json['output'][0]['renew-mode'] == 0 # test case: drive mode auto @@ -185,7 +185,7 @@ def test_md_310_111(self, env): MDRenewMode auto MDomain testdomain.org www.testdomain.org mail.testdomain.org """).install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' assert env.a2md(["list"]).json['output'][0]['renew-mode'] == 1 # test case: drive mode always @@ -194,7 +194,7 @@ def test_md_310_112(self, env): MDRenewMode always MDomain testdomain.org www.testdomain.org mail.testdomain.org """).install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' assert env.a2md(["list"]).json['output'][0]['renew-mode'] == 2 # test case: renew window - 14 days @@ -203,7 +203,7 @@ def test_md_310_113a(self, env): MDRenewWindow 14d MDomain testdomain.org www.testdomain.org mail.testdomain.org """).install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' assert env.a2md(["list"]).json['output'][0]['renew-window'] == '14d' # test case: renew window - 10 percent @@ -212,7 +212,7 @@ def test_md_310_113b(self, env): MDRenewWindow 10% MDomain testdomain.org www.testdomain.org mail.testdomain.org """).install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' assert env.a2md(["list"]).json['output'][0]['renew-window'] == '10%' # test case: ca challenge type - http-01 @@ -221,7 +221,7 @@ def test_md_310_114(self, env): MDCAChallenges http-01 MDomain testdomain.org www.testdomain.org mail.testdomain.org """).install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' assert env.a2md(["list"]).json['output'][0]['ca']['challenges'] == ['http-01'] # test case: ca challenge type - http-01 @@ -230,7 +230,7 @@ def test_md_310_115(self, env): MDCAChallenges tls-alpn-01 MDomain testdomain.org www.testdomain.org mail.testdomain.org """).install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' assert env.a2md(["list"]).json['output'][0]['ca']['challenges'] == ['tls-alpn-01'] # test case: ca challenge type - all @@ -239,7 +239,7 @@ def test_md_310_116(self, env): MDCAChallenges http-01 tls-alpn-01 MDomain testdomain.org www.testdomain.org mail.testdomain.org """).install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' assert env.a2md(["list"]).json['output'][0]['ca']['challenges'] == ['http-01', 'tls-alpn-01'] # test case: automatically collect md names from vhost config @@ -252,7 +252,7 @@ def test_md_310_117(self, env): "testdomain.org", "test.testdomain.org", "mail.testdomain.org", ], with_ssl=True) conf.install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' assert env.a2md(["list"]).json['output'][0]['domains'] == \ ['testdomain.org', 'test.testdomain.org', 'mail.testdomain.org'] @@ -261,12 +261,12 @@ def test_md_310_118(self, env): MDConf(env, text=""" MDomain testdomain.org www.testdomain.org mail.testdomain.org """).install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' MDConf(env, text=""" MDRenewWindow 14d MDomain testdomain.org www.testdomain.org mail.testdomain.org """).install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' stat = env.get_md_status("testdomain.org") assert stat['renew-window'] == '14d' @@ -276,7 +276,7 @@ def test_md_310_119(self, env): MDPrivateKeys RSA 2048 MDomain testdomain.org www.testdomain.org mail.testdomain.org """).install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' assert env.a2md(["list"]).json['output'][0]['privkey'] == { "type": "RSA", "bits": 2048 @@ -288,7 +288,7 @@ def test_md_310_120(self, env): MDPrivateKeys RSA 4096 MDomain testdomain.org www.testdomain.org mail.testdomain.org """).install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' assert env.a2md(["list"]).json['output'][0]['privkey'] == { "type": "RSA", "bits": 4096 @@ -300,7 +300,7 @@ def test_md_310_121(self, env): MDomain testdomain.org www.testdomain.org mail.testdomain.org MDRequireHttps temporary """).install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' assert env.a2md(["list"]).json['output'][0]['require-https'] == "temporary" # test case: require OCSP stapling @@ -309,7 +309,7 @@ def test_md_310_122(self, env): MDomain testdomain.org www.testdomain.org mail.testdomain.org MDMustStaple on """).install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' assert env.a2md(["list"]).json['output'][0]['must-staple'] is True # test case: remove managed domain from config @@ -319,7 +319,7 @@ def test_md_310_200(self, env): env.check_md(dns_list, state=1) conf = MDConf(env,) conf.install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' # check: md stays in store env.check_md(dns_list, state=1) @@ -331,7 +331,7 @@ def test_md_310_201(self, env): MDConf(env, text=""" MDomain testdomain.org www.testdomain.org mail.testdomain.org """).install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' # check: DNS has been removed from md in store env.check_md(["testdomain.org", "www.testdomain.org", "mail.testdomain.org"], state=1) @@ -343,7 +343,7 @@ def test_md_310_202(self, env): MDConf(env, text=""" MDomain testdomain.org www.testdomain.org mail.testdomain.org """).install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' # check: md overwrite previous name and changes name env.check_md(["testdomain.org", "www.testdomain.org", "mail.testdomain.org"], md="testdomain.org", state=1) @@ -359,7 +359,7 @@ def test_md_310_203(self, env): MDConf(env, text=""" MDomain testdomain.org www.testdomain.org mail.testdomain.org """).install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' # all mds stay in store env.check_md(dns_list1, state=1) env.check_md(dns_list2, state=1) @@ -374,12 +374,12 @@ def test_md_310_204(self, env): MDomain testdomain.org www.testdomain.org mail.testdomain.org """).install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' # setup: sync with ca info removed MDConf(env, local_ca=False, text=""" MDomain testdomain.org www.testdomain.org mail.testdomain.org """).install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' env.check_md([name, "www.testdomain.org", "mail.testdomain.org"], state=1, ca="https://acme-v02.api.letsencrypt.org/directory", protocol="ACME") @@ -389,12 +389,12 @@ def test_md_310_205(self, env): MDConf(env, admin="admin@testdomain.org", text=""" MDomain testdomain.org www.testdomain.org mail.testdomain.org """).install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' # setup: sync with admin info removed MDConf(env, admin="", text=""" MDomain testdomain.org www.testdomain.org mail.testdomain.org """).install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' # check: md stays the same with previous admin info env.check_md([name, "www.testdomain.org", "mail.testdomain.org"], state=1, contacts=["mailto:admin@testdomain.org"]) @@ -405,12 +405,12 @@ def test_md_310_206(self, env): MDRenewWindow 14d MDomain testdomain.org www.testdomain.org mail.testdomain.org """).install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' assert env.a2md(["list"]).json['output'][0]['renew-window'] == '14d' MDConf(env, text=""" MDomain testdomain.org www.testdomain.org mail.testdomain.org """).install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' # check: renew window not set assert env.a2md(["list"]).json['output'][0]['renew-window'] == '33%' @@ -425,13 +425,13 @@ def test_md_310_207(self, env, renew_mode, exp_code): MDRenewMode %s MDomain testdomain.org www.testdomain.org mail.testdomain.org """ % renew_mode).install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' assert env.a2md(["list"]).json['output'][0]['renew-mode'] == exp_code # MDConf(env, text=""" MDomain testdomain.org www.testdomain.org mail.testdomain.org """).install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' assert env.a2md(["list"]).json['output'][0]['renew-mode'] == 1 # test case: remove challenges from conf -> fallback to default (not set) @@ -440,13 +440,13 @@ def test_md_310_208(self, env): MDCAChallenges http-01 MDomain testdomain.org www.testdomain.org mail.testdomain.org """).install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' assert env.a2md(["list"]).json['output'][0]['ca']['challenges'] == ['http-01'] # MDConf(env, text=""" MDomain testdomain.org www.testdomain.org mail.testdomain.org """).install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' assert 'challenges' not in env.a2md(["list"]).json['output'][0]['ca'] # test case: specify RSA key @@ -456,13 +456,13 @@ def test_md_310_209(self, env, key_size): MDPrivateKeys RSA %s MDomain testdomain.org www.testdomain.org mail.testdomain.org """ % key_size).install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' assert env.a2md(["list"]).json['output'][0]['privkey']['type'] == "RSA" # MDConf(env, text=""" MDomain testdomain.org www.testdomain.org mail.testdomain.org """).install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' assert "privkey" not in env.a2md(["list"]).json['output'][0] # test case: require HTTPS @@ -474,14 +474,14 @@ def test_md_310_210(self, env, mode): MDRequireHttps %s """ % mode).install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' assert env.a2md(["list"]).json['output'][0]['require-https'] == mode, \ "Unexpected HTTPS require mode in store. config: {}".format(mode) # MDConf(env, text=""" MDomain testdomain.org www.testdomain.org mail.testdomain.org """).install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' assert "require-https" not in env.a2md(["list"]).json['output'][0], \ "HTTPS require still persisted in store. config: {}".format(mode) @@ -491,13 +491,13 @@ def test_md_310_211(self, env): MDomain testdomain.org www.testdomain.org mail.testdomain.org MDMustStaple on """).install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' assert env.a2md(["list"]).json['output'][0]['must-staple'] is True # MDConf(env, text=""" MDomain testdomain.org www.testdomain.org mail.testdomain.org """).install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' assert env.a2md(["list"]).json['output'][0]['must-staple'] is False # test case: reorder DNS names in md definition @@ -508,7 +508,7 @@ def test_md_310_300(self, env): MDConf(env, text=""" MDomain testdomain.org www.testdomain.org mail.testdomain.org """).install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' # check: dns list changes env.check_md(["testdomain.org", "www.testdomain.org", "mail.testdomain.org"], state=1) @@ -523,7 +523,7 @@ def test_md_310_301(self, env): MDomain testdomain.org www.testdomain.org mail.testdomain.org MDomain testdomain2.org www.testdomain2.org mail.testdomain2.org """).install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' env.check_md(["testdomain.org", "www.testdomain.org", "mail.testdomain.org"], state=1) env.check_md(["testdomain2.org", "www.testdomain2.org", "mail.testdomain2.org"], state=1) @@ -537,7 +537,7 @@ def test_md_310_302(self, env): MDomain testdomain.org www.testdomain.org mail.testdomain.org """).install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' # setup: sync with changed ca info MDConf(env, local_ca=False, admin="webmaster@testdomain.org", text=""" @@ -547,7 +547,7 @@ def test_md_310_302(self, env): MDomain testdomain.org www.testdomain.org mail.testdomain.org """).install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' # check: md stays the same with previous ca info env.check_md([name, "www.testdomain.org", "mail.testdomain.org"], state=1, ca="http://somewhere.com:6666/directory", protocol="ACME", @@ -559,7 +559,7 @@ def test_md_310_303(self, env): MDConf(env, admin="admin@testdomain.org", text=""" MDomain testdomain.org www.testdomain.org mail.testdomain.org """).install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' # setup: sync with changed admin info MDConf(env, local_ca=False, admin="webmaster@testdomain.org", text=""" MDCertificateAuthority http://somewhere.com:6666/directory @@ -568,7 +568,7 @@ def test_md_310_303(self, env): MDomain testdomain.org www.testdomain.org mail.testdomain.org """).install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' # check: md stays the same with previous admin info env.check_md([name, "www.testdomain.org", "mail.testdomain.org"], state=1, contacts=["mailto:webmaster@testdomain.org"]) @@ -579,21 +579,21 @@ def test_md_310_304(self, env): MDRenewMode manual MDomain testdomain.org www.testdomain.org mail.testdomain.org """).install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' assert env.a2md(["list"]).json['output'][0]['renew-mode'] == 0 # test case: drive mode auto MDConf(env, text=""" MDRenewMode auto MDomain testdomain.org www.testdomain.org mail.testdomain.org """).install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' assert env.a2md(["list"]).json['output'][0]['renew-mode'] == 1 # test case: drive mode always MDConf(env, text=""" MDRenewMode always MDomain testdomain.org www.testdomain.org mail.testdomain.org """).install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' assert env.a2md(["list"]).json['output'][0]['renew-mode'] == 2 # test case: change config value for renew window, use various syntax alternatives @@ -602,21 +602,21 @@ def test_md_310_305(self, env): MDRenewWindow 14d MDomain testdomain.org www.testdomain.org mail.testdomain.org """).install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' md = env.a2md(["list"]).json['output'][0] assert md['renew-window'] == '14d' MDConf(env, text=""" MDRenewWindow 10 MDomain testdomain.org www.testdomain.org mail.testdomain.org """).install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' md = env.a2md(["list"]).json['output'][0] assert md['renew-window'] == '10d' MDConf(env, text=""" MDRenewWindow 10% MDomain testdomain.org www.testdomain.org mail.testdomain.org """).install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' md = env.a2md(["list"]).json['output'][0] assert md['renew-window'] == '10%' @@ -626,21 +626,21 @@ def test_md_310_306(self, env): MDCAChallenges http-01 MDomain testdomain.org www.testdomain.org mail.testdomain.org """).install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' assert env.a2md(["list"]).json['output'][0]['ca']['challenges'] == ['http-01'] # test case: drive mode auto MDConf(env, text=""" MDCAChallenges tls-alpn-01 MDomain testdomain.org www.testdomain.org mail.testdomain.org """).install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' assert env.a2md(["list"]).json['output'][0]['ca']['challenges'] == ['tls-alpn-01'] # test case: drive mode always MDConf(env, text=""" MDCAChallenges http-01 tls-alpn-01 MDomain testdomain.org www.testdomain.org mail.testdomain.org """).install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' assert env.a2md(["list"]).json['output'][0]['ca']['challenges'] == ['http-01', 'tls-alpn-01'] # test case: RSA key length: 4096 -> 2048 -> 4096 @@ -649,7 +649,7 @@ def test_md_310_307(self, env): MDPrivateKeys RSA 4096 MDomain testdomain.org www.testdomain.org mail.testdomain.org """).install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' assert env.a2md(["list"]).json['output'][0]['privkey'] == { "type": "RSA", "bits": 4096 @@ -658,7 +658,7 @@ def test_md_310_307(self, env): MDPrivateKeys RSA 2048 MDomain testdomain.org www.testdomain.org mail.testdomain.org """).install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' assert env.a2md(["list"]).json['output'][0]['privkey'] == { "type": "RSA", "bits": 2048 @@ -667,7 +667,7 @@ def test_md_310_307(self, env): MDPrivateKeys RSA 4096 MDomain testdomain.org www.testdomain.org mail.testdomain.org """).install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' assert env.a2md(["list"]).json['output'][0]['privkey'] == { "type": "RSA", "bits": 4096 @@ -679,14 +679,14 @@ def test_md_310_308(self, env): MDConf(env, text=""" MDomain testdomain.org www.testdomain.org mail.testdomain.org """).install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' assert "require-https" not in env.a2md(["list"]).json['output'][0] # test case: temporary redirect MDConf(env, text=""" MDomain testdomain.org www.testdomain.org mail.testdomain.org MDRequireHttps temporary """).install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' assert env.a2md(["list"]).json['output'][0]['require-https'] == "temporary" # test case: permanent redirect MDConf(env, text=""" @@ -695,7 +695,7 @@ def test_md_310_308(self, env): MDRequireHttps permanent """).install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' assert env.a2md(["list"]).json['output'][0]['require-https'] == "permanent" # test case: change OCSP stapling settings on existing md @@ -704,21 +704,21 @@ def test_md_310_309(self, env): MDConf(env, text=""" MDomain testdomain.org www.testdomain.org mail.testdomain.org """).install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' assert env.a2md(["list"]).json['output'][0]['must-staple'] is False # test case: OCSP stapling on MDConf(env, text=""" MDomain testdomain.org www.testdomain.org mail.testdomain.org MDMustStaple on """).install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' assert env.a2md(["list"]).json['output'][0]['must-staple'] is True # test case: OCSP stapling off MDConf(env, text=""" MDomain testdomain.org www.testdomain.org mail.testdomain.org MDMustStaple off """).install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' assert env.a2md(["list"]).json['output'][0]['must-staple'] is False # test case: change renew window parameter @@ -735,7 +735,7 @@ def test_md_310_310(self, env, window): conf.end_md() conf.add_vhost(domains=domain) conf.install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' stat = env.get_md_status(domain) assert stat["renew-window"] == window @@ -748,7 +748,7 @@ def test_md_310_400(self, env): assert env.a2md(["update", name, "contacts", "admin@" + name]).exit_code == 0 assert env.a2md(["update", name, "agreement", env.acme_tos]).exit_code == 0 MDConf(env).install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' # setup: drive it r = env.a2md(["-v", "drive", name]) @@ -771,7 +771,7 @@ def test_md_310_401(self, env): assert env.a2md(["add", name]).exit_code == 0 assert env.a2md(["update", name, "contacts", "admin@" + name]).exit_code == 0 assert env.a2md(["update", name, "agreement", env.acme_tos]).exit_code == 0 - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' # setup: drive it assert env.a2md(["drive", name]).exit_code == 0 assert env.a2md(["list", name]).json['output'][0]['state'] == env.MD_S_COMPLETE @@ -786,7 +786,7 @@ def test_md_310_500(self, env): MDStoreDir md-other MDomain testdomain.org www.testdomain.org mail.testdomain.org """).install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' assert env.a2md(["list"]).json['output'] == [] env.set_store_dir("md-other") env.check_md(["testdomain.org", "www.testdomain.org", "mail.testdomain.org"], state=1) @@ -802,13 +802,13 @@ def test_md_310_501(self, env): conf.end_md() conf.add_vhost(domains=[domain]) conf.install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' # add a file at top level assert env.await_completion([domain]) fpath = os.path.join(env.store_domains(), "wrong.com") with open(fpath, 'w') as fd: fd.write("this does not belong here\n") - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' # test case: add external account binding def test_md_310_601(self, env): @@ -821,7 +821,7 @@ def test_md_310_601(self, env): conf.end_md() conf.add_vhost(domains=domain) conf.install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' stat = env.get_md_status(domain) assert stat["eab"] == {'kid': 'k123', 'hmac': '***'} # eab inherited @@ -832,7 +832,7 @@ def test_md_310_601(self, env): conf.end_md() conf.add_vhost(domains=domain) conf.install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' stat = env.get_md_status(domain) assert stat["eab"] == {'kid': 'k456', 'hmac': '***'} # override eab inherited @@ -844,7 +844,7 @@ def test_md_310_601(self, env): conf.end_md() conf.add_vhost(domains=domain) conf.install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' stat = env.get_md_status(domain) assert "eab" not in stat diff --git a/test/modules/md/test_502_acmev2_drive.py b/test/modules/md/test_502_acmev2_drive.py index b064647..484e4d4 100644 --- a/test/modules/md/test_502_acmev2_drive.py +++ b/test/modules/md/test_502_acmev2_drive.py @@ -25,7 +25,7 @@ def _class_scope(self, env, acme): env.check_acme() env.APACHE_CONF_SRC = "data/test_drive" MDConf(env).install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' @pytest.fixture(autouse=True, scope='function') def _method_scope(self, env, request): @@ -76,7 +76,7 @@ def test_md_502_100(self, env): domain = self.test_domain name = "www." + domain self._prepare_md(env, [name]) - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' # drive prev_md = env.a2md(["list", name]).json['output'][0] r = env.a2md(["-vv", "drive", "-c", "http-01", name]) @@ -117,7 +117,7 @@ def test_md_502_101(self, env): domain = self.test_domain name = "www." + domain self._prepare_md(env, [name, "test." + domain]) - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' # drive r = env.a2md(["-vv", "drive", "-c", "http-01", name]) assert r.exit_code == 0, "a2md drive failed: {0}".format(r.stderr) @@ -132,7 +132,7 @@ def test_md_502_103(self, env): name = "www." + domain assert env.a2md(["add", name]).exit_code == 0 assert env.a2md(["update", name, "contacts", "admin@" + domain]).exit_code == 0 - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' # setup: create account on server r = env.a2md(["-t", "accepted", "acme", "newreg", "admin@" + domain], raw=True) assert r.exit_code == 0 @@ -152,7 +152,7 @@ def test_md_502_105(self, env): domain = self.test_domain name = "www." + domain self._prepare_md(env, [name]) - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' # setup: create account on server r = env.a2md(["-t", "accepted", "acme", "newreg", "test@" + domain], raw=True) assert r.exit_code == 0 @@ -172,7 +172,7 @@ def test_md_502_107(self, env): domain = self.test_domain name = "www." + domain self._prepare_md(env, [name]) - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' # drive r = env.a2md(["-vv", "drive", name]) assert r.exit_code == 0, "a2md drive failed: {0}".format(r.stderr) @@ -204,7 +204,7 @@ def test_md_502_108(self, env): conf = MDConf(env, proxy=True) conf.add('LogLevel proxy:trace8') conf.install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' # drive it, with wrong proxy url -> FAIL r = env.a2md(["-p", "http://localhost:1", "drive", name]) @@ -231,11 +231,11 @@ def test_md_502_109(self, env): # setup: create resource files self._write_res_file(os.path.join(env.server_docs_dir, "test"), "name.txt", name) self._write_res_file(os.path.join(env.server_docs_dir), "name.txt", "not-forbidden.org") - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' # drive it assert env.a2md(["drive", name]).exit_code == 0 - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' # test HTTP access - no redirect jdata = env.get_json_content(f"test1.{env.http_tld}", "/alive.json", use_https=False) assert jdata['host']== "test1" @@ -249,7 +249,7 @@ def test_md_502_109(self, env): # test HTTP access again -> redirect to default HTTPS port conf.add("MDRequireHttps temporary") conf.install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' r = env.get_meta(name, "/name.txt", use_https=False) assert r.response['status'] == 302 exp_location = "https://%s/name.txt" % name @@ -266,7 +266,7 @@ def test_md_502_109(self, env): # test HTTP access again -> redirect permanent conf.add("MDRequireHttps permanent") conf.install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' r = env.get_meta(name, "/name.txt", use_https=False) assert r.response['status'] == 301 exp_location = "https://%s/name.txt" % name @@ -288,15 +288,15 @@ def test_md_502_110(self, env): conf.add_vhost(name, port=env.http_port) conf.add_vhost(name) conf.install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' # drive it assert env.a2md(["drive", name]).exit_code == 0 - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' # test override HSTS header conf.add('Header set Strict-Transport-Security "max-age=10886400; includeSubDomains; preload"') conf.install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' r = env.get_meta(name, "/name.txt", use_https=True) assert 'strict-transport-security' in r.response['header'], r.response['header'] assert r.response['header']['strict-transport-security'] == \ @@ -306,7 +306,7 @@ def test_md_502_110(self, env): conf.add(' Redirect /a /name.txt') conf.add(' Redirect seeother /b /name.txt') conf.install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' # check: default redirect by mod_md still works exp_location = "https://%s/name.txt" % name r = env.get_meta(name, "/name.txt", use_https=False) @@ -330,17 +330,17 @@ def test_md_502_111(self, env): conf.add_vhost(name, port=env.http_port) conf.add_vhost(name) conf.install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' # drive it r = env.a2md(["-v", "drive", name]) assert r.exit_code == 0, "a2md drive failed: {0}".format(r.stderr) - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' # setup: place redirect rules conf.add(' Redirect /a /name.txt') conf.add(' Redirect seeother /b /name.txt') conf.install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' # check: redirects on HTTP exp_location = "http://%s:%s/name.txt" % (name, env.http_port) r = env.get_meta(name, "/a", use_https=False) @@ -367,12 +367,12 @@ def test_md_502_120(self, env): conf.add_md([name]) conf.add_vhost(name) conf.install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' env.run(["openssl", "s_client", f"-connect", "localhost:{env.https_port}", "-servername", "example.com", "-crlf" ], intext="GET https:// HTTP/1.1\nHost: example.com\n\n") - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' # --------- critical state change -> drive again --------- @@ -382,7 +382,7 @@ def test_md_502_200(self, env): domain = self.test_domain name = "www." + domain self._prepare_md(env, [name]) - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' # setup: drive it r = env.a2md(["drive", name]) assert r.exit_code == 0, "a2md drive failed: {0}".format(r.stderr) @@ -419,7 +419,7 @@ def test_md_502_201(self, env, renew_window, test_data_list): conf.add_renew_window(renew_window) conf.add_md([name]) conf.install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' assert env.a2md(["list", name]).json['output'][0]['state'] == env.MD_S_INCOMPLETE # setup: drive it r = env.a2md(["drive", name]) @@ -457,7 +457,7 @@ def test_md_502_202(self, env, key_type, key_params, exp_key_length): conf.add_private_key(key_type, key_params) conf.add_md([name]) conf.install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' assert env.a2md(["list", name]).json['output'][0]['state'] == env.MD_S_INCOMPLETE # setup: drive it r = env.a2md(["-vv", "drive", name]) @@ -477,7 +477,7 @@ def test_md_502_300(self, env): domain = self.test_domain name = "www." + domain self._prepare_md(env, [name, "test." + domain, "xxx." + domain]) - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' # setup: drive it r = env.a2md(["drive", name]) assert r.exit_code == 0, "a2md drive failed: {0}".format(r.stderr) @@ -496,7 +496,7 @@ def test_md_502_301(self, env): domain = self.test_domain name = "www." + domain self._prepare_md(env, [name]) - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' # setup: drive it r = env.a2md(["drive", name]) assert r.exit_code == 0, "a2md drive failed: {0}".format(r.stderr) diff --git a/test/modules/md/test_602_roundtrip.py b/test/modules/md/test_602_roundtrip.py index 9ff87e5..2d050ae 100644 --- a/test/modules/md/test_602_roundtrip.py +++ b/test/modules/md/test_602_roundtrip.py @@ -39,16 +39,16 @@ def test_md_602_000(self, env): conf.add_md(domains) conf.install() # - restart, check that md is in store - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' env.check_md(domains) # - drive assert env.a2md(["-v", "drive", domain]).exit_code == 0 - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' env.check_md_complete(domain) # - append vhost to config conf.add_vhost(domains) conf.install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' # check: SSL is running OK cert = env.get_cert(domain) assert domain in cert.get_san_list() @@ -71,14 +71,14 @@ def test_md_602_001(self, env): conf.install() # - restart, check that md is in store - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' env.check_md(domains_a) env.check_md(domains_b) # - drive assert env.a2md(["drive", domain_a]).exit_code == 0 assert env.a2md(["drive", domain_b]).exit_code == 0 - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' env.check_md_complete(domain_a) env.check_md_complete(domain_b) @@ -88,7 +88,7 @@ def test_md_602_001(self, env): conf.install() # check: SSL is running OK - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' cert_a = env.get_cert(domain_a) assert domains_a == cert_a.get_san_list() cert_b = env.get_cert(domain_b) @@ -108,12 +108,12 @@ def test_md_602_002(self, env): conf.install() # - restart, check that md is in store - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' env.check_md(domains) # - drive assert env.a2md(["drive", domain]).exit_code == 0 - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' env.check_md_complete(domain) # - append vhost to config @@ -126,7 +126,7 @@ def test_md_602_002(self, env): self._write_res_file(os.path.join(env.server_docs_dir, "b"), "name.txt", name_b) # check: SSL is running OK - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' cert_a = env.get_cert(name_a) assert name_a in cert_a.get_san_list() cert_b = env.get_cert(name_b) diff --git a/test/modules/md/test_702_auto.py b/test/modules/md/test_702_auto.py index 90103e3..83ed3ff 100644 --- a/test/modules/md/test_702_auto.py +++ b/test/modules/md/test_702_auto.py @@ -21,7 +21,7 @@ def _class_scope(self, env, acme): env.check_acme() env.clear_store() MDConf(env).install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' @pytest.fixture(autouse=True, scope='function') def _method_scope(self, env, request): @@ -44,7 +44,7 @@ def test_md_702_001(self, env): conf.install() # # restart, check that MD is synched to store - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' env.check_md(domains) stat = env.get_md_status(domain) assert stat["watched"] == 0 @@ -52,7 +52,7 @@ def test_md_702_001(self, env): # add vhost for MD, restart should drive it conf.add_vhost(domains) conf.install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' assert env.await_completion([domain]) env.check_md_complete(domain) stat = env.get_md_status(domain) @@ -89,7 +89,7 @@ def test_md_702_002(self, env): conf.install() # # restart, check that md is in store - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' env.check_md(domains_a) env.check_md(domains_b) # @@ -106,7 +106,7 @@ def test_md_702_002(self, env): assert status['state-descr'] == "certificate(rsa) is missing" # restart and activate - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' # check: SSL is running OK cert_a = env.get_cert(domain_a) assert domains_a == cert_a.get_san_list() @@ -136,7 +136,7 @@ def test_md_702_003(self, env): self._write_res_file(os.path.join(env.server_docs_dir, "b"), "name.txt", name_b) # # restart (-> drive), check that MD was synched and completes - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' env.check_md(domains) assert env.await_completion([domain]) md = env.check_md_complete(domain) @@ -170,7 +170,7 @@ def test_md_702_004(self, env, challenge_type): conf.install() # # restart (-> drive), check that MD was synched and completes - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' env.check_md(domains) assert env.await_completion([domain]) env.check_md_complete(domain) @@ -196,7 +196,7 @@ def test_md_702_005(self, env): self._write_res_file(os.path.join(env.server_docs_dir, "a"), "name.txt", name_a) # # restart, check that md is in store - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' env.check_md(domains) # # check: that request to domains give 503 Service Unavailable @@ -227,7 +227,7 @@ def test_md_702_006(self, env): self._write_res_file(os.path.join(env.server_docs_dir, "a"), "name.txt", name_a) # # restart, check that md is in store - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' env.check_md(domains) # await drive completion md = env.await_error(domain) @@ -262,7 +262,7 @@ def test_md_702_008(self, env): conf.install() # # - restart (-> drive) - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' # await drive completion md = env.await_error(domain) assert md @@ -291,9 +291,9 @@ def test_md_702_008a(self, env): conf.install() # # - restart (-> drive), check that md is in store - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' assert env.await_completion([domain]) - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' env.check_md_complete(domain) # Force cert renewal due to critical remaining valid duration @@ -311,7 +311,7 @@ def test_md_702_009(self, env): conf.install() # # restart (-> drive), check that md+cert is in store, TLS is up - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' assert env.await_completion([domain]) env.check_md_complete(domain) cert1 = MDCertUtil(env.store_domain_file(domain, 'pubcert.pem')) @@ -327,7 +327,7 @@ def test_md_702_009(self, env): creds.save_cert_pem(env.store_domain_file(domain, 'pubcert.pem')) creds.save_pkey_pem(env.store_domain_file(domain, 'privkey.pem')) assert creds.certificate.serial_number == 7029 - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' stat = env.get_certificate_status(domain) assert creds.certificate.serial_number == int(stat['rsa']['serial'], 16) # @@ -348,7 +348,7 @@ def test_md_702_010(self, env): conf.add_md(domains) conf.add_vhost(domains) conf.install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' md = env.await_error(domain) assert md["renewal"]["errors"] > 0 # @@ -360,7 +360,7 @@ def test_md_702_010(self, env): conf.add_md(domains) conf.add_vhost(domains) conf.install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' env.check_md(domains) assert env.await_completion([domain]) # @@ -386,7 +386,7 @@ def test_md_702_011(self, env): conf.add_md(domains) conf.add_vhost(domains) conf.install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' md = env.await_error(domain) assert md["renewal"]["errors"] > 0 # @@ -399,7 +399,7 @@ def test_md_702_011(self, env): conf.add_md(domains) conf.add_vhost(domains) conf.install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' env.check_md(domains) assert env.await_completion([domain]) # @@ -431,7 +431,7 @@ def test_md_702_030(self, env): conf.install() # # restart (-> drive), check that MD was synched and completes - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' env.check_md(domains) assert env.await_completion([name_x]) env.check_md_complete(name_x) @@ -451,7 +451,7 @@ def test_md_702_030(self, env): conf.add_vhost(name_b) conf.install() # restart, check that host still works and kept the cert - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' env.check_md(new_list) status = env.get_certificate_status(name_a) assert cert_a.same_serial_as(status['rsa']['serial']) @@ -475,7 +475,7 @@ def test_md_702_031(self, env): conf.install() # # restart (-> drive), check that MD was synched and completes - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' env.check_md(domains) assert env.await_completion([name_x]) env.check_md_complete(name_x) @@ -495,7 +495,7 @@ def test_md_702_031(self, env): conf.add_vhost(name_b) conf.install() # restart, check that host still works and have new cert - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' env.check_md(new_list) assert env.await_completion([name_a]) # @@ -520,7 +520,7 @@ def test_md_702_032(self, env): conf.install() # # restart (-> drive), check that MD was synched and completes - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' env.check_md([name1]) env.check_md([name2]) assert env.await_completion([name1, name2]) @@ -538,7 +538,7 @@ def test_md_702_032(self, env): conf.add_md([name1]) conf.add_vhost([name1, name2]) conf.install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' env.check_md([name1, name2]) assert env.await_completion([name1]) # @@ -563,7 +563,7 @@ def test_md_702_033(self, env): conf.install() # # restart (-> drive), check that MD was synched and completes - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' env.check_md(domains1) assert env.await_completion([name_x]) env.check_md_complete(name_x) @@ -576,7 +576,7 @@ def test_md_702_033(self, env): conf.add_vhost(domains=domains2) conf.install() # restart, check that host still works and kept the cert - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' status = env.get_certificate_status(name_a) assert cert_x.same_serial_as(status['rsa']['serial']) @@ -597,7 +597,7 @@ def test_md_702_040(self, env): conf.install() # # restart (-> drive), check that MD was synched and completes - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' env.check_md(domains) # check that acme-tls/1 is available for all domains stat = env.get_md_status(domain) @@ -625,7 +625,7 @@ def test_md_702_041(self, env): # # restart (-> drive), check that MD job shows errors # and that missing proto is detected - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' env.check_md(domains) # check that acme-tls/1 is available for none of the domains stat = env.get_md_status(domain) @@ -645,7 +645,7 @@ def test_md_702_042(self, env): conf.add_md(dns_list) conf.add_vhost(dns_list) conf.install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' assert env.await_completion([domain]) # test case: test "tls-alpn-01" without enabling 'acme-tls/1' challenge protocol @@ -666,7 +666,7 @@ def test_md_702_043(self, env): # # restart (-> drive), check that MD job shows errors # and that missing proto is detected - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' env.check_md(domains) # check that acme-tls/1 is available for none of the domains stat = env.get_md_status(domain) @@ -694,7 +694,7 @@ def test_md_702_044(self, env, challenge_type): conf.install() # # restart (-> drive), check that MD was synched and completes - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' env.check_md(md_domains) assert env.await_completion([domain]) env.check_md_complete(domain) @@ -714,7 +714,7 @@ def test_md_702_050(self, env): """) conf.add_md([domain]) conf.install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' assert env.await_completion([domain]) # Make a setup using the base server without http:, will fail. @@ -728,7 +728,7 @@ def test_md_702_051(self, env): """) conf.add_md([domain]) conf.install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' assert env.await_error(domain) # env.httpd_error_log.ignore_recent( @@ -759,7 +759,7 @@ def test_md_702_052(self, env): ]) conf.add_md([domain]) conf.install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' stat = env.get_md_status(domain, via_domain=env.http_addr, use_https=False) assert stat["proto"]["acme-tls/1"] == [domain] assert env.await_completion([domain], via_domain=env.http_addr, use_https=False) @@ -786,7 +786,7 @@ def test_md_702_060(self, env, challenge_type): conf.add_md(domains) conf.add_vhost(domains) conf.install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' env.check_md(domains) assert env.await_error(long_domain) # add a short domain to the SAN list, the CA should now use that one @@ -800,7 +800,7 @@ def test_md_702_060(self, env, challenge_type): conf.add_md(domains) conf.add_vhost(domains) conf.install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' assert env.await_completion([long_domain]) env.check_md_complete(long_domain) # @@ -823,7 +823,7 @@ def test_md_702_070(self, env): conf.install() # # restart (-> drive), check that MD was synched and completes - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' assert env.await_completion(domains) env.check_md_complete(domains[0]) @@ -842,7 +842,7 @@ def test_md_702_071(self, env): conf.install() # # restart (-> drive), check that MD was synched and completes - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' assert env.await_completion(domains) env.check_md_complete(domains[0]) diff --git a/test/modules/md/test_720_wildcard.py b/test/modules/md/test_720_wildcard.py index 916c47a..1930f72 100644 --- a/test/modules/md/test_720_wildcard.py +++ b/test/modules/md/test_720_wildcard.py @@ -18,7 +18,7 @@ def _class_scope(self, env, acme): env.check_acme() env.clear_store() MDConf(env).install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' @pytest.fixture(autouse=True, scope='function') def _method_scope(self, env, request): @@ -37,7 +37,7 @@ def test_md_720_001(self, env): conf.install() # restart, check that md is in store - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' env.check_md(domains) # await drive completion md = env.await_error(domain) @@ -69,7 +69,7 @@ def test_md_720_002(self, env): conf.install() # restart, check that md is in store - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' env.check_md(domains) # await drive completion md = env.await_error(domain) @@ -100,7 +100,7 @@ def test_md_720_002b(self, env): conf.install() # restart, check that md is in store - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' env.check_md(domains) # await drive completion assert env.await_completion([domain]) @@ -125,7 +125,7 @@ def test_md_720_003(self, env): conf.install() # restart, check that md is in store - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' env.check_md(domains) # await drive completion md = env.await_error(domain) @@ -156,7 +156,7 @@ def test_md_720_004(self, env): conf.install() # restart, check that md is in store - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' env.check_md(domains) # await drive completion assert env.await_completion([domain]) @@ -183,7 +183,7 @@ def test_md_720_005(self, env): conf.install() # restart, check that md is in store - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' env.check_md(domains) # await drive completion assert env.await_completion([domain]) @@ -211,7 +211,7 @@ def test_md_720_006(self, env): conf.install() # restart, check that md is in store - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' env.check_md(domains) # await drive completion assert env.await_completion([domain]) @@ -238,7 +238,7 @@ def test_md_720_007(self, env): conf.install() # restart, check that md is in store - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' env.check_md(domains) # await drive completion assert env.await_completion([wwwdomain]) @@ -270,7 +270,7 @@ def test_md_720_008(self, env): fd.write(content) # restart, check that md is in store - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' env.check_md(domains) # await drive completion assert env.await_completion([domain], restart=False) @@ -278,5 +278,5 @@ def test_md_720_008(self, env): r = env.curl_get(f"http://{domain}:{env.http_port}/.well-known/acme-challenge/123456") assert r.response['status'] == 200 assert r.response['body'] == content - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' env.check_md_complete(domain) diff --git a/test/modules/md/test_730_static.py b/test/modules/md/test_730_static.py index 91a5f44..3c4d26e 100644 --- a/test/modules/md/test_730_static.py +++ b/test/modules/md/test_730_static.py @@ -19,7 +19,7 @@ def _class_scope(self, env, acme): env.check_acme() env.clear_store() MDConf(env).install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' @pytest.fixture(autouse=True, scope='function') def _method_scope(self, env, request): @@ -48,7 +48,7 @@ def test_md_730_001(self, env): conf.end_md() conf.add_vhost(domain) conf.install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' # check if the domain uses it, it appears in our stats and renewal is off cert = env.get_cert(domain) @@ -83,7 +83,7 @@ def test_md_730_002(self, env): conf.end_md() conf.add_vhost(domain) conf.install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' # this should enforce a renewal stat = env.get_md_status(domain) assert stat['renew'] is True, stat diff --git a/test/modules/md/test_740_acme_errors.py b/test/modules/md/test_740_acme_errors.py index 364aaca..130723b 100644 --- a/test/modules/md/test_740_acme_errors.py +++ b/test/modules/md/test_740_acme_errors.py @@ -16,7 +16,7 @@ def _class_scope(self, env, acme): env.check_acme() env.clear_store() MDConf(env).install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' @pytest.fixture(autouse=True, scope='function') def _method_scope(self, env, request): @@ -33,7 +33,7 @@ def test_md_740_000(self, env): conf.add_md(domains) conf.add_vhost(domains) conf.install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' md = env.await_error(domain) assert md assert md['renewal']['errors'] > 0 @@ -65,7 +65,7 @@ def test_md_740_001(self, env): conf.add_md(domains) conf.add_vhost(domains) conf.install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' md = env.await_error(domain) assert md assert md['renewal']['errors'] > 0 diff --git a/test/modules/md/test_741_setup_errors.py b/test/modules/md/test_741_setup_errors.py index 958f13f..d041e97 100644 --- a/test/modules/md/test_741_setup_errors.py +++ b/test/modules/md/test_741_setup_errors.py @@ -18,7 +18,7 @@ def _class_scope(self, env, acme): env.check_acme() env.clear_store() MDConf(env).install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' @pytest.fixture(autouse=True, scope='function') def _method_scope(self, env, request): @@ -42,7 +42,7 @@ def test_md_741_001(self, env): conf.add_md(domains) conf.add_vhost(domains) conf.install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' md = env.await_error(domain, errors=2, timeout=10) assert md assert md['renewal']['errors'] > 0 @@ -65,13 +65,13 @@ def test_md_741_002(self, env): conf.add_md(domains) conf.add_vhost(domains) conf.install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' env.check_md(domains) assert env.await_completion([domain], restart=False) staged_md_path = env.store_staged_file(domain, 'md.json') with open(staged_md_path, 'w') as fd: fd.write('garbage\n') - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' assert env.await_completion([domain]) env.check_md_complete(domain) env.httpd_error_log.ignore_recent( diff --git a/test/modules/md/test_750_eab.py b/test/modules/md/test_750_eab.py index aec7e89..894ac85 100644 --- a/test/modules/md/test_750_eab.py +++ b/test/modules/md/test_750_eab.py @@ -18,7 +18,7 @@ def _class_scope(self, env, acme): env.check_acme() env.clear_store() MDConf(env).install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' @pytest.fixture(autouse=True, scope='function') def _method_scope(self, env, request): @@ -33,7 +33,7 @@ def test_md_750_001(self, env): conf.add_md(domains) conf.add_vhost(domains=domains) conf.install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' md = env.await_error(domain) assert md['renewal']['errors'] > 0 assert md['renewal']['last']['problem'] == 'urn:ietf:params:acme:error:externalAccountRequired' @@ -56,7 +56,7 @@ def test_md_750_002(self, env): conf.add_md(domains) conf.add_vhost(domains=domains) conf.install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' md = env.await_error(domain) assert md['renewal']['errors'] > 0 assert md['renewal']['last']['problem'] == 'apache:eab-hmac-invalid' @@ -79,7 +79,7 @@ def test_md_750_003(self, env): conf.add_md(domains) conf.add_vhost(domains=domains) conf.install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' md = env.await_error(domain) assert md['renewal']['errors'] > 0 assert md['renewal']['last']['problem'] in [ @@ -105,7 +105,7 @@ def test_md_750_004(self, env): conf.add_md(domains) conf.add_vhost(domains=domains) conf.install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' md = env.await_error(domain) assert md['renewal']['errors'] > 0 assert md['renewal']['last']['problem'] in [ @@ -131,7 +131,7 @@ def test_md_750_005(self, env): conf.add_md(domains) conf.add_vhost(domains=domains) conf.install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' md = env.await_error(domain) assert md['renewal']['errors'] > 0 assert md['renewal']['last']['problem'] in [ @@ -158,7 +158,7 @@ def test_md_750_010(self, env): conf.add_md(domains) conf.add_vhost(domains=domains) conf.install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' assert env.await_completion(domains) def test_md_750_011(self, env): @@ -174,7 +174,7 @@ def test_md_750_011(self, env): conf.add_md([domain_b]) conf.add_vhost(domains=[domain_b]) conf.install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' assert env.await_completion([domain_a], restart=False) md = env.await_error(domain_b) assert md['renewal']['errors'] > 0 @@ -202,7 +202,7 @@ def test_md_750_012(self, env): conf.end_md() conf.add_vhost(domains=[domain_b]) conf.install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' assert env.await_completion([domain_b], restart=False) md = env.await_error(domain_a) assert md['renewal']['errors'] > 0 @@ -231,7 +231,7 @@ def test_md_750_013(self, env): conf.end_md() conf.add_vhost(domains=[domain_b]) conf.install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' assert env.await_completion([domain_a, domain_b]) md_a = env.get_md_status(domain_a) md_b = env.get_md_status(domain_b) @@ -247,7 +247,7 @@ def test_md_750_014(self, env): conf.add_md(domains) conf.add_vhost(domains=domains) conf.install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' assert env.await_completion(domains) md_1 = env.get_md_status(domain) conf = MDConf(env) @@ -258,7 +258,7 @@ def test_md_750_014(self, env): conf.add_md(domains) conf.add_vhost(domains=domains) conf.install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' assert env.await_completion(domains) md_2 = env.get_md_status(domain) assert md_1['ca'] != md_2['ca'] @@ -273,7 +273,7 @@ def test_md_750_015(self, env): conf.add_md(domains) conf.add_vhost(domains=domains) conf.install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' assert env.await_completion(domains) conf = MDConf(env) # this is another one of the values in conf/pebble-eab.json @@ -282,7 +282,7 @@ def test_md_750_015(self, env): conf.add_md(domains) conf.add_vhost(domains=domains) conf.install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' assert env.await_error(domain) md = env.await_error(domain) assert md['renewal']['errors'] > 0 @@ -307,7 +307,7 @@ def test_md_750_016(self, env): conf.add_md(domains) conf.add_vhost(domains=domains) conf.install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' assert env.await_completion(domains) conf = MDConf(env) # this is another one of the values in conf/pebble-eab.json @@ -317,7 +317,7 @@ def test_md_750_016(self, env): conf.add_md(domains) conf.add_vhost(domains=domains) conf.install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' assert env.await_error(domain) md = env.await_error(domain) assert md['renewal']['errors'] > 0 @@ -343,7 +343,7 @@ def test_md_750_017(self, env): conf.end_md() conf.add_vhost(domains=domains) conf.install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' md = env.await_error(domain) assert md['renewal']['errors'] > 0 assert md['renewal']['last']['problem'] == 'urn:ietf:params:acme:error:externalAccountRequired' @@ -432,5 +432,5 @@ def test_md_750_022(self, env): conf.add_md(domains) conf.add_vhost(domains=domains) conf.install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' assert env.await_completion(domains) diff --git a/test/modules/md/test_751_sectigo.py b/test/modules/md/test_751_sectigo.py index 5cbd642..f5a7040 100644 --- a/test/modules/md/test_751_sectigo.py +++ b/test/modules/md/test_751_sectigo.py @@ -46,7 +46,7 @@ def _class_scope(self, env, acme): env.check_acme() env.clear_store() MDConf(env).install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' @pytest.fixture(autouse=True, scope='function') def _method_scope(self, env, request): @@ -65,7 +65,7 @@ def test_md_751_001(self, env): conf.end_md() conf.add_vhost(domains=domains) conf.install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' assert env.await_completion(domains) r = env.curl_get(f"https://{domain}:{env.https_port}", options=[ "--cacert", f"{env.test_dir}/data/sectigo-demo-root.pem" @@ -83,7 +83,7 @@ def test_md_751_002(self, env): conf.end_md() conf.add_vhost(domains=domains) conf.install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' assert env.await_error(domain) md = env.get_md_status(domain) assert md['renewal']['errors'] > 0 @@ -101,7 +101,7 @@ def test_md_751_003(self, env): conf.end_md() conf.add_vhost(domains=domains) conf.install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' assert env.await_error(domain) md = env.get_md_status(domain) assert md['renewal']['errors'] > 0 @@ -120,7 +120,7 @@ def test_md_751_004(self, env): conf.end_md() conf.add_vhost(domains=domains) conf.install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' assert env.await_completion(domains) r = env.curl_get(f"https://{domain}:{env.https_port}", options=[ "--cacert", f"{env.test_dir}/data/sectigo-demo-root.pem" @@ -142,7 +142,7 @@ def test_md_751_004(self, env): conf.end_md() conf.add_vhost(domains=domains) conf.install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' assert env.await_completion(domains) r = env.curl_get(f"https://{domain2}:{env.https_port}", options=[ "--cacert", f"{env.test_dir}/data/sectigo-demo-root.pem" @@ -167,7 +167,7 @@ def test_md_751_020(self, env): conf.end_md() conf.add_vhost(domains=domains) conf.install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' assert env.await_completion(domains) r = env.curl_get(f"https://{domain}:{env.https_port}", options=[ "--cacert", f"{env.test_dir}/data/sectigo-demo-root.pem" diff --git a/test/modules/md/test_752_zerossl.py b/test/modules/md/test_752_zerossl.py index 1884665..70505a3 100644 --- a/test/modules/md/test_752_zerossl.py +++ b/test/modules/md/test_752_zerossl.py @@ -43,7 +43,7 @@ def _class_scope(self, env, acme): env.check_acme() env.clear_store() MDConf(env).install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' @pytest.fixture(autouse=True, scope='function') def _method_scope(self, env, request): @@ -66,7 +66,7 @@ def test_md_752_001(self, env): conf.end_md() conf.add_vhost(domains=domains) conf.install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' assert env.await_completion(domains) r = env.curl_get(f"https://{domain}:{env.https_port}", options=[ "--cacert", f"{env.test_dir}/data/sectigo-demo-root.pem" @@ -88,7 +88,7 @@ def test_md_752_002(self, env): conf.end_md() conf.add_vhost(domains=domains) conf.install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' assert env.await_error(domain) md = env.get_md_status(domain) assert md['renewal']['errors'] > 0 @@ -110,7 +110,7 @@ def test_md_752_003(self, env): conf.end_md() conf.add_vhost(domains=domains) conf.install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' assert env.await_error(domain) md = env.get_md_status(domain) assert md['renewal']['errors'] > 0 @@ -134,7 +134,7 @@ def test_md_752_004(self, env): conf.end_md() conf.add_vhost(domains=domains) conf.install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' assert env.await_completion(domains) r = env.curl_get(f"https://{domain}:{env.https_port}", options=[ "--cacert", f"{env.test_dir}/data/sectigo-demo-root.pem" @@ -160,7 +160,7 @@ def test_md_752_004(self, env): conf.end_md() conf.add_vhost(domains=domains) conf.install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' assert env.await_completion(domains) r = env.curl_get(f"https://{domain2}:{env.https_port}", options=[ "--cacert", f"{env.test_dir}/data/sectigo-demo-root.pem" @@ -188,7 +188,7 @@ def test_md_752_020(self, env): conf.end_md() conf.add_vhost(domains=domains) conf.install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' assert env.await_completion(domains) r = env.curl_get(f"https://{domain}:{env.https_port}", options=[ "--cacert", f"{env.test_dir}/data/sectigo-demo-root.pem" diff --git a/test/modules/md/test_780_tailscale.py b/test/modules/md/test_780_tailscale.py index 27a2df4..bb218f9 100644 --- a/test/modules/md/test_780_tailscale.py +++ b/test/modules/md/test_780_tailscale.py @@ -103,7 +103,7 @@ def _class_scope(self, env, acme): acme.start(config='default') env.clear_store() MDConf(env).install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' yield faker.stop() @@ -133,7 +133,7 @@ def test_md_780_001(self, env): conf.add_vhost(domains) conf.install() # restart and watch it fail due to wrong tailscale unix socket path - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' md = env.await_error(domain) assert md assert md['renewal']['errors'] > 0 @@ -163,9 +163,9 @@ def test_md_780_002(self, env): conf.add_vhost(domains) conf.install() # restart and watch it fail due to wrong tailscale unix socket path - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' assert env.await_completion(domains) - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' env.check_md_complete(domain) # create a MD using `tailscale` as protocol, but domain name not assigned by tailscale @@ -184,7 +184,7 @@ def test_md_780_003(self, env): conf.add_vhost(domains) conf.install() # restart and watch it fail due to wrong tailscale unix socket path - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' md = env.await_error(domain) assert md assert md['renewal']['errors'] > 0 diff --git a/test/modules/md/test_790_failover.py b/test/modules/md/test_790_failover.py index 696161f..5b9d4e2 100644 --- a/test/modules/md/test_790_failover.py +++ b/test/modules/md/test_790_failover.py @@ -16,7 +16,7 @@ def _class_scope(self, env, acme): conf = MDConf(env) conf.install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' @pytest.fixture(autouse=True, scope='function') def _method_scope(self, env, request): @@ -39,7 +39,7 @@ def test_md_790_001(self, env): conf.end_md() conf.add_vhost(domains) conf.install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' assert env.await_completion([domain]) env.check_md_complete(domain) @@ -60,7 +60,7 @@ def test_md_790_002(self, env): conf.end_md() conf.add_vhost(domains) conf.install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' assert env.await_completion([domain]) env.check_md_complete(domain) # @@ -91,7 +91,7 @@ def test_md_790_003(self, env): conf.end_md() conf.add_vhost(domains) conf.install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' assert env.await_completion([domain]) env.check_md_complete(domain) # diff --git a/test/modules/md/test_800_must_staple.py b/test/modules/md/test_800_must_staple.py index 32edee3..8433ca8 100644 --- a/test/modules/md/test_800_must_staple.py +++ b/test/modules/md/test_800_must_staple.py @@ -17,7 +17,7 @@ def _class_scope(self, env, acme): env.check_acme() env.clear_store() MDConf(env).install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' @pytest.fixture(autouse=True, scope='function') def _method_scope(self, env, request): @@ -33,7 +33,7 @@ def configure_httpd(self, env, domain, add_lines=""): # MD with default, e.g. not staple def test_md_800_001(self, env): self.configure_httpd(env, self.domain) - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' assert env.await_completion([self.domain]) env.check_md_complete(self.domain) cert1 = MDCertUtil(env.store_domain_file(self.domain, 'pubcert.pem')) @@ -42,7 +42,7 @@ def test_md_800_001(self, env): # MD that should explicitly not staple def test_md_800_002(self, env): self.configure_httpd(env, self.domain, "MDMustStaple off") - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' env.check_md_complete(self.domain) cert1 = MDCertUtil(env.store_domain_file(self.domain, 'pubcert.pem')) assert not cert1.get_must_staple() @@ -53,13 +53,13 @@ def test_md_800_002(self, env): @pytest.mark.skipif(MDTestEnv.lacks_ocsp(), reason="no OCSP responder") def test_md_800_003(self, env): self.configure_httpd(env, self.domain, "MDMustStaple on") - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' assert env.await_completion([self.domain]) env.check_md_complete(self.domain) cert1 = MDCertUtil(env.store_domain_file(self.domain, 'pubcert.pem')) assert cert1.get_must_staple() self.configure_httpd(env, self.domain, "MDMustStaple off") - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' assert env.await_completion([self.domain]) env.check_md_complete(self.domain) cert1 = MDCertUtil(env.store_domain_file(self.domain, 'pubcert.pem')) @@ -78,7 +78,7 @@ def test_md_800_004(self, env): SSLUseStapling On SSLStaplingCache shmcb:stapling_cache(128000) """) - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' stat = env.get_ocsp_status(self.domain) assert stat['ocsp'] == "successful (0x0)" assert stat['verify'] == "0 (ok)" diff --git a/test/modules/md/test_801_stapling.py b/test/modules/md/test_801_stapling.py index a17c6c4..3348572 100644 --- a/test/modules/md/test_801_stapling.py +++ b/test/modules/md/test_801_stapling.py @@ -24,7 +24,7 @@ def _class_scope(self, env, acme): mdB = "b-" + domain self.configure_httpd(env, [mdA, mdB]).install() env.apache_stop() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' assert env.await_completion([mdA, mdB]) env.check_md_complete(mdA) env.check_md_complete(mdB) @@ -67,10 +67,10 @@ def configure_httpd(self, env, domains=None, add_lines="", ssl_stapling=False): def test_md_801_001(self, env): md = self.mdA self.configure_httpd(env, md).install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' stat = env.get_ocsp_status(md) if MDTestEnv.lacks_ocsp(): - assert 'ocsp' not in stat, f'{stat}' + assert 'ocsp' not in stat or stat['ocsp'] == "no response sent", f'{stat}' else: assert stat['ocsp'] == "no response sent" stat = env.get_md_status(md) @@ -81,10 +81,10 @@ def test_md_801_001(self, env): MDStapling on LogLevel md:trace5 """).install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' if MDTestEnv.lacks_ocsp(): stat = env.get_md_status(md) - assert 'ocsp' not in stat, f'{stat}' + assert 'ocsp' not in stat or stat['ocsp'] == "no response sent", f'{stat}' else: stat = env.await_ocsp_status(md) assert stat['ocsp'] == "successful (0x0)" @@ -102,10 +102,10 @@ def test_md_801_001(self, env): # # turn stapling off (explicitly) again, should disappear self.configure_httpd(env, md, "MDStapling off").install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' stat = env.get_ocsp_status(md) if MDTestEnv.lacks_ocsp(): - assert 'ocsp' not in stat, f'{stat}' + assert 'ocsp' not in stat or stat['ocsp'] == "no response sent", f'{stat}' else: assert stat['ocsp'] == "no response sent" stat = env.get_md_status(md) @@ -117,7 +117,7 @@ def test_md_801_001(self, env): def test_md_801_002(self, env): md = self.mdA self.configure_httpd(env, md, ssl_stapling=True).install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' stat = env.get_ocsp_status(md) assert stat['ocsp'] == "successful (0x0)" if \ env.ssl_module == "mod_ssl" else "no response sent" @@ -126,7 +126,7 @@ def test_md_801_002(self, env): # # turn stapling on, wait for it to appear in connections self.configure_httpd(env, md, "MDStapling on", ssl_stapling=True).install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' stat = env.await_ocsp_status(md) assert stat['ocsp'] == "successful (0x0)" assert stat['verify'] == "0 (ok)" @@ -138,7 +138,7 @@ def test_md_801_002(self, env): # # turn stapling off (explicitly) again, should disappear self.configure_httpd(env, md, "MDStapling off", ssl_stapling=True).install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' stat = env.get_ocsp_status(md) assert stat['ocsp'] == "successful (0x0)" if \ env.ssl_module == "mod_ssl" else "no response sent" @@ -160,11 +160,11 @@ def test_md_801_003(self, env): conf.add_vhost(md_a) conf.add_vhost(md_b) conf.install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' # mdA has stapling if MDTestEnv.lacks_ocsp(): stat = env.get_ocsp_status(md_a) - assert 'ocsp' not in stat, f'{stat}' + assert 'ocsp' not in stat or stat['ocsp'] == "no response sent", f'{stat}' else: stat = env.await_ocsp_status(md_a) assert stat['ocsp'] == "successful (0x0)" @@ -198,7 +198,7 @@ def test_md_801_004(self, env): conf.add_vhost(md_a) conf.add_vhost(md_b) conf.install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' # mdA has stapling stat = env.await_ocsp_status(md_a) assert stat['ocsp'] == "successful (0x0)" @@ -223,7 +223,7 @@ def test_md_801_005(self, env): # turn stapling on, wait for it to appear in connections md = self.mdA self.configure_httpd(env, md, "MDStapling on").install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' stat = env.await_ocsp_status(md) assert stat['ocsp'] == "successful (0x0)" assert stat['verify'] == "0 (ok)" @@ -238,7 +238,7 @@ def test_md_801_005(self, env): mtime1 = os.path.getmtime(ocsp_file) # wait a sec, restart and check that file does not change time.sleep(1) - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' stat = env.await_ocsp_status(md) assert stat['ocsp'] == "successful (0x0)" mtime2 = os.path.getmtime(ocsp_file) @@ -250,12 +250,12 @@ def test_md_801_005(self, env): MDStapling on MDStaplingKeepResponse 1s """).install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' stat = env.await_ocsp_status(md) assert stat['ocsp'] == "successful (0x0)" assert not os.path.exists(ocsp_file) # if we restart again, a new file needs to appear - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' stat = env.await_ocsp_status(md) assert stat['ocsp'] == "successful (0x0)" mtime3 = os.path.getmtime(ocsp_file) @@ -268,7 +268,7 @@ def test_md_801_006(self, env): # turn stapling on, wait for it to appear in connections md = self.mdA self.configure_httpd(env, md, "MDStapling on").install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' stat = env.await_ocsp_status(md) assert stat['ocsp'] == "successful (0x0)" assert stat['verify'] == "0 (ok)" @@ -281,7 +281,7 @@ def test_md_801_006(self, env): ocsp_file = os.path.join(dirpath, name) assert ocsp_file mtime1 = os.path.getmtime(ocsp_file) - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' stat = env.await_ocsp_status(md) assert stat['ocsp'] == "successful (0x0)" # wait a sec, restart and check that file does not change @@ -293,7 +293,7 @@ def test_md_801_006(self, env): MDStapling on MDStaplingRenewWindow 10d """).install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' stat = env.await_ocsp_status(md) assert stat['ocsp'] == "successful (0x0)" # wait a sec, restart and check that file does change @@ -317,7 +317,7 @@ def test_md_801_007(self, env): env.store_domain_file(md, 'pubcert.pem'))) conf.add_vhost(md) conf.install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' stat = env.await_ocsp_status(md) assert stat['ocsp'] == "successful (0x0)" assert stat['verify'] == "0 (ok)" @@ -342,7 +342,7 @@ def test_md_801_008(self, env): env.store_domain_file(md, 'privkey.pem')) conf.end_vhost() conf.install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' stat = env.await_ocsp_status(md) assert stat['ocsp'] == "successful (0x0)" assert stat['verify'] == "0 (ok)" @@ -380,7 +380,7 @@ def test_md_801_009(self, env): conf.end_md() conf.add_vhost(md) conf.install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' time.sleep(1) stat = env.get_ocsp_status(md) assert stat['ocsp'] == "no response sent" @@ -397,7 +397,7 @@ def test_md_801_010(self, env): conf.add("MDStapling on") conf.end_md() conf.install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' stat = env.get_server_status() assert stat @@ -414,9 +414,9 @@ def test_md_801_011(self, env): MDStapling on LogLevel md:trace2 ssl:warn """).install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' assert env.await_completion(domains, restart=False, timeout=120) - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' # now the certs are installed and ocsp will be retrieved time.sleep(1) for domain in domains: diff --git a/test/modules/md/test_810_ec.py b/test/modules/md/test_810_ec.py index 5c31018..f12fdb0 100644 --- a/test/modules/md/test_810_ec.py +++ b/test/modules/md/test_810_ec.py @@ -18,7 +18,7 @@ def _class_scope(self, env, acme): env.check_acme() env.clear_store() MDConf(env).install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' @pytest.fixture(autouse=True, scope='function') def _method_scope(self, env, request): @@ -33,7 +33,7 @@ def set_get_pkeys(self, env, domain, pkeys, conf=None): conf.add_md(domains) conf.add_vhost(domains) conf.install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' assert env.await_completion([domain]) def check_pkeys(self, env, domain, pkeys): @@ -100,7 +100,7 @@ def test_md_810_004(self, env): conf.add_md(domains) conf.add_vhost(domains) conf.install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' md = env.await_error(domain) assert md assert md['renewal']['errors'] > 0 @@ -135,14 +135,14 @@ def test_md_810_007(self, env): conf.add_md(domains) conf.add_vhost(domains) conf.install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' assert env.await_completion(domains) conf = MDConf(env) conf.add("MDPrivateKeys rsa3072 secp384r1") conf.add_md(domains) conf.add_vhost(domains) conf.install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' mds = env.get_md_status(domain, via_domain=domain, use_https=True) assert 'renew' in mds and mds['renew'] is True, f"{mds}" assert env.await_completion(domains) diff --git a/test/modules/md/test_820_locks.py b/test/modules/md/test_820_locks.py index 9436912..fc55914 100644 --- a/test/modules/md/test_820_locks.py +++ b/test/modules/md/test_820_locks.py @@ -37,7 +37,7 @@ def test_md_820_001(self, env): self.configure_httpd(env, [domain], add_lines=[ "MDStoreLocks 1s" ]) - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' assert env.await_completion([domain]) # renewal, with global lock held during restert @@ -47,26 +47,26 @@ def test_md_820_002(self, env): self.configure_httpd(env, [domain], add_lines=[ "MDStoreLocks 1s" ]) - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' assert env.await_completion([domain]) # we have a cert now, add a dns name to force renewal certa = MDCertUtil(env.store_domain_file(domain, 'pubcert.pem')) self.configure_httpd(env, [domain, f"x.{domain}"], add_lines=[ "MDStoreLocks 1s" ]) - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' # await new cert, but do not restart, keeps the cert in staging assert env.await_completion([domain], restart=False) # obtain global lock and restart lockfile = os.path.join(env.store_dir, "store.lock") with FileLock(lockfile): - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' # lock should have prevented staging from being activated, # meaning we will have the same cert certb = MDCertUtil(env.store_domain_file(domain, 'pubcert.pem')) assert certa.same_serial_as(certb) # now restart without lock - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' certc = MDCertUtil(env.store_domain_file(domain, 'pubcert.pem')) assert not certa.same_serial_as(certc) diff --git a/test/modules/md/test_900_notify.py b/test/modules/md/test_900_notify.py index 9d18da5..15521c5 100644 --- a/test/modules/md/test_900_notify.py +++ b/test/modules/md/test_900_notify.py @@ -45,7 +45,7 @@ def test_md_900_001(self, env): self.configure_httpd(env, self.domain, f""" MDNotifyCmd {command} {args} """) - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' assert env.await_error(self.domain) stat = env.get_md_status(self.domain) assert stat["renewal"]["last"]["problem"] == "urn:org:apache:httpd:log:AH10108:" @@ -63,7 +63,7 @@ def test_md_900_002(self, env): self.configure_httpd(env, self.domain, f""" MDNotifyCmd {command} {args} """) - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' assert env.await_error(self.domain) stat = env.get_md_status(self.domain) assert stat["renewal"]["last"]["problem"] == "urn:org:apache:httpd:log:AH10108:" @@ -83,7 +83,7 @@ def test_md_900_010(self, env): self.configure_httpd(env, self.domain, f""" MDNotifyCmd {command} {args} """) - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' assert env.await_completion([self.domain], restart=False) time.sleep(1) stat = env.get_md_status(self.domain) @@ -102,7 +102,7 @@ def test_md_900_011(self, env): self.configure_httpd(env, self.domain, f""" MDNotifyCmd {command} {args} {extra_arg} """) - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' assert env.await_completion([self.domain], restart=False) time.sleep(1) stat = env.get_md_status(self.domain) @@ -125,7 +125,7 @@ def test_md_900_012(self, env): conf.add_vhost(domains1) conf.add_vhost(domains2) conf.install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' assert env.await_completion([md1, md2], restart=False) time.sleep(1) stat = env.get_md_status(md1) diff --git a/test/modules/md/test_901_message.py b/test/modules/md/test_901_message.py index c001839..86475fc 100644 --- a/test/modules/md/test_901_message.py +++ b/test/modules/md/test_901_message.py @@ -22,7 +22,7 @@ def _class_scope(self, env, acme): env.check_acme() env.clear_store() MDConf(env).install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' @pytest.fixture(autouse=True, scope='function') def _method_scope(self, env, request): @@ -43,7 +43,7 @@ def test_md_901_001(self, env): conf.add_md(domains) conf.add_vhost(domains) conf.install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' assert env.await_file(env.store_staged_file(domain, 'job.json')) stat = env.get_md_status(domain) # this command should have failed and logged an error @@ -70,7 +70,7 @@ def test_md_901_002(self, env): conf.add_md(domains) conf.add_vhost(domains) conf.install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' assert env.await_error(domain) stat = env.get_md_status(domain) # this command should have failed and logged an error @@ -96,7 +96,7 @@ def test_md_901_003(self, env): conf.add_md(domains) conf.add_vhost(domains) conf.install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' assert env.await_completion([domain], restart=False) time.sleep(1) stat = env.get_md_status(domain) @@ -134,7 +134,7 @@ def test_md_901_004(self, env): conf.add_md(domains) conf.add_vhost(domains) conf.install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' assert env.await_completion([domain]) # force renew conf = MDConf(env) @@ -144,7 +144,7 @@ def test_md_901_004(self, env): conf.add_md(domains) conf.add_vhost(domains) conf.install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' assert env.await_completion([domain], restart=False) env.get_md_status(domain) assert env.await_file(self.mlog) @@ -175,7 +175,7 @@ def test_md_901_010(self, env): conf.end_md() conf.add_vhost(domain) conf.install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' assert not os.path.isfile(self.mlog) def test_md_901_011(self, env): @@ -201,13 +201,13 @@ def test_md_901_011(self, env): conf.end_md() conf.add_vhost(domain) conf.install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' assert env.await_file(self.mlog) nlines = open(self.mlog).readlines() assert len(nlines) == 1 assert nlines[0].strip() == f"['{self.mcmd}', '{self.mlog}', 'expiring', '{domain}']" # check that we do not get it resend right away again - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' time.sleep(1) nlines = open(self.mlog).readlines() assert len(nlines) == 1 @@ -225,7 +225,7 @@ def test_md_901_020(self, env): conf.add("MDStapling on") conf.add_vhost(domains) conf.install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' assert env.await_completion([domain]) env.await_ocsp_status(domain) assert env.await_file(self.mlog) @@ -251,7 +251,7 @@ def test_md_901_030(self, env): conf.add_md(domains) conf.add_vhost(domains) conf.install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' assert env.await_completion([domain]) # set the warn window that triggers right away and a failing message command conf = MDConf(env) @@ -262,7 +262,7 @@ def test_md_901_030(self, env): """) conf.add_vhost(domains) conf.install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' env.get_md_status(domain) # this command should have failed and logged an error # shut down server to make sure that md has completed @@ -285,7 +285,7 @@ def test_md_901_030(self, env): """) conf.add_vhost(domains) conf.install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' assert env.await_file(self.mlog) # we see the notification logged by the command nlines = open(self.mlog).readlines() @@ -308,7 +308,7 @@ def test_md_901_040(self, env): conf.add_md(domains) conf.add_vhost(domains) conf.install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' assert env.await_error(domain) assert env.await_file(self.mlog) time.sleep(1) diff --git a/test/modules/md/test_910_cleanups.py b/test/modules/md/test_910_cleanups.py index 1971fda..08578c1 100644 --- a/test/modules/md/test_910_cleanups.py +++ b/test/modules/md/test_910_cleanups.py @@ -19,7 +19,7 @@ def _class_scope(self, env, acme): env.check_acme() env.clear_store() MDConf(env).install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' @pytest.fixture(autouse=True, scope='function') def _method_scope(self, env, request): @@ -45,7 +45,7 @@ def test_md_910_01(self, env): for name in dirs_before: os.makedirs(os.path.join(challenges_dir, name)) - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' # the one we use is still there assert os.path.isdir(os.path.join(challenges_dir, domain)) # and the others are gone diff --git a/test/modules/md/test_920_status.py b/test/modules/md/test_920_status.py index 21e7298..9839729 100644 --- a/test/modules/md/test_920_status.py +++ b/test/modules/md/test_920_status.py @@ -36,7 +36,7 @@ def test_md_920_001(self, env): conf.add_md(domains) conf.add_vhost(domain) conf.install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' assert env.await_completion([domain], restart=False) # we started without a valid certificate, so we expect /.httpd/certificate-status # to not give information about one and - since we waited for the ACME signup @@ -49,7 +49,7 @@ def test_md_920_001(self, env): assert 'sha256-fingerprint' in status['renewal']['cert']['rsa'] # restart and activate # once activated, the staging must be gone and attributes exist for the active cert - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' status = env.get_certificate_status(domain) assert 'renewal' not in status assert 'sha256-fingerprint' in status['rsa'] @@ -64,7 +64,7 @@ def test_md_920_002(self, env): conf.add_md(domains) conf.add_vhost(domain) conf.install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' assert env.await_completion([domain], restart=False) # copy a real certificate from LE over to staging staged_cert = os.path.join(env.store_dir, 'staging', domain, 'pubcert.pem') @@ -87,7 +87,7 @@ def test_md_920_003(self, env): conf.add("MDCertificateStatus off") conf.add_vhost(domain) conf.install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' assert env.await_completion([domain], restart=False) status = env.get_certificate_status(domain) assert not status @@ -100,7 +100,7 @@ def test_md_920_004(self, env): conf.add("MDCertificateStatus off") conf.add_vhost(domain) conf.install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' assert env.await_completion([domain]) status = env.get_md_status("") assert "version" in status @@ -138,7 +138,7 @@ def test_md_920_010(self, env): """) conf.add_md(domains) conf.install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' assert env.await_completion([domain], restart=False, via_domain=env.http_addr, use_https=False) status = env.get_md_status("", via_domain=env.http_addr, use_https=False) @@ -208,7 +208,7 @@ def test_md_920_011(self, env): conf.add("SSLEngine off") conf.end_vhost() conf.install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' status = env.get_md_status(domain, via_domain=env.http_addr, use_https=False) assert status assert 'renewal' not in status @@ -226,7 +226,7 @@ def test_md_920_020(self, env): conf.add_md(domains) conf.add_vhost(domain) conf.install() - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' assert env.await_completion([domain], restart=False) # In the stats JSON, we expect 2 certificates under 'renewal' stat = env.get_md_status(domain) @@ -242,7 +242,7 @@ def test_md_920_020(self, env): assert 'rsa' in status['renewal']['cert'] # restart and activate # once activated, certs are listed in status - assert env.apache_restart() == 0 + assert env.apache_restart() == 0, f'{env.apachectl_stderr}' stat = env.get_md_status(domain) assert 'cert' in stat assert 'valid' in stat['cert'] diff --git a/test/pyhttpd/conf/httpd.conf.template b/test/pyhttpd/conf/httpd.conf.template index 445409b..85b4fe5 100644 --- a/test/pyhttpd/conf/httpd.conf.template +++ b/test/pyhttpd/conf/httpd.conf.template @@ -3,7 +3,7 @@ ServerRoot "${server_dir}" # not in 2.4.x #DefaultRuntimeDir logs -#PidFile httpd.pid +PidFile "${server_dir}/logs/httpd.pid" Include "conf/modules.conf" diff --git a/test/pyhttpd/conf/stop.conf.template b/test/pyhttpd/conf/stop.conf.template index 21bae84..810b4bd 100644 --- a/test/pyhttpd/conf/stop.conf.template +++ b/test/pyhttpd/conf/stop.conf.template @@ -5,6 +5,10 @@ ServerName localhost ServerRoot "${server_dir}" +# not in 2.4.x +#DefaultRuntimeDir logs +PidFile "${server_dir}/logs/httpd.pid" + Include "conf/modules.conf" DocumentRoot "${server_dir}/htdocs" diff --git a/test/pyhttpd/config.ini.in b/test/pyhttpd/config.ini.in index 3f42248..8699a06 100644 --- a/test/pyhttpd/config.ini.in +++ b/test/pyhttpd/config.ini.in @@ -12,7 +12,7 @@ libexecdir = @libexecdir@ apr_bindir = @APR_BINDIR@ apxs = @bindir@/apxs -apachectl = @sbindir@/apachectl +httpd = @HTTPD@ [httpd] version = @HTTPD_VERSION@ @@ -21,6 +21,7 @@ dso_modules = @DSO_MODULES@ mpm_modules = @MPM_MODULES@ [test] +src_dir = @abs_top_srcdir@ gen_dir = @abs_srcdir@/../gen http_port = 5002 https_port = 5001 diff --git a/test/pyhttpd/env.py b/test/pyhttpd/env.py index cbae30c..211e016 100644 --- a/test/pyhttpd/env.py +++ b/test/pyhttpd/env.py @@ -10,7 +10,7 @@ import time from datetime import datetime, timedelta from string import Template -from typing import List, Optional +from typing import List, Optional, Tuple from configparser import ConfigParser, ExtendedInterpolation from urllib.parse import urlparse @@ -72,6 +72,7 @@ def __init__(self, env: 'HttpdTestEnv'): self._source_dirs = [os.path.dirname(inspect.getfile(HttpdTestSetup))] self._modules = HttpdTestSetup.MODULES.copy() self._optional_modules = [] + self._local_modules = [] def add_source_dir(self, source_dir): self._source_dirs.append(source_dir) @@ -82,6 +83,9 @@ def add_modules(self, modules: List[str]): def add_optional_modules(self, modules: List[str]): self._optional_modules.extend(modules) + def add_local_module(self, mod_name: str, mod_path: str): + self._local_modules.append((mod_name, mod_path)) + def make(self): self._make_dirs() self._make_conf() @@ -92,6 +96,7 @@ def make(self): self.add_modules([self.env.ssl_module]) self._make_modules_conf() self._make_htdocs() + self._add_local_modules() self._add_aptest() self.env.clear_curl_headerfiles() @@ -196,6 +201,14 @@ def _add_aptest(self): # load our test module which is not installed fd.write(f"LoadModule aptest_module \"{local_dir}/mod_aptest/.libs/mod_aptest.so\"\n") + def _add_local_modules(self): + if len(self._local_modules): + modules_conf = os.path.join(self.env.server_dir, 'conf/modules.conf') + with open(modules_conf, 'a') as fd: + for mod_name, mod_path in self._local_modules: + mod_path = os.path.join(self.env.src_dir, mod_path) + fd.write(f"LoadModule {mod_name}_module \"{mod_path}\"\n") + class HttpdTestEnv: @@ -233,7 +246,7 @@ def __init__(self, pytestconfig=None): self._bin_dir = self.config.get('global', 'bindir') self._apxs = self.config.get('global', 'apxs') self._prefix = self.config.get('global', 'prefix') - self._apachectl = self.config.get('global', 'apachectl') + self._httpd = self.config.get('global', 'httpd') if HttpdTestEnv.LIBEXEC_DIR is None: HttpdTestEnv.LIBEXEC_DIR = self._libexec_dir = self.get_apxs_var('LIBEXECDIR') self._curl = self.config.get('global', 'curl_bin') @@ -254,14 +267,17 @@ def __init__(self, pytestconfig=None): self._http_tld = self.config.get('test', 'http_tld') self._test_dir = self.config.get('test', 'test_dir') self._clients_dir = os.path.join(os.path.dirname(self._test_dir), 'clients') + self._src_dir = self.config.get('test', 'src_dir') self._gen_dir = self.config.get('test', 'gen_dir') self._server_dir = os.path.join(self._gen_dir, 'apache') self._server_conf_dir = os.path.join(self._server_dir, "conf") self._server_docs_dir = os.path.join(self._server_dir, "htdocs") + self._server_lock_dir = os.path.join(self.server_dir, "locks") self._server_logs_dir = os.path.join(self.server_dir, "logs") + self._server_run_dir = os.path.join(self.server_dir, "run") self._server_access_log = os.path.join(self._server_logs_dir, "access_log") self._error_log = HttpdErrorLog(os.path.join(self._server_logs_dir, "error_log")) - self._apachectl_stderr = None + self._httpd_cmd_stderr = None self._dso_modules = self.config.get('httpd', 'dso_modules').split(' ') self._mpm_modules = self.config.get('httpd', 'mpm_modules').split(' ') @@ -320,6 +336,7 @@ def setup_httpd(self, setup: HttpdTestSetup = None): log_level = "debug" else: log_level = "info" + log_level = "trace2" self._log_interesting = "LogLevel" for name in self._httpd_log_modules: self._log_interesting += f" {name}:{log_level}" @@ -398,6 +415,10 @@ def bin_dir(self) -> str: def gen_dir(self) -> str: return self._gen_dir + @property + def src_dir(self) -> str: + return self._src_dir + @property def test_dir(self) -> str: return self._test_dir @@ -458,7 +479,7 @@ def set_current_test_name(self, val) -> None: @property def apachectl_stderr(self): - return self._apachectl_stderr + return self._httpd_cmd_stderr def add_cert_specs(self, specs: List[CertificateSpec]): self._cert_specs.extend(specs) @@ -535,14 +556,17 @@ def mkpath(self, path): if not os.path.exists(path): return os.makedirs(path) - def run(self, args, stdout_list=False, intext=None, inbytes=None, debug_log=True): + def run(self, args, stdout_list=False, intext=None, inbytes=None, debug_log=True, + run_env=None): + if not run_env: + run_env = os.environ if debug_log: log.debug(f"run: {args}") start = datetime.now() if intext is not None: inbytes = intext.encode() p = subprocess.run(args, stderr=subprocess.PIPE, stdout=subprocess.PIPE, - input=inbytes) + input=inbytes, env=run_env) stdout_as_list = None if stdout_list: try: @@ -592,10 +616,11 @@ def is_live(self, url: str = None, timeout: timedelta = None): timeout = timedelta(seconds=5) try_until = datetime.now() + timeout last_err = "" + r = None while datetime.now() < try_until: # noinspection PyBroadException try: - r = self.curl_get(url, insecure=True) + r = self.curl_get(url, insecure=True, options=['-vvvv']) if r.exit_code == 0: return True time.sleep(.1) @@ -635,49 +660,68 @@ def is_dead(self, url: str = None, timeout: timedelta = None): log.debug(f"Server still responding after {timeout}") return False - def _run_apachectl(self, cmd) -> ExecResult: + def _httpd_cmd(self, cmd) -> ExecResult: conf_file = 'stop.conf' if cmd == 'stop' else 'httpd.conf' - args = [self._apachectl, + env = os.environ.copy() + args = [self._httpd, "-d", self.server_dir, "-f", os.path.join(self._server_dir, f'conf/{conf_file}'), "-k", cmd] - r = self.run(args) - self._apachectl_stderr = r.stderr + r = self.run(args, run_env=env) + self._httpd_cmd_stderr = r.stderr if r.exit_code != 0: log.warning(f"failed: {r}") return r def apache_reload(self): - r = self._run_apachectl("graceful") + r = self._httpd_cmd("graceful") if r.exit_code == 0: timeout = timedelta(seconds=10) - return 0 if self.is_live(self._http_base, timeout=timeout) else -1 + if self.is_live(self._http_base, timeout=timeout): + return 0 + log.error('failed to reload apache') + self._error_log.dump(log) + return -1 return r.exit_code def apache_restart(self): - self.apache_stop() - r = self._run_apachectl("start") + x = self.apache_stop() + if x != 0: + return x + r = self._httpd_cmd("start") if r.exit_code == 0: timeout = timedelta(seconds=10) - return 0 if self.is_live(self._http_base, timeout=timeout) else -1 + if self.is_live(self._http_base, timeout=timeout): + return 0 + log.error('failed to reload apache') + self._error_log.dump(log) + return -1 return r.exit_code def apache_stop(self): - r = self._run_apachectl("stop") + r = self._httpd_cmd("stop") if r.exit_code == 0: timeout = timedelta(seconds=10) - return 0 if self.is_dead(self._http_base, timeout=timeout) else -1 + if self.is_dead(self._http_base, timeout=timeout): + return 0 + log.error('failed to stop apache') + self._error_log.dump(log) + return -1 return r def apache_graceful_stop(self): log.debug("stop apache") - self._run_apachectl("graceful-stop") - return 0 if self.is_dead() else -1 + self._httpd_cmd("graceful-stop") + if self.is_dead(): + return 0 + log.error('failed to gracefully stop apache') + self._error_log.dump(log) + return -1 def apache_fail(self): log.debug("expect apache fail") - self._run_apachectl("stop") - rv = self._run_apachectl("start") + self._httpd_cmd("stop") + rv = self._httpd_cmd("start") if rv == 0: rv = 0 if self.is_dead() else -1 else: diff --git a/test/pyhttpd/log.py b/test/pyhttpd/log.py index 17b0502..b3aeeff 100644 --- a/test/pyhttpd/log.py +++ b/test/pyhttpd/log.py @@ -150,3 +150,7 @@ def scan_recent(self, pattern: re.Pattern, timeout=10): raise TimeoutError(f"pattern not found in error log after {timeout} seconds") time.sleep(.1) return False + + def dump(self, logger): + for line in open(self.path).readlines(): + logger.error(f'httpd: {line}') diff --git a/test/requirements.txt b/test/requirements.txt new file mode 100644 index 0000000..cd6da87 --- /dev/null +++ b/test/requirements.txt @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Stefan Eissing (https://dev-icing.de) +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +pytest +cryptography +filelock +multipart +psutil