Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/certbot/certbot.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrad Warren <bmw@users.noreply.github.com>2021-05-31 10:01:01 +0300
committerGitHub <noreply@github.com>2021-05-31 10:01:01 +0300
commit492b578662f10d9c33b9fc71bf5ee9b48ef2e279 (patch)
tree3d1972dd4d46106492b8cdab3d2d559903e1a293 /certbot-ci
parente946479b9facf4818c620d8846807a3aab0a0d8e (diff)
Update coverage and pytest (#8875)
* unpin pytest and update pinnings * ignore external mock warnings * fix assertion * fix test_revoke_mutual_exclusive_flags * fix output count * capture stdout and stderr separately * undouble counts * rename variable * don't use capture_output * fix leaky test * update coverage
Diffstat (limited to 'certbot-ci')
-rw-r--r--certbot-ci/certbot_integration_tests/certbot_tests/context.py2
-rw-r--r--certbot-ci/certbot_integration_tests/certbot_tests/test_main.py40
-rwxr-xr-xcertbot-ci/certbot_integration_tests/utils/certbot_call.py14
3 files changed, 31 insertions, 25 deletions
diff --git a/certbot-ci/certbot_integration_tests/certbot_tests/context.py b/certbot-ci/certbot_integration_tests/certbot_tests/context.py
index 9af1bc15c..c86a06754 100644
--- a/certbot-ci/certbot_integration_tests/certbot_tests/context.py
+++ b/certbot-ci/certbot_integration_tests/certbot_tests/context.py
@@ -61,7 +61,7 @@ class IntegrationTestsContext:
Execute certbot with given args, not renewing certificates by default.
:param args: args to pass to certbot
:param force_renew: set to False to not renew by default
- :return: output of certbot execution
+ :return: stdout and stderr from certbot execution
"""
command = ['--authenticator', 'standalone', '--installer', 'null']
command.extend(args)
diff --git a/certbot-ci/certbot_integration_tests/certbot_tests/test_main.py b/certbot-ci/certbot_integration_tests/certbot_tests/test_main.py
index c9fa5ff65..965e4b6d8 100644
--- a/certbot-ci/certbot_integration_tests/certbot_tests/test_main.py
+++ b/certbot-ci/certbot_integration_tests/certbot_tests/test_main.py
@@ -78,9 +78,9 @@ def test_registration_override(context):
def test_prepare_plugins(context):
"""Test that plugins are correctly instantiated and displayed."""
- output = context.certbot(['plugins', '--init', '--prepare'])
+ stdout, _ = context.certbot(['plugins', '--init', '--prepare'])
- assert 'webroot' in output
+ assert 'webroot' in stdout
def test_http_01(context):
@@ -407,9 +407,9 @@ def test_invalid_domain_with_dns_challenge(context):
'--manual-cleanup-hook', context.manual_dns_cleanup_hook
])
- output = context.certbot(['certificates'])
+ stdout, _ = context.certbot(['certificates'])
- assert context.get_domain('fail-dns1') not in output
+ assert context.get_domain('fail-dns1') not in stdout
def test_reuse_key(context):
@@ -614,11 +614,11 @@ def test_revoke_and_unregister(context):
context.certbot(['unregister'])
- output = context.certbot(['certificates'])
+ stdout, _ = context.certbot(['certificates'])
- assert cert1 not in output
- assert cert2 not in output
- assert cert3 in output
+ assert cert1 not in stdout
+ assert cert2 not in stdout
+ assert cert3 in stdout
def test_revoke_mutual_exclusive_flags(context):
@@ -630,7 +630,7 @@ def test_revoke_mutual_exclusive_flags(context):
'revoke', '--cert-name', cert,
'--cert-path', join(context.config_dir, 'live', cert, 'fullchain.pem')
])
- assert 'Exactly one of --cert-path or --cert-name must be specified' in error.out
+ assert 'Exactly one of --cert-path or --cert-name must be specified' in error.value.stderr
def test_revoke_multiple_lineages(context):
@@ -685,12 +685,12 @@ def test_wildcard_certificates(context):
def test_ocsp_status_stale(context):
"""Test retrieval of OCSP statuses for staled config"""
sample_data_path = misc.load_sample_data_path(context.workspace)
- output = context.certbot(['certificates', '--config-dir', sample_data_path])
+ stdout, _ = context.certbot(['certificates', '--config-dir', sample_data_path])
- assert output.count('TEST_CERT') == 2, ('Did not find two test certs as expected ({0})'
- .format(output.count('TEST_CERT')))
- assert output.count('EXPIRED') == 2, ('Did not find two expired certs as expected ({0})'
- .format(output.count('EXPIRED')))
+ assert stdout.count('TEST_CERT') == 2, ('Did not find two test certs as expected ({0})'
+ .format(stdout.count('TEST_CERT')))
+ assert stdout.count('EXPIRED') == 2, ('Did not find two expired certs as expected ({0})'
+ .format(stdout.count('EXPIRED')))
def test_ocsp_status_live(context):
@@ -699,20 +699,20 @@ def test_ocsp_status_live(context):
# OSCP 1: Check live certificate OCSP status (VALID)
context.certbot(['--domains', cert])
- output = context.certbot(['certificates'])
+ stdout, _ = context.certbot(['certificates'])
- assert output.count('VALID') == 1, 'Expected {0} to be VALID'.format(cert)
- assert output.count('EXPIRED') == 0, 'Did not expect {0} to be EXPIRED'.format(cert)
+ assert stdout.count('VALID') == 1, 'Expected {0} to be VALID'.format(cert)
+ assert stdout.count('EXPIRED') == 0, 'Did not expect {0} to be EXPIRED'.format(cert)
# OSCP 2: Check live certificate OCSP status (REVOKED)
context.certbot(['revoke', '--cert-name', cert, '--no-delete-after-revoke'])
# Sometimes in oldest tests (using openssl binary and not cryptography), the OCSP status is
# not seen immediately by Certbot as invalid. Waiting few seconds solves this transient issue.
time.sleep(5)
- output = context.certbot(['certificates'])
+ stdout, _ = context.certbot(['certificates'])
- assert output.count('INVALID') == 1, 'Expected {0} to be INVALID'.format(cert)
- assert output.count('REVOKED') == 1, 'Expected {0} to be REVOKED'.format(cert)
+ assert stdout.count('INVALID') == 1, 'Expected {0} to be INVALID'.format(cert)
+ assert stdout.count('REVOKED') == 1, 'Expected {0} to be REVOKED'.format(cert)
def test_ocsp_renew(context):
diff --git a/certbot-ci/certbot_integration_tests/utils/certbot_call.py b/certbot-ci/certbot_integration_tests/utils/certbot_call.py
index 965ab6881..570a02bcb 100755
--- a/certbot-ci/certbot_integration_tests/utils/certbot_call.py
+++ b/certbot-ci/certbot_integration_tests/utils/certbot_call.py
@@ -17,7 +17,7 @@ def certbot_test(certbot_args, directory_url, http_01_port, tls_alpn_01_port,
Invoke the certbot executable available in PATH in a test context for the given args.
The test context consists in running certbot in debug mode, with various flags suitable
for tests (eg. no ssl check, customizable ACME challenge ports and config directory ...).
- This command captures stdout and returns it to the caller.
+ This command captures both stdout and stderr and returns it to the caller.
:param list certbot_args: the arguments to pass to the certbot executable
:param str directory_url: URL of the ACME directory server to use
:param int http_01_port: port for the HTTP-01 challenges
@@ -25,13 +25,19 @@ def certbot_test(certbot_args, directory_url, http_01_port, tls_alpn_01_port,
:param str config_dir: certbot configuration directory to use
:param str workspace: certbot current directory to use
:param bool force_renew: set False to not force renew existing certificates (default: True)
- :return: stdout as string
- :rtype: str
+ :return: stdout and stderr as strings
+ :rtype: `tuple` of `str`
"""
command, env = _prepare_args_env(certbot_args, directory_url, http_01_port, tls_alpn_01_port,
config_dir, workspace, force_renew)
- return subprocess.check_output(command, universal_newlines=True, cwd=workspace, env=env)
+ proc = subprocess.run(command, stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE, check=False, universal_newlines=True,
+ cwd=workspace, env=env)
+ print('--> Certbot log output was:')
+ print(proc.stderr)
+ proc.check_returncode()
+ return proc.stdout, proc.stderr
def _prepare_environ(workspace):