mirror of
https://github.com/certbot/certbot.git
synced 2026-06-04 06:15:36 -04:00
s/letsencrypt/certbot
This commit is contained in:
parent
4af2b3e9e8
commit
3961b70deb
102 changed files with 734 additions and 736 deletions
0
letsencrypt/.gitignore → certbot/.gitignore
vendored
0
letsencrypt/.gitignore → certbot/.gitignore
vendored
|
|
@ -14,9 +14,9 @@ from acme import fields as acme_fields
|
|||
from acme import jose
|
||||
from acme import messages
|
||||
|
||||
from letsencrypt import errors
|
||||
from letsencrypt import interfaces
|
||||
from letsencrypt import le_util
|
||||
from certbot import errors
|
||||
from certbot import interfaces
|
||||
from certbot import le_util
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
|
@ -6,7 +6,7 @@ and :class:`.ChallengeBody` (denoted by ``challb``)::
|
|||
|
||||
from acme import challenges
|
||||
from acme import messages
|
||||
from letsencrypt import achallenges
|
||||
from certbot import achallenges
|
||||
|
||||
chall = challenges.DNS(token='foo')
|
||||
challb = messages.ChallengeBody(chall=chall)
|
||||
|
|
@ -8,10 +8,10 @@ import zope.component
|
|||
from acme import challenges
|
||||
from acme import messages
|
||||
|
||||
from letsencrypt import achallenges
|
||||
from letsencrypt import errors
|
||||
from letsencrypt import error_handler
|
||||
from letsencrypt import interfaces
|
||||
from certbot import achallenges
|
||||
from certbot import errors
|
||||
from certbot import error_handler
|
||||
from certbot import interfaces
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
|
@ -22,17 +22,17 @@ class AuthHandler(object):
|
|||
|
||||
:ivar auth: Authenticator capable of solving
|
||||
:class:`~acme.challenges.Challenge` types
|
||||
:type auth: :class:`letsencrypt.interfaces.IAuthenticator`
|
||||
:type auth: :class:`certbot.interfaces.IAuthenticator`
|
||||
|
||||
:ivar acme.client.Client acme: ACME client API.
|
||||
|
||||
:ivar account: Client's Account
|
||||
:type account: :class:`letsencrypt.account.Account`
|
||||
:type account: :class:`certbot.account.Account`
|
||||
|
||||
:ivar dict authzr: ACME Authorization Resource dict where keys are domains
|
||||
and values are :class:`acme.messages.AuthorizationResource`
|
||||
:ivar list achalls: DV challenges in the form of
|
||||
:class:`letsencrypt.achallenges.AnnotatedChallenge`
|
||||
:class:`certbot.achallenges.AnnotatedChallenge`
|
||||
|
||||
"""
|
||||
def __init__(self, auth, acme, account):
|
||||
|
|
@ -287,7 +287,7 @@ class AuthHandler(object):
|
|||
:param list path: List of indices from `challenges`.
|
||||
|
||||
:returns: achalls, list of challenge type
|
||||
:class:`letsencrypt.achallenges.Indexed`
|
||||
:class:`certbot.achallenges.Indexed`
|
||||
:rtype: list
|
||||
|
||||
:raises .errors.Error: if challenge type is not recognized
|
||||
|
|
@ -310,7 +310,7 @@ def challb_to_achall(challb, account_key, domain):
|
|||
:param str domain: Domain of the challb
|
||||
|
||||
:returns: Appropriate AnnotatedChallenge
|
||||
:rtype: :class:`letsencrypt.achallenges.AnnotatedChallenge`
|
||||
:rtype: :class:`certbot.achallenges.AnnotatedChallenge`
|
||||
|
||||
"""
|
||||
chall = challb.chall
|
||||
|
|
@ -347,7 +347,7 @@ def gen_challenge_path(challbs, preferences, combinations):
|
|||
:returns: tuple of indices from ``challenges``.
|
||||
:rtype: tuple
|
||||
|
||||
:raises letsencrypt.errors.AuthorizationError: If a
|
||||
:raises certbot.errors.AuthorizationError: If a
|
||||
path cannot be created that satisfies the CA given the preferences and
|
||||
combinations.
|
||||
|
||||
|
|
@ -463,7 +463,7 @@ def _report_failed_challs(failed_achalls):
|
|||
"""Notifies the user about failed challenges.
|
||||
|
||||
:param set failed_achalls: A set of failed
|
||||
:class:`letsencrypt.achallenges.AnnotatedChallenge`.
|
||||
:class:`certbot.achallenges.AnnotatedChallenge`.
|
||||
|
||||
"""
|
||||
problems = dict()
|
||||
|
|
@ -481,7 +481,7 @@ def _generate_failed_chall_msg(failed_achalls):
|
|||
"""Creates a user friendly error message about failed challenges.
|
||||
|
||||
:param list failed_achalls: A list of failed
|
||||
:class:`letsencrypt.achallenges.AnnotatedChallenge` with the same error
|
||||
:class:`certbot.achallenges.AnnotatedChallenge` with the same error
|
||||
type.
|
||||
|
||||
:returns: A formatted error message for the client.
|
||||
|
|
@ -12,17 +12,17 @@ import configargparse
|
|||
import OpenSSL
|
||||
import six
|
||||
|
||||
import letsencrypt
|
||||
import certbot
|
||||
|
||||
from letsencrypt import constants
|
||||
from letsencrypt import crypto_util
|
||||
from letsencrypt import errors
|
||||
from letsencrypt import hooks
|
||||
from letsencrypt import interfaces
|
||||
from letsencrypt import le_util
|
||||
from certbot import constants
|
||||
from certbot import crypto_util
|
||||
from certbot import errors
|
||||
from certbot import hooks
|
||||
from certbot import interfaces
|
||||
from certbot import le_util
|
||||
|
||||
from letsencrypt.plugins import disco as plugins_disco
|
||||
import letsencrypt.plugins.selection as plugin_selection
|
||||
from certbot.plugins import disco as plugins_disco
|
||||
import certbot.plugins.selection as plugin_selection
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
|
@ -31,14 +31,14 @@ helpful_parser = None
|
|||
|
||||
# For help strings, figure out how the user ran us.
|
||||
# When invoked from letsencrypt-auto, sys.argv[0] is something like:
|
||||
# "/home/user/.local/share/letsencrypt/bin/letsencrypt"
|
||||
# "/home/user/.local/share/certbot/bin/certbot"
|
||||
# Note that this won't work if the user set VENV_PATH or XDG_DATA_HOME before
|
||||
# running letsencrypt-auto (and sudo stops us from seeing if they did), so it
|
||||
# should only be used for purposes where inability to detect letsencrypt-auto
|
||||
# fails safely
|
||||
|
||||
fragment = os.path.join(".local", "share", "letsencrypt")
|
||||
cli_command = "letsencrypt-auto" if fragment in sys.argv[0] else "letsencrypt"
|
||||
fragment = os.path.join(".local", "share", "certbot")
|
||||
cli_command = "letsencrypt-auto" if fragment in sys.argv[0] else "certbot"
|
||||
|
||||
# Argparse's help formatting has a lot of unhelpful peculiarities, so we want
|
||||
# to replace as much of it as we can...
|
||||
|
|
@ -63,7 +63,7 @@ the cert. Major SUBCOMMANDS are:
|
|||
|
||||
""".format(cli_command)
|
||||
|
||||
# This is the short help for letsencrypt --help, where we disable argparse
|
||||
# This is the short help for certbot --help, where we disable argparse
|
||||
# altogether
|
||||
USAGE = SHORT_USAGE + """Choice of server plugins for obtaining and installing cert:
|
||||
|
||||
|
|
@ -256,12 +256,12 @@ class HelpfulArgumentParser(object):
|
|||
|
||||
This class wraps argparse, adding the ability to make --help less
|
||||
verbose, and request help on specific subcategories at a time, eg
|
||||
'letsencrypt --help security' for security options.
|
||||
'certbot --help security' for security options.
|
||||
|
||||
"""
|
||||
|
||||
def __init__(self, args, plugins, detect_defaults=False):
|
||||
from letsencrypt import main
|
||||
from certbot import main
|
||||
self.VERBS = {"auth": main.obtain_cert, "certonly": main.obtain_cert,
|
||||
"config_changes": main.config_changes, "run": main.run,
|
||||
"install": main.install, "plugins": main.plugins_cmd,
|
||||
|
|
@ -616,7 +616,7 @@ def prepare_and_parse_args(plugins, args, detect_defaults=False):
|
|||
"always expand and replace it with the additional names.")
|
||||
helpful.add(
|
||||
"automation", "--version", action="version",
|
||||
version="%(prog)s {0}".format(letsencrypt.__version__),
|
||||
version="%(prog)s {0}".format(certbot.__version__),
|
||||
help="show program's version number and exit")
|
||||
helpful.add(
|
||||
"automation", "--force-renewal", "--renew-by-default",
|
||||
|
|
@ -11,23 +11,23 @@ from acme import client as acme_client
|
|||
from acme import jose
|
||||
from acme import messages
|
||||
|
||||
import letsencrypt
|
||||
import certbot
|
||||
|
||||
from letsencrypt import account
|
||||
from letsencrypt import auth_handler
|
||||
from letsencrypt import configuration
|
||||
from letsencrypt import constants
|
||||
from letsencrypt import crypto_util
|
||||
from letsencrypt import errors
|
||||
from letsencrypt import error_handler
|
||||
from letsencrypt import interfaces
|
||||
from letsencrypt import le_util
|
||||
from letsencrypt import reverter
|
||||
from letsencrypt import storage
|
||||
from certbot import account
|
||||
from certbot import auth_handler
|
||||
from certbot import configuration
|
||||
from certbot import constants
|
||||
from certbot import crypto_util
|
||||
from certbot import errors
|
||||
from certbot import error_handler
|
||||
from certbot import interfaces
|
||||
from certbot import le_util
|
||||
from certbot import reverter
|
||||
from certbot import storage
|
||||
|
||||
from letsencrypt.display import ops as display_ops
|
||||
from letsencrypt.display import enhancements
|
||||
from letsencrypt.plugins import selection as plugin_selection
|
||||
from certbot.display import ops as display_ops
|
||||
from certbot.display import enhancements
|
||||
from certbot.plugins import selection as plugin_selection
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
|
@ -52,7 +52,7 @@ def _determine_user_agent(config):
|
|||
|
||||
if config.user_agent is None:
|
||||
ua = "LetsEncryptPythonClient/{0} ({1}) Authenticator/{2} Installer/{3}"
|
||||
ua = ua.format(letsencrypt.__version__, " ".join(le_util.get_os_info()),
|
||||
ua = ua.format(certbot.__version__, " ".join(le_util.get_os_info()),
|
||||
config.authenticator, config.installer)
|
||||
else:
|
||||
ua = config.user_agent
|
||||
|
|
@ -87,7 +87,7 @@ def register(config, account_storage, tos_cb=None):
|
|||
None``. This argument is optional, if not supplied it will
|
||||
default to automatic acceptance!
|
||||
|
||||
:raises letsencrypt.errors.Error: In case of any client problems, in
|
||||
:raises certbot.errors.Error: In case of any client problems, in
|
||||
particular registration failure, or unaccepted Terms of Service.
|
||||
:raises acme.errors.Error: In case of any protocol problems.
|
||||
|
||||
|
|
@ -266,7 +266,7 @@ class Client(object):
|
|||
:param list domains: Domains to request.
|
||||
:param plugins: A PluginsFactory object.
|
||||
|
||||
:returns: A new :class:`letsencrypt.storage.RenewableCert` instance
|
||||
:returns: A new :class:`certbot.storage.RenewableCert` instance
|
||||
referred to the enrolled cert lineage, False if the cert could not
|
||||
be obtained, or None if doing a successful dry run.
|
||||
|
||||
|
|
@ -492,7 +492,7 @@ def validate_key_csr(privkey, csr=None):
|
|||
If csr is left as None, only the key will be validated.
|
||||
|
||||
:param privkey: Key associated with CSR
|
||||
:type privkey: :class:`letsencrypt.le_util.Key`
|
||||
:type privkey: :class:`certbot.le_util.Key`
|
||||
|
||||
:param .le_util.CSR csr: CSR
|
||||
|
||||
|
|
@ -532,7 +532,7 @@ def rollback(default_installer, checkpoints, config, plugins):
|
|||
:param int checkpoints: Number of checkpoints to revert.
|
||||
|
||||
:param config: Configuration.
|
||||
:type config: :class:`letsencrypt.interfaces.IConfig`
|
||||
:type config: :class:`certbot.interfaces.IConfig`
|
||||
|
||||
"""
|
||||
# Misconfigurations are only a slight problems... allow the user to rollback
|
||||
|
|
@ -554,7 +554,7 @@ def view_config_changes(config, num=None):
|
|||
.. note:: This assumes that the installation is using a Reverter object.
|
||||
|
||||
:param config: Configuration.
|
||||
:type config: :class:`letsencrypt.interfaces.IConfig`
|
||||
:type config: :class:`certbot.interfaces.IConfig`
|
||||
|
||||
"""
|
||||
rev = reverter.Reverter(config)
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
import logging
|
||||
import sys
|
||||
|
||||
from letsencrypt import le_util
|
||||
from certbot import le_util
|
||||
|
||||
|
||||
class StreamHandler(logging.StreamHandler):
|
||||
|
|
@ -5,10 +5,10 @@ import os
|
|||
from six.moves.urllib import parse # pylint: disable=import-error
|
||||
import zope.interface
|
||||
|
||||
from letsencrypt import constants
|
||||
from letsencrypt import errors
|
||||
from letsencrypt import interfaces
|
||||
from letsencrypt import le_util
|
||||
from certbot import constants
|
||||
from certbot import errors
|
||||
from certbot import interfaces
|
||||
from certbot import le_util
|
||||
|
||||
|
||||
@zope.interface.implementer(interfaces.IConfig)
|
||||
|
|
@ -16,10 +16,10 @@ class NamespaceConfig(object):
|
|||
"""Configuration wrapper around :class:`argparse.Namespace`.
|
||||
|
||||
For more documentation, including available attributes, please see
|
||||
:class:`letsencrypt.interfaces.IConfig`. However, note that
|
||||
:class:`certbot.interfaces.IConfig`. However, note that
|
||||
the following attributes are dynamically resolved using
|
||||
:attr:`~letsencrypt.interfaces.IConfig.work_dir` and relative
|
||||
paths defined in :py:mod:`letsencrypt.constants`:
|
||||
:attr:`~certbot.interfaces.IConfig.work_dir` and relative
|
||||
paths defined in :py:mod:`certbot.constants`:
|
||||
|
||||
- `accounts_dir`
|
||||
- `csr_dir`
|
||||
|
|
@ -119,7 +119,7 @@ def check_config_sanity(config):
|
|||
requirements are not met.
|
||||
|
||||
:param config: IConfig instance holding user configuration
|
||||
:type args: :class:`letsencrypt.interfaces.IConfig`
|
||||
:type args: :class:`certbot.interfaces.IConfig`
|
||||
|
||||
"""
|
||||
# Port check
|
||||
|
|
@ -5,7 +5,7 @@ import logging
|
|||
from acme import challenges
|
||||
|
||||
|
||||
SETUPTOOLS_PLUGINS_ENTRY_POINT = "letsencrypt.plugins"
|
||||
SETUPTOOLS_PLUGINS_ENTRY_POINT = "certbot.plugins"
|
||||
"""Setuptools entry point group name for plugins."""
|
||||
|
||||
CLI_DEFAULTS = dict(
|
||||
|
|
@ -45,7 +45,7 @@ RENEWER_DEFAULTS = dict(
|
|||
|
||||
|
||||
ENHANCEMENTS = ["redirect", "http-header", "ocsp-stapling", "spdy"]
|
||||
"""List of possible :class:`letsencrypt.interfaces.IInstaller`
|
||||
"""List of possible :class:`certbot.interfaces.IInstaller`
|
||||
enhancements.
|
||||
|
||||
List of expected options parameters:
|
||||
|
|
@ -14,16 +14,16 @@ import zope.component
|
|||
from acme import crypto_util as acme_crypto_util
|
||||
from acme import jose
|
||||
|
||||
from letsencrypt import errors
|
||||
from letsencrypt import interfaces
|
||||
from letsencrypt import le_util
|
||||
from certbot import errors
|
||||
from certbot import interfaces
|
||||
from certbot import le_util
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
# High level functions
|
||||
def init_save_key(key_size, key_dir, keyname="key-letsencrypt.pem"):
|
||||
def init_save_key(key_size, key_dir, keyname="key-certbot.pem"):
|
||||
"""Initializes and saves a privkey.
|
||||
|
||||
Inits key and saves it in PEM format on the filesystem.
|
||||
|
|
@ -36,7 +36,7 @@ def init_save_key(key_size, key_dir, keyname="key-letsencrypt.pem"):
|
|||
:param str keyname: Filename of key
|
||||
|
||||
:returns: Key
|
||||
:rtype: :class:`letsencrypt.le_util.Key`
|
||||
:rtype: :class:`certbot.le_util.Key`
|
||||
|
||||
:raises ValueError: If unable to generate the key given key_size.
|
||||
|
||||
|
|
@ -61,18 +61,18 @@ def init_save_key(key_size, key_dir, keyname="key-letsencrypt.pem"):
|
|||
return le_util.Key(key_path, key_pem)
|
||||
|
||||
|
||||
def init_save_csr(privkey, names, path, csrname="csr-letsencrypt.pem"):
|
||||
def init_save_csr(privkey, names, path, csrname="csr-certbot.pem"):
|
||||
"""Initialize a CSR with the given private key.
|
||||
|
||||
:param privkey: Key to include in the CSR
|
||||
:type privkey: :class:`letsencrypt.le_util.Key`
|
||||
:type privkey: :class:`certbot.le_util.Key`
|
||||
|
||||
:param set names: `str` names to include in the CSR
|
||||
|
||||
:param str path: Certificate save directory.
|
||||
|
||||
:returns: CSR
|
||||
:rtype: :class:`letsencrypt.le_util.CSR`
|
||||
:rtype: :class:`certbot.le_util.CSR`
|
||||
|
||||
"""
|
||||
csr_pem, csr_der = make_csr(privkey.pem, names)
|
||||
|
|
@ -4,7 +4,7 @@ import glob
|
|||
try:
|
||||
import readline
|
||||
except ImportError:
|
||||
import letsencrypt.display.dummy_readline as readline
|
||||
import certbot.display.dummy_readline as readline
|
||||
|
||||
|
||||
class Completer(object):
|
||||
|
|
@ -3,9 +3,9 @@ import logging
|
|||
|
||||
import zope.component
|
||||
|
||||
from letsencrypt import errors
|
||||
from letsencrypt import interfaces
|
||||
from letsencrypt.display import util as display_util
|
||||
from certbot import errors
|
||||
from certbot import interfaces
|
||||
from certbot.display import util as display_util
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
|
@ -18,7 +18,7 @@ def ask(enhancement):
|
|||
"""Display the enhancement to the user.
|
||||
|
||||
:param str enhancement: One of the
|
||||
:class:`letsencrypt.CONFIG.ENHANCEMENTS` enhancements
|
||||
:class:`certbot.CONFIG.ENHANCEMENTS` enhancements
|
||||
|
||||
:returns: True if feature is desired, False otherwise
|
||||
:rtype: bool
|
||||
|
|
@ -4,10 +4,10 @@ import os
|
|||
|
||||
import zope.component
|
||||
|
||||
from letsencrypt import errors
|
||||
from letsencrypt import interfaces
|
||||
from letsencrypt import le_util
|
||||
from letsencrypt.display import util as display_util
|
||||
from certbot import errors
|
||||
from certbot import interfaces
|
||||
from certbot import le_util
|
||||
from certbot.display import util as display_util
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
|
@ -56,7 +56,7 @@ def choose_account(accounts):
|
|||
"""Choose an account.
|
||||
|
||||
:param list accounts: Containing at least one
|
||||
:class:`~letsencrypt.account.Account`
|
||||
:class:`~certbot.account.Account`
|
||||
|
||||
"""
|
||||
# Note this will get more complicated once we start recording authorizations
|
||||
|
|
@ -74,7 +74,7 @@ def choose_names(installer):
|
|||
"""Display screen to select domains to validate.
|
||||
|
||||
:param installer: An installer object
|
||||
:type installer: :class:`letsencrypt.interfaces.IInstaller`
|
||||
:type installer: :class:`certbot.interfaces.IInstaller`
|
||||
|
||||
:returns: List of selected names
|
||||
:rtype: `list` of `str`
|
||||
|
|
@ -5,9 +5,9 @@ import textwrap
|
|||
import dialog
|
||||
import zope.interface
|
||||
|
||||
from letsencrypt import interfaces
|
||||
from letsencrypt import errors
|
||||
from letsencrypt.display import completer
|
||||
from certbot import interfaces
|
||||
from certbot import errors
|
||||
from certbot.display import completer
|
||||
|
||||
WIDTH = 72
|
||||
HEIGHT = 20
|
||||
|
|
@ -6,7 +6,7 @@ import os
|
|||
|
||||
from subprocess import Popen, PIPE
|
||||
|
||||
from letsencrypt import errors
|
||||
from certbot import errors
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
|
@ -51,7 +51,7 @@ class IPluginFactory(zope.interface.Interface):
|
|||
setup(
|
||||
...
|
||||
entry_points={
|
||||
'letsencrypt.plugins': [
|
||||
'certbot.plugins': [
|
||||
'name=example_project.plugin[plugin_deps]',
|
||||
],
|
||||
},
|
||||
|
|
@ -154,7 +154,7 @@ class IAuthenticator(IPlugin):
|
|||
"""Perform the given challenge.
|
||||
|
||||
:param list achalls: Non-empty (guaranteed) list of
|
||||
:class:`~letsencrypt.achallenges.AnnotatedChallenge`
|
||||
:class:`~certbot.achallenges.AnnotatedChallenge`
|
||||
instances, such that it contains types found within
|
||||
:func:`get_chall_pref` only.
|
||||
|
||||
|
|
@ -181,7 +181,7 @@ class IAuthenticator(IPlugin):
|
|||
"""Revert changes and shutdown after challenges complete.
|
||||
|
||||
:param list achalls: Non-empty (guaranteed) list of
|
||||
:class:`~letsencrypt.achallenges.AnnotatedChallenge`
|
||||
:class:`~certbot.achallenges.AnnotatedChallenge`
|
||||
instances, a subset of those previously passed to :func:`perform`.
|
||||
|
||||
:raises PluginError: if original configuration cannot be restored
|
||||
|
|
@ -262,10 +262,10 @@ class IInstaller(IPlugin):
|
|||
|
||||
:param str domain: domain for which to provide enhancement
|
||||
:param str enhancement: An enhancement as defined in
|
||||
:const:`~letsencrypt.constants.ENHANCEMENTS`
|
||||
:const:`~certbot.constants.ENHANCEMENTS`
|
||||
:param options: Flexible options parameter for enhancement.
|
||||
Check documentation of
|
||||
:const:`~letsencrypt.constants.ENHANCEMENTS`
|
||||
:const:`~certbot.constants.ENHANCEMENTS`
|
||||
for expected options for each enhancement.
|
||||
|
||||
:raises .PluginError: If Enhancement is not supported, or if
|
||||
|
|
@ -277,7 +277,7 @@ class IInstaller(IPlugin):
|
|||
"""Returns a list of supported enhancements.
|
||||
|
||||
:returns: supported enhancements which should be a subset of
|
||||
:const:`~letsencrypt.constants.ENHANCEMENTS`
|
||||
:const:`~certbot.constants.ENHANCEMENTS`
|
||||
:rtype: :class:`list` of :class:`str`
|
||||
|
||||
"""
|
||||
|
|
@ -14,7 +14,7 @@ import sys
|
|||
|
||||
import configargparse
|
||||
|
||||
from letsencrypt import errors
|
||||
from certbot import errors
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
|
@ -3,7 +3,7 @@ import logging
|
|||
|
||||
import dialog
|
||||
|
||||
from letsencrypt.display import util as display_util
|
||||
from certbot.display import util as display_util
|
||||
|
||||
|
||||
class DialogHandler(logging.Handler): # pylint: disable=too-few-public-methods
|
||||
|
|
@ -12,27 +12,27 @@ import zope.component
|
|||
|
||||
from acme import jose
|
||||
|
||||
import letsencrypt
|
||||
import certbot
|
||||
|
||||
from letsencrypt import account
|
||||
from letsencrypt import client
|
||||
from letsencrypt import cli
|
||||
from letsencrypt import crypto_util
|
||||
from letsencrypt import colored_logging
|
||||
from letsencrypt import configuration
|
||||
from letsencrypt import constants
|
||||
from letsencrypt import errors
|
||||
from letsencrypt import hooks
|
||||
from letsencrypt import interfaces
|
||||
from letsencrypt import le_util
|
||||
from letsencrypt import log
|
||||
from letsencrypt import reporter
|
||||
from letsencrypt import renewal
|
||||
from letsencrypt import storage
|
||||
from certbot import account
|
||||
from certbot import client
|
||||
from certbot import cli
|
||||
from certbot import crypto_util
|
||||
from certbot import colored_logging
|
||||
from certbot import configuration
|
||||
from certbot import constants
|
||||
from certbot import errors
|
||||
from certbot import hooks
|
||||
from certbot import interfaces
|
||||
from certbot import le_util
|
||||
from certbot import log
|
||||
from certbot import reporter
|
||||
from certbot import renewal
|
||||
from certbot import storage
|
||||
|
||||
from letsencrypt.display import util as display_util, ops as display_ops
|
||||
from letsencrypt.plugins import disco as plugins_disco
|
||||
from letsencrypt.plugins import selection as plug_sel
|
||||
from certbot.display import util as display_util, ops as display_ops
|
||||
from certbot.plugins import disco as plugins_disco
|
||||
from certbot.plugins import selection as plug_sel
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
|
@ -302,12 +302,12 @@ def _determine_account(config):
|
|||
user input. Same for ``config.email``.
|
||||
|
||||
:param argparse.Namespace config: CLI arguments
|
||||
:param letsencrypt.interface.IConfig config: Configuration object
|
||||
:param certbot.interface.IConfig config: Configuration object
|
||||
:param .AccountStorage account_storage: Account storage.
|
||||
|
||||
:returns: Account and optionally ACME client API (biproduct of new
|
||||
registration).
|
||||
:rtype: `tuple` of `letsencrypt.account.Account` and
|
||||
:rtype: `tuple` of `certbot.account.Account` and
|
||||
`acme.client.Client`
|
||||
|
||||
"""
|
||||
|
|
@ -605,7 +605,7 @@ def _handle_exception(exc_type, exc_value, trace, config):
|
|||
|
||||
if issubclass(exc_type, Exception) and (config is None or not config.debug):
|
||||
if config is None:
|
||||
logfile = "letsencrypt.log"
|
||||
logfile = "certbot.log"
|
||||
try:
|
||||
with open(logfile, "w") as logfd:
|
||||
traceback.print_exception(
|
||||
|
|
@ -662,7 +662,7 @@ def main(cli_args=sys.argv[1:]):
|
|||
config.logs_dir, 0o700, os.geteuid(), "--strict-permissions" in cli_args)
|
||||
setup_logging(config, _cli_log_handler, logfile='letsencrypt.log')
|
||||
|
||||
logger.debug("letsencrypt version: %s", letsencrypt.__version__)
|
||||
logger.debug("certbot version: %s", certbot.__version__)
|
||||
# do not log `config`, as it contains sensitive data (e.g. revoke --key)!
|
||||
logger.debug("Arguments: %r", cli_args)
|
||||
logger.debug("Discovered plugins: %r", plugins)
|
||||
|
|
@ -10,9 +10,9 @@ import zope.interface
|
|||
|
||||
from acme.jose import util as jose_util
|
||||
|
||||
from letsencrypt import constants
|
||||
from letsencrypt import interfaces
|
||||
from letsencrypt import le_util
|
||||
from certbot import constants
|
||||
from certbot import interfaces
|
||||
from certbot import le_util
|
||||
|
||||
|
||||
def option_namespace(name):
|
||||
|
|
@ -261,7 +261,7 @@ class TLSSNI01(object):
|
|||
return response
|
||||
|
||||
|
||||
# test utils used by letsencrypt_apache/letsencrypt_nginx (hence
|
||||
# test utils used by certbot_apache/certbot_nginx (hence
|
||||
# "pragma: no cover") TODO: this might quickly lead to dead code (also
|
||||
# c.f. #383)
|
||||
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
"""Tests for letsencrypt.plugins.common."""
|
||||
"""Tests for certbot.plugins.common."""
|
||||
import unittest
|
||||
|
||||
import mock
|
||||
|
|
@ -7,33 +7,33 @@ import OpenSSL
|
|||
from acme import challenges
|
||||
from acme import jose
|
||||
|
||||
from letsencrypt import achallenges
|
||||
from certbot import achallenges
|
||||
|
||||
from letsencrypt.tests import acme_util
|
||||
from letsencrypt.tests import test_util
|
||||
from certbot.tests import acme_util
|
||||
from certbot.tests import test_util
|
||||
|
||||
|
||||
class NamespaceFunctionsTest(unittest.TestCase):
|
||||
"""Tests for letsencrypt.plugins.common.*_namespace functions."""
|
||||
"""Tests for certbot.plugins.common.*_namespace functions."""
|
||||
|
||||
def test_option_namespace(self):
|
||||
from letsencrypt.plugins.common import option_namespace
|
||||
from certbot.plugins.common import option_namespace
|
||||
self.assertEqual("foo-", option_namespace("foo"))
|
||||
|
||||
def test_dest_namespace(self):
|
||||
from letsencrypt.plugins.common import dest_namespace
|
||||
from certbot.plugins.common import dest_namespace
|
||||
self.assertEqual("foo_", dest_namespace("foo"))
|
||||
|
||||
def test_dest_namespace_with_dashes(self):
|
||||
from letsencrypt.plugins.common import dest_namespace
|
||||
from certbot.plugins.common import dest_namespace
|
||||
self.assertEqual("foo_bar_", dest_namespace("foo-bar"))
|
||||
|
||||
|
||||
class PluginTest(unittest.TestCase):
|
||||
"""Test for letsencrypt.plugins.common.Plugin."""
|
||||
"""Test for certbot.plugins.common.Plugin."""
|
||||
|
||||
def setUp(self):
|
||||
from letsencrypt.plugins.common import Plugin
|
||||
from certbot.plugins.common import Plugin
|
||||
|
||||
class MockPlugin(Plugin): # pylint: disable=missing-docstring
|
||||
@classmethod
|
||||
|
|
@ -74,10 +74,10 @@ class PluginTest(unittest.TestCase):
|
|||
|
||||
|
||||
class AddrTest(unittest.TestCase):
|
||||
"""Tests for letsencrypt.client.plugins.common.Addr."""
|
||||
"""Tests for certbot.client.plugins.common.Addr."""
|
||||
|
||||
def setUp(self):
|
||||
from letsencrypt.plugins.common import Addr
|
||||
from certbot.plugins.common import Addr
|
||||
self.addr1 = Addr.fromstring("192.168.1.1")
|
||||
self.addr2 = Addr.fromstring("192.168.1.1:*")
|
||||
self.addr3 = Addr.fromstring("192.168.1.1:80")
|
||||
|
|
@ -132,13 +132,13 @@ class AddrTest(unittest.TestCase):
|
|||
self.assertEqual(self.addr4, self.addr4.get_addr_obj(""))
|
||||
self.assertNotEqual(self.addr4, self.addr5)
|
||||
self.assertFalse(self.addr4 == 3333)
|
||||
from letsencrypt.plugins.common import Addr
|
||||
from certbot.plugins.common import Addr
|
||||
self.assertEqual(self.addr4, Addr.fromstring("[fe00:0:0::1]"))
|
||||
self.assertEqual(self.addr4, Addr.fromstring("[fe00:0::0:0:1]"))
|
||||
|
||||
|
||||
def test_set_inclusion(self):
|
||||
from letsencrypt.plugins.common import Addr
|
||||
from certbot.plugins.common import Addr
|
||||
set_a = set([self.addr1, self.addr2])
|
||||
addr1b = Addr.fromstring("192.168.1.1")
|
||||
addr2b = Addr.fromstring("192.168.1.1:*")
|
||||
|
|
@ -155,7 +155,7 @@ class AddrTest(unittest.TestCase):
|
|||
|
||||
|
||||
class TLSSNI01Test(unittest.TestCase):
|
||||
"""Tests for letsencrypt.plugins.common.TLSSNI01."""
|
||||
"""Tests for certbot.plugins.common.TLSSNI01."""
|
||||
|
||||
auth_key = jose.JWKRSA.load(test_util.load_vector("rsa512_key.pem"))
|
||||
achalls = [
|
||||
|
|
@ -166,11 +166,11 @@ class TLSSNI01Test(unittest.TestCase):
|
|||
achallenges.KeyAuthorizationAnnotatedChallenge(
|
||||
challb=acme_util.chall_to_challb(
|
||||
challenges.TLSSNI01(token=b'token2'), "pending"),
|
||||
domain="letsencrypt.demo", account_key=auth_key),
|
||||
domain="certbot.demo", account_key=auth_key),
|
||||
]
|
||||
|
||||
def setUp(self):
|
||||
from letsencrypt.plugins.common import TLSSNI01
|
||||
from certbot.plugins.common import TLSSNI01
|
||||
self.sni = TLSSNI01(configurator=mock.MagicMock())
|
||||
|
||||
def test_add_chall(self):
|
||||
|
|
@ -191,9 +191,9 @@ class TLSSNI01Test(unittest.TestCase):
|
|||
achall.response_and_validation.return_value = (
|
||||
response, (test_util.load_cert("cert.pem"), key))
|
||||
|
||||
with mock.patch("letsencrypt.plugins.common.open",
|
||||
with mock.patch("certbot.plugins.common.open",
|
||||
mock_open, create=True):
|
||||
with mock.patch("letsencrypt.plugins.common.le_util.safe_open",
|
||||
with mock.patch("certbot.plugins.common.le_util.safe_open",
|
||||
mock_safe_open):
|
||||
# pylint: disable=protected-access
|
||||
self.assertEqual(response, self.sni._setup_challenge_cert(
|
||||
|
|
@ -6,9 +6,9 @@ import pkg_resources
|
|||
import zope.interface
|
||||
import zope.interface.verify
|
||||
|
||||
from letsencrypt import constants
|
||||
from letsencrypt import errors
|
||||
from letsencrypt import interfaces
|
||||
from certbot import constants
|
||||
from certbot import errors
|
||||
from certbot import interfaces
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
|
@ -18,9 +18,9 @@ class PluginEntryPoint(object):
|
|||
"""Plugin entry point."""
|
||||
|
||||
PREFIX_FREE_DISTRIBUTIONS = [
|
||||
"letsencrypt",
|
||||
"letsencrypt-apache",
|
||||
"letsencrypt-nginx",
|
||||
"certbot",
|
||||
"certbot-apache",
|
||||
"certbot-nginx",
|
||||
]
|
||||
"""Distributions for which prefix will be omitted."""
|
||||
|
||||
|
|
@ -1,23 +1,23 @@
|
|||
"""Tests for letsencrypt.plugins.disco."""
|
||||
"""Tests for certbot.plugins.disco."""
|
||||
import unittest
|
||||
|
||||
import mock
|
||||
import pkg_resources
|
||||
import zope.interface
|
||||
|
||||
from letsencrypt import errors
|
||||
from letsencrypt import interfaces
|
||||
from certbot import errors
|
||||
from certbot import interfaces
|
||||
|
||||
from letsencrypt.plugins import standalone
|
||||
from certbot.plugins import standalone
|
||||
|
||||
EP_SA = pkg_resources.EntryPoint(
|
||||
"sa", "letsencrypt.plugins.standalone",
|
||||
"sa", "certbot.plugins.standalone",
|
||||
attrs=("Authenticator",),
|
||||
dist=mock.MagicMock(key="letsencrypt"))
|
||||
dist=mock.MagicMock(key="certbot"))
|
||||
|
||||
|
||||
class PluginEntryPointTest(unittest.TestCase):
|
||||
"""Tests for letsencrypt.plugins.disco.PluginEntryPoint."""
|
||||
"""Tests for certbot.plugins.disco.PluginEntryPoint."""
|
||||
|
||||
def setUp(self):
|
||||
self.ep1 = pkg_resources.EntryPoint(
|
||||
|
|
@ -31,11 +31,11 @@ class PluginEntryPointTest(unittest.TestCase):
|
|||
self.ep3 = pkg_resources.EntryPoint(
|
||||
"ep3", "a.ep3", dist=mock.MagicMock(key="p3"))
|
||||
|
||||
from letsencrypt.plugins.disco import PluginEntryPoint
|
||||
from certbot.plugins.disco import PluginEntryPoint
|
||||
self.plugin_ep = PluginEntryPoint(EP_SA)
|
||||
|
||||
def test_entry_point_to_plugin_name(self):
|
||||
from letsencrypt.plugins.disco import PluginEntryPoint
|
||||
from certbot.plugins.disco import PluginEntryPoint
|
||||
|
||||
names = {
|
||||
self.ep1: "p1:ep1",
|
||||
|
|
@ -100,7 +100,7 @@ class PluginEntryPointTest(unittest.TestCase):
|
|||
self.plugin_ep._initialized = plugin = mock.MagicMock()
|
||||
|
||||
exceptions = zope.interface.exceptions
|
||||
with mock.patch("letsencrypt.plugins."
|
||||
with mock.patch("certbot.plugins."
|
||||
"disco.zope.interface") as mock_zope:
|
||||
mock_zope.exceptions = exceptions
|
||||
|
||||
|
|
@ -164,18 +164,18 @@ class PluginEntryPointTest(unittest.TestCase):
|
|||
|
||||
|
||||
class PluginsRegistryTest(unittest.TestCase):
|
||||
"""Tests for letsencrypt.plugins.disco.PluginsRegistry."""
|
||||
"""Tests for certbot.plugins.disco.PluginsRegistry."""
|
||||
|
||||
def setUp(self):
|
||||
from letsencrypt.plugins.disco import PluginsRegistry
|
||||
from certbot.plugins.disco import PluginsRegistry
|
||||
self.plugin_ep = mock.MagicMock(name="mock")
|
||||
self.plugin_ep.__hash__.side_effect = TypeError
|
||||
self.plugins = {"mock": self.plugin_ep}
|
||||
self.reg = PluginsRegistry(self.plugins)
|
||||
|
||||
def test_find_all(self):
|
||||
from letsencrypt.plugins.disco import PluginsRegistry
|
||||
with mock.patch("letsencrypt.plugins.disco.pkg_resources") as mock_pkg:
|
||||
from certbot.plugins.disco import PluginsRegistry
|
||||
with mock.patch("certbot.plugins.disco.pkg_resources") as mock_pkg:
|
||||
mock_pkg.iter_entry_points.return_value = iter([EP_SA])
|
||||
plugins = PluginsRegistry.find_all()
|
||||
self.assertTrue(plugins["sa"].plugin_cls is standalone.Authenticator)
|
||||
|
|
@ -15,9 +15,9 @@ import zope.interface
|
|||
|
||||
from acme import challenges
|
||||
|
||||
from letsencrypt import errors
|
||||
from letsencrypt import interfaces
|
||||
from letsencrypt.plugins import common
|
||||
from certbot import errors
|
||||
from certbot import interfaces
|
||||
from certbot.plugins import common
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
|
@ -55,13 +55,13 @@ command on the target server (as root):
|
|||
# a disclaimer about your current IP being transmitted to Let's Encrypt's servers.
|
||||
IP_DISCLAIMER = """\
|
||||
NOTE: The IP of this machine will be publicly logged as having requested this certificate. \
|
||||
If you're running letsencrypt in manual mode on a machine that is not your server, \
|
||||
If you're running certbot in manual mode on a machine that is not your server, \
|
||||
please ensure you're okay with that.
|
||||
|
||||
Are you OK with your IP being logged?
|
||||
"""
|
||||
|
||||
# "cd /tmp/letsencrypt" makes sure user doesn't serve /root,
|
||||
# "cd /tmp/certbot" makes sure user doesn't serve /root,
|
||||
# separate "public_html" ensures that cert.pem/key.pem are not
|
||||
# served and makes it more obvious that Python command will serve
|
||||
# anything recursively under the cwd
|
||||
|
|
@ -80,7 +80,7 @@ s.serve_forever()" """
|
|||
def __init__(self, *args, **kwargs):
|
||||
super(Authenticator, self).__init__(*args, **kwargs)
|
||||
self._root = (tempfile.mkdtemp() if self.conf("test-mode")
|
||||
else "/tmp/letsencrypt")
|
||||
else "/tmp/certbot")
|
||||
self._httpd = None
|
||||
|
||||
@classmethod
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
"""Tests for letsencrypt.plugins.manual."""
|
||||
"""Tests for certbot.plugins.manual."""
|
||||
import signal
|
||||
import unittest
|
||||
|
||||
|
|
@ -7,21 +7,21 @@ import mock
|
|||
from acme import challenges
|
||||
from acme import jose
|
||||
|
||||
from letsencrypt import achallenges
|
||||
from letsencrypt import errors
|
||||
from certbot import achallenges
|
||||
from certbot import errors
|
||||
|
||||
from letsencrypt.tests import acme_util
|
||||
from letsencrypt.tests import test_util
|
||||
from certbot.tests import acme_util
|
||||
from certbot.tests import test_util
|
||||
|
||||
|
||||
KEY = jose.JWKRSA.load(test_util.load_vector("rsa512_key.pem"))
|
||||
|
||||
|
||||
class AuthenticatorTest(unittest.TestCase):
|
||||
"""Tests for letsencrypt.plugins.manual.Authenticator."""
|
||||
"""Tests for certbot.plugins.manual.Authenticator."""
|
||||
|
||||
def setUp(self):
|
||||
from letsencrypt.plugins.manual import Authenticator
|
||||
from certbot.plugins.manual import Authenticator
|
||||
self.config = mock.MagicMock(
|
||||
http01_port=8080, manual_test_mode=False,
|
||||
manual_public_ip_logging_ok=False, noninteractive_mode=True)
|
||||
|
|
@ -48,8 +48,8 @@ class AuthenticatorTest(unittest.TestCase):
|
|||
def test_perform_empty(self):
|
||||
self.assertEqual([], self.auth.perform([]))
|
||||
|
||||
@mock.patch("letsencrypt.plugins.manual.zope.component.getUtility")
|
||||
@mock.patch("letsencrypt.plugins.manual.sys.stdout")
|
||||
@mock.patch("certbot.plugins.manual.zope.component.getUtility")
|
||||
@mock.patch("certbot.plugins.manual.sys.stdout")
|
||||
@mock.patch("acme.challenges.HTTP01Response.simple_verify")
|
||||
@mock.patch("__builtin__.raw_input")
|
||||
def test_perform(self, mock_raw_input, mock_verify, mock_stdout, mock_interaction):
|
||||
|
|
@ -66,12 +66,12 @@ class AuthenticatorTest(unittest.TestCase):
|
|||
self.assertTrue(self.achalls[0].chall.encode("token") in message)
|
||||
|
||||
mock_verify.return_value = False
|
||||
with mock.patch("letsencrypt.plugins.manual.logger") as mock_logger:
|
||||
with mock.patch("certbot.plugins.manual.logger") as mock_logger:
|
||||
self.auth.perform(self.achalls)
|
||||
mock_logger.warning.assert_called_once_with(mock.ANY)
|
||||
|
||||
@mock.patch("letsencrypt.plugins.manual.zope.component.getUtility")
|
||||
@mock.patch("letsencrypt.plugins.manual.Authenticator._notify_and_wait")
|
||||
@mock.patch("certbot.plugins.manual.zope.component.getUtility")
|
||||
@mock.patch("certbot.plugins.manual.Authenticator._notify_and_wait")
|
||||
def test_disagree_with_ip_logging(self, mock_notify, mock_interaction):
|
||||
mock_interaction().yesno.return_value = False
|
||||
mock_notify.side_effect = errors.Error("Exception not raised, \
|
||||
|
|
@ -79,14 +79,14 @@ class AuthenticatorTest(unittest.TestCase):
|
|||
|
||||
self.assertRaises(errors.PluginError, self.auth.perform, self.achalls)
|
||||
|
||||
@mock.patch("letsencrypt.plugins.manual.subprocess.Popen", autospec=True)
|
||||
@mock.patch("certbot.plugins.manual.subprocess.Popen", autospec=True)
|
||||
def test_perform_test_command_oserror(self, mock_popen):
|
||||
mock_popen.side_effect = OSError
|
||||
self.assertEqual([False], self.auth_test_mode.perform(self.achalls))
|
||||
|
||||
@mock.patch("letsencrypt.plugins.manual.socket.socket")
|
||||
@mock.patch("letsencrypt.plugins.manual.time.sleep", autospec=True)
|
||||
@mock.patch("letsencrypt.plugins.manual.subprocess.Popen", autospec=True)
|
||||
@mock.patch("certbot.plugins.manual.socket.socket")
|
||||
@mock.patch("certbot.plugins.manual.time.sleep", autospec=True)
|
||||
@mock.patch("certbot.plugins.manual.subprocess.Popen", autospec=True)
|
||||
def test_perform_test_command_run_failure(
|
||||
self, mock_popen, unused_mock_sleep, unused_mock_socket):
|
||||
mock_popen.poll.return_value = 10
|
||||
|
|
@ -100,7 +100,7 @@ class AuthenticatorTest(unittest.TestCase):
|
|||
httpd.poll.return_value = 0
|
||||
self.auth_test_mode.cleanup(self.achalls)
|
||||
|
||||
@mock.patch("letsencrypt.plugins.manual.os.killpg", autospec=True)
|
||||
@mock.patch("certbot.plugins.manual.os.killpg", autospec=True)
|
||||
def test_cleanup_test_mode_kills_still_running(self, mock_killpg):
|
||||
# pylint: disable=protected-access
|
||||
self.auth_test_mode._httpd = httpd = mock.Mock(pid=1234)
|
||||
|
|
@ -4,8 +4,8 @@ import logging
|
|||
import zope.component
|
||||
import zope.interface
|
||||
|
||||
from letsencrypt import interfaces
|
||||
from letsencrypt.plugins import common
|
||||
from certbot import interfaces
|
||||
from certbot.plugins import common
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
|
@ -1,14 +1,14 @@
|
|||
"""Tests for letsencrypt.plugins.null."""
|
||||
"""Tests for certbot.plugins.null."""
|
||||
import unittest
|
||||
|
||||
import mock
|
||||
|
||||
|
||||
class InstallerTest(unittest.TestCase):
|
||||
"""Tests for letsencrypt.plugins.null.Installer."""
|
||||
"""Tests for certbot.plugins.null.Installer."""
|
||||
|
||||
def setUp(self):
|
||||
from letsencrypt.plugins.null import Installer
|
||||
from certbot.plugins.null import Installer
|
||||
self.installer = Installer(config=mock.MagicMock(), name="null")
|
||||
|
||||
def test_it(self):
|
||||
|
|
@ -6,10 +6,10 @@ import logging
|
|||
|
||||
import zope.component
|
||||
|
||||
from letsencrypt import errors
|
||||
from letsencrypt import interfaces
|
||||
from certbot import errors
|
||||
from certbot import interfaces
|
||||
|
||||
from letsencrypt.display import util as display_util
|
||||
from certbot.display import util as display_util
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
z_util = zope.component.getUtility
|
||||
|
|
@ -42,9 +42,9 @@ def pick_authenticator(
|
|||
def pick_plugin(config, default, plugins, question, ifaces):
|
||||
"""Pick plugin.
|
||||
|
||||
:param letsencrypt.interfaces.IConfig: Configuration
|
||||
:param certbot.interfaces.IConfig: Configuration
|
||||
:param str default: Plugin name supplied by user or ``None``.
|
||||
:param letsencrypt.plugins.disco.PluginsRegistry plugins:
|
||||
:param certbot.plugins.disco.PluginsRegistry plugins:
|
||||
All plugins registered as entry points.
|
||||
:param str question: Question to be presented to the user in case
|
||||
multiple candidates are found.
|
||||
|
|
@ -158,7 +158,7 @@ def choose_configurator_plugins(config, plugins, verb):
|
|||
# Which plugins do we need?
|
||||
if verb == "run":
|
||||
need_inst = need_auth = True
|
||||
from letsencrypt.cli import cli_command
|
||||
from certbot.cli import cli_command
|
||||
if req_auth in noninstaller_plugins and not req_inst:
|
||||
msg = ('With the {0} plugin, you probably want to use the "certonly" command, eg:{1}'
|
||||
'{1} {2} certonly --{0}{1}{1}'
|
||||
|
|
@ -263,7 +263,7 @@ def diagnose_configurator_problem(cfg_type, requested, plugins):
|
|||
if os.path.exists("/etc/debian_version"):
|
||||
# Debian... installers are at least possible
|
||||
msg = ('No installers seem to be present and working on your system; '
|
||||
'fix that or try running letsencrypt with the "certonly" command')
|
||||
'fix that or try running certbot with the "certonly" command')
|
||||
else:
|
||||
# XXX update this logic as we make progress on #788 and nginx support
|
||||
msg = ('No installers are available on your OS yet; try running '
|
||||
|
|
@ -5,40 +5,40 @@ import unittest
|
|||
import mock
|
||||
import zope.component
|
||||
|
||||
from letsencrypt.display import util as display_util
|
||||
from letsencrypt import interfaces
|
||||
from certbot.display import util as display_util
|
||||
from certbot import interfaces
|
||||
|
||||
|
||||
class ConveniencePickPluginTest(unittest.TestCase):
|
||||
"""Tests for letsencrypt.plugins.selection.pick_*."""
|
||||
"""Tests for certbot.plugins.selection.pick_*."""
|
||||
|
||||
def _test(self, fun, ifaces):
|
||||
config = mock.Mock()
|
||||
default = mock.Mock()
|
||||
plugins = mock.Mock()
|
||||
|
||||
with mock.patch("letsencrypt.plugins.selection.pick_plugin") as mock_p:
|
||||
with mock.patch("certbot.plugins.selection.pick_plugin") as mock_p:
|
||||
mock_p.return_value = "foo"
|
||||
self.assertEqual("foo", fun(config, default, plugins, "Question?"))
|
||||
mock_p.assert_called_once_with(
|
||||
config, default, plugins, "Question?", ifaces)
|
||||
|
||||
def test_authenticator(self):
|
||||
from letsencrypt.plugins.selection import pick_authenticator
|
||||
from certbot.plugins.selection import pick_authenticator
|
||||
self._test(pick_authenticator, (interfaces.IAuthenticator,))
|
||||
|
||||
def test_installer(self):
|
||||
from letsencrypt.plugins.selection import pick_installer
|
||||
from certbot.plugins.selection import pick_installer
|
||||
self._test(pick_installer, (interfaces.IInstaller,))
|
||||
|
||||
def test_configurator(self):
|
||||
from letsencrypt.plugins.selection import pick_configurator
|
||||
from certbot.plugins.selection import pick_configurator
|
||||
self._test(pick_configurator,
|
||||
(interfaces.IAuthenticator, interfaces.IInstaller))
|
||||
|
||||
|
||||
class PickPluginTest(unittest.TestCase):
|
||||
"""Tests for letsencrypt.plugins.selection.pick_plugin."""
|
||||
"""Tests for certbot.plugins.selection.pick_plugin."""
|
||||
|
||||
def setUp(self):
|
||||
self.config = mock.Mock(noninteractive_mode=False)
|
||||
|
|
@ -48,7 +48,7 @@ class PickPluginTest(unittest.TestCase):
|
|||
self.ifaces = []
|
||||
|
||||
def _call(self):
|
||||
from letsencrypt.plugins.selection import pick_plugin
|
||||
from certbot.plugins.selection import pick_plugin
|
||||
return pick_plugin(self.config, self.default, self.reg,
|
||||
self.question, self.ifaces)
|
||||
|
||||
|
|
@ -89,7 +89,7 @@ class PickPluginTest(unittest.TestCase):
|
|||
"bar": plugin_ep,
|
||||
"baz": plugin_ep,
|
||||
}
|
||||
with mock.patch("letsencrypt.plugins.selection.choose_plugin") as mock_choose:
|
||||
with mock.patch("certbot.plugins.selection.choose_plugin") as mock_choose:
|
||||
mock_choose.return_value = plugin_ep
|
||||
self.assertEqual("foo", self._call())
|
||||
mock_choose.assert_called_once_with(
|
||||
|
|
@ -101,13 +101,13 @@ class PickPluginTest(unittest.TestCase):
|
|||
"baz": None,
|
||||
}
|
||||
|
||||
with mock.patch("letsencrypt.plugins.selection.choose_plugin") as mock_choose:
|
||||
with mock.patch("certbot.plugins.selection.choose_plugin") as mock_choose:
|
||||
mock_choose.return_value = None
|
||||
self.assertTrue(self._call() is None)
|
||||
|
||||
|
||||
class ChoosePluginTest(unittest.TestCase):
|
||||
"""Tests for letsencrypt.plugins.selection.choose_plugin."""
|
||||
"""Tests for certbot.plugins.selection.choose_plugin."""
|
||||
|
||||
def setUp(self):
|
||||
zope.component.provideUtility(display_util.FileDisplay(sys.stdout))
|
||||
|
|
@ -122,17 +122,17 @@ class ChoosePluginTest(unittest.TestCase):
|
|||
]
|
||||
|
||||
def _call(self):
|
||||
from letsencrypt.plugins.selection import choose_plugin
|
||||
from certbot.plugins.selection import choose_plugin
|
||||
return choose_plugin(self.plugins, "Question?")
|
||||
|
||||
@mock.patch("letsencrypt.plugins.selection.z_util")
|
||||
@mock.patch("certbot.plugins.selection.z_util")
|
||||
def test_selection(self, mock_util):
|
||||
mock_util().menu.side_effect = [(display_util.OK, 0),
|
||||
(display_util.OK, 1)]
|
||||
self.assertEqual(self.mock_stand, self._call())
|
||||
self.assertEqual(mock_util().notification.call_count, 1)
|
||||
|
||||
@mock.patch("letsencrypt.plugins.selection.z_util")
|
||||
@mock.patch("certbot.plugins.selection.z_util")
|
||||
def test_more_info(self, mock_util):
|
||||
mock_util().menu.side_effect = [
|
||||
(display_util.HELP, 0),
|
||||
|
|
@ -143,7 +143,7 @@ class ChoosePluginTest(unittest.TestCase):
|
|||
self.assertEqual(self.mock_stand, self._call())
|
||||
self.assertEqual(mock_util().notification.call_count, 2)
|
||||
|
||||
@mock.patch("letsencrypt.plugins.selection.z_util")
|
||||
@mock.patch("certbot.plugins.selection.z_util")
|
||||
def test_no_choice(self, mock_util):
|
||||
mock_util().menu.return_value = (display_util.CANCEL, 0)
|
||||
self.assertTrue(self._call() is None)
|
||||
|
|
@ -12,11 +12,11 @@ import zope.interface
|
|||
from acme import challenges
|
||||
from acme import standalone as acme_standalone
|
||||
|
||||
from letsencrypt import errors
|
||||
from letsencrypt import interfaces
|
||||
from certbot import errors
|
||||
from certbot import interfaces
|
||||
|
||||
from letsencrypt.plugins import common
|
||||
from letsencrypt.plugins import util
|
||||
from certbot.plugins import common
|
||||
from certbot.plugins import util
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
|
@ -91,7 +91,7 @@ class ServerManager(object):
|
|||
*instance.server.socket.getsockname()[:2])
|
||||
instance.server.shutdown()
|
||||
# Not calling server_close causes problems when renewing multiple
|
||||
# certs with `letsencrypt renew` using TLSSNI01 and PyOpenSSL 0.13
|
||||
# certs with `certbot renew` using TLSSNI01 and PyOpenSSL 0.13
|
||||
instance.server.server_close()
|
||||
instance.thread.join()
|
||||
del self._instances[port]
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
"""Tests for letsencrypt.plugins.standalone."""
|
||||
"""Tests for certbot.plugins.standalone."""
|
||||
import argparse
|
||||
import socket
|
||||
import unittest
|
||||
|
|
@ -10,19 +10,19 @@ from acme import challenges
|
|||
from acme import jose
|
||||
from acme import standalone as acme_standalone
|
||||
|
||||
from letsencrypt import achallenges
|
||||
from letsencrypt import errors
|
||||
from letsencrypt import interfaces
|
||||
from certbot import achallenges
|
||||
from certbot import errors
|
||||
from certbot import interfaces
|
||||
|
||||
from letsencrypt.tests import acme_util
|
||||
from letsencrypt.tests import test_util
|
||||
from certbot.tests import acme_util
|
||||
from certbot.tests import test_util
|
||||
|
||||
|
||||
class ServerManagerTest(unittest.TestCase):
|
||||
"""Tests for letsencrypt.plugins.standalone.ServerManager."""
|
||||
"""Tests for certbot.plugins.standalone.ServerManager."""
|
||||
|
||||
def setUp(self):
|
||||
from letsencrypt.plugins.standalone import ServerManager
|
||||
from certbot.plugins.standalone import ServerManager
|
||||
self.certs = {}
|
||||
self.http_01_resources = {}
|
||||
self.mgr = ServerManager(self.certs, self.http_01_resources)
|
||||
|
|
@ -68,7 +68,7 @@ class SupportedChallengesValidatorTest(unittest.TestCase):
|
|||
"""Tests for plugins.standalone.supported_challenges_validator."""
|
||||
|
||||
def _call(self, data):
|
||||
from letsencrypt.plugins.standalone import (
|
||||
from certbot.plugins.standalone import (
|
||||
supported_challenges_validator)
|
||||
return supported_challenges_validator(data)
|
||||
|
||||
|
|
@ -87,10 +87,10 @@ class SupportedChallengesValidatorTest(unittest.TestCase):
|
|||
|
||||
|
||||
class AuthenticatorTest(unittest.TestCase):
|
||||
"""Tests for letsencrypt.plugins.standalone.Authenticator."""
|
||||
"""Tests for certbot.plugins.standalone.Authenticator."""
|
||||
|
||||
def setUp(self):
|
||||
from letsencrypt.plugins.standalone import Authenticator
|
||||
from certbot.plugins.standalone import Authenticator
|
||||
self.config = mock.MagicMock(
|
||||
tls_sni_01_port=1234, http01_port=4321,
|
||||
standalone_supported_challenges="tls-sni-01,http-01")
|
||||
|
|
@ -117,7 +117,7 @@ class AuthenticatorTest(unittest.TestCase):
|
|||
self.assertEqual(self.auth.get_chall_pref(domain=None),
|
||||
[challenges.TLSSNI01])
|
||||
|
||||
@mock.patch("letsencrypt.plugins.standalone.util")
|
||||
@mock.patch("certbot.plugins.standalone.util")
|
||||
def test_perform_already_listening(self, mock_util):
|
||||
for chall, port in ((challenges.TLSSNI01.typ, 1234),
|
||||
(challenges.HTTP01.typ, 4321)):
|
||||
|
|
@ -128,14 +128,14 @@ class AuthenticatorTest(unittest.TestCase):
|
|||
mock_util.already_listening.assert_called_once_with(port, False)
|
||||
mock_util.already_listening.reset_mock()
|
||||
|
||||
@mock.patch("letsencrypt.plugins.standalone.zope.component.getUtility")
|
||||
@mock.patch("certbot.plugins.standalone.zope.component.getUtility")
|
||||
def test_perform(self, unused_mock_get_utility):
|
||||
achalls = [1, 2, 3]
|
||||
self.auth.perform2 = mock.Mock(return_value=mock.sentinel.responses)
|
||||
self.assertEqual(mock.sentinel.responses, self.auth.perform(achalls))
|
||||
self.auth.perform2.assert_called_once_with(achalls)
|
||||
|
||||
@mock.patch("letsencrypt.plugins.standalone.zope.component.getUtility")
|
||||
@mock.patch("certbot.plugins.standalone.zope.component.getUtility")
|
||||
def _test_perform_bind_errors(self, errno, achalls, mock_get_utility):
|
||||
def _perform2(unused_achalls):
|
||||
raise errors.StandaloneBindError(mock.Mock(errno=errno), 1234)
|
||||
|
|
@ -5,7 +5,7 @@ import socket
|
|||
import psutil
|
||||
import zope.component
|
||||
|
||||
from letsencrypt import interfaces
|
||||
from certbot import interfaces
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
"""Tests for letsencrypt.plugins.util."""
|
||||
"""Tests for certbot.plugins.util."""
|
||||
import unittest
|
||||
|
||||
import mock
|
||||
|
|
@ -6,14 +6,14 @@ import psutil
|
|||
|
||||
|
||||
class AlreadyListeningTest(unittest.TestCase):
|
||||
"""Tests for letsencrypt.plugins.already_listening."""
|
||||
"""Tests for certbot.plugins.already_listening."""
|
||||
def _call(self, *args, **kwargs):
|
||||
from letsencrypt.plugins.util import already_listening
|
||||
from certbot.plugins.util import already_listening
|
||||
return already_listening(*args, **kwargs)
|
||||
|
||||
@mock.patch("letsencrypt.plugins.util.psutil.net_connections")
|
||||
@mock.patch("letsencrypt.plugins.util.psutil.Process")
|
||||
@mock.patch("letsencrypt.plugins.util.zope.component.getUtility")
|
||||
@mock.patch("certbot.plugins.util.psutil.net_connections")
|
||||
@mock.patch("certbot.plugins.util.psutil.Process")
|
||||
@mock.patch("certbot.plugins.util.zope.component.getUtility")
|
||||
def test_race_condition(self, mock_get_utility, mock_process, mock_net):
|
||||
# This tests a race condition, or permission problem, or OS
|
||||
# incompatibility in which, for some reason, no process name can be
|
||||
|
|
@ -36,9 +36,9 @@ class AlreadyListeningTest(unittest.TestCase):
|
|||
self.assertEqual(mock_get_utility.generic_notification.call_count, 0)
|
||||
mock_process.assert_called_once_with(4416)
|
||||
|
||||
@mock.patch("letsencrypt.plugins.util.psutil.net_connections")
|
||||
@mock.patch("letsencrypt.plugins.util.psutil.Process")
|
||||
@mock.patch("letsencrypt.plugins.util.zope.component.getUtility")
|
||||
@mock.patch("certbot.plugins.util.psutil.net_connections")
|
||||
@mock.patch("certbot.plugins.util.psutil.Process")
|
||||
@mock.patch("certbot.plugins.util.zope.component.getUtility")
|
||||
def test_not_listening(self, mock_get_utility, mock_process, mock_net):
|
||||
from psutil._common import sconn
|
||||
conns = [
|
||||
|
|
@ -54,9 +54,9 @@ class AlreadyListeningTest(unittest.TestCase):
|
|||
self.assertEqual(mock_get_utility.generic_notification.call_count, 0)
|
||||
self.assertEqual(mock_process.call_count, 0)
|
||||
|
||||
@mock.patch("letsencrypt.plugins.util.psutil.net_connections")
|
||||
@mock.patch("letsencrypt.plugins.util.psutil.Process")
|
||||
@mock.patch("letsencrypt.plugins.util.zope.component.getUtility")
|
||||
@mock.patch("certbot.plugins.util.psutil.net_connections")
|
||||
@mock.patch("certbot.plugins.util.psutil.Process")
|
||||
@mock.patch("certbot.plugins.util.zope.component.getUtility")
|
||||
def test_listening_ipv4(self, mock_get_utility, mock_process, mock_net):
|
||||
from psutil._common import sconn
|
||||
conns = [
|
||||
|
|
@ -75,9 +75,9 @@ class AlreadyListeningTest(unittest.TestCase):
|
|||
self.assertEqual(mock_get_utility.call_count, 1)
|
||||
mock_process.assert_called_once_with(4416)
|
||||
|
||||
@mock.patch("letsencrypt.plugins.util.psutil.net_connections")
|
||||
@mock.patch("letsencrypt.plugins.util.psutil.Process")
|
||||
@mock.patch("letsencrypt.plugins.util.zope.component.getUtility")
|
||||
@mock.patch("certbot.plugins.util.psutil.net_connections")
|
||||
@mock.patch("certbot.plugins.util.psutil.Process")
|
||||
@mock.patch("certbot.plugins.util.zope.component.getUtility")
|
||||
def test_listening_ipv6(self, mock_get_utility, mock_process, mock_net):
|
||||
from psutil._common import sconn
|
||||
conns = [
|
||||
|
|
@ -98,7 +98,7 @@ class AlreadyListeningTest(unittest.TestCase):
|
|||
self.assertEqual(mock_get_utility.call_count, 1)
|
||||
mock_process.assert_called_once_with(4420)
|
||||
|
||||
@mock.patch("letsencrypt.plugins.util.psutil.net_connections")
|
||||
@mock.patch("certbot.plugins.util.psutil.net_connections")
|
||||
def test_access_denied_exception(self, mock_net):
|
||||
mock_net.side_effect = psutil.AccessDenied("")
|
||||
self.assertFalse(self._call(12345))
|
||||
|
|
@ -12,11 +12,11 @@ import zope.interface
|
|||
|
||||
from acme import challenges
|
||||
|
||||
from letsencrypt import cli
|
||||
from letsencrypt import errors
|
||||
from letsencrypt import interfaces
|
||||
from letsencrypt.display import util as display_util
|
||||
from letsencrypt.plugins import common
|
||||
from certbot import cli
|
||||
from certbot import errors
|
||||
from certbot import interfaces
|
||||
from certbot.display import util as display_util
|
||||
from certbot.plugins import common
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
"""Tests for letsencrypt.plugins.webroot."""
|
||||
"""Tests for certbot.plugins.webroot."""
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
|
|
@ -16,25 +16,25 @@ import six
|
|||
from acme import challenges
|
||||
from acme import jose
|
||||
|
||||
from letsencrypt import achallenges
|
||||
from letsencrypt import errors
|
||||
from letsencrypt.display import util as display_util
|
||||
from certbot import achallenges
|
||||
from certbot import errors
|
||||
from certbot.display import util as display_util
|
||||
|
||||
from letsencrypt.tests import acme_util
|
||||
from letsencrypt.tests import test_util
|
||||
from certbot.tests import acme_util
|
||||
from certbot.tests import test_util
|
||||
|
||||
|
||||
KEY = jose.JWKRSA.load(test_util.load_vector("rsa512_key.pem"))
|
||||
|
||||
|
||||
class AuthenticatorTest(unittest.TestCase):
|
||||
"""Tests for letsencrypt.plugins.webroot.Authenticator."""
|
||||
"""Tests for certbot.plugins.webroot.Authenticator."""
|
||||
|
||||
achall = achallenges.KeyAuthorizationAnnotatedChallenge(
|
||||
challb=acme_util.HTTP01_P, domain="thing.com", account_key=KEY)
|
||||
|
||||
def setUp(self):
|
||||
from letsencrypt.plugins.webroot import Authenticator
|
||||
from certbot.plugins.webroot import Authenticator
|
||||
self.path = tempfile.mkdtemp()
|
||||
self.root_challenge_path = os.path.join(
|
||||
self.path, ".well-known", "acme-challenge")
|
||||
|
|
@ -61,7 +61,7 @@ class AuthenticatorTest(unittest.TestCase):
|
|||
def test_prepare(self):
|
||||
self.auth.prepare() # shouldn't raise any exceptions
|
||||
|
||||
@mock.patch("letsencrypt.plugins.webroot.zope.component.getUtility")
|
||||
@mock.patch("certbot.plugins.webroot.zope.component.getUtility")
|
||||
def test_webroot_from_list(self, mock_get_utility):
|
||||
self.config.webroot_path = []
|
||||
self.config.webroot_map = {"otherthing.com": self.path}
|
||||
|
|
@ -78,7 +78,7 @@ class AuthenticatorTest(unittest.TestCase):
|
|||
self.assertEqual(self.config.webroot_map[self.achall.domain],
|
||||
self.path)
|
||||
|
||||
@mock.patch("letsencrypt.plugins.webroot.zope.component.getUtility")
|
||||
@mock.patch("certbot.plugins.webroot.zope.component.getUtility")
|
||||
def test_webroot_from_list_help_and_cancel(self, mock_get_utility):
|
||||
self.config.webroot_path = []
|
||||
self.config.webroot_map = {"otherthing.com": self.path}
|
||||
|
|
@ -95,7 +95,7 @@ class AuthenticatorTest(unittest.TestCase):
|
|||
webroot in call[0][1]
|
||||
for webroot in six.itervalues(self.config.webroot_map)))
|
||||
|
||||
@mock.patch("letsencrypt.plugins.webroot.zope.component.getUtility")
|
||||
@mock.patch("certbot.plugins.webroot.zope.component.getUtility")
|
||||
def test_new_webroot(self, mock_get_utility):
|
||||
self.config.webroot_path = []
|
||||
self.config.webroot_map = {}
|
||||
|
|
@ -137,12 +137,12 @@ class AuthenticatorTest(unittest.TestCase):
|
|||
self.assertRaises(errors.PluginError, self.auth.perform, [])
|
||||
os.chmod(self.path, 0o700)
|
||||
|
||||
@mock.patch("letsencrypt.plugins.webroot.os.chown")
|
||||
@mock.patch("certbot.plugins.webroot.os.chown")
|
||||
def test_failed_chown_eacces(self, mock_chown):
|
||||
mock_chown.side_effect = OSError(errno.EACCES, "msg")
|
||||
self.auth.perform([self.achall]) # exception caught and logged
|
||||
|
||||
@mock.patch("letsencrypt.plugins.webroot.os.chown")
|
||||
@mock.patch("certbot.plugins.webroot.os.chown")
|
||||
def test_failed_chown_not_eacces(self, mock_chown):
|
||||
mock_chown.side_effect = OSError()
|
||||
self.assertRaises(errors.PluginError, self.auth.perform, [])
|
||||
|
|
@ -233,7 +233,7 @@ class WebrootActionTest(unittest.TestCase):
|
|||
challb=acme_util.HTTP01_P, domain="thing.com", account_key=KEY)
|
||||
|
||||
def setUp(self):
|
||||
from letsencrypt.plugins.webroot import Authenticator
|
||||
from certbot.plugins.webroot import Authenticator
|
||||
self.path = tempfile.mkdtemp()
|
||||
self.parser = argparse.ArgumentParser()
|
||||
self.parser.add_argument("-d", "--domains",
|
||||
|
|
@ -266,7 +266,7 @@ class WebrootActionTest(unittest.TestCase):
|
|||
config.webroot_map[self.achall.domain], self.path)
|
||||
|
||||
def _get_config_after_perform(self, config):
|
||||
from letsencrypt.plugins.webroot import Authenticator
|
||||
from certbot.plugins.webroot import Authenticator
|
||||
auth = Authenticator(config, "webroot")
|
||||
auth.perform([self.achall])
|
||||
return auth.config
|
||||
|
|
@ -11,17 +11,17 @@ import zope.component
|
|||
|
||||
import OpenSSL
|
||||
|
||||
from letsencrypt import configuration
|
||||
from letsencrypt import cli
|
||||
from letsencrypt import constants
|
||||
from certbot import configuration
|
||||
from certbot import cli
|
||||
from certbot import constants
|
||||
|
||||
from letsencrypt import crypto_util
|
||||
from letsencrypt import errors
|
||||
from letsencrypt import interfaces
|
||||
from letsencrypt import le_util
|
||||
from letsencrypt import hooks
|
||||
from letsencrypt import storage
|
||||
from letsencrypt.plugins import disco as plugins_disco
|
||||
from certbot import crypto_util
|
||||
from certbot import errors
|
||||
from certbot import interfaces
|
||||
from certbot import le_util
|
||||
from certbot import hooks
|
||||
from certbot import storage
|
||||
from certbot.plugins import disco as plugins_disco
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
|
@ -262,7 +262,7 @@ def _renew_describe_results(config, renew_successes, renew_failures,
|
|||
notify = out.append
|
||||
|
||||
if config.dry_run:
|
||||
notify("** DRY RUN: simulating 'letsencrypt renew' close to cert expiry")
|
||||
notify("** DRY RUN: simulating 'certbot renew' close to cert expiry")
|
||||
notify("** (The test certificates below have not been saved.)")
|
||||
notify("")
|
||||
if renew_skipped:
|
||||
|
|
@ -290,7 +290,7 @@ def _renew_describe_results(config, renew_successes, renew_failures,
|
|||
notify(parse_failures, "parsefail")
|
||||
|
||||
if config.dry_run:
|
||||
notify("** DRY RUN: simulating 'letsencrypt renew' close to cert expiry")
|
||||
notify("** DRY RUN: simulating 'certbot renew' close to cert expiry")
|
||||
notify("** (The test certificates above have not been saved.)")
|
||||
|
||||
if config.quiet and not (renew_failures or parse_failures):
|
||||
|
|
@ -338,7 +338,7 @@ def renew_all_lineages(config):
|
|||
zope.component.provideUtility(lineage_config)
|
||||
if should_renew(lineage_config, renewal_candidate):
|
||||
plugins = plugins_disco.PluginsRegistry.find_all()
|
||||
from letsencrypt import main
|
||||
from certbot import main
|
||||
main.obtain_cert(lineage_config, plugins, renewal_candidate)
|
||||
renew_successes.append(renewal_candidate.fullchain)
|
||||
else:
|
||||
|
|
@ -10,8 +10,8 @@ import textwrap
|
|||
from six.moves import queue # pylint: disable=import-error
|
||||
import zope.interface
|
||||
|
||||
from letsencrypt import interfaces
|
||||
from letsencrypt import le_util
|
||||
from certbot import interfaces
|
||||
from certbot import le_util
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
|
@ -9,12 +9,12 @@ import traceback
|
|||
|
||||
import zope.component
|
||||
|
||||
from letsencrypt import constants
|
||||
from letsencrypt import errors
|
||||
from letsencrypt import interfaces
|
||||
from letsencrypt import le_util
|
||||
from certbot import constants
|
||||
from certbot import errors
|
||||
from certbot import interfaces
|
||||
from certbot import le_util
|
||||
|
||||
from letsencrypt.display import util as display_util
|
||||
from certbot.display import util as display_util
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
|
@ -26,7 +26,7 @@ class Reverter(object):
|
|||
.. note:: Consider moving everything over to CSV format.
|
||||
|
||||
:param config: Configuration.
|
||||
:type config: :class:`letsencrypt.interfaces.IConfig`
|
||||
:type config: :class:`certbot.interfaces.IConfig`
|
||||
|
||||
"""
|
||||
def __init__(self, config):
|
||||
|
|
@ -100,7 +100,7 @@ class Reverter(object):
|
|||
"""Displays all saved checkpoints.
|
||||
|
||||
All checkpoints are printed by
|
||||
:meth:`letsencrypt.interfaces.IDisplay.notification`.
|
||||
:meth:`certbot.interfaces.IDisplay.notification`.
|
||||
|
||||
.. todo:: Decide on a policy for error handling, OSError IOError...
|
||||
|
||||
|
|
@ -291,7 +291,7 @@ class Reverter(object):
|
|||
|
||||
:param set save_files: Set of files about to be saved.
|
||||
|
||||
:raises letsencrypt.errors.ReverterError:
|
||||
:raises certbot.errors.ReverterError:
|
||||
when save is attempting to overwrite a temporary file.
|
||||
|
||||
"""
|
||||
|
|
@ -317,7 +317,7 @@ class Reverter(object):
|
|||
"file - %s" % filename)
|
||||
|
||||
def register_file_creation(self, temporary, *files):
|
||||
r"""Register the creation of all files during letsencrypt execution.
|
||||
r"""Register the creation of all files during certbot execution.
|
||||
|
||||
Call this method before writing to the file to make sure that the
|
||||
file will be cleaned up if the program exits unexpectedly.
|
||||
|
|
@ -327,7 +327,7 @@ class Reverter(object):
|
|||
a temp or permanent save.
|
||||
:param \*files: file paths (str) to be registered
|
||||
|
||||
:raises letsencrypt.errors.ReverterError: If
|
||||
:raises certbot.errors.ReverterError: If
|
||||
call does not contain necessary parameters or if the file creation
|
||||
is unable to be registered.
|
||||
|
||||
|
|
@ -439,7 +439,7 @@ class Reverter(object):
|
|||
:returns: Success
|
||||
:rtype: bool
|
||||
|
||||
:raises letsencrypt.errors.ReverterError: If
|
||||
:raises certbot.errors.ReverterError: If
|
||||
all files within file_list cannot be removed
|
||||
|
||||
"""
|
||||
|
|
@ -477,7 +477,7 @@ class Reverter(object):
|
|||
|
||||
:param str title: Title describing checkpoint
|
||||
|
||||
:raises letsencrypt.errors.ReverterError: when the
|
||||
:raises certbot.errors.ReverterError: when the
|
||||
checkpoint is not able to be finalized.
|
||||
|
||||
"""
|
||||
|
|
@ -8,11 +8,11 @@ import configobj
|
|||
import parsedatetime
|
||||
import pytz
|
||||
|
||||
from letsencrypt import constants
|
||||
from letsencrypt import crypto_util
|
||||
from letsencrypt import errors
|
||||
from letsencrypt import error_handler
|
||||
from letsencrypt import le_util
|
||||
from certbot import constants
|
||||
from certbot import crypto_util
|
||||
from certbot import errors
|
||||
from certbot import error_handler
|
||||
from certbot import le_util
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
|
@ -137,8 +137,8 @@ def _relevant(option):
|
|||
:rtype: bool
|
||||
"""
|
||||
# The list() here produces a list of the plugin names as strings.
|
||||
from letsencrypt import renewal
|
||||
from letsencrypt.plugins import disco as plugins_disco
|
||||
from certbot import renewal
|
||||
from certbot.plugins import disco as plugins_disco
|
||||
plugins = list(plugins_disco.PluginsRegistry.find_all())
|
||||
return (option in renewal.STR_CONFIG_ITEMS
|
||||
or option in renewal.INT_CONFIG_ITEMS
|
||||
|
|
@ -153,7 +153,7 @@ def relevant_values(all_values):
|
|||
:returns: A new dictionary containing items that can be used in renewal.
|
||||
:rtype dict:"""
|
||||
|
||||
from letsencrypt import cli
|
||||
from certbot import cli
|
||||
|
||||
def _is_cli_default(option, value):
|
||||
# Look through the CLI parser defaults and see if this option is
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
"""Tests for letsencrypt.account."""
|
||||
"""Tests for certbot.account."""
|
||||
import datetime
|
||||
import os
|
||||
import shutil
|
||||
|
|
@ -12,29 +12,29 @@ import pytz
|
|||
from acme import jose
|
||||
from acme import messages
|
||||
|
||||
from letsencrypt import errors
|
||||
from certbot import errors
|
||||
|
||||
from letsencrypt.tests import test_util
|
||||
from certbot.tests import test_util
|
||||
|
||||
|
||||
KEY = jose.JWKRSA.load(test_util.load_vector("rsa512_key_2.pem"))
|
||||
|
||||
|
||||
class AccountTest(unittest.TestCase):
|
||||
"""Tests for letsencrypt.account.Account."""
|
||||
"""Tests for certbot.account.Account."""
|
||||
|
||||
def setUp(self):
|
||||
from letsencrypt.account import Account
|
||||
from certbot.account import Account
|
||||
self.regr = mock.MagicMock()
|
||||
self.meta = Account.Meta(
|
||||
creation_host="test.letsencrypt.org",
|
||||
creation_host="test.certbot.org",
|
||||
creation_dt=datetime.datetime(
|
||||
2015, 7, 4, 14, 4, 10, tzinfo=pytz.UTC))
|
||||
self.acc = Account(self.regr, KEY, self.meta)
|
||||
|
||||
with mock.patch("letsencrypt.account.socket") as mock_socket:
|
||||
mock_socket.getfqdn.return_value = "test.letsencrypt.org"
|
||||
with mock.patch("letsencrypt.account.datetime") as mock_dt:
|
||||
with mock.patch("certbot.account.socket") as mock_socket:
|
||||
mock_socket.getfqdn.return_value = "test.certbot.org"
|
||||
with mock.patch("certbot.account.datetime") as mock_dt:
|
||||
mock_dt.datetime.now.return_value = self.meta.creation_dt
|
||||
self.acc_no_meta = Account(self.regr, KEY)
|
||||
|
||||
|
|
@ -49,7 +49,7 @@ class AccountTest(unittest.TestCase):
|
|||
|
||||
def test_slug(self):
|
||||
self.assertEqual(
|
||||
self.acc.slug, "test.letsencrypt.org@2015-07-04T14:04:10Z (bca5)")
|
||||
self.acc.slug, "test.certbot.org@2015-07-04T14:04:10Z (bca5)")
|
||||
|
||||
def test_repr(self):
|
||||
self.assertEqual(
|
||||
|
|
@ -58,7 +58,7 @@ class AccountTest(unittest.TestCase):
|
|||
|
||||
|
||||
class ReportNewAccountTest(unittest.TestCase):
|
||||
"""Tests for letsencrypt.account.report_new_account."""
|
||||
"""Tests for certbot.account.report_new_account."""
|
||||
|
||||
def setUp(self):
|
||||
self.config = mock.MagicMock(config_dir="/etc/letsencrypt")
|
||||
|
|
@ -67,15 +67,15 @@ class ReportNewAccountTest(unittest.TestCase):
|
|||
uri=None, new_authzr_uri=None, body=reg))
|
||||
|
||||
def _call(self):
|
||||
from letsencrypt.account import report_new_account
|
||||
from certbot.account import report_new_account
|
||||
report_new_account(self.acc, self.config)
|
||||
|
||||
@mock.patch("letsencrypt.account.zope.component.queryUtility")
|
||||
@mock.patch("certbot.account.zope.component.queryUtility")
|
||||
def test_no_reporter(self, mock_zope):
|
||||
mock_zope.return_value = None
|
||||
self._call()
|
||||
|
||||
@mock.patch("letsencrypt.account.zope.component.queryUtility")
|
||||
@mock.patch("certbot.account.zope.component.queryUtility")
|
||||
def test_it(self, mock_zope):
|
||||
self._call()
|
||||
call_list = mock_zope().add_message.call_args_list
|
||||
|
|
@ -85,10 +85,10 @@ class ReportNewAccountTest(unittest.TestCase):
|
|||
|
||||
|
||||
class AccountMemoryStorageTest(unittest.TestCase):
|
||||
"""Tests for letsencrypt.account.AccountMemoryStorage."""
|
||||
"""Tests for certbot.account.AccountMemoryStorage."""
|
||||
|
||||
def setUp(self):
|
||||
from letsencrypt.account import AccountMemoryStorage
|
||||
from certbot.account import AccountMemoryStorage
|
||||
self.storage = AccountMemoryStorage()
|
||||
|
||||
def test_it(self):
|
||||
|
|
@ -103,16 +103,16 @@ class AccountMemoryStorageTest(unittest.TestCase):
|
|||
|
||||
|
||||
class AccountFileStorageTest(unittest.TestCase):
|
||||
"""Tests for letsencrypt.account.AccountFileStorage."""
|
||||
"""Tests for certbot.account.AccountFileStorage."""
|
||||
|
||||
def setUp(self):
|
||||
self.tmp = tempfile.mkdtemp()
|
||||
self.config = mock.MagicMock(
|
||||
accounts_dir=os.path.join(self.tmp, "accounts"))
|
||||
from letsencrypt.account import AccountFileStorage
|
||||
from certbot.account import AccountFileStorage
|
||||
self.storage = AccountFileStorage(self.config)
|
||||
|
||||
from letsencrypt.account import Account
|
||||
from certbot.account import Account
|
||||
self.acc = Account(
|
||||
regr=messages.RegistrationResource(
|
||||
uri=None, new_authzr_uri=None, body=messages.Registration()),
|
||||
|
|
@ -151,7 +151,7 @@ class AccountFileStorageTest(unittest.TestCase):
|
|||
def test_find_all_load_skips(self):
|
||||
self.storage.load = mock.MagicMock(
|
||||
side_effect=["x", errors.AccountStorageError, "z"])
|
||||
with mock.patch("letsencrypt.account.os.listdir") as mock_listdir:
|
||||
with mock.patch("certbot.account.os.listdir") as mock_listdir:
|
||||
mock_listdir.return_value = ["x", "y", "z"]
|
||||
self.assertEqual(["x", "z"], self.storage.find_all())
|
||||
|
||||
|
|
@ -6,7 +6,7 @@ from acme import challenges
|
|||
from acme import jose
|
||||
from acme import messages
|
||||
|
||||
from letsencrypt.tests import test_util
|
||||
from certbot.tests import test_util
|
||||
|
||||
|
||||
KEY = test_util.load_rsa_private_key('rsa512_key.pem')
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
"""Tests for letsencrypt.auth_handler."""
|
||||
"""Tests for certbot.auth_handler."""
|
||||
import functools
|
||||
import logging
|
||||
import unittest
|
||||
|
|
@ -9,18 +9,18 @@ from acme import challenges
|
|||
from acme import client as acme_client
|
||||
from acme import messages
|
||||
|
||||
from letsencrypt import achallenges
|
||||
from letsencrypt import errors
|
||||
from letsencrypt import le_util
|
||||
from certbot import achallenges
|
||||
from certbot import errors
|
||||
from certbot import le_util
|
||||
|
||||
from letsencrypt.tests import acme_util
|
||||
from certbot.tests import acme_util
|
||||
|
||||
|
||||
class ChallengeFactoryTest(unittest.TestCase):
|
||||
# pylint: disable=protected-access
|
||||
|
||||
def setUp(self):
|
||||
from letsencrypt.auth_handler import AuthHandler
|
||||
from certbot.auth_handler import AuthHandler
|
||||
|
||||
# Account is mocked...
|
||||
self.handler = AuthHandler(None, None, mock.Mock(key="mock_key"))
|
||||
|
|
@ -61,7 +61,7 @@ class GetAuthorizationsTest(unittest.TestCase):
|
|||
"""
|
||||
|
||||
def setUp(self):
|
||||
from letsencrypt.auth_handler import AuthHandler
|
||||
from certbot.auth_handler import AuthHandler
|
||||
|
||||
self.mock_auth = mock.MagicMock(name="ApacheConfigurator")
|
||||
|
||||
|
|
@ -80,7 +80,7 @@ class GetAuthorizationsTest(unittest.TestCase):
|
|||
def tearDown(self):
|
||||
logging.disable(logging.NOTSET)
|
||||
|
||||
@mock.patch("letsencrypt.auth_handler.AuthHandler._poll_challenges")
|
||||
@mock.patch("certbot.auth_handler.AuthHandler._poll_challenges")
|
||||
def test_name1_tls_sni_01_1(self, mock_poll):
|
||||
self.mock_net.request_domain_challenges.side_effect = functools.partial(
|
||||
gen_dom_authzr, challs=acme_util.CHALLENGES)
|
||||
|
|
@ -103,7 +103,7 @@ class GetAuthorizationsTest(unittest.TestCase):
|
|||
|
||||
self.assertEqual(len(authzr), 1)
|
||||
|
||||
@mock.patch("letsencrypt.auth_handler.AuthHandler._poll_challenges")
|
||||
@mock.patch("certbot.auth_handler.AuthHandler._poll_challenges")
|
||||
def test_name1_tls_sni_01_1_http_01_1_dns_1(self, mock_poll):
|
||||
self.mock_net.request_domain_challenges.side_effect = functools.partial(
|
||||
gen_dom_authzr, challs=acme_util.CHALLENGES, combos=False)
|
||||
|
|
@ -129,7 +129,7 @@ class GetAuthorizationsTest(unittest.TestCase):
|
|||
# Length of authorizations list
|
||||
self.assertEqual(len(authzr), 1)
|
||||
|
||||
@mock.patch("letsencrypt.auth_handler.AuthHandler._poll_challenges")
|
||||
@mock.patch("certbot.auth_handler.AuthHandler._poll_challenges")
|
||||
def test_name3_tls_sni_01_3(self, mock_poll):
|
||||
self.mock_net.request_domain_challenges.side_effect = functools.partial(
|
||||
gen_dom_authzr, challs=acme_util.CHALLENGES)
|
||||
|
|
@ -182,8 +182,8 @@ class PollChallengesTest(unittest.TestCase):
|
|||
"""Test poll challenges."""
|
||||
|
||||
def setUp(self):
|
||||
from letsencrypt.auth_handler import challb_to_achall
|
||||
from letsencrypt.auth_handler import AuthHandler
|
||||
from certbot.auth_handler import challb_to_achall
|
||||
from certbot.auth_handler import AuthHandler
|
||||
|
||||
# Account and network are mocked...
|
||||
self.mock_net = mock.MagicMock()
|
||||
|
|
@ -210,7 +210,7 @@ class PollChallengesTest(unittest.TestCase):
|
|||
challb_to_achall(challb, mock.Mock(key="dummy_key"), dom)
|
||||
for challb in self.handler.authzr[dom].body.challenges]
|
||||
|
||||
@mock.patch("letsencrypt.auth_handler.time")
|
||||
@mock.patch("certbot.auth_handler.time")
|
||||
def test_poll_challenges(self, unused_mock_time):
|
||||
self.mock_net.poll.side_effect = self._mock_poll_solve_one_valid
|
||||
self.handler._poll_challenges(self.chall_update, False)
|
||||
|
|
@ -218,7 +218,7 @@ class PollChallengesTest(unittest.TestCase):
|
|||
for authzr in self.handler.authzr.values():
|
||||
self.assertEqual(authzr.body.status, messages.STATUS_VALID)
|
||||
|
||||
@mock.patch("letsencrypt.auth_handler.time")
|
||||
@mock.patch("certbot.auth_handler.time")
|
||||
def test_poll_challenges_failure_best_effort(self, unused_mock_time):
|
||||
self.mock_net.poll.side_effect = self._mock_poll_solve_one_invalid
|
||||
self.handler._poll_challenges(self.chall_update, True)
|
||||
|
|
@ -226,17 +226,17 @@ class PollChallengesTest(unittest.TestCase):
|
|||
for authzr in self.handler.authzr.values():
|
||||
self.assertEqual(authzr.body.status, messages.STATUS_PENDING)
|
||||
|
||||
@mock.patch("letsencrypt.auth_handler.time")
|
||||
@mock.patch("letsencrypt.auth_handler.zope.component.getUtility")
|
||||
@mock.patch("certbot.auth_handler.time")
|
||||
@mock.patch("certbot.auth_handler.zope.component.getUtility")
|
||||
def test_poll_challenges_failure(self, unused_mock_time, unused_mock_zope):
|
||||
self.mock_net.poll.side_effect = self._mock_poll_solve_one_invalid
|
||||
self.assertRaises(
|
||||
errors.AuthorizationError, self.handler._poll_challenges,
|
||||
self.chall_update, False)
|
||||
|
||||
@mock.patch("letsencrypt.auth_handler.time")
|
||||
@mock.patch("certbot.auth_handler.time")
|
||||
def test_unable_to_find_challenge_status(self, unused_mock_time):
|
||||
from letsencrypt.auth_handler import challb_to_achall
|
||||
from certbot.auth_handler import challb_to_achall
|
||||
self.mock_net.poll.side_effect = self._mock_poll_solve_one_valid
|
||||
self.chall_update[self.doms[0]].append(
|
||||
challb_to_achall(acme_util.DNS_P, "key", self.doms[0]))
|
||||
|
|
@ -295,10 +295,10 @@ class PollChallengesTest(unittest.TestCase):
|
|||
|
||||
|
||||
class ChallbToAchallTest(unittest.TestCase):
|
||||
"""Tests for letsencrypt.auth_handler.challb_to_achall."""
|
||||
"""Tests for certbot.auth_handler.challb_to_achall."""
|
||||
|
||||
def _call(self, challb):
|
||||
from letsencrypt.auth_handler import challb_to_achall
|
||||
from certbot.auth_handler import challb_to_achall
|
||||
return challb_to_achall(challb, "account_key", "domain")
|
||||
|
||||
def test_it(self):
|
||||
|
|
@ -311,7 +311,7 @@ class ChallbToAchallTest(unittest.TestCase):
|
|||
|
||||
|
||||
class GenChallengePathTest(unittest.TestCase):
|
||||
"""Tests for letsencrypt.auth_handler.gen_challenge_path.
|
||||
"""Tests for certbot.auth_handler.gen_challenge_path.
|
||||
|
||||
.. todo:: Add more tests for dumb_path... depending on what we want to do.
|
||||
|
||||
|
|
@ -324,7 +324,7 @@ class GenChallengePathTest(unittest.TestCase):
|
|||
|
||||
@classmethod
|
||||
def _call(cls, challbs, preferences, combinations):
|
||||
from letsencrypt.auth_handler import gen_challenge_path
|
||||
from certbot.auth_handler import gen_challenge_path
|
||||
return gen_challenge_path(challbs, preferences, combinations)
|
||||
|
||||
def test_common_case(self):
|
||||
|
|
@ -354,7 +354,7 @@ class GenChallengePathTest(unittest.TestCase):
|
|||
|
||||
|
||||
class ReportFailedChallsTest(unittest.TestCase):
|
||||
"""Tests for letsencrypt.auth_handler._report_failed_challs."""
|
||||
"""Tests for certbot.auth_handler._report_failed_challs."""
|
||||
# pylint: disable=protected-access
|
||||
|
||||
def setUp(self):
|
||||
|
|
@ -388,18 +388,18 @@ class ReportFailedChallsTest(unittest.TestCase):
|
|||
domain="foo.bar",
|
||||
account_key="key")
|
||||
|
||||
@mock.patch("letsencrypt.auth_handler.zope.component.getUtility")
|
||||
@mock.patch("certbot.auth_handler.zope.component.getUtility")
|
||||
def test_same_error_and_domain(self, mock_zope):
|
||||
from letsencrypt import auth_handler
|
||||
from certbot import auth_handler
|
||||
|
||||
auth_handler._report_failed_challs([self.http01, self.tls_sni_same])
|
||||
call_list = mock_zope().add_message.call_args_list
|
||||
self.assertTrue(len(call_list) == 1)
|
||||
self.assertTrue("Domain: example.com\nType: tls\nDetail: detail" in call_list[0][0][0])
|
||||
|
||||
@mock.patch("letsencrypt.auth_handler.zope.component.getUtility")
|
||||
@mock.patch("certbot.auth_handler.zope.component.getUtility")
|
||||
def test_different_errors_and_domains(self, mock_zope):
|
||||
from letsencrypt import auth_handler
|
||||
from certbot import auth_handler
|
||||
|
||||
auth_handler._report_failed_challs([self.http01, self.tls_sni_diff])
|
||||
self.assertTrue(mock_zope().add_message.call_count == 2)
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
"""Tests for letsencrypt.cli."""
|
||||
"""Tests for certbot.cli."""
|
||||
from __future__ import print_function
|
||||
|
||||
import argparse
|
||||
|
|
@ -16,22 +16,22 @@ from six.moves import reload_module # pylint: disable=import-error
|
|||
|
||||
from acme import jose
|
||||
|
||||
from letsencrypt import account
|
||||
from letsencrypt import cli
|
||||
from letsencrypt import configuration
|
||||
from letsencrypt import constants
|
||||
from letsencrypt import crypto_util
|
||||
from letsencrypt import errors
|
||||
from letsencrypt import le_util
|
||||
from letsencrypt import main
|
||||
from letsencrypt import renewal
|
||||
from letsencrypt import storage
|
||||
from certbot import account
|
||||
from certbot import cli
|
||||
from certbot import configuration
|
||||
from certbot import constants
|
||||
from certbot import crypto_util
|
||||
from certbot import errors
|
||||
from certbot import le_util
|
||||
from certbot import main
|
||||
from certbot import renewal
|
||||
from certbot import storage
|
||||
|
||||
from letsencrypt.plugins import disco
|
||||
from letsencrypt.plugins import manual
|
||||
from certbot.plugins import disco
|
||||
from certbot.plugins import manual
|
||||
|
||||
from letsencrypt.tests import storage_test
|
||||
from letsencrypt.tests import test_util
|
||||
from certbot.tests import storage_test
|
||||
from certbot.tests import test_util
|
||||
|
||||
|
||||
CERT = test_util.vector_path('cert.pem')
|
||||
|
|
@ -59,7 +59,7 @@ class CLITest(unittest.TestCase): # pylint: disable=too-many-public-methods
|
|||
|
||||
def _call(self, args, stdout=None):
|
||||
"Run the cli with output streams and actual client mocked out"
|
||||
with mock.patch('letsencrypt.main.client') as client:
|
||||
with mock.patch('certbot.main.client') as client:
|
||||
ret, stdout, stderr = self._call_no_clientmock(args, stdout)
|
||||
return ret, stdout, stderr, client
|
||||
|
||||
|
|
@ -68,13 +68,13 @@ class CLITest(unittest.TestCase): # pylint: disable=too-many-public-methods
|
|||
args = self.standard_args + args
|
||||
|
||||
toy_stdout = stdout if stdout else six.StringIO()
|
||||
with mock.patch('letsencrypt.main.sys.stdout', new=toy_stdout):
|
||||
with mock.patch('letsencrypt.main.sys.stderr') as stderr:
|
||||
with mock.patch('certbot.main.sys.stdout', new=toy_stdout):
|
||||
with mock.patch('certbot.main.sys.stderr') as stderr:
|
||||
ret = main.main(args[:]) # NOTE: parser can alter its args!
|
||||
return ret, toy_stdout, stderr
|
||||
|
||||
def test_no_flags(self):
|
||||
with mock.patch('letsencrypt.main.run') as mock_run:
|
||||
with mock.patch('certbot.main.run') as mock_run:
|
||||
self._call([])
|
||||
self.assertEqual(1, mock_run.call_count)
|
||||
|
||||
|
|
@ -133,7 +133,7 @@ class CLITest(unittest.TestCase): # pylint: disable=too-many-public-methods
|
|||
"Ensure that a particular error raises a missing cli flag error containing message"
|
||||
exc = None
|
||||
try:
|
||||
with mock.patch('letsencrypt.main.sys.stderr'):
|
||||
with mock.patch('certbot.main.sys.stderr'):
|
||||
main.main(self.standard_args + args[:]) # NOTE: parser can alter its args!
|
||||
except errors.MissingCommandlineFlag as exc:
|
||||
self.assertTrue(message in str(exc))
|
||||
|
|
@ -144,15 +144,15 @@ class CLITest(unittest.TestCase): # pylint: disable=too-many-public-methods
|
|||
self._cli_missing_flag(args, "specify a plugin")
|
||||
args.extend(['--standalone', '-d', 'eg.is'])
|
||||
self._cli_missing_flag(args, "register before running")
|
||||
with mock.patch('letsencrypt.main._auth_from_domains'):
|
||||
with mock.patch('letsencrypt.main.client.acme_from_config_key'):
|
||||
with mock.patch('certbot.main._auth_from_domains'):
|
||||
with mock.patch('certbot.main.client.acme_from_config_key'):
|
||||
args.extend(['--email', 'io@io.is'])
|
||||
self._cli_missing_flag(args, "--agree-tos")
|
||||
|
||||
@mock.patch('letsencrypt.main.client.acme_client.Client')
|
||||
@mock.patch('letsencrypt.main._determine_account')
|
||||
@mock.patch('letsencrypt.main.client.Client.obtain_and_enroll_certificate')
|
||||
@mock.patch('letsencrypt.main._auth_from_domains')
|
||||
@mock.patch('certbot.main.client.acme_client.Client')
|
||||
@mock.patch('certbot.main._determine_account')
|
||||
@mock.patch('certbot.main.client.Client.obtain_and_enroll_certificate')
|
||||
@mock.patch('certbot.main._auth_from_domains')
|
||||
def test_user_agent(self, afd, _obt, det, _client):
|
||||
# Normally the client is totally mocked out, but here we need more
|
||||
# arguments to automate it...
|
||||
|
|
@ -161,7 +161,7 @@ class CLITest(unittest.TestCase): # pylint: disable=too-many-public-methods
|
|||
det.return_value = mock.MagicMock(), None
|
||||
afd.return_value = mock.MagicMock(), "newcert"
|
||||
|
||||
with mock.patch('letsencrypt.main.client.acme_client.ClientNetwork') as acme_net:
|
||||
with mock.patch('certbot.main.client.acme_client.ClientNetwork') as acme_net:
|
||||
self._call_no_clientmock(args)
|
||||
os_ver = " ".join(le_util.get_os_info())
|
||||
ua = acme_net.call_args[1]["user_agent"]
|
||||
|
|
@ -171,7 +171,7 @@ class CLITest(unittest.TestCase): # pylint: disable=too-many-public-methods
|
|||
if "linux" in plat.lower():
|
||||
self.assertTrue(platform.linux_distribution()[0] in ua)
|
||||
|
||||
with mock.patch('letsencrypt.main.client.acme_client.ClientNetwork') as acme_net:
|
||||
with mock.patch('certbot.main.client.acme_client.ClientNetwork') as acme_net:
|
||||
ua = "bandersnatch"
|
||||
args += ["--user-agent", ua]
|
||||
self._call_no_clientmock(args)
|
||||
|
|
@ -183,7 +183,7 @@ class CLITest(unittest.TestCase): # pylint: disable=too-many-public-methods
|
|||
chain = 'chain'
|
||||
fullchain = 'fullchain'
|
||||
|
||||
with mock.patch('letsencrypt.main.install') as mock_install:
|
||||
with mock.patch('certbot.main.install') as mock_install:
|
||||
self._call(['install', '--cert-path', cert, '--key-path', 'key',
|
||||
'--chain-path', 'chain',
|
||||
'--fullchain-path', 'fullchain'])
|
||||
|
|
@ -194,14 +194,14 @@ class CLITest(unittest.TestCase): # pylint: disable=too-many-public-methods
|
|||
self.assertEqual(args.chain_path, os.path.abspath(chain))
|
||||
self.assertEqual(args.fullchain_path, os.path.abspath(fullchain))
|
||||
|
||||
@mock.patch('letsencrypt.main.plug_sel.record_chosen_plugins')
|
||||
@mock.patch('letsencrypt.main.plug_sel.pick_installer')
|
||||
@mock.patch('certbot.main.plug_sel.record_chosen_plugins')
|
||||
@mock.patch('certbot.main.plug_sel.pick_installer')
|
||||
def test_installer_selection(self, mock_pick_installer, _rec):
|
||||
self._call(['install', '--domains', 'foo.bar', '--cert-path', 'cert',
|
||||
'--key-path', 'key', '--chain-path', 'chain'])
|
||||
self.assertEqual(mock_pick_installer.call_count, 1)
|
||||
|
||||
@mock.patch('letsencrypt.le_util.exe_exists')
|
||||
@mock.patch('certbot.le_util.exe_exists')
|
||||
def test_configurator_selection(self, mock_exe_exists):
|
||||
mock_exe_exists.return_value = True
|
||||
real_plugins = disco.PluginsRegistry.find_all()
|
||||
|
|
@ -210,7 +210,7 @@ class CLITest(unittest.TestCase): # pylint: disable=too-many-public-methods
|
|||
# This needed two calls to find_all(), which we're avoiding for now
|
||||
# because of possible side effects:
|
||||
# https://github.com/letsencrypt/letsencrypt/commit/51ed2b681f87b1eb29088dd48718a54f401e4855
|
||||
#with mock.patch('letsencrypt.cli.plugins_testable') as plugins:
|
||||
#with mock.patch('certbot.cli.plugins_testable') as plugins:
|
||||
# plugins.return_value = {"apache": True, "nginx": True}
|
||||
# ret, _, _, _ = self._call(args)
|
||||
# self.assertTrue("Too many flags setting" in ret)
|
||||
|
|
@ -220,21 +220,21 @@ class CLITest(unittest.TestCase): # pylint: disable=too-many-public-methods
|
|||
"example.com", "--debug"]
|
||||
if "nginx" in real_plugins:
|
||||
# Sending nginx a non-existent conf dir will simulate misconfiguration
|
||||
# (we can only do that if letsencrypt-nginx is actually present)
|
||||
# (we can only do that if certbot-nginx is actually present)
|
||||
ret, _, _, _ = self._call(args)
|
||||
self.assertTrue("The nginx plugin is not working" in ret)
|
||||
self.assertTrue("MisconfigurationError" in ret)
|
||||
|
||||
self._cli_missing_flag(["--standalone"], "With the standalone plugin, you probably")
|
||||
|
||||
with mock.patch("letsencrypt.main._init_le_client") as mock_init:
|
||||
with mock.patch("letsencrypt.main._auth_from_domains") as mock_afd:
|
||||
with mock.patch("certbot.main._init_le_client") as mock_init:
|
||||
with mock.patch("certbot.main._auth_from_domains") as mock_afd:
|
||||
mock_afd.return_value = (mock.MagicMock(), mock.MagicMock())
|
||||
self._call(["certonly", "--manual", "-d", "foo.bar"])
|
||||
unused_config, auth, unused_installer = mock_init.call_args[0]
|
||||
self.assertTrue(isinstance(auth, manual.Authenticator))
|
||||
|
||||
with mock.patch('letsencrypt.main.obtain_cert') as mock_certonly:
|
||||
with mock.patch('certbot.main.obtain_cert') as mock_certonly:
|
||||
self._call(["auth", "--standalone"])
|
||||
self.assertEqual(1, mock_certonly.call_count)
|
||||
|
||||
|
|
@ -257,8 +257,8 @@ class CLITest(unittest.TestCase): # pylint: disable=too-many-public-methods
|
|||
for r in xrange(len(flags)))):
|
||||
self._call(['plugins'] + list(args))
|
||||
|
||||
@mock.patch('letsencrypt.main.plugins_disco')
|
||||
@mock.patch('letsencrypt.main.cli.HelpfulArgumentParser.determine_help_topics')
|
||||
@mock.patch('certbot.main.plugins_disco')
|
||||
@mock.patch('certbot.main.cli.HelpfulArgumentParser.determine_help_topics')
|
||||
def test_plugins_no_args(self, _det, mock_disco):
|
||||
ifaces = []
|
||||
plugins = mock_disco.PluginsRegistry.find_all()
|
||||
|
|
@ -269,8 +269,8 @@ class CLITest(unittest.TestCase): # pylint: disable=too-many-public-methods
|
|||
filtered = plugins.visible().ifaces()
|
||||
self.assertEqual(stdout.getvalue().strip(), str(filtered))
|
||||
|
||||
@mock.patch('letsencrypt.main.plugins_disco')
|
||||
@mock.patch('letsencrypt.main.cli.HelpfulArgumentParser.determine_help_topics')
|
||||
@mock.patch('certbot.main.plugins_disco')
|
||||
@mock.patch('certbot.main.cli.HelpfulArgumentParser.determine_help_topics')
|
||||
def test_plugins_init(self, _det, mock_disco):
|
||||
ifaces = []
|
||||
plugins = mock_disco.PluginsRegistry.find_all()
|
||||
|
|
@ -284,8 +284,8 @@ class CLITest(unittest.TestCase): # pylint: disable=too-many-public-methods
|
|||
verified = filtered.verify()
|
||||
self.assertEqual(stdout.getvalue().strip(), str(verified))
|
||||
|
||||
@mock.patch('letsencrypt.main.plugins_disco')
|
||||
@mock.patch('letsencrypt.main.cli.HelpfulArgumentParser.determine_help_topics')
|
||||
@mock.patch('certbot.main.plugins_disco')
|
||||
@mock.patch('certbot.main.cli.HelpfulArgumentParser.determine_help_topics')
|
||||
def test_plugins_prepare(self, _det, mock_disco):
|
||||
ifaces = []
|
||||
plugins = mock_disco.PluginsRegistry.find_all()
|
||||
|
|
@ -307,7 +307,7 @@ class CLITest(unittest.TestCase): # pylint: disable=too-many-public-methods
|
|||
chain = 'chain'
|
||||
fullchain = 'fullchain'
|
||||
|
||||
with mock.patch('letsencrypt.main.obtain_cert') as mock_obtaincert:
|
||||
with mock.patch('certbot.main.obtain_cert') as mock_obtaincert:
|
||||
self._call(['certonly', '--cert-path', cert, '--key-path', 'key',
|
||||
'--chain-path', 'chain',
|
||||
'--fullchain-path', 'fullchain'])
|
||||
|
|
@ -464,16 +464,16 @@ class CLITest(unittest.TestCase): # pylint: disable=too-many-public-methods
|
|||
self._check_server_conflict_message(short_args, conflicts)
|
||||
|
||||
def _certonly_new_request_common(self, mock_client, args=None):
|
||||
with mock.patch('letsencrypt.main._treat_as_renewal') as mock_renewal:
|
||||
with mock.patch('certbot.main._treat_as_renewal') as mock_renewal:
|
||||
mock_renewal.return_value = ("newcert", None)
|
||||
with mock.patch('letsencrypt.main._init_le_client') as mock_init:
|
||||
with mock.patch('certbot.main._init_le_client') as mock_init:
|
||||
mock_init.return_value = mock_client
|
||||
if args is None:
|
||||
args = []
|
||||
args += '-d foo.bar -a standalone certonly'.split()
|
||||
self._call(args)
|
||||
|
||||
@mock.patch('letsencrypt.main.zope.component.getUtility')
|
||||
@mock.patch('certbot.main.zope.component.getUtility')
|
||||
def test_certonly_dry_run_new_request_success(self, mock_get_utility):
|
||||
mock_client = mock.MagicMock()
|
||||
mock_client.obtain_and_enroll_certificate.return_value = None
|
||||
|
|
@ -485,8 +485,8 @@ class CLITest(unittest.TestCase): # pylint: disable=too-many-public-methods
|
|||
# Asserts we don't suggest donating after a successful dry run
|
||||
self.assertEqual(mock_get_utility().add_message.call_count, 1)
|
||||
|
||||
@mock.patch('letsencrypt.crypto_util.notAfter')
|
||||
@mock.patch('letsencrypt.main.zope.component.getUtility')
|
||||
@mock.patch('certbot.crypto_util.notAfter')
|
||||
@mock.patch('certbot.main.zope.component.getUtility')
|
||||
def test_certonly_new_request_success(self, mock_get_utility, mock_notAfter):
|
||||
cert_path = '/etc/letsencrypt/live/foo.bar'
|
||||
date = '1970-01-01'
|
||||
|
|
@ -513,7 +513,7 @@ class CLITest(unittest.TestCase): # pylint: disable=too-many-public-methods
|
|||
def _test_renewal_common(self, due_for_renewal, extra_args, log_out=None,
|
||||
args=None, should_renew=True, error_expected=False):
|
||||
# pylint: disable=too-many-locals,too-many-arguments
|
||||
cert_path = 'letsencrypt/tests/testdata/cert.pem'
|
||||
cert_path = 'certbot/tests/testdata/cert.pem'
|
||||
chain_path = '/etc/letsencrypt/live/foo.bar/fullchain.pem'
|
||||
mock_lineage = mock.MagicMock(cert=cert_path, fullchain=chain_path)
|
||||
mock_lineage.should_autorenew.return_value = due_for_renewal
|
||||
|
|
@ -524,17 +524,17 @@ class CLITest(unittest.TestCase): # pylint: disable=too-many-public-methods
|
|||
mock_client.obtain_certificate.return_value = (mock_certr, 'chain',
|
||||
mock_key, 'csr')
|
||||
try:
|
||||
with mock.patch('letsencrypt.main._find_duplicative_certs') as mock_fdc:
|
||||
with mock.patch('certbot.main._find_duplicative_certs') as mock_fdc:
|
||||
mock_fdc.return_value = (mock_lineage, None)
|
||||
with mock.patch('letsencrypt.main._init_le_client') as mock_init:
|
||||
with mock.patch('certbot.main._init_le_client') as mock_init:
|
||||
mock_init.return_value = mock_client
|
||||
get_utility_path = 'letsencrypt.main.zope.component.getUtility'
|
||||
get_utility_path = 'certbot.main.zope.component.getUtility'
|
||||
with mock.patch(get_utility_path) as mock_get_utility:
|
||||
with mock.patch('letsencrypt.main.renewal.OpenSSL') as mock_ssl:
|
||||
with mock.patch('certbot.main.renewal.OpenSSL') as mock_ssl:
|
||||
mock_latest = mock.MagicMock()
|
||||
mock_latest.get_issuer.return_value = "Fake fake"
|
||||
mock_ssl.crypto.load_certificate.return_value = mock_latest
|
||||
with mock.patch('letsencrypt.main.renewal.crypto_util'):
|
||||
with mock.patch('certbot.main.renewal.crypto_util'):
|
||||
if not args:
|
||||
args = ['-d', 'isnot.org', '-a', 'standalone', 'certonly']
|
||||
if extra_args:
|
||||
|
|
@ -625,7 +625,7 @@ class CLITest(unittest.TestCase): # pylint: disable=too-many-public-methods
|
|||
self.assertEqual("", out)
|
||||
|
||||
|
||||
@mock.patch("letsencrypt.cli.set_by_cli")
|
||||
@mock.patch("certbot.cli.set_by_cli")
|
||||
def test_ancient_webroot_renewal_conf(self, mock_set_by_cli):
|
||||
mock_set_by_cli.return_value = False
|
||||
rc_path = self._make_test_renewal_conf('sample-renewal-ancient.conf')
|
||||
|
|
@ -656,7 +656,7 @@ class CLITest(unittest.TestCase): # pylint: disable=too-many-public-methods
|
|||
def _test_renew_common(self, renewalparams=None, names=None,
|
||||
assert_oc_called=None, **kwargs):
|
||||
self._make_dummy_renewal_config()
|
||||
with mock.patch('letsencrypt.storage.RenewableCert') as mock_rc:
|
||||
with mock.patch('certbot.storage.RenewableCert') as mock_rc:
|
||||
mock_lineage = mock.MagicMock()
|
||||
mock_lineage.fullchain = "somepath/fullchain.pem"
|
||||
if renewalparams is not None:
|
||||
|
|
@ -664,7 +664,7 @@ class CLITest(unittest.TestCase): # pylint: disable=too-many-public-methods
|
|||
if names is not None:
|
||||
mock_lineage.names.return_value = names
|
||||
mock_rc.return_value = mock_lineage
|
||||
with mock.patch('letsencrypt.main.obtain_cert') as mock_obtain_cert:
|
||||
with mock.patch('certbot.main.obtain_cert') as mock_obtain_cert:
|
||||
kwargs.setdefault('args', ['renew'])
|
||||
self._test_renewal_common(True, None, should_renew=False, **kwargs)
|
||||
|
||||
|
|
@ -714,19 +714,19 @@ class CLITest(unittest.TestCase): # pylint: disable=too-many-public-methods
|
|||
|
||||
def test_renew_reconstitute_error(self):
|
||||
# pylint: disable=protected-access
|
||||
with mock.patch('letsencrypt.main.renewal._reconstitute') as mock_reconstitute:
|
||||
with mock.patch('certbot.main.renewal._reconstitute') as mock_reconstitute:
|
||||
mock_reconstitute.side_effect = Exception
|
||||
self._test_renew_common(assert_oc_called=False, error_expected=True)
|
||||
|
||||
def test_renew_obtain_cert_error(self):
|
||||
self._make_dummy_renewal_config()
|
||||
with mock.patch('letsencrypt.storage.RenewableCert') as mock_rc:
|
||||
with mock.patch('certbot.storage.RenewableCert') as mock_rc:
|
||||
mock_lineage = mock.MagicMock()
|
||||
mock_lineage.fullchain = "somewhere/fullchain.pem"
|
||||
mock_rc.return_value = mock_lineage
|
||||
mock_lineage.configuration = {
|
||||
'renewalparams': {'authenticator': 'webroot'}}
|
||||
with mock.patch('letsencrypt.main.obtain_cert') as mock_obtain_cert:
|
||||
with mock.patch('certbot.main.obtain_cert') as mock_obtain_cert:
|
||||
mock_obtain_cert.side_effect = Exception
|
||||
self._test_renewal_common(True, None, error_expected=True,
|
||||
args=['renew'], should_renew=False)
|
||||
|
|
@ -737,9 +737,9 @@ class CLITest(unittest.TestCase): # pylint: disable=too-many-public-methods
|
|||
self._test_renewal_common(True, None, args='renew --csr {0}'.format(CSR).split(),
|
||||
should_renew=False, error_expected=True)
|
||||
|
||||
@mock.patch('letsencrypt.main.zope.component.getUtility')
|
||||
@mock.patch('letsencrypt.main._treat_as_renewal')
|
||||
@mock.patch('letsencrypt.main._init_le_client')
|
||||
@mock.patch('certbot.main.zope.component.getUtility')
|
||||
@mock.patch('certbot.main._treat_as_renewal')
|
||||
@mock.patch('certbot.main._init_le_client')
|
||||
def test_certonly_reinstall(self, mock_init, mock_renewal, mock_get_utility):
|
||||
mock_renewal.return_value = ('reinstall', mock.MagicMock())
|
||||
mock_init.return_value = mock_client = mock.MagicMock()
|
||||
|
|
@ -756,9 +756,9 @@ class CLITest(unittest.TestCase): # pylint: disable=too-many-public-methods
|
|||
mock_client.obtain_certificate_from_csr.return_value = (certr, chain)
|
||||
cert_path = '/etc/letsencrypt/live/example.com/cert.pem'
|
||||
mock_client.save_certificate.return_value = cert_path, None, None
|
||||
with mock.patch('letsencrypt.main._init_le_client') as mock_init:
|
||||
with mock.patch('certbot.main._init_le_client') as mock_init:
|
||||
mock_init.return_value = mock_client
|
||||
get_utility_path = 'letsencrypt.main.zope.component.getUtility'
|
||||
get_utility_path = 'certbot.main.zope.component.getUtility'
|
||||
with mock.patch(get_utility_path) as mock_get_utility:
|
||||
chain_path = '/etc/letsencrypt/live/example.com/chain.pem'
|
||||
full_path = '/etc/letsencrypt/live/example.com/fullchain.pem'
|
||||
|
|
@ -767,7 +767,7 @@ class CLITest(unittest.TestCase): # pylint: disable=too-many-public-methods
|
|||
CSR, cert_path, chain_path, full_path).split()
|
||||
if extra_args:
|
||||
args += extra_args
|
||||
with mock.patch('letsencrypt.main.crypto_util'):
|
||||
with mock.patch('certbot.main.crypto_util'):
|
||||
self._call(args)
|
||||
|
||||
if '--dry-run' in args:
|
||||
|
|
@ -791,7 +791,7 @@ class CLITest(unittest.TestCase): # pylint: disable=too-many-public-methods
|
|||
self.assertTrue(
|
||||
'dry run' in mock_get_utility().add_message.call_args[0][0])
|
||||
|
||||
@mock.patch('letsencrypt.main.client.acme_client')
|
||||
@mock.patch('certbot.main.client.acme_client')
|
||||
def test_revoke_with_key(self, mock_acme_client):
|
||||
server = 'foo.bar'
|
||||
self._call_no_clientmock(['--cert-path', CERT, '--key-path', KEY,
|
||||
|
|
@ -804,7 +804,7 @@ class CLITest(unittest.TestCase): # pylint: disable=too-many-public-methods
|
|||
mock_revoke = mock_acme_client.Client().revoke
|
||||
mock_revoke.assert_called_once_with(jose.ComparableX509(cert))
|
||||
|
||||
@mock.patch('letsencrypt.main._determine_account')
|
||||
@mock.patch('certbot.main._determine_account')
|
||||
def test_revoke_without_key(self, mock_determine_account):
|
||||
mock_determine_account.return_value = (mock.MagicMock(), None)
|
||||
_, _, _, client = self._call(['--cert-path', CERT, 'revoke'])
|
||||
|
|
@ -813,7 +813,7 @@ class CLITest(unittest.TestCase): # pylint: disable=too-many-public-methods
|
|||
mock_revoke = client.acme_from_config_key().revoke
|
||||
mock_revoke.assert_called_once_with(jose.ComparableX509(cert))
|
||||
|
||||
@mock.patch('letsencrypt.main.sys')
|
||||
@mock.patch('certbot.main.sys')
|
||||
def test_handle_exception(self, mock_sys):
|
||||
# pylint: disable=protected-access
|
||||
from acme import messages
|
||||
|
|
@ -821,7 +821,7 @@ class CLITest(unittest.TestCase): # pylint: disable=too-many-public-methods
|
|||
config = mock.MagicMock()
|
||||
mock_open = mock.mock_open()
|
||||
|
||||
with mock.patch('letsencrypt.main.open', mock_open, create=True):
|
||||
with mock.patch('certbot.main.open', mock_open, create=True):
|
||||
exception = Exception('detail')
|
||||
config.verbose_count = 1
|
||||
main._handle_exception(
|
||||
|
|
@ -831,7 +831,7 @@ class CLITest(unittest.TestCase): # pylint: disable=too-many-public-methods
|
|||
error_msg = mock_sys.exit.call_args_list[0][0][0]
|
||||
self.assertTrue('unexpected error' in error_msg)
|
||||
|
||||
with mock.patch('letsencrypt.main.open', mock_open, create=True):
|
||||
with mock.patch('certbot.main.open', mock_open, create=True):
|
||||
mock_open.side_effect = [KeyboardInterrupt]
|
||||
error = errors.Error('detail')
|
||||
main._handle_exception(
|
||||
|
|
@ -878,13 +878,13 @@ class CLITest(unittest.TestCase): # pylint: disable=too-many-public-methods
|
|||
self.assertEqual(contents, test_contents)
|
||||
|
||||
def test_agree_dev_preview_config(self):
|
||||
with mock.patch('letsencrypt.main.run') as mocked_run:
|
||||
with mock.patch('certbot.main.run') as mocked_run:
|
||||
self._call(['-c', test_util.vector_path('cli.ini')])
|
||||
self.assertTrue(mocked_run.called)
|
||||
|
||||
|
||||
class DetermineAccountTest(unittest.TestCase):
|
||||
"""Tests for letsencrypt.cli._determine_account."""
|
||||
"""Tests for certbot.cli._determine_account."""
|
||||
|
||||
def setUp(self):
|
||||
self.args = mock.MagicMock(account=None, email=None,
|
||||
|
|
@ -895,8 +895,8 @@ class DetermineAccountTest(unittest.TestCase):
|
|||
|
||||
def _call(self):
|
||||
# pylint: disable=protected-access
|
||||
from letsencrypt.main import _determine_account
|
||||
with mock.patch('letsencrypt.main.account.AccountFileStorage') as mock_storage:
|
||||
from certbot.main import _determine_account
|
||||
with mock.patch('certbot.main.account.AccountFileStorage') as mock_storage:
|
||||
mock_storage.return_value = self.account_storage
|
||||
return _determine_account(self.config)
|
||||
|
||||
|
|
@ -913,7 +913,7 @@ class DetermineAccountTest(unittest.TestCase):
|
|||
self.assertEqual(self.accs[0].id, self.config.account)
|
||||
self.assertTrue(self.config.email is None)
|
||||
|
||||
@mock.patch('letsencrypt.client.display_ops.choose_account')
|
||||
@mock.patch('certbot.client.display_ops.choose_account')
|
||||
def test_multiple_accounts(self, mock_choose_accounts):
|
||||
for acc in self.accs:
|
||||
self.account_storage.save(acc)
|
||||
|
|
@ -924,11 +924,11 @@ class DetermineAccountTest(unittest.TestCase):
|
|||
self.assertEqual(self.accs[1].id, self.config.account)
|
||||
self.assertTrue(self.config.email is None)
|
||||
|
||||
@mock.patch('letsencrypt.client.display_ops.get_email')
|
||||
@mock.patch('certbot.client.display_ops.get_email')
|
||||
def test_no_accounts_no_email(self, mock_get_email):
|
||||
mock_get_email.return_value = 'foo@bar.baz'
|
||||
|
||||
with mock.patch('letsencrypt.main.client') as client:
|
||||
with mock.patch('certbot.main.client') as client:
|
||||
client.register.return_value = (
|
||||
self.accs[0], mock.sentinel.acme)
|
||||
self.assertEqual((self.accs[0], mock.sentinel.acme), self._call())
|
||||
|
|
@ -940,7 +940,7 @@ class DetermineAccountTest(unittest.TestCase):
|
|||
|
||||
def test_no_accounts_email(self):
|
||||
self.config.email = 'other email'
|
||||
with mock.patch('letsencrypt.main.client') as client:
|
||||
with mock.patch('certbot.main.client') as client:
|
||||
client.register.return_value = (self.accs[1], mock.sentinel.acme)
|
||||
self._call()
|
||||
self.assertEqual(self.accs[1].id, self.config.account)
|
||||
|
|
@ -958,9 +958,9 @@ class DuplicativeCertsTest(storage_test.BaseRenewableCertTest):
|
|||
def tearDown(self):
|
||||
shutil.rmtree(self.tempdir)
|
||||
|
||||
@mock.patch('letsencrypt.le_util.make_or_verify_dir')
|
||||
@mock.patch('certbot.le_util.make_or_verify_dir')
|
||||
def test_find_duplicative_names(self, unused_makedir):
|
||||
from letsencrypt.main import _find_duplicative_certs
|
||||
from certbot.main import _find_duplicative_certs
|
||||
test_cert = test_util.load_vector('cert-san.pem')
|
||||
with open(self.test_rc.cert, 'w') as f:
|
||||
f.write(test_cert)
|
||||
|
|
@ -989,7 +989,7 @@ class DuplicativeCertsTest(storage_test.BaseRenewableCertTest):
|
|||
|
||||
|
||||
class DefaultTest(unittest.TestCase):
|
||||
"""Tests for letsencrypt.cli._Default."""
|
||||
"""Tests for certbot.cli._Default."""
|
||||
|
||||
def setUp(self):
|
||||
# pylint: disable=protected-access
|
||||
|
|
@ -1008,7 +1008,7 @@ class DefaultTest(unittest.TestCase):
|
|||
|
||||
|
||||
class SetByCliTest(unittest.TestCase):
|
||||
"""Tests for letsencrypt.set_by_cli and related functions."""
|
||||
"""Tests for certbot.set_by_cli and related functions."""
|
||||
|
||||
def setUp(self):
|
||||
reload_module(cli)
|
||||
|
|
@ -1056,7 +1056,7 @@ class SetByCliTest(unittest.TestCase):
|
|||
|
||||
|
||||
def _call_set_by_cli(var, args, verb):
|
||||
with mock.patch('letsencrypt.cli.helpful_parser') as mock_parser:
|
||||
with mock.patch('certbot.cli.helpful_parser') as mock_parser:
|
||||
mock_parser.args = args
|
||||
mock_parser.verb = verb
|
||||
return cli.set_by_cli(var)
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
"""Tests for letsencrypt.client."""
|
||||
"""Tests for certbot.client."""
|
||||
import os
|
||||
import shutil
|
||||
import tempfile
|
||||
|
|
@ -9,11 +9,11 @@ import mock
|
|||
|
||||
from acme import jose
|
||||
|
||||
from letsencrypt import account
|
||||
from letsencrypt import errors
|
||||
from letsencrypt import le_util
|
||||
from certbot import account
|
||||
from certbot import errors
|
||||
from certbot import le_util
|
||||
|
||||
from letsencrypt.tests import test_util
|
||||
from certbot.tests import test_util
|
||||
|
||||
|
||||
KEY = test_util.load_vector("rsa512_key.pem")
|
||||
|
|
@ -30,7 +30,7 @@ class ConfigHelper(object):
|
|||
self.__dict__.update(kwds)
|
||||
|
||||
class RegisterTest(unittest.TestCase):
|
||||
"""Tests for letsencrypt.client.register."""
|
||||
"""Tests for certbot.client.register."""
|
||||
|
||||
def setUp(self):
|
||||
self.config = mock.MagicMock(rsa_key_size=1024, register_unsafely_without_email=False)
|
||||
|
|
@ -38,13 +38,13 @@ class RegisterTest(unittest.TestCase):
|
|||
self.tos_cb = mock.MagicMock()
|
||||
|
||||
def _call(self):
|
||||
from letsencrypt.client import register
|
||||
from certbot.client import register
|
||||
return register(self.config, self.account_storage, self.tos_cb)
|
||||
|
||||
def test_no_tos(self):
|
||||
with mock.patch("letsencrypt.client.acme_client.Client") as mock_client:
|
||||
with mock.patch("certbot.client.acme_client.Client") as mock_client:
|
||||
mock_client.register().terms_of_service = "http://tos"
|
||||
with mock.patch("letsencrypt.account.report_new_account"):
|
||||
with mock.patch("certbot.account.report_new_account"):
|
||||
self.tos_cb.return_value = False
|
||||
self.assertRaises(errors.Error, self._call)
|
||||
|
||||
|
|
@ -55,17 +55,17 @@ class RegisterTest(unittest.TestCase):
|
|||
self._call()
|
||||
|
||||
def test_it(self):
|
||||
with mock.patch("letsencrypt.client.acme_client.Client"):
|
||||
with mock.patch("letsencrypt.account.report_new_account"):
|
||||
with mock.patch("certbot.client.acme_client.Client"):
|
||||
with mock.patch("certbot.account.report_new_account"):
|
||||
self._call()
|
||||
|
||||
@mock.patch("letsencrypt.account.report_new_account")
|
||||
@mock.patch("letsencrypt.client.display_ops.get_email")
|
||||
@mock.patch("certbot.account.report_new_account")
|
||||
@mock.patch("certbot.client.display_ops.get_email")
|
||||
def test_email_retry(self, _rep, mock_get_email):
|
||||
from acme import messages
|
||||
msg = "DNS problem: NXDOMAIN looking up MX for example.com"
|
||||
mx_err = messages.Error(detail=msg, typ="urn:acme:error:invalidEmail")
|
||||
with mock.patch("letsencrypt.client.acme_client.Client") as mock_client:
|
||||
with mock.patch("certbot.client.acme_client.Client") as mock_client:
|
||||
mock_client().register.side_effect = [mx_err, mock.MagicMock()]
|
||||
self._call()
|
||||
self.assertEqual(mock_get_email.call_count, 1)
|
||||
|
|
@ -74,10 +74,10 @@ class RegisterTest(unittest.TestCase):
|
|||
self.config.email = None
|
||||
self.assertRaises(errors.Error, self._call)
|
||||
|
||||
@mock.patch("letsencrypt.client.logger")
|
||||
@mock.patch("certbot.client.logger")
|
||||
def test_without_email(self, mock_logger):
|
||||
with mock.patch("letsencrypt.client.acme_client.Client"):
|
||||
with mock.patch("letsencrypt.account.report_new_account"):
|
||||
with mock.patch("certbot.client.acme_client.Client"):
|
||||
with mock.patch("certbot.account.report_new_account"):
|
||||
self.config.email = None
|
||||
self.config.register_unsafely_without_email = True
|
||||
self.config.dry_run = False
|
||||
|
|
@ -88,12 +88,12 @@ class RegisterTest(unittest.TestCase):
|
|||
from acme import messages
|
||||
msg = "Test"
|
||||
mx_err = messages.Error(detail=msg, typ="malformed", title="title")
|
||||
with mock.patch("letsencrypt.client.acme_client.Client") as mock_client:
|
||||
with mock.patch("certbot.client.acme_client.Client") as mock_client:
|
||||
mock_client().register.side_effect = [mx_err, mock.MagicMock()]
|
||||
self.assertRaises(messages.Error, self._call)
|
||||
|
||||
class ClientTest(unittest.TestCase):
|
||||
"""Tests for letsencrypt.client.Client."""
|
||||
"""Tests for certbot.client.Client."""
|
||||
|
||||
def setUp(self):
|
||||
self.config = mock.MagicMock(
|
||||
|
|
@ -102,8 +102,8 @@ class ClientTest(unittest.TestCase):
|
|||
self.account = mock.MagicMock(**{"key.pem": KEY})
|
||||
self.eg_domains = ["example.com", "www.example.com"]
|
||||
|
||||
from letsencrypt.client import Client
|
||||
with mock.patch("letsencrypt.client.acme_client.Client") as acme:
|
||||
from certbot.client import Client
|
||||
with mock.patch("certbot.client.acme_client.Client") as acme:
|
||||
self.acme_client = acme
|
||||
self.acme = acme.return_value = mock.MagicMock()
|
||||
self.client = Client(
|
||||
|
|
@ -135,16 +135,16 @@ class ClientTest(unittest.TestCase):
|
|||
self.acme.fetch_chain.assert_called_once_with(mock.sentinel.certr)
|
||||
|
||||
# FIXME move parts of this to test_cli.py...
|
||||
@mock.patch("letsencrypt.client.logger")
|
||||
@mock.patch("certbot.client.logger")
|
||||
def test_obtain_certificate_from_csr(self, mock_logger):
|
||||
self._mock_obtain_certificate()
|
||||
from letsencrypt import cli
|
||||
from certbot import cli
|
||||
test_csr = le_util.CSR(form="der", file=None, data=CSR_SAN)
|
||||
mock_parsed_args = mock.MagicMock()
|
||||
# The CLI should believe that this is a certonly request, because
|
||||
# a CSR would not be allowed with other kinds of requests!
|
||||
mock_parsed_args.verb = "certonly"
|
||||
with mock.patch("letsencrypt.client.le_util.CSR") as mock_CSR:
|
||||
with mock.patch("certbot.client.le_util.CSR") as mock_CSR:
|
||||
mock_CSR.return_value = test_csr
|
||||
mock_parsed_args.domains = self.eg_domains[:]
|
||||
mock_parser = mock.MagicMock(cli.HelpfulArgumentParser)
|
||||
|
|
@ -186,7 +186,7 @@ class ClientTest(unittest.TestCase):
|
|||
test_csr)
|
||||
mock_logger.warning.assert_called_once_with(mock.ANY)
|
||||
|
||||
@mock.patch("letsencrypt.client.crypto_util")
|
||||
@mock.patch("certbot.client.crypto_util")
|
||||
def test_obtain_certificate(self, mock_crypto_util):
|
||||
self._mock_obtain_certificate()
|
||||
|
||||
|
|
@ -290,7 +290,7 @@ class ClientTest(unittest.TestCase):
|
|||
["foo.bar"], "key", "cert", "chain", "fullchain")
|
||||
installer.recovery_routine.assert_called_once_with()
|
||||
|
||||
@mock.patch("letsencrypt.client.zope.component.getUtility")
|
||||
@mock.patch("certbot.client.zope.component.getUtility")
|
||||
def test_deploy_certificate_restart_failure(self, mock_get_utility):
|
||||
installer = mock.MagicMock()
|
||||
installer.restart.side_effect = [errors.PluginError, None]
|
||||
|
|
@ -302,7 +302,7 @@ class ClientTest(unittest.TestCase):
|
|||
installer.rollback_checkpoints.assert_called_once_with()
|
||||
self.assertEqual(installer.restart.call_count, 2)
|
||||
|
||||
@mock.patch("letsencrypt.client.zope.component.getUtility")
|
||||
@mock.patch("certbot.client.zope.component.getUtility")
|
||||
def test_deploy_certificate_restart_failure2(self, mock_get_utility):
|
||||
installer = mock.MagicMock()
|
||||
installer.restart.side_effect = errors.PluginError
|
||||
|
|
@ -315,7 +315,7 @@ class ClientTest(unittest.TestCase):
|
|||
installer.rollback_checkpoints.assert_called_once_with()
|
||||
self.assertEqual(installer.restart.call_count, 1)
|
||||
|
||||
@mock.patch("letsencrypt.client.enhancements")
|
||||
@mock.patch("certbot.client.enhancements")
|
||||
def test_enhance_config(self, mock_enhancements):
|
||||
config = ConfigHelper(redirect=True, hsts=False, uir=False)
|
||||
self.assertRaises(errors.Error,
|
||||
|
|
@ -331,7 +331,7 @@ class ClientTest(unittest.TestCase):
|
|||
self.assertEqual(installer.save.call_count, 1)
|
||||
installer.restart.assert_called_once_with()
|
||||
|
||||
@mock.patch("letsencrypt.client.enhancements")
|
||||
@mock.patch("certbot.client.enhancements")
|
||||
def test_enhance_config_no_ask(self, mock_enhancements):
|
||||
config = ConfigHelper(redirect=True, hsts=False, uir=False)
|
||||
self.assertRaises(errors.Error,
|
||||
|
|
@ -359,7 +359,7 @@ class ClientTest(unittest.TestCase):
|
|||
self.assertEqual(installer.save.call_count, 3)
|
||||
self.assertEqual(installer.restart.call_count, 3)
|
||||
|
||||
@mock.patch("letsencrypt.client.enhancements")
|
||||
@mock.patch("certbot.client.enhancements")
|
||||
def test_enhance_config_unsupported(self, mock_enhancements):
|
||||
installer = mock.MagicMock()
|
||||
self.client.installer = installer
|
||||
|
|
@ -375,8 +375,8 @@ class ClientTest(unittest.TestCase):
|
|||
self.assertRaises(errors.Error,
|
||||
self.client.enhance_config, ["foo.bar"], config)
|
||||
|
||||
@mock.patch("letsencrypt.client.zope.component.getUtility")
|
||||
@mock.patch("letsencrypt.client.enhancements")
|
||||
@mock.patch("certbot.client.zope.component.getUtility")
|
||||
@mock.patch("certbot.client.enhancements")
|
||||
def test_enhance_config_enhance_failure(self, mock_enhancements,
|
||||
mock_get_utility):
|
||||
mock_enhancements.ask.return_value = True
|
||||
|
|
@ -392,8 +392,8 @@ class ClientTest(unittest.TestCase):
|
|||
installer.recovery_routine.assert_called_once_with()
|
||||
self.assertEqual(mock_get_utility().add_message.call_count, 1)
|
||||
|
||||
@mock.patch("letsencrypt.client.zope.component.getUtility")
|
||||
@mock.patch("letsencrypt.client.enhancements")
|
||||
@mock.patch("certbot.client.zope.component.getUtility")
|
||||
@mock.patch("certbot.client.enhancements")
|
||||
def test_enhance_config_save_failure(self, mock_enhancements,
|
||||
mock_get_utility):
|
||||
mock_enhancements.ask.return_value = True
|
||||
|
|
@ -409,8 +409,8 @@ class ClientTest(unittest.TestCase):
|
|||
installer.recovery_routine.assert_called_once_with()
|
||||
self.assertEqual(mock_get_utility().add_message.call_count, 1)
|
||||
|
||||
@mock.patch("letsencrypt.client.zope.component.getUtility")
|
||||
@mock.patch("letsencrypt.client.enhancements")
|
||||
@mock.patch("certbot.client.zope.component.getUtility")
|
||||
@mock.patch("certbot.client.enhancements")
|
||||
def test_enhance_config_restart_failure(self, mock_enhancements,
|
||||
mock_get_utility):
|
||||
mock_enhancements.ask.return_value = True
|
||||
|
|
@ -428,8 +428,8 @@ class ClientTest(unittest.TestCase):
|
|||
installer.rollback_checkpoints.assert_called_once_with()
|
||||
self.assertEqual(installer.restart.call_count, 2)
|
||||
|
||||
@mock.patch("letsencrypt.client.zope.component.getUtility")
|
||||
@mock.patch("letsencrypt.client.enhancements")
|
||||
@mock.patch("certbot.client.zope.component.getUtility")
|
||||
@mock.patch("certbot.client.enhancements")
|
||||
def test_enhance_config_restart_failure2(self, mock_enhancements,
|
||||
mock_get_utility):
|
||||
mock_enhancements.ask.return_value = True
|
||||
|
|
@ -449,15 +449,15 @@ class ClientTest(unittest.TestCase):
|
|||
|
||||
|
||||
class RollbackTest(unittest.TestCase):
|
||||
"""Tests for letsencrypt.client.rollback."""
|
||||
"""Tests for certbot.client.rollback."""
|
||||
|
||||
def setUp(self):
|
||||
self.m_install = mock.MagicMock()
|
||||
|
||||
@classmethod
|
||||
def _call(cls, checkpoints, side_effect):
|
||||
from letsencrypt.client import rollback
|
||||
with mock.patch("letsencrypt.client.plugin_selection.pick_installer") as mpi:
|
||||
from certbot.client import rollback
|
||||
with mock.patch("certbot.client.plugin_selection.pick_installer") as mpi:
|
||||
mpi.side_effect = side_effect
|
||||
rollback(None, checkpoints, {}, mock.MagicMock())
|
||||
|
||||
|
|
@ -1,17 +1,17 @@
|
|||
"""Tests for letsencrypt.colored_logging."""
|
||||
"""Tests for certbot.colored_logging."""
|
||||
import logging
|
||||
import unittest
|
||||
|
||||
import six
|
||||
|
||||
from letsencrypt import le_util
|
||||
from certbot import le_util
|
||||
|
||||
|
||||
class StreamHandlerTest(unittest.TestCase):
|
||||
"""Tests for letsencrypt.colored_logging."""
|
||||
"""Tests for certbot.colored_logging."""
|
||||
|
||||
def setUp(self):
|
||||
from letsencrypt import colored_logging
|
||||
from certbot import colored_logging
|
||||
|
||||
self.stream = six.StringIO()
|
||||
self.stream.isatty = lambda: True
|
||||
|
|
@ -1,26 +1,26 @@
|
|||
"""Tests for letsencrypt.configuration."""
|
||||
"""Tests for certbot.configuration."""
|
||||
import os
|
||||
import unittest
|
||||
|
||||
import mock
|
||||
|
||||
from letsencrypt import errors
|
||||
from certbot import errors
|
||||
|
||||
|
||||
class NamespaceConfigTest(unittest.TestCase):
|
||||
"""Tests for letsencrypt.configuration.NamespaceConfig."""
|
||||
"""Tests for certbot.configuration.NamespaceConfig."""
|
||||
|
||||
def setUp(self):
|
||||
self.namespace = mock.MagicMock(
|
||||
config_dir='/tmp/config', work_dir='/tmp/foo', foo='bar',
|
||||
server='https://acme-server.org:443/new',
|
||||
tls_sni_01_port=1234, http01_port=4321)
|
||||
from letsencrypt.configuration import NamespaceConfig
|
||||
from certbot.configuration import NamespaceConfig
|
||||
self.config = NamespaceConfig(self.namespace)
|
||||
|
||||
def test_init_same_ports(self):
|
||||
self.namespace.tls_sni_01_port = 4321
|
||||
from letsencrypt.configuration import NamespaceConfig
|
||||
from certbot.configuration import NamespaceConfig
|
||||
self.assertRaises(errors.Error, NamespaceConfig, self.namespace)
|
||||
|
||||
def test_proxy_getattr(self):
|
||||
|
|
@ -36,7 +36,7 @@ class NamespaceConfigTest(unittest.TestCase):
|
|||
self.assertEqual(['user:pass@acme.server:443', 'p', 'a', 't', 'h'],
|
||||
self.config.server_path.split(os.path.sep))
|
||||
|
||||
@mock.patch('letsencrypt.configuration.constants')
|
||||
@mock.patch('certbot.configuration.constants')
|
||||
def test_dynamic_dirs(self, constants):
|
||||
constants.ACCOUNTS_DIR = 'acc'
|
||||
constants.BACKUP_DIR = 'backups'
|
||||
|
|
@ -55,7 +55,7 @@ class NamespaceConfigTest(unittest.TestCase):
|
|||
self.assertEqual(self.config.temp_checkpoint_dir, '/tmp/foo/t')
|
||||
|
||||
def test_absolute_paths(self):
|
||||
from letsencrypt.configuration import NamespaceConfig
|
||||
from certbot.configuration import NamespaceConfig
|
||||
|
||||
config_base = "foo"
|
||||
work_base = "bar"
|
||||
|
|
@ -88,14 +88,14 @@ class NamespaceConfigTest(unittest.TestCase):
|
|||
|
||||
|
||||
class RenewerConfigurationTest(unittest.TestCase):
|
||||
"""Test for letsencrypt.configuration.RenewerConfiguration."""
|
||||
"""Test for certbot.configuration.RenewerConfiguration."""
|
||||
|
||||
def setUp(self):
|
||||
self.namespace = mock.MagicMock(config_dir='/tmp/config')
|
||||
from letsencrypt.configuration import RenewerConfiguration
|
||||
from certbot.configuration import RenewerConfiguration
|
||||
self.config = RenewerConfiguration(self.namespace)
|
||||
|
||||
@mock.patch('letsencrypt.configuration.constants')
|
||||
@mock.patch('certbot.configuration.constants')
|
||||
def test_dynamic_dirs(self, constants):
|
||||
constants.ARCHIVE_DIR = 'a'
|
||||
constants.LIVE_DIR = 'l'
|
||||
|
|
@ -109,8 +109,8 @@ class RenewerConfigurationTest(unittest.TestCase):
|
|||
self.assertEqual(self.config.renewer_config_file, '/tmp/config/r.conf')
|
||||
|
||||
def test_absolute_paths(self):
|
||||
from letsencrypt.configuration import NamespaceConfig
|
||||
from letsencrypt.configuration import RenewerConfiguration
|
||||
from certbot.configuration import NamespaceConfig
|
||||
from certbot.configuration import RenewerConfiguration
|
||||
|
||||
config_base = "foo"
|
||||
work_base = "bar"
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
"""Tests for letsencrypt.crypto_util."""
|
||||
"""Tests for certbot.crypto_util."""
|
||||
import logging
|
||||
import shutil
|
||||
import tempfile
|
||||
|
|
@ -8,9 +8,9 @@ import OpenSSL
|
|||
import mock
|
||||
import zope.component
|
||||
|
||||
from letsencrypt import errors
|
||||
from letsencrypt import interfaces
|
||||
from letsencrypt.tests import test_util
|
||||
from certbot import errors
|
||||
from certbot import interfaces
|
||||
from certbot.tests import test_util
|
||||
|
||||
|
||||
RSA256_KEY = test_util.load_vector('rsa256_key.pem')
|
||||
|
|
@ -21,7 +21,7 @@ SAN_CERT = test_util.load_vector('cert-san.pem')
|
|||
|
||||
|
||||
class InitSaveKeyTest(unittest.TestCase):
|
||||
"""Tests for letsencrypt.crypto_util.init_save_key."""
|
||||
"""Tests for certbot.crypto_util.init_save_key."""
|
||||
def setUp(self):
|
||||
logging.disable(logging.CRITICAL)
|
||||
zope.component.provideUtility(
|
||||
|
|
@ -34,24 +34,24 @@ class InitSaveKeyTest(unittest.TestCase):
|
|||
|
||||
@classmethod
|
||||
def _call(cls, key_size, key_dir):
|
||||
from letsencrypt.crypto_util import init_save_key
|
||||
return init_save_key(key_size, key_dir, 'key-letsencrypt.pem')
|
||||
from certbot.crypto_util import init_save_key
|
||||
return init_save_key(key_size, key_dir, 'key-certbot.pem')
|
||||
|
||||
@mock.patch('letsencrypt.crypto_util.make_key')
|
||||
@mock.patch('certbot.crypto_util.make_key')
|
||||
def test_success(self, mock_make):
|
||||
mock_make.return_value = 'key_pem'
|
||||
key = self._call(1024, self.key_dir)
|
||||
self.assertEqual(key.pem, 'key_pem')
|
||||
self.assertTrue('key-letsencrypt.pem' in key.file)
|
||||
self.assertTrue('key-certbot.pem' in key.file)
|
||||
|
||||
@mock.patch('letsencrypt.crypto_util.make_key')
|
||||
@mock.patch('certbot.crypto_util.make_key')
|
||||
def test_key_failure(self, mock_make):
|
||||
mock_make.side_effect = ValueError
|
||||
self.assertRaises(ValueError, self._call, 431, self.key_dir)
|
||||
|
||||
|
||||
class InitSaveCSRTest(unittest.TestCase):
|
||||
"""Tests for letsencrypt.crypto_util.init_save_csr."""
|
||||
"""Tests for certbot.crypto_util.init_save_csr."""
|
||||
|
||||
def setUp(self):
|
||||
zope.component.provideUtility(
|
||||
|
|
@ -61,31 +61,31 @@ class InitSaveCSRTest(unittest.TestCase):
|
|||
def tearDown(self):
|
||||
shutil.rmtree(self.csr_dir)
|
||||
|
||||
@mock.patch('letsencrypt.crypto_util.make_csr')
|
||||
@mock.patch('letsencrypt.crypto_util.le_util.make_or_verify_dir')
|
||||
@mock.patch('certbot.crypto_util.make_csr')
|
||||
@mock.patch('certbot.crypto_util.le_util.make_or_verify_dir')
|
||||
def test_it(self, unused_mock_verify, mock_csr):
|
||||
from letsencrypt.crypto_util import init_save_csr
|
||||
from certbot.crypto_util import init_save_csr
|
||||
|
||||
mock_csr.return_value = ('csr_pem', 'csr_der')
|
||||
|
||||
csr = init_save_csr(
|
||||
mock.Mock(pem='dummy_key'), 'example.com', self.csr_dir,
|
||||
'csr-letsencrypt.pem')
|
||||
'csr-certbot.pem')
|
||||
|
||||
self.assertEqual(csr.data, 'csr_der')
|
||||
self.assertTrue('csr-letsencrypt.pem' in csr.file)
|
||||
self.assertTrue('csr-certbot.pem' in csr.file)
|
||||
|
||||
|
||||
class MakeCSRTest(unittest.TestCase):
|
||||
"""Tests for letsencrypt.crypto_util.make_csr."""
|
||||
"""Tests for certbot.crypto_util.make_csr."""
|
||||
|
||||
@classmethod
|
||||
def _call(cls, *args, **kwargs):
|
||||
from letsencrypt.crypto_util import make_csr
|
||||
from certbot.crypto_util import make_csr
|
||||
return make_csr(*args, **kwargs)
|
||||
|
||||
def test_san(self):
|
||||
from letsencrypt.crypto_util import get_sans_from_csr
|
||||
from certbot.crypto_util import get_sans_from_csr
|
||||
# TODO: Fails for RSA256_KEY
|
||||
csr_pem, csr_der = self._call(
|
||||
RSA512_KEY, ['example.com', 'www.example.com'])
|
||||
|
|
@ -97,11 +97,11 @@ class MakeCSRTest(unittest.TestCase):
|
|||
|
||||
|
||||
class ValidCSRTest(unittest.TestCase):
|
||||
"""Tests for letsencrypt.crypto_util.valid_csr."""
|
||||
"""Tests for certbot.crypto_util.valid_csr."""
|
||||
|
||||
@classmethod
|
||||
def _call(cls, csr):
|
||||
from letsencrypt.crypto_util import valid_csr
|
||||
from certbot.crypto_util import valid_csr
|
||||
return valid_csr(csr)
|
||||
|
||||
def test_valid_pem_true(self):
|
||||
|
|
@ -124,11 +124,11 @@ class ValidCSRTest(unittest.TestCase):
|
|||
|
||||
|
||||
class CSRMatchesPubkeyTest(unittest.TestCase):
|
||||
"""Tests for letsencrypt.crypto_util.csr_matches_pubkey."""
|
||||
"""Tests for certbot.crypto_util.csr_matches_pubkey."""
|
||||
|
||||
@classmethod
|
||||
def _call(cls, *args, **kwargs):
|
||||
from letsencrypt.crypto_util import csr_matches_pubkey
|
||||
from certbot.crypto_util import csr_matches_pubkey
|
||||
return csr_matches_pubkey(*args, **kwargs)
|
||||
|
||||
def test_valid_true(self):
|
||||
|
|
@ -141,21 +141,21 @@ class CSRMatchesPubkeyTest(unittest.TestCase):
|
|||
|
||||
|
||||
class MakeKeyTest(unittest.TestCase): # pylint: disable=too-few-public-methods
|
||||
"""Tests for letsencrypt.crypto_util.make_key."""
|
||||
"""Tests for certbot.crypto_util.make_key."""
|
||||
|
||||
def test_it(self): # pylint: disable=no-self-use
|
||||
from letsencrypt.crypto_util import make_key
|
||||
from certbot.crypto_util import make_key
|
||||
# Do not test larger keys as it takes too long.
|
||||
OpenSSL.crypto.load_privatekey(
|
||||
OpenSSL.crypto.FILETYPE_PEM, make_key(1024))
|
||||
|
||||
|
||||
class ValidPrivkeyTest(unittest.TestCase):
|
||||
"""Tests for letsencrypt.crypto_util.valid_privkey."""
|
||||
"""Tests for certbot.crypto_util.valid_privkey."""
|
||||
|
||||
@classmethod
|
||||
def _call(cls, privkey):
|
||||
from letsencrypt.crypto_util import valid_privkey
|
||||
from certbot.crypto_util import valid_privkey
|
||||
return valid_privkey(privkey)
|
||||
|
||||
def test_valid_true(self):
|
||||
|
|
@ -169,11 +169,11 @@ class ValidPrivkeyTest(unittest.TestCase):
|
|||
|
||||
|
||||
class GetSANsFromCertTest(unittest.TestCase):
|
||||
"""Tests for letsencrypt.crypto_util.get_sans_from_cert."""
|
||||
"""Tests for certbot.crypto_util.get_sans_from_cert."""
|
||||
|
||||
@classmethod
|
||||
def _call(cls, *args, **kwargs):
|
||||
from letsencrypt.crypto_util import get_sans_from_cert
|
||||
from certbot.crypto_util import get_sans_from_cert
|
||||
return get_sans_from_cert(*args, **kwargs)
|
||||
|
||||
def test_single(self):
|
||||
|
|
@ -186,11 +186,11 @@ class GetSANsFromCertTest(unittest.TestCase):
|
|||
|
||||
|
||||
class GetSANsFromCSRTest(unittest.TestCase):
|
||||
"""Tests for letsencrypt.crypto_util.get_sans_from_csr."""
|
||||
"""Tests for certbot.crypto_util.get_sans_from_csr."""
|
||||
|
||||
@classmethod
|
||||
def _call(cls, *args, **kwargs):
|
||||
from letsencrypt.crypto_util import get_sans_from_csr
|
||||
from certbot.crypto_util import get_sans_from_csr
|
||||
return get_sans_from_csr(*args, **kwargs)
|
||||
|
||||
def test_extract_one_san(self):
|
||||
|
|
@ -216,36 +216,36 @@ class GetSANsFromCSRTest(unittest.TestCase):
|
|||
|
||||
|
||||
class CertLoaderTest(unittest.TestCase):
|
||||
"""Tests for letsencrypt.crypto_util.pyopenssl_load_certificate"""
|
||||
"""Tests for certbot.crypto_util.pyopenssl_load_certificate"""
|
||||
|
||||
def test_load_valid_cert(self):
|
||||
from letsencrypt.crypto_util import pyopenssl_load_certificate
|
||||
from certbot.crypto_util import pyopenssl_load_certificate
|
||||
|
||||
cert, file_type = pyopenssl_load_certificate(CERT)
|
||||
self.assertEqual(cert.digest('sha1'),
|
||||
OpenSSL.crypto.load_certificate(file_type, CERT).digest('sha1'))
|
||||
|
||||
def test_load_invalid_cert(self):
|
||||
from letsencrypt.crypto_util import pyopenssl_load_certificate
|
||||
from certbot.crypto_util import pyopenssl_load_certificate
|
||||
bad_cert_data = CERT.replace("BEGIN CERTIFICATE", "ASDFASDFASDF!!!")
|
||||
self.assertRaises(
|
||||
errors.Error, pyopenssl_load_certificate, bad_cert_data)
|
||||
|
||||
|
||||
class NotBeforeTest(unittest.TestCase):
|
||||
"""Tests for letsencrypt.crypto_util.notBefore"""
|
||||
"""Tests for certbot.crypto_util.notBefore"""
|
||||
|
||||
def test_notBefore(self):
|
||||
from letsencrypt.crypto_util import notBefore
|
||||
from certbot.crypto_util import notBefore
|
||||
self.assertEqual(notBefore(CERT_PATH).isoformat(),
|
||||
'2014-12-11T22:34:45+00:00')
|
||||
|
||||
|
||||
class NotAfterTest(unittest.TestCase):
|
||||
"""Tests for letsencrypt.crypto_util.notAfter"""
|
||||
"""Tests for certbot.crypto_util.notAfter"""
|
||||
|
||||
def test_notAfter(self):
|
||||
from letsencrypt.crypto_util import notAfter
|
||||
from certbot.crypto_util import notAfter
|
||||
self.assertEqual(notAfter(CERT_PATH).isoformat(),
|
||||
'2014-12-18T22:34:45+00:00')
|
||||
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
"""Test letsencrypt.display.completer."""
|
||||
"""Test certbot.display.completer."""
|
||||
import os
|
||||
import readline
|
||||
import shutil
|
||||
|
|
@ -12,7 +12,7 @@ from six.moves import reload_module # pylint: disable=import-error
|
|||
|
||||
|
||||
class CompleterTest(unittest.TestCase):
|
||||
"""Test letsencrypt.display.completer.Completer."""
|
||||
"""Test certbot.display.completer.Completer."""
|
||||
|
||||
def setUp(self):
|
||||
self.temp_dir = tempfile.mkdtemp()
|
||||
|
|
@ -37,7 +37,7 @@ class CompleterTest(unittest.TestCase):
|
|||
shutil.rmtree(self.temp_dir)
|
||||
|
||||
def test_complete(self):
|
||||
from letsencrypt.display import completer
|
||||
from certbot.display import completer
|
||||
my_completer = completer.Completer()
|
||||
num_paths = len(self.paths)
|
||||
|
||||
|
|
@ -59,7 +59,7 @@ class CompleterTest(unittest.TestCase):
|
|||
sys.modules['readline'] = original_readline
|
||||
|
||||
def test_context_manager_with_unmocked_readline(self):
|
||||
from letsencrypt.display import completer
|
||||
from certbot.display import completer
|
||||
reload_module(completer)
|
||||
|
||||
original_completer = readline.get_completer()
|
||||
|
|
@ -71,18 +71,18 @@ class CompleterTest(unittest.TestCase):
|
|||
self.assertEqual(readline.get_completer(), original_completer)
|
||||
self.assertEqual(readline.get_completer_delims(), original_delims)
|
||||
|
||||
@mock.patch('letsencrypt.display.completer.readline', autospec=True)
|
||||
@mock.patch('certbot.display.completer.readline', autospec=True)
|
||||
def test_context_manager_libedit(self, mock_readline):
|
||||
mock_readline.__doc__ = 'libedit'
|
||||
self._test_context_manager_with_mock_readline(mock_readline)
|
||||
|
||||
@mock.patch('letsencrypt.display.completer.readline', autospec=True)
|
||||
@mock.patch('certbot.display.completer.readline', autospec=True)
|
||||
def test_context_manager_readline(self, mock_readline):
|
||||
mock_readline.__doc__ = 'GNU readline'
|
||||
self._test_context_manager_with_mock_readline(mock_readline)
|
||||
|
||||
def _test_context_manager_with_mock_readline(self, mock_readline):
|
||||
from letsencrypt.display import completer
|
||||
from certbot.display import completer
|
||||
|
||||
mock_readline.parse_and_bind.side_effect = enable_tab_completion
|
||||
|
||||
|
|
@ -4,8 +4,8 @@ import unittest
|
|||
|
||||
import mock
|
||||
|
||||
from letsencrypt import errors
|
||||
from letsencrypt.display import util as display_util
|
||||
from certbot import errors
|
||||
from certbot.display import util as display_util
|
||||
|
||||
|
||||
class AskTest(unittest.TestCase):
|
||||
|
|
@ -18,10 +18,10 @@ class AskTest(unittest.TestCase):
|
|||
|
||||
@classmethod
|
||||
def _call(cls, enhancement):
|
||||
from letsencrypt.display.enhancements import ask
|
||||
from certbot.display.enhancements import ask
|
||||
return ask(enhancement)
|
||||
|
||||
@mock.patch("letsencrypt.display.enhancements.util")
|
||||
@mock.patch("certbot.display.enhancements.util")
|
||||
def test_redirect(self, mock_util):
|
||||
mock_util().menu.return_value = (display_util.OK, 1)
|
||||
self.assertTrue(self._call("redirect"))
|
||||
|
|
@ -34,20 +34,20 @@ class RedirectTest(unittest.TestCase):
|
|||
"""Test the redirect_by_default method."""
|
||||
@classmethod
|
||||
def _call(cls):
|
||||
from letsencrypt.display.enhancements import redirect_by_default
|
||||
from certbot.display.enhancements import redirect_by_default
|
||||
return redirect_by_default()
|
||||
|
||||
@mock.patch("letsencrypt.display.enhancements.util")
|
||||
@mock.patch("certbot.display.enhancements.util")
|
||||
def test_secure(self, mock_util):
|
||||
mock_util().menu.return_value = (display_util.OK, 1)
|
||||
self.assertTrue(self._call())
|
||||
|
||||
@mock.patch("letsencrypt.display.enhancements.util")
|
||||
@mock.patch("certbot.display.enhancements.util")
|
||||
def test_cancel(self, mock_util):
|
||||
mock_util().menu.return_value = (display_util.CANCEL, 1)
|
||||
self.assertFalse(self._call())
|
||||
|
||||
@mock.patch("letsencrypt.display.enhancements.util")
|
||||
@mock.patch("certbot.display.enhancements.util")
|
||||
def test_easy(self, mock_util):
|
||||
mock_util().menu.return_value = (display_util.OK, 0)
|
||||
self.assertFalse(self._call())
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
# coding=utf-8
|
||||
"""Test letsencrypt.display.ops."""
|
||||
"""Test certbot.display.ops."""
|
||||
import os
|
||||
import sys
|
||||
import tempfile
|
||||
|
|
@ -11,19 +11,19 @@ import zope.component
|
|||
from acme import jose
|
||||
from acme import messages
|
||||
|
||||
from letsencrypt import account
|
||||
from letsencrypt import interfaces
|
||||
from certbot import account
|
||||
from certbot import interfaces
|
||||
|
||||
from letsencrypt.display import util as display_util
|
||||
from certbot.display import util as display_util
|
||||
|
||||
from letsencrypt.tests import test_util
|
||||
from certbot.tests import test_util
|
||||
|
||||
|
||||
KEY = jose.JWKRSA.load(test_util.load_vector("rsa512_key.pem"))
|
||||
|
||||
|
||||
class GetEmailTest(unittest.TestCase):
|
||||
"""Tests for letsencrypt.display.ops.get_email."""
|
||||
"""Tests for certbot.display.ops.get_email."""
|
||||
|
||||
def setUp(self):
|
||||
mock_display = mock.MagicMock()
|
||||
|
|
@ -32,7 +32,7 @@ class GetEmailTest(unittest.TestCase):
|
|||
|
||||
@classmethod
|
||||
def _call(cls, **kwargs):
|
||||
from letsencrypt.display.ops import get_email
|
||||
from certbot.display.ops import get_email
|
||||
return get_email(**kwargs)
|
||||
|
||||
def test_cancel_none(self):
|
||||
|
|
@ -41,13 +41,13 @@ class GetEmailTest(unittest.TestCase):
|
|||
|
||||
def test_ok_safe(self):
|
||||
self.input.return_value = (display_util.OK, "foo@bar.baz")
|
||||
with mock.patch("letsencrypt.display.ops.le_util.safe_email") as mock_safe_email:
|
||||
with mock.patch("certbot.display.ops.le_util.safe_email") as mock_safe_email:
|
||||
mock_safe_email.return_value = True
|
||||
self.assertTrue(self._call() is "foo@bar.baz")
|
||||
|
||||
def test_ok_not_safe(self):
|
||||
self.input.return_value = (display_util.OK, "foo@bar.baz")
|
||||
with mock.patch("letsencrypt.display.ops.le_util.safe_email") as mock_safe_email:
|
||||
with mock.patch("certbot.display.ops.le_util.safe_email") as mock_safe_email:
|
||||
mock_safe_email.side_effect = [False, True]
|
||||
self.assertTrue(self._call() is "foo@bar.baz")
|
||||
|
||||
|
|
@ -56,7 +56,7 @@ class GetEmailTest(unittest.TestCase):
|
|||
invalid_txt = "There seem to be problems"
|
||||
base_txt = "Enter email"
|
||||
self.input.return_value = (display_util.OK, "foo@bar.baz")
|
||||
with mock.patch("letsencrypt.display.ops.le_util.safe_email") as mock_safe_email:
|
||||
with mock.patch("certbot.display.ops.le_util.safe_email") as mock_safe_email:
|
||||
mock_safe_email.return_value = True
|
||||
self._call()
|
||||
msg = self.input.call_args[0][0]
|
||||
|
|
@ -75,7 +75,7 @@ class GetEmailTest(unittest.TestCase):
|
|||
|
||||
|
||||
class ChooseAccountTest(unittest.TestCase):
|
||||
"""Tests for letsencrypt.display.ops.choose_account."""
|
||||
"""Tests for certbot.display.ops.choose_account."""
|
||||
def setUp(self):
|
||||
zope.component.provideUtility(display_util.FileDisplay(sys.stdout))
|
||||
|
||||
|
|
@ -86,7 +86,7 @@ class ChooseAccountTest(unittest.TestCase):
|
|||
self.config = mock.MagicMock(
|
||||
accounts_dir=self.accounts_dir,
|
||||
account_keys_dir=self.account_keys_dir,
|
||||
server="letsencrypt-demo.org")
|
||||
server="certbot-demo.org")
|
||||
self.key = KEY
|
||||
|
||||
self.acc1 = account.Account(messages.RegistrationResource(
|
||||
|
|
@ -98,20 +98,20 @@ class ChooseAccountTest(unittest.TestCase):
|
|||
|
||||
@classmethod
|
||||
def _call(cls, accounts):
|
||||
from letsencrypt.display import ops
|
||||
from certbot.display import ops
|
||||
return ops.choose_account(accounts)
|
||||
|
||||
@mock.patch("letsencrypt.display.ops.z_util")
|
||||
@mock.patch("certbot.display.ops.z_util")
|
||||
def test_one(self, mock_util):
|
||||
mock_util().menu.return_value = (display_util.OK, 0)
|
||||
self.assertEqual(self._call([self.acc1]), self.acc1)
|
||||
|
||||
@mock.patch("letsencrypt.display.ops.z_util")
|
||||
@mock.patch("certbot.display.ops.z_util")
|
||||
def test_two(self, mock_util):
|
||||
mock_util().menu.return_value = (display_util.OK, 1)
|
||||
self.assertEqual(self._call([self.acc1, self.acc2]), self.acc2)
|
||||
|
||||
@mock.patch("letsencrypt.display.ops.z_util")
|
||||
@mock.patch("certbot.display.ops.z_util")
|
||||
def test_cancel(self, mock_util):
|
||||
mock_util().menu.return_value = (display_util.CANCEL, 1)
|
||||
self.assertTrue(self._call([self.acc1, self.acc2]) is None)
|
||||
|
|
@ -124,7 +124,7 @@ class GenSSLLabURLs(unittest.TestCase):
|
|||
|
||||
@classmethod
|
||||
def _call(cls, domains):
|
||||
from letsencrypt.display.ops import _gen_ssl_lab_urls
|
||||
from certbot.display.ops import _gen_ssl_lab_urls
|
||||
return _gen_ssl_lab_urls(domains)
|
||||
|
||||
def test_zero(self):
|
||||
|
|
@ -143,7 +143,7 @@ class GenHttpsNamesTest(unittest.TestCase):
|
|||
|
||||
@classmethod
|
||||
def _call(cls, domains):
|
||||
from letsencrypt.display.ops import _gen_https_names
|
||||
from certbot.display.ops import _gen_https_names
|
||||
return _gen_https_names(domains)
|
||||
|
||||
def test_zero(self):
|
||||
|
|
@ -191,20 +191,20 @@ class ChooseNamesTest(unittest.TestCase):
|
|||
|
||||
@classmethod
|
||||
def _call(cls, installer):
|
||||
from letsencrypt.display.ops import choose_names
|
||||
from certbot.display.ops import choose_names
|
||||
return choose_names(installer)
|
||||
|
||||
@mock.patch("letsencrypt.display.ops._choose_names_manually")
|
||||
@mock.patch("certbot.display.ops._choose_names_manually")
|
||||
def test_no_installer(self, mock_manual):
|
||||
self._call(None)
|
||||
self.assertEqual(mock_manual.call_count, 1)
|
||||
|
||||
@mock.patch("letsencrypt.display.ops.z_util")
|
||||
@mock.patch("certbot.display.ops.z_util")
|
||||
def test_no_installer_cancel(self, mock_util):
|
||||
mock_util().input.return_value = (display_util.CANCEL, [])
|
||||
self.assertEqual(self._call(None), [])
|
||||
|
||||
@mock.patch("letsencrypt.display.ops.z_util")
|
||||
@mock.patch("certbot.display.ops.z_util")
|
||||
def test_no_names_choose(self, mock_util):
|
||||
self.mock_install().get_all_names.return_value = set()
|
||||
mock_util().yesno.return_value = True
|
||||
|
|
@ -215,14 +215,14 @@ class ChooseNamesTest(unittest.TestCase):
|
|||
self.assertEqual(mock_util().input.call_count, 1)
|
||||
self.assertEqual(actual_doms, [domain])
|
||||
|
||||
@mock.patch("letsencrypt.display.ops.z_util")
|
||||
@mock.patch("certbot.display.ops.z_util")
|
||||
def test_no_names_quit(self, mock_util):
|
||||
self.mock_install().get_all_names.return_value = set()
|
||||
mock_util().yesno.return_value = False
|
||||
|
||||
self.assertEqual(self._call(self.mock_install), [])
|
||||
|
||||
@mock.patch("letsencrypt.display.ops.z_util")
|
||||
@mock.patch("certbot.display.ops.z_util")
|
||||
def test_filter_names_valid_return(self, mock_util):
|
||||
self.mock_install.get_all_names.return_value = set(["example.com"])
|
||||
mock_util().checklist.return_value = (display_util.OK, ["example.com"])
|
||||
|
|
@ -231,14 +231,14 @@ class ChooseNamesTest(unittest.TestCase):
|
|||
self.assertEqual(names, ["example.com"])
|
||||
self.assertEqual(mock_util().checklist.call_count, 1)
|
||||
|
||||
@mock.patch("letsencrypt.display.ops.z_util")
|
||||
@mock.patch("certbot.display.ops.z_util")
|
||||
def test_filter_names_nothing_selected(self, mock_util):
|
||||
self.mock_install.get_all_names.return_value = set(["example.com"])
|
||||
mock_util().checklist.return_value = (display_util.OK, [])
|
||||
|
||||
self.assertEqual(self._call(self.mock_install), [])
|
||||
|
||||
@mock.patch("letsencrypt.display.ops.z_util")
|
||||
@mock.patch("certbot.display.ops.z_util")
|
||||
def test_filter_names_cancel(self, mock_util):
|
||||
self.mock_install.get_all_names.return_value = set(["example.com"])
|
||||
mock_util().checklist.return_value = (
|
||||
|
|
@ -247,7 +247,7 @@ class ChooseNamesTest(unittest.TestCase):
|
|||
self.assertEqual(self._call(self.mock_install), [])
|
||||
|
||||
def test_get_valid_domains(self):
|
||||
from letsencrypt.display.ops import get_valid_domains
|
||||
from certbot.display.ops import get_valid_domains
|
||||
all_valid = ["example.com", "second.example.com",
|
||||
"also.example.com"]
|
||||
all_invalid = ["xn--ls8h.tld", "*.wildcard.com", "notFQDN",
|
||||
|
|
@ -257,9 +257,9 @@ class ChooseNamesTest(unittest.TestCase):
|
|||
self.assertEqual(get_valid_domains(all_invalid), [])
|
||||
self.assertEqual(len(get_valid_domains(two_valid)), 2)
|
||||
|
||||
@mock.patch("letsencrypt.display.ops.z_util")
|
||||
@mock.patch("certbot.display.ops.z_util")
|
||||
def test_choose_manually(self, mock_util):
|
||||
from letsencrypt.display.ops import _choose_names_manually
|
||||
from certbot.display.ops import _choose_names_manually
|
||||
# No retry
|
||||
mock_util().yesno.return_value = False
|
||||
# IDN and no retry
|
||||
|
|
@ -268,7 +268,7 @@ class ChooseNamesTest(unittest.TestCase):
|
|||
self.assertEqual(_choose_names_manually(), [])
|
||||
# IDN exception with previous mocks
|
||||
with mock.patch(
|
||||
"letsencrypt.display.ops.display_util.separate_list_input"
|
||||
"certbot.display.ops.display_util.separate_list_input"
|
||||
) as mock_sli:
|
||||
unicode_error = UnicodeEncodeError('mock', u'', 0, 1, 'mock')
|
||||
mock_sli.side_effect = unicode_error
|
||||
|
|
@ -302,10 +302,10 @@ class SuccessInstallationTest(unittest.TestCase):
|
|||
"""Test the success installation message."""
|
||||
@classmethod
|
||||
def _call(cls, names):
|
||||
from letsencrypt.display.ops import success_installation
|
||||
from certbot.display.ops import success_installation
|
||||
success_installation(names)
|
||||
|
||||
@mock.patch("letsencrypt.display.ops.z_util")
|
||||
@mock.patch("certbot.display.ops.z_util")
|
||||
def test_success_installation(self, mock_util):
|
||||
mock_util().notification.return_value = None
|
||||
names = ["example.com", "abc.com"]
|
||||
|
|
@ -324,10 +324,10 @@ class SuccessRenewalTest(unittest.TestCase):
|
|||
"""Test the success renewal message."""
|
||||
@classmethod
|
||||
def _call(cls, names):
|
||||
from letsencrypt.display.ops import success_renewal
|
||||
from certbot.display.ops import success_renewal
|
||||
success_renewal(names, "renew")
|
||||
|
||||
@mock.patch("letsencrypt.display.ops.z_util")
|
||||
@mock.patch("certbot.display.ops.z_util")
|
||||
def test_success_renewal(self, mock_util):
|
||||
mock_util().notification.return_value = None
|
||||
names = ["example.com", "abc.com"]
|
||||
|
|
@ -1,12 +1,12 @@
|
|||
"""Test :mod:`letsencrypt.display.util`."""
|
||||
"""Test :mod:`certbot.display.util`."""
|
||||
import os
|
||||
import unittest
|
||||
|
||||
import mock
|
||||
|
||||
import letsencrypt.errors as errors
|
||||
import certbot.errors as errors
|
||||
|
||||
from letsencrypt.display import util as display_util
|
||||
from certbot.display import util as display_util
|
||||
|
||||
|
||||
CHOICES = [("First", "Description1"), ("Second", "Description2")]
|
||||
|
|
@ -40,13 +40,13 @@ class NcursesDisplayTest(unittest.TestCase):
|
|||
"menu_height": display_util.HEIGHT - 6,
|
||||
}
|
||||
|
||||
@mock.patch("letsencrypt.display.util.dialog.Dialog.msgbox")
|
||||
@mock.patch("certbot.display.util.dialog.Dialog.msgbox")
|
||||
def test_notification(self, mock_msgbox):
|
||||
"""Kind of worthless... one liner."""
|
||||
self.displayer.notification("message")
|
||||
self.assertEqual(mock_msgbox.call_count, 1)
|
||||
|
||||
@mock.patch("letsencrypt.display.util.dialog.Dialog.menu")
|
||||
@mock.patch("certbot.display.util.dialog.Dialog.menu")
|
||||
def test_menu_tag_and_desc(self, mock_menu):
|
||||
mock_menu.return_value = (display_util.OK, "First")
|
||||
|
||||
|
|
@ -55,7 +55,7 @@ class NcursesDisplayTest(unittest.TestCase):
|
|||
|
||||
self.assertEqual(ret, (display_util.OK, 0))
|
||||
|
||||
@mock.patch("letsencrypt.display.util.dialog.Dialog.menu")
|
||||
@mock.patch("certbot.display.util.dialog.Dialog.menu")
|
||||
def test_menu_tag_and_desc_cancel(self, mock_menu):
|
||||
mock_menu.return_value = (display_util.CANCEL, "")
|
||||
|
||||
|
|
@ -65,7 +65,7 @@ class NcursesDisplayTest(unittest.TestCase):
|
|||
|
||||
self.assertEqual(ret, (display_util.CANCEL, -1))
|
||||
|
||||
@mock.patch("letsencrypt.display.util.dialog.Dialog.menu")
|
||||
@mock.patch("certbot.display.util.dialog.Dialog.menu")
|
||||
def test_menu_desc_only(self, mock_menu):
|
||||
mock_menu.return_value = (display_util.OK, "1")
|
||||
|
||||
|
|
@ -77,7 +77,7 @@ class NcursesDisplayTest(unittest.TestCase):
|
|||
|
||||
self.assertEqual(ret, (display_util.OK, 0))
|
||||
|
||||
@mock.patch("letsencrypt.display.util.dialog.Dialog.menu")
|
||||
@mock.patch("certbot.display.util.dialog.Dialog.menu")
|
||||
def test_menu_desc_only_help(self, mock_menu):
|
||||
mock_menu.return_value = (display_util.HELP, "2")
|
||||
|
||||
|
|
@ -85,7 +85,7 @@ class NcursesDisplayTest(unittest.TestCase):
|
|||
|
||||
self.assertEqual(ret, (display_util.HELP, 1))
|
||||
|
||||
@mock.patch("letsencrypt.display.util.dialog.Dialog.menu")
|
||||
@mock.patch("certbot.display.util.dialog.Dialog.menu")
|
||||
def test_menu_desc_only_cancel(self, mock_menu):
|
||||
mock_menu.return_value = (display_util.CANCEL, "")
|
||||
|
||||
|
|
@ -93,13 +93,13 @@ class NcursesDisplayTest(unittest.TestCase):
|
|||
|
||||
self.assertEqual(ret, (display_util.CANCEL, -1))
|
||||
|
||||
@mock.patch("letsencrypt.display.util."
|
||||
@mock.patch("certbot.display.util."
|
||||
"dialog.Dialog.inputbox")
|
||||
def test_input(self, mock_input):
|
||||
self.displayer.input("message")
|
||||
self.assertEqual(mock_input.call_count, 1)
|
||||
|
||||
@mock.patch("letsencrypt.display.util.dialog.Dialog.yesno")
|
||||
@mock.patch("certbot.display.util.dialog.Dialog.yesno")
|
||||
def test_yesno(self, mock_yesno):
|
||||
mock_yesno.return_value = display_util.OK
|
||||
|
||||
|
|
@ -109,7 +109,7 @@ class NcursesDisplayTest(unittest.TestCase):
|
|||
"message", display_util.HEIGHT, display_util.WIDTH,
|
||||
yes_label="Yes", no_label="No")
|
||||
|
||||
@mock.patch("letsencrypt.display.util."
|
||||
@mock.patch("certbot.display.util."
|
||||
"dialog.Dialog.checklist")
|
||||
def test_checklist(self, mock_checklist):
|
||||
self.displayer.checklist("message", TAGS)
|
||||
|
|
@ -123,7 +123,7 @@ class NcursesDisplayTest(unittest.TestCase):
|
|||
"message", width=display_util.WIDTH, height=display_util.HEIGHT,
|
||||
choices=choices)
|
||||
|
||||
@mock.patch("letsencrypt.display.util.dialog.Dialog.dselect")
|
||||
@mock.patch("certbot.display.util.dialog.Dialog.dselect")
|
||||
def test_directory_select(self, mock_dselect):
|
||||
self.displayer.directory_select("message")
|
||||
self.assertEqual(mock_dselect.call_count, 1)
|
||||
|
|
@ -153,7 +153,7 @@ class FileOutputDisplayTest(unittest.TestCase):
|
|||
|
||||
self.assertTrue("message" in self.mock_stdout.write.call_args[0][0])
|
||||
|
||||
@mock.patch("letsencrypt.display.util."
|
||||
@mock.patch("certbot.display.util."
|
||||
"FileDisplay._get_valid_int_ans")
|
||||
def test_menu(self, mock_ans):
|
||||
mock_ans.return_value = (display_util.OK, 1)
|
||||
|
|
@ -188,14 +188,14 @@ class FileOutputDisplayTest(unittest.TestCase):
|
|||
with mock.patch("__builtin__.raw_input", return_value="a"):
|
||||
self.assertTrue(self.displayer.yesno("msg", yes_label="Agree"))
|
||||
|
||||
@mock.patch("letsencrypt.display.util.FileDisplay.input")
|
||||
@mock.patch("certbot.display.util.FileDisplay.input")
|
||||
def test_checklist_valid(self, mock_input):
|
||||
mock_input.return_value = (display_util.OK, "2 1")
|
||||
code, tag_list = self.displayer.checklist("msg", TAGS)
|
||||
self.assertEqual(
|
||||
(code, set(tag_list)), (display_util.OK, set(["tag1", "tag2"])))
|
||||
|
||||
@mock.patch("letsencrypt.display.util.FileDisplay.input")
|
||||
@mock.patch("certbot.display.util.FileDisplay.input")
|
||||
def test_checklist_miss_valid(self, mock_input):
|
||||
mock_input.side_effect = [
|
||||
(display_util.OK, "10"),
|
||||
|
|
@ -206,7 +206,7 @@ class FileOutputDisplayTest(unittest.TestCase):
|
|||
ret = self.displayer.checklist("msg", TAGS)
|
||||
self.assertEqual(ret, (display_util.OK, ["tag1"]))
|
||||
|
||||
@mock.patch("letsencrypt.display.util.FileDisplay.input")
|
||||
@mock.patch("certbot.display.util.FileDisplay.input")
|
||||
def test_checklist_miss_quit(self, mock_input):
|
||||
mock_input.side_effect = [
|
||||
(display_util.OK, "10"),
|
||||
|
|
@ -232,7 +232,7 @@ class FileOutputDisplayTest(unittest.TestCase):
|
|||
self.displayer._scrub_checklist_input(list_, TAGS))
|
||||
self.assertEqual(set_tags, exp[i])
|
||||
|
||||
@mock.patch("letsencrypt.display.util.FileDisplay.input")
|
||||
@mock.patch("certbot.display.util.FileDisplay.input")
|
||||
def test_directory_select(self, mock_input):
|
||||
message = "msg"
|
||||
result = (display_util.OK, "/var/www/html",)
|
||||
|
|
@ -352,7 +352,7 @@ class SeparateListInputTest(unittest.TestCase):
|
|||
|
||||
@classmethod
|
||||
def _call(cls, input_):
|
||||
from letsencrypt.display.util import separate_list_input
|
||||
from certbot.display.util import separate_list_input
|
||||
return separate_list_input(input_)
|
||||
|
||||
def test_commas(self):
|
||||
|
|
@ -378,7 +378,7 @@ class SeparateListInputTest(unittest.TestCase):
|
|||
class PlaceParensTest(unittest.TestCase):
|
||||
@classmethod
|
||||
def _call(cls, label): # pylint: disable=protected-access
|
||||
from letsencrypt.display.util import _parens_around_char
|
||||
from certbot.display.util import _parens_around_char
|
||||
return _parens_around_char(label)
|
||||
|
||||
def test_single_letter(self):
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
"""Tests for letsencrypt.error_handler."""
|
||||
"""Tests for certbot.error_handler."""
|
||||
import signal
|
||||
import sys
|
||||
import unittest
|
||||
|
|
@ -7,10 +7,10 @@ import mock
|
|||
|
||||
|
||||
class ErrorHandlerTest(unittest.TestCase):
|
||||
"""Tests for letsencrypt.error_handler."""
|
||||
"""Tests for certbot.error_handler."""
|
||||
|
||||
def setUp(self):
|
||||
from letsencrypt import error_handler
|
||||
from certbot import error_handler
|
||||
|
||||
self.init_func = mock.MagicMock()
|
||||
self.init_args = set((42,))
|
||||
|
|
@ -30,8 +30,8 @@ class ErrorHandlerTest(unittest.TestCase):
|
|||
self.init_func.assert_called_once_with(*self.init_args,
|
||||
**self.init_kwargs)
|
||||
|
||||
@mock.patch('letsencrypt.error_handler.os')
|
||||
@mock.patch('letsencrypt.error_handler.signal')
|
||||
@mock.patch('certbot.error_handler.os')
|
||||
@mock.patch('certbot.error_handler.signal')
|
||||
def test_signal_handler(self, mock_signal, mock_os):
|
||||
# pylint: disable=protected-access
|
||||
mock_signal.getsignal.return_value = signal.SIG_DFL
|
||||
|
|
@ -1,19 +1,19 @@
|
|||
"""Tests for letsencrypt.errors."""
|
||||
"""Tests for certbot.errors."""
|
||||
import unittest
|
||||
|
||||
import mock
|
||||
|
||||
from acme import messages
|
||||
|
||||
from letsencrypt import achallenges
|
||||
from letsencrypt.tests import acme_util
|
||||
from certbot import achallenges
|
||||
from certbot.tests import acme_util
|
||||
|
||||
|
||||
class FaiiledChallengesTest(unittest.TestCase):
|
||||
"""Tests for letsencrypt.errors.FailedChallenges."""
|
||||
"""Tests for certbot.errors.FailedChallenges."""
|
||||
|
||||
def setUp(self):
|
||||
from letsencrypt.errors import FailedChallenges
|
||||
from certbot.errors import FailedChallenges
|
||||
self.error = FailedChallenges(set([achallenges.DNS(
|
||||
domain="example.com", challb=messages.ChallengeBody(
|
||||
chall=acme_util.DNS, uri=None,
|
||||
|
|
@ -25,10 +25,10 @@ class FaiiledChallengesTest(unittest.TestCase):
|
|||
|
||||
|
||||
class StandaloneBindErrorTest(unittest.TestCase):
|
||||
"""Tests for letsencrypt.errors.StandaloneBindError."""
|
||||
"""Tests for certbot.errors.StandaloneBindError."""
|
||||
|
||||
def setUp(self):
|
||||
from letsencrypt.errors import StandaloneBindError
|
||||
from certbot.errors import StandaloneBindError
|
||||
self.error = StandaloneBindError(mock.sentinel.error, 1234)
|
||||
|
||||
def test_instance_args(self):
|
||||
|
|
@ -6,8 +6,8 @@ import unittest
|
|||
|
||||
import mock
|
||||
|
||||
from letsencrypt import errors
|
||||
from letsencrypt import hooks
|
||||
from certbot import errors
|
||||
from certbot import hooks
|
||||
|
||||
class HookTest(unittest.TestCase):
|
||||
def setUp(self):
|
||||
|
|
@ -16,7 +16,7 @@ class HookTest(unittest.TestCase):
|
|||
def tearDown(self):
|
||||
pass
|
||||
|
||||
@mock.patch('letsencrypt.hooks._prog')
|
||||
@mock.patch('certbot.hooks._prog')
|
||||
def test_validate_hooks(self, mock_prog):
|
||||
config = mock.MagicMock(pre_hook="", post_hook="ls -lR", renew_hook="uptime")
|
||||
hooks.validate_hooks(config)
|
||||
|
|
@ -27,7 +27,7 @@ class HookTest(unittest.TestCase):
|
|||
config = mock.MagicMock(pre_hook="explodinator", post_hook="", renew_hook="")
|
||||
self.assertRaises(errors.HookCommandNotFound, hooks.validate_hooks, config)
|
||||
|
||||
@mock.patch('letsencrypt.hooks._is_exe')
|
||||
@mock.patch('certbot.hooks._is_exe')
|
||||
def test_which(self, mock_is_exe):
|
||||
mock_is_exe.return_value = True
|
||||
self.assertEqual(hooks._which("/path/to/something"), "/path/to/something")
|
||||
|
|
@ -39,7 +39,7 @@ class HookTest(unittest.TestCase):
|
|||
self.assertEqual(hooks._which("pingify"), None)
|
||||
self.assertEqual(hooks._which("/path/to/something"), None)
|
||||
|
||||
@mock.patch('letsencrypt.hooks._which')
|
||||
@mock.patch('certbot.hooks._which')
|
||||
def test_prog(self, mockwhich):
|
||||
mockwhich.return_value = "/very/very/funky"
|
||||
self.assertEqual(hooks._prog("funky"), "funky")
|
||||
|
|
@ -47,9 +47,9 @@ class HookTest(unittest.TestCase):
|
|||
self.assertEqual(hooks._prog("funky"), None)
|
||||
|
||||
def _test_a_hook(self, config, hook_function, calls_expected):
|
||||
with mock.patch('letsencrypt.hooks.logger') as mock_logger:
|
||||
with mock.patch('certbot.hooks.logger') as mock_logger:
|
||||
mock_logger.warning = mock.MagicMock()
|
||||
with mock.patch('letsencrypt.hooks._run_hook') as mock_run_hook:
|
||||
with mock.patch('certbot.hooks._run_hook') as mock_run_hook:
|
||||
hook_function(config)
|
||||
hook_function(config)
|
||||
self.assertEqual(mock_run_hook.call_count, calls_expected)
|
||||
|
|
@ -82,16 +82,16 @@ class HookTest(unittest.TestCase):
|
|||
mock_warn = self._test_a_hook(config, rhook, 0)
|
||||
self.assertEqual(mock_warn.call_count, 2)
|
||||
|
||||
@mock.patch('letsencrypt.hooks.Popen')
|
||||
@mock.patch('certbot.hooks.Popen')
|
||||
def test_run_hook(self, mock_popen):
|
||||
with mock.patch('letsencrypt.hooks.logger.error') as mock_error:
|
||||
with mock.patch('certbot.hooks.logger.error') as mock_error:
|
||||
mock_cmd = mock.MagicMock()
|
||||
mock_cmd.returncode = 1
|
||||
mock_cmd.communicate.return_value = ("", "")
|
||||
mock_popen.return_value = mock_cmd
|
||||
hooks._run_hook("ls")
|
||||
self.assertEqual(mock_error.call_count, 1)
|
||||
with mock.patch('letsencrypt.hooks.logger.error') as mock_error:
|
||||
with mock.patch('certbot.hooks.logger.error') as mock_error:
|
||||
mock_cmd.communicate.return_value = ("", "thing")
|
||||
hooks._run_hook("ls")
|
||||
self.assertEqual(mock_error.call_count, 2)
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
"""Tests for letsencrypt.le_util."""
|
||||
"""Tests for certbot.le_util."""
|
||||
import argparse
|
||||
import errno
|
||||
import os
|
||||
|
|
@ -10,17 +10,17 @@ import unittest
|
|||
import mock
|
||||
import six
|
||||
|
||||
from letsencrypt import errors
|
||||
from certbot import errors
|
||||
|
||||
|
||||
class RunScriptTest(unittest.TestCase):
|
||||
"""Tests for letsencrypt.le_util.run_script."""
|
||||
"""Tests for certbot.le_util.run_script."""
|
||||
@classmethod
|
||||
def _call(cls, params):
|
||||
from letsencrypt.le_util import run_script
|
||||
from certbot.le_util import run_script
|
||||
return run_script(params)
|
||||
|
||||
@mock.patch("letsencrypt.le_util.subprocess.Popen")
|
||||
@mock.patch("certbot.le_util.subprocess.Popen")
|
||||
def test_default(self, mock_popen):
|
||||
"""These will be changed soon enough with reload."""
|
||||
mock_popen().returncode = 0
|
||||
|
|
@ -30,13 +30,13 @@ class RunScriptTest(unittest.TestCase):
|
|||
self.assertEqual(out, "stdout")
|
||||
self.assertEqual(err, "stderr")
|
||||
|
||||
@mock.patch("letsencrypt.le_util.subprocess.Popen")
|
||||
@mock.patch("certbot.le_util.subprocess.Popen")
|
||||
def test_bad_process(self, mock_popen):
|
||||
mock_popen.side_effect = OSError
|
||||
|
||||
self.assertRaises(errors.SubprocessError, self._call, ["test"])
|
||||
|
||||
@mock.patch("letsencrypt.le_util.subprocess.Popen")
|
||||
@mock.patch("certbot.le_util.subprocess.Popen")
|
||||
def test_failure(self, mock_popen):
|
||||
mock_popen().communicate.return_value = ("", "")
|
||||
mock_popen().returncode = 1
|
||||
|
|
@ -45,29 +45,29 @@ class RunScriptTest(unittest.TestCase):
|
|||
|
||||
|
||||
class ExeExistsTest(unittest.TestCase):
|
||||
"""Tests for letsencrypt.le_util.exe_exists."""
|
||||
"""Tests for certbot.le_util.exe_exists."""
|
||||
|
||||
@classmethod
|
||||
def _call(cls, exe):
|
||||
from letsencrypt.le_util import exe_exists
|
||||
from certbot.le_util import exe_exists
|
||||
return exe_exists(exe)
|
||||
|
||||
@mock.patch("letsencrypt.le_util.os.path.isfile")
|
||||
@mock.patch("letsencrypt.le_util.os.access")
|
||||
@mock.patch("certbot.le_util.os.path.isfile")
|
||||
@mock.patch("certbot.le_util.os.access")
|
||||
def test_full_path(self, mock_access, mock_isfile):
|
||||
mock_access.return_value = True
|
||||
mock_isfile.return_value = True
|
||||
self.assertTrue(self._call("/path/to/exe"))
|
||||
|
||||
@mock.patch("letsencrypt.le_util.os.path.isfile")
|
||||
@mock.patch("letsencrypt.le_util.os.access")
|
||||
@mock.patch("certbot.le_util.os.path.isfile")
|
||||
@mock.patch("certbot.le_util.os.access")
|
||||
def test_on_path(self, mock_access, mock_isfile):
|
||||
mock_access.return_value = True
|
||||
mock_isfile.return_value = True
|
||||
self.assertTrue(self._call("exe"))
|
||||
|
||||
@mock.patch("letsencrypt.le_util.os.path.isfile")
|
||||
@mock.patch("letsencrypt.le_util.os.access")
|
||||
@mock.patch("certbot.le_util.os.path.isfile")
|
||||
@mock.patch("certbot.le_util.os.access")
|
||||
def test_not_found(self, mock_access, mock_isfile):
|
||||
mock_access.return_value = False
|
||||
mock_isfile.return_value = True
|
||||
|
|
@ -75,7 +75,7 @@ class ExeExistsTest(unittest.TestCase):
|
|||
|
||||
|
||||
class MakeOrVerifyDirTest(unittest.TestCase):
|
||||
"""Tests for letsencrypt.le_util.make_or_verify_dir.
|
||||
"""Tests for certbot.le_util.make_or_verify_dir.
|
||||
|
||||
Note that it is not possible to test for a wrong directory owner,
|
||||
as this testing script would have to be run as root.
|
||||
|
|
@ -93,7 +93,7 @@ class MakeOrVerifyDirTest(unittest.TestCase):
|
|||
shutil.rmtree(self.root_path, ignore_errors=True)
|
||||
|
||||
def _call(self, directory, mode):
|
||||
from letsencrypt.le_util import make_or_verify_dir
|
||||
from certbot.le_util import make_or_verify_dir
|
||||
return make_or_verify_dir(directory, mode, self.uid, strict=True)
|
||||
|
||||
def test_creates_dir_when_missing(self):
|
||||
|
|
@ -116,7 +116,7 @@ class MakeOrVerifyDirTest(unittest.TestCase):
|
|||
|
||||
|
||||
class CheckPermissionsTest(unittest.TestCase):
|
||||
"""Tests for letsencrypt.le_util.check_permissions.
|
||||
"""Tests for certbot.le_util.check_permissions.
|
||||
|
||||
Note that it is not possible to test for a wrong file owner,
|
||||
as this testing script would have to be run as root.
|
||||
|
|
@ -131,7 +131,7 @@ class CheckPermissionsTest(unittest.TestCase):
|
|||
os.remove(self.path)
|
||||
|
||||
def _call(self, mode):
|
||||
from letsencrypt.le_util import check_permissions
|
||||
from certbot.le_util import check_permissions
|
||||
return check_permissions(self.path, mode, self.uid)
|
||||
|
||||
def test_ok_mode(self):
|
||||
|
|
@ -144,7 +144,7 @@ class CheckPermissionsTest(unittest.TestCase):
|
|||
|
||||
|
||||
class UniqueFileTest(unittest.TestCase):
|
||||
"""Tests for letsencrypt.le_util.unique_file."""
|
||||
"""Tests for certbot.le_util.unique_file."""
|
||||
|
||||
def setUp(self):
|
||||
self.root_path = tempfile.mkdtemp()
|
||||
|
|
@ -154,7 +154,7 @@ class UniqueFileTest(unittest.TestCase):
|
|||
shutil.rmtree(self.root_path, ignore_errors=True)
|
||||
|
||||
def _call(self, mode=0o600):
|
||||
from letsencrypt.le_util import unique_file
|
||||
from certbot.le_util import unique_file
|
||||
return unique_file(self.default_name, mode)
|
||||
|
||||
def test_returns_fd_for_writing(self):
|
||||
|
|
@ -189,7 +189,7 @@ class UniqueFileTest(unittest.TestCase):
|
|||
|
||||
|
||||
class UniqueLineageNameTest(unittest.TestCase):
|
||||
"""Tests for letsencrypt.le_util.unique_lineage_name."""
|
||||
"""Tests for certbot.le_util.unique_lineage_name."""
|
||||
|
||||
def setUp(self):
|
||||
self.root_path = tempfile.mkdtemp()
|
||||
|
|
@ -198,7 +198,7 @@ class UniqueLineageNameTest(unittest.TestCase):
|
|||
shutil.rmtree(self.root_path, ignore_errors=True)
|
||||
|
||||
def _call(self, filename, mode=0o777):
|
||||
from letsencrypt.le_util import unique_lineage_name
|
||||
from certbot.le_util import unique_lineage_name
|
||||
return unique_lineage_name(self.root_path, filename, mode)
|
||||
|
||||
def test_basic(self):
|
||||
|
|
@ -213,14 +213,14 @@ class UniqueLineageNameTest(unittest.TestCase):
|
|||
self.assertTrue(isinstance(name, str))
|
||||
self.assertTrue("wow-0009.conf" in name)
|
||||
|
||||
@mock.patch("letsencrypt.le_util.os.fdopen")
|
||||
@mock.patch("certbot.le_util.os.fdopen")
|
||||
def test_failure(self, mock_fdopen):
|
||||
err = OSError("whoops")
|
||||
err.errno = errno.EIO
|
||||
mock_fdopen.side_effect = err
|
||||
self.assertRaises(OSError, self._call, "wow")
|
||||
|
||||
@mock.patch("letsencrypt.le_util.os.fdopen")
|
||||
@mock.patch("certbot.le_util.os.fdopen")
|
||||
def test_subsequent_failure(self, mock_fdopen):
|
||||
self._call("wow")
|
||||
err = OSError("whoops")
|
||||
|
|
@ -230,7 +230,7 @@ class UniqueLineageNameTest(unittest.TestCase):
|
|||
|
||||
|
||||
class SafelyRemoveTest(unittest.TestCase):
|
||||
"""Tests for letsencrypt.le_util.safely_remove."""
|
||||
"""Tests for certbot.le_util.safely_remove."""
|
||||
|
||||
def setUp(self):
|
||||
self.tmp = tempfile.mkdtemp()
|
||||
|
|
@ -240,7 +240,7 @@ class SafelyRemoveTest(unittest.TestCase):
|
|||
shutil.rmtree(self.tmp)
|
||||
|
||||
def _call(self):
|
||||
from letsencrypt.le_util import safely_remove
|
||||
from certbot.le_util import safely_remove
|
||||
return safely_remove(self.path)
|
||||
|
||||
def test_exists(self):
|
||||
|
|
@ -254,7 +254,7 @@ class SafelyRemoveTest(unittest.TestCase):
|
|||
# no error, yay!
|
||||
self.assertFalse(os.path.exists(self.path))
|
||||
|
||||
@mock.patch("letsencrypt.le_util.os.remove")
|
||||
@mock.patch("certbot.le_util.os.remove")
|
||||
def test_other_error_passthrough(self, mock_remove):
|
||||
mock_remove.side_effect = OSError
|
||||
self.assertRaises(OSError, self._call)
|
||||
|
|
@ -264,12 +264,12 @@ class SafeEmailTest(unittest.TestCase):
|
|||
"""Test safe_email."""
|
||||
@classmethod
|
||||
def _call(cls, addr):
|
||||
from letsencrypt.le_util import safe_email
|
||||
from certbot.le_util import safe_email
|
||||
return safe_email(addr)
|
||||
|
||||
def test_valid_emails(self):
|
||||
addrs = [
|
||||
"letsencrypt@letsencrypt.org",
|
||||
"certbot@certbot.org",
|
||||
"tbd.ade@gmail.com",
|
||||
"abc_def.jdk@hotmail.museum",
|
||||
]
|
||||
|
|
@ -278,7 +278,7 @@ class SafeEmailTest(unittest.TestCase):
|
|||
|
||||
def test_invalid_emails(self):
|
||||
addrs = [
|
||||
"letsencrypt@letsencrypt..org",
|
||||
"certbot@certbot..org",
|
||||
".tbd.ade@gmail.com",
|
||||
"~/abc_def.jdk@hotmail.museum",
|
||||
]
|
||||
|
|
@ -292,7 +292,7 @@ class AddDeprecatedArgumentTest(unittest.TestCase):
|
|||
self.parser = argparse.ArgumentParser()
|
||||
|
||||
def _call(self, argument_name, nargs):
|
||||
from letsencrypt.le_util import add_deprecated_argument
|
||||
from certbot.le_util import add_deprecated_argument
|
||||
|
||||
add_deprecated_argument(self.parser.add_argument, argument_name, nargs)
|
||||
|
||||
|
|
@ -308,14 +308,14 @@ class AddDeprecatedArgumentTest(unittest.TestCase):
|
|||
|
||||
def _get_argparse_warnings(self, args):
|
||||
stderr = six.StringIO()
|
||||
with mock.patch("letsencrypt.le_util.sys.stderr", new=stderr):
|
||||
with mock.patch("certbot.le_util.sys.stderr", new=stderr):
|
||||
self.parser.parse_args(args)
|
||||
return stderr.getvalue()
|
||||
|
||||
def test_help(self):
|
||||
self._call("--old-option", 2)
|
||||
stdout = six.StringIO()
|
||||
with mock.patch("letsencrypt.le_util.sys.stdout", new=stdout):
|
||||
with mock.patch("certbot.le_util.sys.stdout", new=stdout):
|
||||
try:
|
||||
self.parser.parse_args(["-h"])
|
||||
except SystemExit:
|
||||
|
|
@ -327,7 +327,7 @@ class EnforceDomainSanityTest(unittest.TestCase):
|
|||
"""Test enforce_domain_sanity."""
|
||||
|
||||
def _call(self, domain):
|
||||
from letsencrypt.le_util import enforce_domain_sanity
|
||||
from certbot.le_util import enforce_domain_sanity
|
||||
return enforce_domain_sanity(domain)
|
||||
|
||||
def test_nonascii_str(self):
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
"""Tests for letsencrypt.log."""
|
||||
"""Tests for certbot.log."""
|
||||
import logging
|
||||
import unittest
|
||||
|
||||
|
|
@ -10,7 +10,7 @@ class DialogHandlerTest(unittest.TestCase):
|
|||
def setUp(self):
|
||||
self.d = mock.MagicMock()
|
||||
|
||||
from letsencrypt.log import DialogHandler
|
||||
from certbot.log import DialogHandler
|
||||
self.handler = DialogHandler(height=2, width=6, d=self.d)
|
||||
self.handler.PADDING_HEIGHT = 2
|
||||
self.handler.PADDING_WIDTH = 4
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
"""Tests for letsencrypt.notify."""
|
||||
"""Tests for certbot.notify."""
|
||||
import socket
|
||||
import unittest
|
||||
|
||||
|
|
@ -8,9 +8,9 @@ import mock
|
|||
class NotifyTests(unittest.TestCase):
|
||||
"""Tests for the notifier."""
|
||||
|
||||
@mock.patch("letsencrypt.notify.smtplib.LMTP")
|
||||
@mock.patch("certbot.notify.smtplib.LMTP")
|
||||
def test_smtp_success(self, mock_lmtp):
|
||||
from letsencrypt.notify import notify
|
||||
from certbot.notify import notify
|
||||
lmtp_obj = mock.MagicMock()
|
||||
mock_lmtp.return_value = lmtp_obj
|
||||
self.assertTrue(notify("Goose", "auntrhody@example.com",
|
||||
|
|
@ -18,10 +18,10 @@ class NotifyTests(unittest.TestCase):
|
|||
self.assertEqual(lmtp_obj.connect.call_count, 1)
|
||||
self.assertEqual(lmtp_obj.sendmail.call_count, 1)
|
||||
|
||||
@mock.patch("letsencrypt.notify.smtplib.LMTP")
|
||||
@mock.patch("letsencrypt.notify.subprocess.Popen")
|
||||
@mock.patch("certbot.notify.smtplib.LMTP")
|
||||
@mock.patch("certbot.notify.subprocess.Popen")
|
||||
def test_smtp_failure(self, mock_popen, mock_lmtp):
|
||||
from letsencrypt.notify import notify
|
||||
from certbot.notify import notify
|
||||
lmtp_obj = mock.MagicMock()
|
||||
mock_lmtp.return_value = lmtp_obj
|
||||
lmtp_obj.sendmail.side_effect = socket.error(17)
|
||||
|
|
@ -32,10 +32,10 @@ class NotifyTests(unittest.TestCase):
|
|||
self.assertEqual(lmtp_obj.sendmail.call_count, 1)
|
||||
self.assertEqual(proc.communicate.call_count, 1)
|
||||
|
||||
@mock.patch("letsencrypt.notify.smtplib.LMTP")
|
||||
@mock.patch("letsencrypt.notify.subprocess.Popen")
|
||||
@mock.patch("certbot.notify.smtplib.LMTP")
|
||||
@mock.patch("certbot.notify.subprocess.Popen")
|
||||
def test_everything_fails(self, mock_popen, mock_lmtp):
|
||||
from letsencrypt.notify import notify
|
||||
from certbot.notify import notify
|
||||
lmtp_obj = mock.MagicMock()
|
||||
mock_lmtp.return_value = lmtp_obj
|
||||
lmtp_obj.sendmail.side_effect = socket.error(17)
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
"""Tests for letsencrypt.reporter."""
|
||||
"""Tests for certbot.reporter."""
|
||||
import mock
|
||||
import sys
|
||||
import unittest
|
||||
|
|
@ -7,10 +7,10 @@ import six
|
|||
|
||||
|
||||
class ReporterTest(unittest.TestCase):
|
||||
"""Tests for letsencrypt.reporter.Reporter."""
|
||||
"""Tests for certbot.reporter.Reporter."""
|
||||
|
||||
def setUp(self):
|
||||
from letsencrypt import reporter
|
||||
from certbot import reporter
|
||||
self.reporter = reporter.Reporter(mock.MagicMock(quiet=False))
|
||||
|
||||
self.old_stdout = sys.stdout
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
"""Test letsencrypt.reverter."""
|
||||
"""Test certbot.reverter."""
|
||||
import csv
|
||||
import itertools
|
||||
import logging
|
||||
|
|
@ -9,14 +9,14 @@ import unittest
|
|||
|
||||
import mock
|
||||
|
||||
from letsencrypt import errors
|
||||
from certbot import errors
|
||||
|
||||
|
||||
class ReverterCheckpointLocalTest(unittest.TestCase):
|
||||
# pylint: disable=too-many-instance-attributes, too-many-public-methods
|
||||
"""Test the Reverter Class."""
|
||||
def setUp(self):
|
||||
from letsencrypt.reverter import Reverter
|
||||
from certbot.reverter import Reverter
|
||||
|
||||
# Disable spurious errors... we are trying to test for them
|
||||
logging.disable(logging.CRITICAL)
|
||||
|
|
@ -50,7 +50,7 @@ class ReverterCheckpointLocalTest(unittest.TestCase):
|
|||
"{0}\n{1}\n".format(self.config1, self.config2))
|
||||
|
||||
def test_add_to_checkpoint_copy_failure(self):
|
||||
with mock.patch("letsencrypt.reverter.shutil.copy2") as mock_copy2:
|
||||
with mock.patch("certbot.reverter.shutil.copy2") as mock_copy2:
|
||||
mock_copy2.side_effect = IOError("bad copy")
|
||||
self.assertRaises(
|
||||
errors.ReverterError, self.reverter.add_to_checkpoint,
|
||||
|
|
@ -116,7 +116,7 @@ class ReverterCheckpointLocalTest(unittest.TestCase):
|
|||
|
||||
def test_register_file_creation_write_error(self):
|
||||
m_open = mock.mock_open()
|
||||
with mock.patch("letsencrypt.reverter.open", m_open, create=True):
|
||||
with mock.patch("certbot.reverter.open", m_open, create=True):
|
||||
m_open.side_effect = OSError("bad open")
|
||||
self.assertRaises(
|
||||
errors.ReverterError, self.reverter.register_file_creation,
|
||||
|
|
@ -144,13 +144,13 @@ class ReverterCheckpointLocalTest(unittest.TestCase):
|
|||
|
||||
def test_bad_register_undo_command(self):
|
||||
m_open = mock.mock_open()
|
||||
with mock.patch("letsencrypt.reverter.open", m_open, create=True):
|
||||
with mock.patch("certbot.reverter.open", m_open, create=True):
|
||||
m_open.side_effect = OSError("bad open")
|
||||
self.assertRaises(
|
||||
errors.ReverterError, self.reverter.register_undo_command,
|
||||
True, ["command"])
|
||||
|
||||
@mock.patch("letsencrypt.le_util.run_script")
|
||||
@mock.patch("certbot.le_util.run_script")
|
||||
def test_run_undo_commands(self, mock_run):
|
||||
mock_run.side_effect = ["", errors.SubprocessError]
|
||||
coms = [
|
||||
|
|
@ -200,7 +200,7 @@ class ReverterCheckpointLocalTest(unittest.TestCase):
|
|||
def test_recover_checkpoint_copy_failure(self):
|
||||
self.reverter.add_to_temp_checkpoint(self.sets[0], "save1")
|
||||
|
||||
with mock.patch("letsencrypt.reverter.shutil.copy2") as mock_copy2:
|
||||
with mock.patch("certbot.reverter.shutil.copy2") as mock_copy2:
|
||||
mock_copy2.side_effect = OSError("bad copy")
|
||||
self.assertRaises(
|
||||
errors.ReverterError, self.reverter.revert_temporary_config)
|
||||
|
|
@ -208,19 +208,19 @@ class ReverterCheckpointLocalTest(unittest.TestCase):
|
|||
def test_recover_checkpoint_rm_failure(self):
|
||||
self.reverter.add_to_temp_checkpoint(self.sets[0], "temp save")
|
||||
|
||||
with mock.patch("letsencrypt.reverter.shutil.rmtree") as mock_rmtree:
|
||||
with mock.patch("certbot.reverter.shutil.rmtree") as mock_rmtree:
|
||||
mock_rmtree.side_effect = OSError("Cannot remove tree")
|
||||
self.assertRaises(
|
||||
errors.ReverterError, self.reverter.revert_temporary_config)
|
||||
|
||||
@mock.patch("letsencrypt.reverter.logger.warning")
|
||||
@mock.patch("certbot.reverter.logger.warning")
|
||||
def test_recover_checkpoint_missing_new_files(self, mock_warn):
|
||||
self.reverter.register_file_creation(
|
||||
True, os.path.join(self.dir1, "missing_file.txt"))
|
||||
self.reverter.revert_temporary_config()
|
||||
self.assertEqual(mock_warn.call_count, 1)
|
||||
|
||||
@mock.patch("letsencrypt.reverter.os.remove")
|
||||
@mock.patch("certbot.reverter.os.remove")
|
||||
def test_recover_checkpoint_remove_failure(self, mock_remove):
|
||||
self.reverter.register_file_creation(True, self.config1)
|
||||
mock_remove.side_effect = OSError("Can't remove")
|
||||
|
|
@ -265,7 +265,7 @@ class TestFullCheckpointsReverter(unittest.TestCase):
|
|||
# pylint: disable=too-many-instance-attributes
|
||||
"""Tests functions having to deal with full checkpoints."""
|
||||
def setUp(self):
|
||||
from letsencrypt.reverter import Reverter
|
||||
from certbot.reverter import Reverter
|
||||
# Disable spurious errors...
|
||||
logging.disable(logging.CRITICAL)
|
||||
|
||||
|
|
@ -324,7 +324,7 @@ class TestFullCheckpointsReverter(unittest.TestCase):
|
|||
# No need to warn for this... just make sure there are no errors.
|
||||
self.reverter.finalize_checkpoint("No checkpoint...")
|
||||
|
||||
@mock.patch("letsencrypt.reverter.shutil.move")
|
||||
@mock.patch("certbot.reverter.shutil.move")
|
||||
def test_finalize_checkpoint_cannot_title(self, mock_move):
|
||||
self.reverter.add_to_checkpoint(self.sets[0], "perm save")
|
||||
mock_move.side_effect = OSError("cannot move")
|
||||
|
|
@ -332,7 +332,7 @@ class TestFullCheckpointsReverter(unittest.TestCase):
|
|||
self.assertRaises(
|
||||
errors.ReverterError, self.reverter.finalize_checkpoint, "Title")
|
||||
|
||||
@mock.patch("letsencrypt.reverter.os.rename")
|
||||
@mock.patch("certbot.reverter.os.rename")
|
||||
def test_finalize_checkpoint_no_rename_directory(self, mock_rename):
|
||||
|
||||
self.reverter.add_to_checkpoint(self.sets[0], "perm save")
|
||||
|
|
@ -341,7 +341,7 @@ class TestFullCheckpointsReverter(unittest.TestCase):
|
|||
self.assertRaises(
|
||||
errors.ReverterError, self.reverter.finalize_checkpoint, "Title")
|
||||
|
||||
@mock.patch("letsencrypt.reverter.logger")
|
||||
@mock.patch("certbot.reverter.logger")
|
||||
def test_rollback_too_many(self, mock_logger):
|
||||
# Test no exist warning...
|
||||
self.reverter.rollback_checkpoints(1)
|
||||
|
|
@ -361,7 +361,7 @@ class TestFullCheckpointsReverter(unittest.TestCase):
|
|||
self.assertEqual(read_in(self.config2), "directive-dir2")
|
||||
self.assertFalse(os.path.isfile(config3))
|
||||
|
||||
@mock.patch("letsencrypt.reverter.zope.component.getUtility")
|
||||
@mock.patch("certbot.reverter.zope.component.getUtility")
|
||||
def test_view_config_changes(self, mock_output):
|
||||
"""This is not strict as this is subject to change."""
|
||||
self._setup_three_checkpoints()
|
||||
|
|
@ -372,7 +372,7 @@ class TestFullCheckpointsReverter(unittest.TestCase):
|
|||
# Make sure notification is output
|
||||
self.assertEqual(mock_output().notification.call_count, 1)
|
||||
|
||||
@mock.patch("letsencrypt.reverter.logger")
|
||||
@mock.patch("certbot.reverter.logger")
|
||||
def test_view_config_changes_no_backups(self, mock_logger):
|
||||
self.reverter.view_config_changes()
|
||||
self.assertTrue(mock_logger.info.call_count > 0)
|
||||
|
|
@ -426,7 +426,7 @@ class TestFullCheckpointsReverter(unittest.TestCase):
|
|||
def setup_work_direc():
|
||||
"""Setup directories.
|
||||
|
||||
:returns: Mocked :class:`letsencrypt.interfaces.IConfig`
|
||||
:returns: Mocked :class:`certbot.interfaces.IConfig`
|
||||
|
||||
"""
|
||||
work_dir = tempfile.mkdtemp("work")
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
"""Tests for letsencrypt.storage."""
|
||||
"""Tests for certbot.storage."""
|
||||
# pylint disable=protected-access
|
||||
import datetime
|
||||
import os
|
||||
|
|
@ -10,11 +10,11 @@ import configobj
|
|||
import mock
|
||||
import pytz
|
||||
|
||||
from letsencrypt import configuration
|
||||
from letsencrypt import errors
|
||||
from letsencrypt.storage import ALL_FOUR
|
||||
from certbot import configuration
|
||||
from certbot import errors
|
||||
from certbot.storage import ALL_FOUR
|
||||
|
||||
from letsencrypt.tests import test_util
|
||||
from certbot.tests import test_util
|
||||
|
||||
|
||||
CERT = test_util.load_cert('cert.pem')
|
||||
|
|
@ -41,7 +41,7 @@ class BaseRenewableCertTest(unittest.TestCase):
|
|||
|
||||
"""
|
||||
def setUp(self):
|
||||
from letsencrypt import storage
|
||||
from certbot import storage
|
||||
self.tempdir = tempfile.mkdtemp()
|
||||
|
||||
self.cli_config = configuration.RenewerConfiguration(
|
||||
|
|
@ -76,7 +76,7 @@ class BaseRenewableCertTest(unittest.TestCase):
|
|||
|
||||
self.defaults = configobj.ConfigObj()
|
||||
|
||||
with mock.patch("letsencrypt.storage.RenewableCert._check_symlinks") as check:
|
||||
with mock.patch("certbot.storage.RenewableCert._check_symlinks") as check:
|
||||
check.return_value = True
|
||||
self.test_rc = storage.RenewableCert(config.filename, self.cli_config)
|
||||
|
||||
|
|
@ -99,7 +99,7 @@ class BaseRenewableCertTest(unittest.TestCase):
|
|||
|
||||
class RenewableCertTests(BaseRenewableCertTest):
|
||||
# pylint: disable=too-many-public-methods
|
||||
"""Tests for letsencrypt.storage."""
|
||||
"""Tests for certbot.storage."""
|
||||
|
||||
def test_initialization(self):
|
||||
self.assertEqual(self.test_rc.lineagename, "example.org")
|
||||
|
|
@ -113,7 +113,7 @@ class RenewableCertTests(BaseRenewableCertTest):
|
|||
the renewal configuration file doesn't end in ".conf"
|
||||
|
||||
"""
|
||||
from letsencrypt import storage
|
||||
from certbot import storage
|
||||
broken = os.path.join(self.tempdir, "broken.conf")
|
||||
with open(broken, "w") as f:
|
||||
f.write("[No closing bracket for you!")
|
||||
|
|
@ -126,7 +126,7 @@ class RenewableCertTests(BaseRenewableCertTest):
|
|||
def test_renewal_incomplete_config(self):
|
||||
"""Test that the RenewableCert constructor will complain if
|
||||
the renewal configuration file is missing a required file element."""
|
||||
from letsencrypt import storage
|
||||
from certbot import storage
|
||||
config = configobj.ConfigObj()
|
||||
config["cert"] = "imaginary_cert.pem"
|
||||
# Here the required privkey is missing.
|
||||
|
|
@ -327,7 +327,7 @@ class RenewableCertTests(BaseRenewableCertTest):
|
|||
real_unlink(path)
|
||||
|
||||
self._write_out_ex_kinds()
|
||||
with mock.patch("letsencrypt.storage.os.unlink") as mock_unlink:
|
||||
with mock.patch("certbot.storage.os.unlink") as mock_unlink:
|
||||
mock_unlink.side_effect = unlink_or_raise
|
||||
self.assertRaises(ValueError, self.test_rc.update_all_links_to, 12)
|
||||
|
||||
|
|
@ -343,7 +343,7 @@ class RenewableCertTests(BaseRenewableCertTest):
|
|||
real_unlink(path)
|
||||
|
||||
self._write_out_ex_kinds()
|
||||
with mock.patch("letsencrypt.storage.os.unlink") as mock_unlink:
|
||||
with mock.patch("certbot.storage.os.unlink") as mock_unlink:
|
||||
mock_unlink.side_effect = unlink_or_raise
|
||||
self.assertRaises(ValueError, self.test_rc.update_all_links_to, 12)
|
||||
|
||||
|
|
@ -394,7 +394,7 @@ class RenewableCertTests(BaseRenewableCertTest):
|
|||
os.unlink(self.test_rc.cert)
|
||||
self.assertRaises(errors.CertStorageError, self.test_rc.names)
|
||||
|
||||
@mock.patch("letsencrypt.storage.datetime")
|
||||
@mock.patch("certbot.storage.datetime")
|
||||
def test_time_interval_judgments(self, mock_datetime):
|
||||
"""Test should_autodeploy() and should_autorenew() on the basis
|
||||
of expiry time windows."""
|
||||
|
|
@ -474,7 +474,7 @@ class RenewableCertTests(BaseRenewableCertTest):
|
|||
self.test_rc.configuration["autorenew"] = "0"
|
||||
self.assertFalse(self.test_rc.autorenewal_is_enabled())
|
||||
|
||||
@mock.patch("letsencrypt.storage.RenewableCert.ocsp_revoked")
|
||||
@mock.patch("certbot.storage.RenewableCert.ocsp_revoked")
|
||||
def test_should_autorenew(self, mock_ocsp):
|
||||
"""Test should_autorenew on the basis of reasons other than
|
||||
expiry time window."""
|
||||
|
|
@ -494,7 +494,7 @@ class RenewableCertTests(BaseRenewableCertTest):
|
|||
self.assertTrue(self.test_rc.should_autorenew())
|
||||
mock_ocsp.return_value = False
|
||||
|
||||
@mock.patch("letsencrypt.storage.relevant_values")
|
||||
@mock.patch("certbot.storage.relevant_values")
|
||||
def test_save_successor(self, mock_rv):
|
||||
# Mock relevant_values() to claim that all values are relevant here
|
||||
# (to avoid instantiating parser)
|
||||
|
|
@ -563,33 +563,33 @@ class RenewableCertTests(BaseRenewableCertTest):
|
|||
self.assertFalse(os.path.islink(self.test_rc.version("privkey", 10)))
|
||||
self.assertFalse(os.path.exists(temp_config_file))
|
||||
|
||||
@mock.patch("letsencrypt.cli.helpful_parser")
|
||||
@mock.patch("certbot.cli.helpful_parser")
|
||||
def test_relevant_values(self, mock_parser):
|
||||
"""Test that relevant_values() can reject an irrelevant value."""
|
||||
# pylint: disable=protected-access
|
||||
from letsencrypt import storage
|
||||
from certbot import storage
|
||||
mock_parser.verb = "certonly"
|
||||
mock_parser.args = ["--standalone"]
|
||||
mock_action = mock.Mock(dest="rsa_key_size", default=2048)
|
||||
mock_parser.parser._actions = [mock_action]
|
||||
self.assertEqual(storage.relevant_values({"hello": "there"}), {})
|
||||
|
||||
@mock.patch("letsencrypt.cli.helpful_parser")
|
||||
@mock.patch("certbot.cli.helpful_parser")
|
||||
def test_relevant_values_default(self, mock_parser):
|
||||
"""Test that relevant_values() can reject a default value."""
|
||||
# pylint: disable=protected-access
|
||||
from letsencrypt import storage
|
||||
from certbot import storage
|
||||
mock_parser.verb = "certonly"
|
||||
mock_parser.args = ["--standalone"]
|
||||
mock_action = mock.Mock(dest="rsa_key_size", default=2048)
|
||||
mock_parser.parser._actions = [mock_action]
|
||||
self.assertEqual(storage.relevant_values({"rsa_key_size": 2048}), {})
|
||||
|
||||
@mock.patch("letsencrypt.cli.helpful_parser")
|
||||
@mock.patch("certbot.cli.helpful_parser")
|
||||
def test_relevant_values_nondefault(self, mock_parser):
|
||||
"""Test that relevant_values() can retain a non-default value."""
|
||||
# pylint: disable=protected-access
|
||||
from letsencrypt import storage
|
||||
from certbot import storage
|
||||
mock_parser.verb = "certonly"
|
||||
mock_parser.args = ["--standalone"]
|
||||
mock_action = mock.Mock(dest="rsa_key_size", default=2048)
|
||||
|
|
@ -597,14 +597,14 @@ class RenewableCertTests(BaseRenewableCertTest):
|
|||
self.assertEqual(storage.relevant_values({"rsa_key_size": 12}),
|
||||
{"rsa_key_size": 12})
|
||||
|
||||
@mock.patch("letsencrypt.storage.relevant_values")
|
||||
@mock.patch("certbot.storage.relevant_values")
|
||||
def test_new_lineage(self, mock_rv):
|
||||
"""Test for new_lineage() class method."""
|
||||
# Mock relevant_values to say everything is relevant here (so we
|
||||
# don't have to mock the parser to help it decide!)
|
||||
mock_rv.side_effect = lambda x: x
|
||||
|
||||
from letsencrypt import storage
|
||||
from certbot import storage
|
||||
result = storage.RenewableCert.new_lineage(
|
||||
"the-lineage.com", "cert", "privkey", "chain", self.cli_config)
|
||||
# This consistency check tests most relevant properties about the
|
||||
|
|
@ -637,14 +637,14 @@ class RenewableCertTests(BaseRenewableCertTest):
|
|||
# TODO: Conceivably we could test that the renewal parameters actually
|
||||
# got saved
|
||||
|
||||
@mock.patch("letsencrypt.storage.relevant_values")
|
||||
@mock.patch("certbot.storage.relevant_values")
|
||||
def test_new_lineage_nonexistent_dirs(self, mock_rv):
|
||||
"""Test that directories can be created if they don't exist."""
|
||||
# Mock relevant_values to say everything is relevant here (so we
|
||||
# don't have to mock the parser to help it decide!)
|
||||
mock_rv.side_effect = lambda x: x
|
||||
|
||||
from letsencrypt import storage
|
||||
from certbot import storage
|
||||
shutil.rmtree(self.cli_config.renewal_configs_dir)
|
||||
shutil.rmtree(self.cli_config.archive_dir)
|
||||
shutil.rmtree(self.cli_config.live_dir)
|
||||
|
|
@ -659,9 +659,9 @@ class RenewableCertTests(BaseRenewableCertTest):
|
|||
self.assertTrue(os.path.exists(os.path.join(
|
||||
self.cli_config.archive_dir, "the-lineage.com", "privkey1.pem")))
|
||||
|
||||
@mock.patch("letsencrypt.storage.le_util.unique_lineage_name")
|
||||
@mock.patch("certbot.storage.le_util.unique_lineage_name")
|
||||
def test_invalid_config_filename(self, mock_uln):
|
||||
from letsencrypt import storage
|
||||
from certbot import storage
|
||||
mock_uln.return_value = "this_does_not_end_with_dot_conf", "yikes"
|
||||
self.assertRaises(errors.CertStorageError,
|
||||
storage.RenewableCert.new_lineage, "example.com",
|
||||
|
|
@ -691,7 +691,7 @@ class RenewableCertTests(BaseRenewableCertTest):
|
|||
self.assertFalse(self.test_rc.ocsp_revoked())
|
||||
|
||||
def test_add_time_interval(self):
|
||||
from letsencrypt import storage
|
||||
from certbot import storage
|
||||
|
||||
# this month has 30 days, and the next year is a leap year
|
||||
time_1 = pytz.UTC.fromutc(datetime.datetime(2003, 11, 20, 11, 59, 21))
|
||||
|
|
@ -733,7 +733,7 @@ class RenewableCertTests(BaseRenewableCertTest):
|
|||
excepted)
|
||||
|
||||
def test_missing_cert(self):
|
||||
from letsencrypt import storage
|
||||
from certbot import storage
|
||||
self.assertRaises(errors.CertStorageError,
|
||||
storage.RenewableCert,
|
||||
self.config.filename, self.cli_config)
|
||||
|
|
@ -755,7 +755,7 @@ class RenewableCertTests(BaseRenewableCertTest):
|
|||
for x in ALL_FOUR:
|
||||
target[x] = "somewhere"
|
||||
relevant_data = {"useful": "new_value"}
|
||||
from letsencrypt import storage
|
||||
from certbot import storage
|
||||
storage.write_renewal_config(temp, temp2, target, relevant_data)
|
||||
with open(temp2, "r") as f:
|
||||
content = f.read()
|
||||
|
|
@ -7,7 +7,7 @@ pep8 --config=acme/.pep8 acme
|
|||
|
||||
pep8 \
|
||||
setup.py \
|
||||
letsencrypt \
|
||||
certbot \
|
||||
letsencrypt-apache \
|
||||
letsencrypt-nginx \
|
||||
letsencrypt-compatibility-test \
|
||||
|
|
|
|||
20
setup.py
20
setup.py
|
|
@ -23,7 +23,7 @@ def read_file(filename, encoding='utf8'):
|
|||
here = os.path.abspath(os.path.dirname(__file__))
|
||||
|
||||
# read version number (and other metadata) from package init
|
||||
init_fn = os.path.join(here, 'letsencrypt', '__init__.py')
|
||||
init_fn = os.path.join(here, 'certbot', '__init__.py')
|
||||
meta = dict(re.findall(r"""__([a-z]+)__ = '([^']+)""", read_file(init_fn)))
|
||||
|
||||
readme = read_file(os.path.join(here, 'README.rst'))
|
||||
|
|
@ -85,7 +85,7 @@ docs_extras = [
|
|||
]
|
||||
|
||||
setup(
|
||||
name='letsencrypt',
|
||||
name='certbot',
|
||||
version=version,
|
||||
description="Let's Encrypt client",
|
||||
long_description=readme, # later: + '\n\n' + changes
|
||||
|
|
@ -122,18 +122,18 @@ setup(
|
|||
},
|
||||
|
||||
# to test all packages run "python setup.py test -s
|
||||
# {acme,letsencrypt_apache,letsencrypt_nginx}"
|
||||
test_suite='letsencrypt',
|
||||
# {acme,certbot_apache,certbot_nginx}"
|
||||
test_suite='certbot',
|
||||
|
||||
entry_points={
|
||||
'console_scripts': [
|
||||
'letsencrypt = letsencrypt.main:main',
|
||||
'certbot = certbot.main:main',
|
||||
],
|
||||
'letsencrypt.plugins': [
|
||||
'manual = letsencrypt.plugins.manual:Authenticator',
|
||||
'null = letsencrypt.plugins.null:Installer',
|
||||
'standalone = letsencrypt.plugins.standalone:Authenticator',
|
||||
'webroot = letsencrypt.plugins.webroot:Authenticator',
|
||||
'certbot.plugins': [
|
||||
'manual = certbot.plugins.manual:Authenticator',
|
||||
'null = certbot.plugins.null:Installer',
|
||||
'standalone = certbot.plugins.standalone:Authenticator',
|
||||
'webroot = certbot.plugins.webroot:Authenticator',
|
||||
],
|
||||
},
|
||||
)
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue