mirror of
https://github.com/certbot/certbot.git
synced 2026-06-03 13:59:02 -04:00
* Fully type certbot-ci module * Fix lint, focus lint * Add trailing comma * Remove unused private function * Type properly for future usages * Update certbot-ci/certbot_integration_tests/utils/acme_server.py Co-authored-by: alexzorin <alex@zor.io> * Cleanup files * Fix import * Fix mypy and lint Co-authored-by: alexzorin <alex@zor.io>
51 lines
2.1 KiB
Python
51 lines
2.1 KiB
Python
#!/usr/bin/env python3
|
|
"""Module executing integration tests against certbot snap."""
|
|
import glob
|
|
import os
|
|
import re
|
|
import subprocess
|
|
from typing import Generator
|
|
|
|
import pytest
|
|
|
|
|
|
@pytest.fixture(autouse=True, scope="module")
|
|
def install_certbot_snap(request: pytest.FixtureRequest) -> Generator[None, None, None]:
|
|
"""Fixture ensuring the certbot snap is installed before each test."""
|
|
with pytest.raises(Exception):
|
|
subprocess.check_call(['certbot', '--version'])
|
|
try:
|
|
snap_folder = request.config.getoption("snap_folder")
|
|
snap_arch = request.config.getoption("snap_arch")
|
|
snap_path = glob.glob(os.path.join(snap_folder, 'certbot_*_{0}.snap'.format(snap_arch)))[0]
|
|
subprocess.check_call(['snap', 'install', '--classic', '--dangerous', snap_path])
|
|
subprocess.check_call(['certbot', '--version'])
|
|
yield
|
|
finally:
|
|
subprocess.call(['snap', 'remove', 'certbot'])
|
|
|
|
|
|
def test_dns_plugin_install(dns_snap_path: str) -> None:
|
|
"""
|
|
Test that each DNS plugin Certbot snap can be installed
|
|
and is usable with the Certbot snap.
|
|
"""
|
|
match = re.match(r'^certbot-(dns-\w+)_.*\.snap$', os.path.basename(dns_snap_path))
|
|
assert match
|
|
plugin_name = match.group(1)
|
|
snap_name = 'certbot-{0}'.format(plugin_name)
|
|
assert plugin_name not in subprocess.check_output(['certbot', 'plugins', '--prepare'],
|
|
universal_newlines=True)
|
|
|
|
try:
|
|
subprocess.check_call(['snap', 'install', '--dangerous', dns_snap_path])
|
|
subprocess.check_call(['snap', 'set', 'certbot', 'trust-plugin-with-root=ok'])
|
|
subprocess.check_call(['snap', 'connect', 'certbot:plugin', snap_name])
|
|
|
|
assert plugin_name in subprocess.check_output(['certbot', 'plugins', '--prepare'],
|
|
universal_newlines=True)
|
|
subprocess.check_call(['snap', 'connect', snap_name + ':certbot-metadata',
|
|
'certbot:certbot-metadata'])
|
|
subprocess.check_call(['snap', 'install', '--dangerous', dns_snap_path])
|
|
finally:
|
|
subprocess.call(['snap', 'remove', plugin_name])
|