summaryrefslogtreecommitdiffstats
path: root/tests/test_acme_dns_tiny.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_acme_dns_tiny.py')
-rw-r--r--tests/test_acme_dns_tiny.py39
1 files changed, 19 insertions, 20 deletions
diff --git a/tests/test_acme_dns_tiny.py b/tests/test_acme_dns_tiny.py
index 5a4a479..bfa8d4a 100644
--- a/tests/test_acme_dns_tiny.py
+++ b/tests/test_acme_dns_tiny.py
@@ -1,6 +1,3 @@
-#!python3
-
-
import contextlib
import logging
import os
@@ -11,14 +8,13 @@ import time
import pytest
-
# append cwd to module importable paths (pytest-3 should be executed from main
# directory).
sys.path.append(os.path.realpath("."))
import acme_dns_tiny
-
acme_dns_tiny.log_configure = False
+log = logging.getLogger(__name__)
ACME_STAGING_DIRECTORY = \
@@ -44,16 +40,18 @@ original_sreq_method = acme_dns_tiny.ACME.sreq
nonce_expiration_sreq_wrapper_counter_max = 3
-nonce_expiration_sreq_wrapper_counter = nonce_expiration_sreq_wrapper_counter_max
+nonce_expiration_sreq_wrapper_counter = \
+ nonce_expiration_sreq_wrapper_counter_max
def nonce_expiration_sreq_wrapper(*args, **kwargs):
global nonce_expiration_sreq_wrapper_counter
nonce_expiration_sreq_wrapper_counter -= 1
if nonce_expiration_sreq_wrapper_counter <= 0:
- nonce_expiration_sreq_wrapper_counter = nonce_expiration_sreq_wrapper_counter_max
+ nonce_expiration_sreq_wrapper_counter \
+ = nonce_expiration_sreq_wrapper_counter_max
wait = 30
- logging.info('waiting %dmin for nonce expiration test', wait)
+ log.info('waiting %dmin for nonce expiration test', wait)
for i in range(wait, 0, -1):
- logging.info('%d min left', i)
+ log.info('%d min left', i)
time.sleep(60)
acme_dns_tiny.ACME.sreq = original_sreq_method # reset original method
return original_sreq_method(*args, **kwargs)
@@ -187,7 +185,7 @@ def main_args(tmpdir_factory, keysdef, request, subj_fixture):
domain_key = keysdef['domain_key_path'](tmpdir)
path = str(tmpdir.join(name))
with tempfile.NamedTemporaryFile('w', encoding='utf8') as conf, \
- open('/etc/ssl/openssl.cnf', 'r', encoding='utf8') as orig:
+ open('/etc/ssl/openssl.cnf', encoding='utf8') as orig:
conf.write(orig.read())
conf.write(f'\n[SAN]\nsubjectAltName={subj_fixture["san"]}\n')
conf.flush()
@@ -215,7 +213,8 @@ def test_sanity_env():
def test_sanity_command():
'check ssh access is correctly working before getting further'
- subprocess.run([SCRIPT, 'add', f'_acme-challenge.{DOMAIN}.', 'dummy'])
+ subprocess.run([SCRIPT, 'add', f'_acme-challenge.{DOMAIN}.', 'dummy'],
+ check=True)
def assert_cert(capsys, args, keysdef):
@@ -223,14 +222,14 @@ def assert_cert(capsys, args, keysdef):
#assert not captured.err
#certlist = captured.out.split()
- logging.debug('captured stdout %s', captured.out)
- logging.debug('captured stderr %s', captured.err)
+ log.debug('captured stdout %s', captured.out)
+ log.debug('captured stderr %s', captured.err)
# Subscriber certificates with RSA public keys are issued from our RSA
# intermediates, which are issued only from our RSA root ISRG Root X1
- # (i.e. they are not cross-signed). Therefore, all RSA subscriber certificates
- # have only a single chain available. (since 2025-06-11, see here for more
- # information https://letsencrypt.org/certificates/).
+ # (i.e. they are not cross-signed). Therefore, all RSA subscriber
+ # certificates have only a single chain available. (since 2025-06-11, see
+ # here for more information https://letsencrypt.org/certificates/).
if (
args['--separator'] is None
or (
@@ -258,19 +257,19 @@ def assert_cert(capsys, args, keysdef):
def module_main_caller(*, capsys, args, expectation, do_expire_nonce, keysdef):
- logging.info(f'module_main_caller({args}, {expectation})')
+ log.info(f'module_main_caller({args}, {expectation})')
- logging.debug('before call to acme_dns_tiny.main()')
+ log.debug('before call to acme_dns_tiny.main()')
with expectation:
acme_dns_tiny.ACME.sreq = original_sreq_method
if do_expire_nonce:
- logging.info('doing expire nonce test')
+ log.info('doing expire nonce test')
acme_dns_tiny.ACME.sreq = nonce_expiration_sreq_wrapper
acme_dns_tiny.main(args)
# check_cert is under the expectation context manager since if
# acme_dns_tiny.main() raises, following statement must not be run.
assert_cert(capsys, args, keysdef)
- logging.debug('after call to acme_dns_tiny.main()')
+ log.debug('after call to acme_dns_tiny.main()')
def test_main(main_args, capsys):