certbot/certbot-compatibility-test/certbot_compatibility_test/interfaces.py

66 lines
2 KiB
Python
Raw Permalink Normal View History

"""Certbot compatibility test interfaces"""
from abc import ABCMeta
from abc import abstractmethod
import argparse
from typing import cast
from typing import Set
2015-07-14 21:04:43 -04:00
from certbot import interfaces
from certbot.configuration import NamespaceConfig
2015-07-14 21:04:43 -04:00
2015-07-22 21:31:26 -04:00
class PluginProxy(interfaces.Plugin, metaclass=ABCMeta):
"""Wraps a Certbot plugin"""
http_port: int = NotImplemented
"""The port to connect to on localhost for HTTP traffic"""
2015-08-03 14:38:22 -04:00
https_port: int = NotImplemented
"""The port to connect to on localhost for HTTPS traffic"""
2015-08-03 14:38:22 -04:00
@classmethod
@abstractmethod
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"""
@abstractmethod
def __init__(self, args: argparse.Namespace) -> None:
2015-07-14 21:04:43 -04:00
"""Initializes the plugin with the given command line args"""
super().__init__(cast(NamespaceConfig, args), 'proxy')
2015-07-14 21:04:43 -04:00
@abstractmethod
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
"""
@abstractmethod
def has_more_configs(self) -> bool:
2015-07-14 21:04:43 -04:00
"""Returns True if there are more configs to test"""
@abstractmethod
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
@abstractmethod
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
class AuthenticatorProxy(PluginProxy, interfaces.Authenticator, metaclass=ABCMeta):
"""Wraps a Certbot authenticator"""
2015-07-14 21:04:43 -04:00
class InstallerProxy(PluginProxy, interfaces.Installer, metaclass=ABCMeta):
"""Wraps a Certbot installer"""
2015-07-14 21:04:43 -04:00
@abstractmethod
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
class ConfiguratorProxy(AuthenticatorProxy, InstallerProxy, metaclass=ABCMeta):
"""Wraps a Certbot configurator"""