2016-04-13 19:59:37 -04:00
|
|
|
"""Certbot compatibility test interfaces"""
|
2021-08-12 21:00:33 -04:00
|
|
|
from abc import ABCMeta
|
|
|
|
|
from abc import abstractmethod
|
2021-12-13 20:14:11 -05:00
|
|
|
import argparse
|
|
|
|
|
from typing import cast
|
|
|
|
|
from typing import Set
|
2015-07-14 21:04:43 -04:00
|
|
|
|
2021-08-12 21:00:33 -04:00
|
|
|
from certbot import interfaces
|
2021-12-13 20:14:11 -05:00
|
|
|
from certbot.configuration import NamespaceConfig
|
2015-07-14 21:04:43 -04:00
|
|
|
|
2015-07-22 21:31:26 -04:00
|
|
|
|
2021-08-12 21:00:33 -04:00
|
|
|
class PluginProxy(interfaces.Plugin, metaclass=ABCMeta):
|
2016-04-13 19:59:37 -04:00
|
|
|
"""Wraps a Certbot plugin"""
|
2018-05-14 12:33:30 -04:00
|
|
|
|
2021-08-12 21:00:33 -04:00
|
|
|
http_port: int = NotImplemented
|
|
|
|
|
"""The port to connect to on localhost for HTTP traffic"""
|
2015-08-03 14:38:22 -04:00
|
|
|
|
2021-08-12 21:00:33 -04:00
|
|
|
https_port: int = NotImplemented
|
|
|
|
|
"""The port to connect to on localhost for HTTPS traffic"""
|
2015-08-03 14:38:22 -04:00
|
|
|
|
2021-08-12 21:00:33 -04:00
|
|
|
@classmethod
|
|
|
|
|
@abstractmethod
|
2021-12-13 20:14:11 -05:00
|
|
|
def add_parser_arguments(cls, parser: argparse.ArgumentParser) -> None:
|
2015-07-14 21:04:43 -04:00
|
|
|
"""Adds command line arguments needed by the parser"""
|
|
|
|
|
|
2021-08-12 21:00:33 -04:00
|
|
|
@abstractmethod
|
2021-12-13 20:14:11 -05:00
|
|
|
def __init__(self, args: argparse.Namespace) -> None:
|
2015-07-14 21:04:43 -04:00
|
|
|
"""Initializes the plugin with the given command line args"""
|
2021-12-13 20:14:11 -05:00
|
|
|
super().__init__(cast(NamespaceConfig, args), 'proxy')
|
2015-07-14 21:04:43 -04:00
|
|
|
|
2021-08-12 21:00:33 -04:00
|
|
|
@abstractmethod
|
2021-12-13 20:14:11 -05:00
|
|
|
def cleanup_from_tests(self) -> None:
|
2015-07-14 21:04:43 -04:00
|
|
|
"""Performs any necessary cleanup from running plugin tests.
|
|
|
|
|
|
2015-09-05 22:35:34 -04:00
|
|
|
This is guaranteed to be called before the program exits.
|
2015-07-14 21:04:43 -04:00
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
2021-08-12 21:00:33 -04:00
|
|
|
@abstractmethod
|
2021-12-13 20:14:11 -05:00
|
|
|
def has_more_configs(self) -> bool:
|
2015-07-14 21:04:43 -04:00
|
|
|
"""Returns True if there are more configs to test"""
|
|
|
|
|
|
2021-08-12 21:00:33 -04:00
|
|
|
@abstractmethod
|
2021-12-13 20:14:11 -05:00
|
|
|
def load_config(self) -> str:
|
2015-07-17 19:21:17 -04:00
|
|
|
"""Loads the next config and returns its name"""
|
2015-07-14 21:04:43 -04:00
|
|
|
|
2021-08-12 21:00:33 -04:00
|
|
|
@abstractmethod
|
2021-12-13 20:14:11 -05:00
|
|
|
def get_testable_domain_names(self) -> Set[str]:
|
2015-07-17 19:21:17 -04:00
|
|
|
"""Returns the domain names that can be used in testing"""
|
2015-07-14 21:04:43 -04:00
|
|
|
|
|
|
|
|
|
2021-08-12 21:00:33 -04:00
|
|
|
class AuthenticatorProxy(PluginProxy, interfaces.Authenticator, metaclass=ABCMeta):
|
2016-04-13 19:59:37 -04:00
|
|
|
"""Wraps a Certbot authenticator"""
|
2015-07-14 21:04:43 -04:00
|
|
|
|
|
|
|
|
|
2021-08-12 21:00:33 -04:00
|
|
|
class InstallerProxy(PluginProxy, interfaces.Installer, metaclass=ABCMeta):
|
2016-04-13 19:59:37 -04:00
|
|
|
"""Wraps a Certbot installer"""
|
2015-07-14 21:04:43 -04:00
|
|
|
|
2021-08-12 21:00:33 -04:00
|
|
|
@abstractmethod
|
2021-12-13 20:14:11 -05:00
|
|
|
def get_all_names_answer(self) -> Set[str]:
|
2015-07-17 19:21:17 -04:00
|
|
|
"""Returns all names that should be found by the installer"""
|
|
|
|
|
|
2015-07-14 21:04:43 -04:00
|
|
|
|
2021-08-12 21:00:33 -04:00
|
|
|
class ConfiguratorProxy(AuthenticatorProxy, InstallerProxy, metaclass=ABCMeta):
|
2016-04-13 19:59:37 -04:00
|
|
|
"""Wraps a Certbot configurator"""
|
2021-08-12 21:00:33 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
class Configurator(interfaces.Installer, interfaces.Authenticator, metaclass=ABCMeta):
|
|
|
|
|
"""Represents a plugin that has both Installer and Authenticator capabilities"""
|