s/letsencrypt/certbot letsencrypt-apache

This commit is contained in:
Brad Warren
2016-04-13 16:30:57 -07:00
parent 1b565ef74a
commit 2002511f81
133 changed files with 297 additions and 297 deletions
+7
View File
@@ -0,0 +1,7 @@
include LICENSE.txt
include README.rst
recursive-include docs *
recursive-include certbot_apache/tests/testdata *
include certbot_apache/centos-options-ssl-apache.conf
include certbot_apache/options-ssl-apache.conf
recursive-include certbot_apache/augeas_lens *.aug
@@ -3,11 +3,11 @@ import logging
import augeas import augeas
from letsencrypt import errors from certbot import errors
from letsencrypt import reverter from certbot import reverter
from letsencrypt.plugins import common from certbot.plugins import common
from letsencrypt_apache import constants from certbot_apache import constants
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@@ -16,14 +16,14 @@ class AugeasConfigurator(common.Plugin):
"""Base Augeas Configurator class. """Base Augeas Configurator class.
:ivar config: Configuration. :ivar config: Configuration.
:type config: :class:`~letsencrypt.interfaces.IConfig` :type config: :class:`~certbot.interfaces.IConfig`
:ivar aug: Augeas object :ivar aug: Augeas object
:type aug: :class:`augeas.Augeas` :type aug: :class:`augeas.Augeas`
:ivar str save_notes: Human-readable configuration change notes :ivar str save_notes: Human-readable configuration change notes
:ivar reverter: saves and reverts checkpoints :ivar reverter: saves and reverts checkpoints
:type reverter: :class:`letsencrypt.reverter.Reverter` :type reverter: :class:`certbot.reverter.Reverter`
""" """
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
@@ -13,18 +13,18 @@ import zope.interface
from acme import challenges from acme import challenges
from letsencrypt import errors from certbot import errors
from letsencrypt import interfaces from certbot import interfaces
from letsencrypt import le_util from certbot import le_util
from letsencrypt.plugins import common from certbot.plugins import common
from letsencrypt_apache import augeas_configurator from certbot_apache import augeas_configurator
from letsencrypt_apache import constants from certbot_apache import constants
from letsencrypt_apache import display_ops from certbot_apache import display_ops
from letsencrypt_apache import tls_sni_01 from certbot_apache import tls_sni_01
from letsencrypt_apache import obj from certbot_apache import obj
from letsencrypt_apache import parser from certbot_apache import parser
from collections import defaultdict from collections import defaultdict
@@ -70,14 +70,14 @@ class ApacheConfigurator(augeas_configurator.AugeasConfigurator):
14.04 Apache 2.4 and it works for Ubuntu 12.04 Apache 2.2 14.04 Apache 2.4 and it works for Ubuntu 12.04 Apache 2.2
:ivar config: Configuration. :ivar config: Configuration.
:type config: :class:`~letsencrypt.interfaces.IConfig` :type config: :class:`~certbot.interfaces.IConfig`
:ivar parser: Handles low level parsing :ivar parser: Handles low level parsing
:type parser: :class:`~letsencrypt_apache.parser` :type parser: :class:`~certbot_apache.parser`
:ivar tup version: version of Apache :ivar tup version: version of Apache
:ivar list vhosts: All vhosts found in the configuration :ivar list vhosts: All vhosts found in the configuration
(:class:`list` of :class:`~letsencrypt_apache.obj.VirtualHost`) (:class:`list` of :class:`~certbot_apache.obj.VirtualHost`)
:ivar dict assoc: Mapping between domains and vhosts :ivar dict assoc: Mapping between domains and vhosts
@@ -205,7 +205,7 @@ class ApacheConfigurator(augeas_configurator.AugeasConfigurator):
installed, the VirtualHost is enabled if it isn't already. installed, the VirtualHost is enabled if it isn't already.
.. todo:: Might be nice to remove chain directive if none exists .. todo:: Might be nice to remove chain directive if none exists
This shouldn't happen within letsencrypt though This shouldn't happen within certbot though
:raises errors.PluginError: When unable to deploy certificate due to :raises errors.PluginError: When unable to deploy certificate due to
a lack of directives a lack of directives
@@ -290,7 +290,7 @@ class ApacheConfigurator(augeas_configurator.AugeasConfigurator):
:param bool temp: whether the vhost is only used temporarily :param bool temp: whether the vhost is only used temporarily
:returns: ssl vhost associated with name :returns: ssl vhost associated with name
:rtype: :class:`~letsencrypt_apache.obj.VirtualHost` :rtype: :class:`~certbot_apache.obj.VirtualHost`
:raises .errors.PluginError: If no vhost is available or chosen :raises .errors.PluginError: If no vhost is available or chosen
@@ -472,7 +472,7 @@ class ApacheConfigurator(augeas_configurator.AugeasConfigurator):
"""Helper function for get_virtual_hosts(). """Helper function for get_virtual_hosts().
:param host: In progress vhost whose names will be added :param host: In progress vhost whose names will be added
:type host: :class:`~letsencrypt_apache.obj.VirtualHost` :type host: :class:`~certbot_apache.obj.VirtualHost`
""" """
# Take the final ServerName as each overrides the previous # Take the final ServerName as each overrides the previous
@@ -498,7 +498,7 @@ class ApacheConfigurator(augeas_configurator.AugeasConfigurator):
:param str path: Augeas path to virtual host :param str path: Augeas path to virtual host
:returns: newly created vhost :returns: newly created vhost
:rtype: :class:`~letsencrypt_apache.obj.VirtualHost` :rtype: :class:`~certbot_apache.obj.VirtualHost`
""" """
addrs = set() addrs = set()
@@ -534,7 +534,7 @@ class ApacheConfigurator(augeas_configurator.AugeasConfigurator):
def get_virtual_hosts(self): def get_virtual_hosts(self):
"""Returns list of virtual hosts found in the Apache configuration. """Returns list of virtual hosts found in the Apache configuration.
:returns: List of :class:`~letsencrypt_apache.obj.VirtualHost` :returns: List of :class:`~certbot_apache.obj.VirtualHost`
objects found in configuration objects found in configuration
:rtype: list :rtype: list
@@ -572,7 +572,7 @@ class ApacheConfigurator(augeas_configurator.AugeasConfigurator):
now NameVirtualHosts. If version is earlier than 2.4, check if addr now NameVirtualHosts. If version is earlier than 2.4, check if addr
has a NameVirtualHost directive in the Apache config has a NameVirtualHost directive in the Apache config
:param letsencrypt_apache.obj.Addr target_addr: vhost address :param certbot_apache.obj.Addr target_addr: vhost address
:returns: Success :returns: Success
:rtype: bool :rtype: bool
@@ -590,7 +590,7 @@ class ApacheConfigurator(augeas_configurator.AugeasConfigurator):
"""Adds NameVirtualHost directive for given address. """Adds NameVirtualHost directive for given address.
:param addr: Address that will be added as NameVirtualHost directive :param addr: Address that will be added as NameVirtualHost directive
:type addr: :class:`~letsencrypt_apache.obj.Addr` :type addr: :class:`~certbot_apache.obj.Addr`
""" """
loc = parser.get_aug_path(self.parser.loc["name"]) loc = parser.get_aug_path(self.parser.loc["name"])
@@ -679,7 +679,7 @@ class ApacheConfigurator(augeas_configurator.AugeasConfigurator):
"""Checks to see if the server is ready for SNI challenges. """Checks to see if the server is ready for SNI challenges.
:param addrs: Addresses to check SNI compatibility :param addrs: Addresses to check SNI compatibility
:type addrs: :class:`~letsencrypt_apache.obj.Addr` :type addrs: :class:`~certbot_apache.obj.Addr`
""" """
# Version 2.4 and later are automatically SNI ready. # Version 2.4 and later are automatically SNI ready.
@@ -697,15 +697,15 @@ class ApacheConfigurator(augeas_configurator.AugeasConfigurator):
Duplicates vhost and adds default ssl options Duplicates vhost and adds default ssl options
New vhost will reside as (nonssl_vhost.path) + New vhost will reside as (nonssl_vhost.path) +
``letsencrypt_apache.constants.os_constant("le_vhost_ext")`` ``certbot_apache.constants.os_constant("le_vhost_ext")``
.. note:: This function saves the configuration .. note:: This function saves the configuration
:param nonssl_vhost: Valid VH that doesn't have SSLEngine on :param nonssl_vhost: Valid VH that doesn't have SSLEngine on
:type nonssl_vhost: :class:`~letsencrypt_apache.obj.VirtualHost` :type nonssl_vhost: :class:`~certbot_apache.obj.VirtualHost`
:returns: SSL vhost :returns: SSL vhost
:rtype: :class:`~letsencrypt_apache.obj.VirtualHost` :rtype: :class:`~certbot_apache.obj.VirtualHost`
:raises .errors.PluginError: If more than one virtual host is in :raises .errors.PluginError: If more than one virtual host is in
the file or if plugin is unable to write/read vhost files. the file or if plugin is unable to write/read vhost files.
@@ -911,7 +911,7 @@ class ApacheConfigurator(augeas_configurator.AugeasConfigurator):
https://httpd.apache.org/docs/2.2/mod/core.html#namevirtualhost https://httpd.apache.org/docs/2.2/mod/core.html#namevirtualhost
:param vhost: New virtual host that was recently created. :param vhost: New virtual host that was recently created.
:type vhost: :class:`~letsencrypt_apache.obj.VirtualHost` :type vhost: :class:`~certbot_apache.obj.VirtualHost`
""" """
need_to_save = False need_to_save = False
@@ -951,9 +951,9 @@ class ApacheConfigurator(augeas_configurator.AugeasConfigurator):
:param str domain: domain to enhance :param str domain: domain to enhance
:param str enhancement: enhancement type defined in :param str enhancement: enhancement type defined in
:const:`~letsencrypt.constants.ENHANCEMENTS` :const:`~certbot.constants.ENHANCEMENTS`
:param options: options for the enhancement :param options: options for the enhancement
See :const:`~letsencrypt.constants.ENHANCEMENTS` See :const:`~certbot.constants.ENHANCEMENTS`
documentation for appropriate parameter. documentation for appropriate parameter.
:raises .errors.PluginError: If Enhancement is not supported, or if :raises .errors.PluginError: If Enhancement is not supported, or if
@@ -981,14 +981,14 @@ class ApacheConfigurator(augeas_configurator.AugeasConfigurator):
.. note:: This function saves the configuration .. note:: This function saves the configuration
:param ssl_vhost: Destination of traffic, an ssl enabled vhost :param ssl_vhost: Destination of traffic, an ssl enabled vhost
:type ssl_vhost: :class:`~letsencrypt_apache.obj.VirtualHost` :type ssl_vhost: :class:`~certbot_apache.obj.VirtualHost`
:param header_substring: string that uniquely identifies a header. :param header_substring: string that uniquely identifies a header.
e.g: Strict-Transport-Security, Upgrade-Insecure-Requests. e.g: Strict-Transport-Security, Upgrade-Insecure-Requests.
:type str :type str
:returns: Success, general_vhost (HTTP vhost) :returns: Success, general_vhost (HTTP vhost)
:rtype: (bool, :class:`~letsencrypt_apache.obj.VirtualHost`) :rtype: (bool, :class:`~certbot_apache.obj.VirtualHost`)
:raises .errors.PluginError: If no viable HTTP host can be created or :raises .errors.PluginError: If no viable HTTP host can be created or
set with header header_substring. set with header header_substring.
@@ -1016,7 +1016,7 @@ class ApacheConfigurator(augeas_configurator.AugeasConfigurator):
contains the string header_substring. contains the string header_substring.
:param ssl_vhost: vhost to check :param ssl_vhost: vhost to check
:type vhost: :class:`~letsencrypt_apache.obj.VirtualHost` :type vhost: :class:`~certbot_apache.obj.VirtualHost`
:param header_substring: string that uniquely identifies a header. :param header_substring: string that uniquely identifies a header.
e.g: Strict-Transport-Security, Upgrade-Insecure-Requests. e.g: Strict-Transport-Security, Upgrade-Insecure-Requests.
@@ -1053,13 +1053,13 @@ class ApacheConfigurator(augeas_configurator.AugeasConfigurator):
.. note:: This function saves the configuration .. note:: This function saves the configuration
:param ssl_vhost: Destination of traffic, an ssl enabled vhost :param ssl_vhost: Destination of traffic, an ssl enabled vhost
:type ssl_vhost: :class:`~letsencrypt_apache.obj.VirtualHost` :type ssl_vhost: :class:`~certbot_apache.obj.VirtualHost`
:param unused_options: Not currently used :param unused_options: Not currently used
:type unused_options: Not Available :type unused_options: Not Available
:returns: Success, general_vhost (HTTP vhost) :returns: Success, general_vhost (HTTP vhost)
:rtype: (bool, :class:`~letsencrypt_apache.obj.VirtualHost`) :rtype: (bool, :class:`~certbot_apache.obj.VirtualHost`)
:raises .errors.PluginError: If no viable HTTP host can be created or :raises .errors.PluginError: If no viable HTTP host can be created or
used for the redirect. used for the redirect.
@@ -1084,10 +1084,10 @@ class ApacheConfigurator(augeas_configurator.AugeasConfigurator):
self._create_redirect_vhost(ssl_vhost) self._create_redirect_vhost(ssl_vhost)
else: else:
# Check if LetsEncrypt redirection already exists # Check if LetsEncrypt redirection already exists
self._verify_no_letsencrypt_redirect(general_vh) self._verify_no_certbot_redirect(general_vh)
# Note: if code flow gets here it means we didn't find the exact # Note: if code flow gets here it means we didn't find the exact
# letsencrypt RewriteRule config for redirection. Finding # certbot RewriteRule config for redirection. Finding
# another RewriteRule is likely to be fine in most or all cases, # another RewriteRule is likely to be fine in most or all cases,
# but redirect loops are possible in very obscure cases; see #1620 # but redirect loops are possible in very obscure cases; see #1620
# for reasoning. # for reasoning.
@@ -1121,17 +1121,17 @@ class ApacheConfigurator(augeas_configurator.AugeasConfigurator):
logger.info("Redirecting vhost in %s to ssl vhost in %s", logger.info("Redirecting vhost in %s to ssl vhost in %s",
general_vh.filep, ssl_vhost.filep) general_vh.filep, ssl_vhost.filep)
def _verify_no_letsencrypt_redirect(self, vhost): def _verify_no_certbot_redirect(self, vhost):
"""Checks to see if a redirect was already installed by letsencrypt. """Checks to see if a redirect was already installed by certbot.
Checks to see if virtualhost already contains a rewrite rule that is Checks to see if virtualhost already contains a rewrite rule that is
identical to Letsencrypt's redirection rewrite rule. identical to Letsencrypt's redirection rewrite rule.
:param vhost: vhost to check :param vhost: vhost to check
:type vhost: :class:`~letsencrypt_apache.obj.VirtualHost` :type vhost: :class:`~certbot_apache.obj.VirtualHost`
:raises errors.PluginEnhancementAlreadyPresent: When the exact :raises errors.PluginEnhancementAlreadyPresent: When the exact
letsencrypt redirection WriteRule exists in virtual host. certbot redirection WriteRule exists in virtual host.
""" """
rewrite_path = self.parser.find_dir( rewrite_path = self.parser.find_dir(
"RewriteRule", None, start=vhost.path) "RewriteRule", None, start=vhost.path)
@@ -1160,7 +1160,7 @@ class ApacheConfigurator(augeas_configurator.AugeasConfigurator):
"""Checks if there exists a RewriteRule directive in vhost """Checks if there exists a RewriteRule directive in vhost
:param vhost: vhost to check :param vhost: vhost to check
:type vhost: :class:`~letsencrypt_apache.obj.VirtualHost` :type vhost: :class:`~certbot_apache.obj.VirtualHost`
:returns: True if a RewriteRule directive exists. :returns: True if a RewriteRule directive exists.
:rtype: bool :rtype: bool
@@ -1174,7 +1174,7 @@ class ApacheConfigurator(augeas_configurator.AugeasConfigurator):
"""Checks if a RewriteEngine directive is on """Checks if a RewriteEngine directive is on
:param vhost: vhost to check :param vhost: vhost to check
:type vhost: :class:`~letsencrypt_apache.obj.VirtualHost` :type vhost: :class:`~certbot_apache.obj.VirtualHost`
""" """
rewrite_engine_path = self.parser.find_dir("RewriteEngine", "on", rewrite_engine_path = self.parser.find_dir("RewriteEngine", "on",
@@ -1187,10 +1187,10 @@ class ApacheConfigurator(augeas_configurator.AugeasConfigurator):
"""Creates an http_vhost specifically to redirect for the ssl_vhost. """Creates an http_vhost specifically to redirect for the ssl_vhost.
:param ssl_vhost: ssl vhost :param ssl_vhost: ssl vhost
:type ssl_vhost: :class:`~letsencrypt_apache.obj.VirtualHost` :type ssl_vhost: :class:`~certbot_apache.obj.VirtualHost`
:returns: tuple of the form :returns: tuple of the form
(`success`, :class:`~letsencrypt_apache.obj.VirtualHost`) (`success`, :class:`~certbot_apache.obj.VirtualHost`)
:rtype: tuple :rtype: tuple
""" """
@@ -1369,7 +1369,7 @@ class ApacheConfigurator(augeas_configurator.AugeasConfigurator):
.. todo:: Make sure link is not broken... .. todo:: Make sure link is not broken...
:param vhost: vhost to enable :param vhost: vhost to enable
:type vhost: :class:`~letsencrypt_apache.obj.VirtualHost` :type vhost: :class:`~certbot_apache.obj.VirtualHost`
:raises .errors.NotSupportedError: If filesystem layout is not :raises .errors.NotSupportedError: If filesystem layout is not
supported. supported.
@@ -1452,7 +1452,7 @@ class ApacheConfigurator(augeas_configurator.AugeasConfigurator):
if not le_util.exe_exists(self.conf("dismod")): if not le_util.exe_exists(self.conf("dismod")):
raise errors.MisconfigurationError( raise errors.MisconfigurationError(
"Unable to find a2dismod, please make sure a2enmod and " "Unable to find a2dismod, please make sure a2enmod and "
"a2dismod are configured correctly for letsencrypt.") "a2dismod are configured correctly for certbot.")
self.reverter.register_undo_command( self.reverter.register_undo_command(
temp, [self.conf("dismod"), mod_name]) temp, [self.conf("dismod"), mod_name])
@@ -1639,7 +1639,7 @@ def install_ssl_options_conf(options_ssl):
required. required.
""" """
# XXX if we ever try to enforce a local privilege boundary (eg, running # XXX if we ever try to enforce a local privilege boundary (eg, running
# letsencrypt for unprivileged users via setuid), this function will need # certbot for unprivileged users via setuid), this function will need
# to be modified. # to be modified.
# XXX if the user is in security-autoupdate mode, we should be willing to # XXX if the user is in security-autoupdate mode, we should be willing to
@@ -1,6 +1,6 @@
"""Apache plugin constants.""" """Apache plugin constants."""
import pkg_resources import pkg_resources
from letsencrypt import le_util from certbot import le_util
CLI_DEFAULTS_DEBIAN = dict( CLI_DEFAULTS_DEBIAN = dict(
@@ -18,7 +18,7 @@ CLI_DEFAULTS_DEBIAN = dict(
handle_sites=True, handle_sites=True,
challenge_location="/etc/apache2", challenge_location="/etc/apache2",
MOD_SSL_CONF_SRC=pkg_resources.resource_filename( MOD_SSL_CONF_SRC=pkg_resources.resource_filename(
"letsencrypt_apache", "options-ssl-apache.conf") "certbot_apache", "options-ssl-apache.conf")
) )
CLI_DEFAULTS_CENTOS = dict( CLI_DEFAULTS_CENTOS = dict(
server_root="/etc/httpd", server_root="/etc/httpd",
@@ -35,7 +35,7 @@ CLI_DEFAULTS_CENTOS = dict(
handle_sites=False, handle_sites=False,
challenge_location="/etc/httpd/conf.d", challenge_location="/etc/httpd/conf.d",
MOD_SSL_CONF_SRC=pkg_resources.resource_filename( MOD_SSL_CONF_SRC=pkg_resources.resource_filename(
"letsencrypt_apache", "centos-options-ssl-apache.conf") "certbot_apache", "centos-options-ssl-apache.conf")
) )
CLI_DEFAULTS_GENTOO = dict( CLI_DEFAULTS_GENTOO = dict(
server_root="/etc/apache2", server_root="/etc/apache2",
@@ -52,7 +52,7 @@ CLI_DEFAULTS_GENTOO = dict(
handle_sites=False, handle_sites=False,
challenge_location="/etc/apache2/vhosts.d", challenge_location="/etc/apache2/vhosts.d",
MOD_SSL_CONF_SRC=pkg_resources.resource_filename( MOD_SSL_CONF_SRC=pkg_resources.resource_filename(
"letsencrypt_apache", "options-ssl-apache.conf") "certbot_apache", "options-ssl-apache.conf")
) )
CLI_DEFAULTS_DARWIN = dict( CLI_DEFAULTS_DARWIN = dict(
server_root="/etc/apache2", server_root="/etc/apache2",
@@ -69,7 +69,7 @@ CLI_DEFAULTS_DARWIN = dict(
handle_sites=False, handle_sites=False,
challenge_location="/etc/apache2/other", challenge_location="/etc/apache2/other",
MOD_SSL_CONF_SRC=pkg_resources.resource_filename( MOD_SSL_CONF_SRC=pkg_resources.resource_filename(
"letsencrypt_apache", "options-ssl-apache.conf") "certbot_apache", "options-ssl-apache.conf")
) )
CLI_DEFAULTS = { CLI_DEFAULTS = {
"debian": CLI_DEFAULTS_DEBIAN, "debian": CLI_DEFAULTS_DEBIAN,
@@ -87,7 +87,7 @@ MOD_SSL_CONF_DEST = "options-ssl-apache.conf"
"""Name of the mod_ssl config file as saved in `IConfig.config_dir`.""" """Name of the mod_ssl config file as saved in `IConfig.config_dir`."""
AUGEAS_LENS_DIR = pkg_resources.resource_filename( AUGEAS_LENS_DIR = pkg_resources.resource_filename(
"letsencrypt_apache", "augeas_lens") "certbot_apache", "augeas_lens")
"""Path to the Augeas lens directory""" """Path to the Augeas lens directory"""
REWRITE_HTTPS_ARGS = [ REWRITE_HTTPS_ARGS = [
@@ -4,10 +4,10 @@ import os
import zope.component import zope.component
from letsencrypt import errors from certbot import errors
from letsencrypt import interfaces from certbot import interfaces
import letsencrypt.display.util as display_util import certbot.display.util as display_util
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@@ -50,7 +50,7 @@ def _vhost_menu(domain, vhosts):
if free_chars < 2: if free_chars < 2:
logger.debug("Display size is too small for " logger.debug("Display size is too small for "
"letsencrypt_apache.display_ops._vhost_menu()") "certbot_apache.display_ops._vhost_menu()")
# This runs the edge off the screen, but it doesn't cause an "error" # This runs the edge off the screen, but it doesn't cause an "error"
filename_size = 1 filename_size = 1
disp_name_size = 1 disp_name_size = 1
@@ -1,7 +1,7 @@
"""Module contains classes used by the Apache Configurator.""" """Module contains classes used by the Apache Configurator."""
import re import re
from letsencrypt.plugins import common from certbot.plugins import common
class Addr(common.Addr): class Addr(common.Addr):
@@ -6,9 +6,9 @@ import os
import re import re
import subprocess import subprocess
from letsencrypt import errors from certbot import errors
from letsencrypt_apache import constants from certbot_apache import constants
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@@ -0,0 +1,6 @@
Issues for which some kind of test case should be constructable, but we do not
currently have one:
https://github.com/certbot/certbot/issues/1213
https://github.com/certbot/certbot/issues/1602
@@ -59,7 +59,7 @@ trap CleanupExit INT
for f in *.conf ; do for f in *.conf ; do
echo -n testing "$f"... echo -n testing "$f"...
Setup Setup
RESULT=`echo c | sudo env "PATH=$PATH" letsencrypt -vvvv --debug --staging --apache --register-unsafely-without-email --agree-tos certonly -t 2>&1` RESULT=`echo c | sudo env "PATH=$PATH" certbot -vvvv --debug --staging --apache --register-unsafely-without-email --agree-tos certonly -t 2>&1`
if echo $RESULT | grep -Eq \("Which names would you like"\|"mod_macro is not yet"\) ; then if echo $RESULT | grep -Eq \("Which names would you like"\|"mod_macro is not yet"\) ; then
echo passed echo passed
else else
@@ -41,7 +41,7 @@ Listen 443
SSLCertificateFile /etc/ssl/certs/ssl-cert-snakeoil.pem SSLCertificateFile /etc/ssl/certs/ssl-cert-snakeoil.pem
SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key
SSLCertificateChainFile /etc/ssl/certs/ssl-cert-snakeoil.pem SSLCertificateChainFile /etc/ssl/certs/ssl-cert-snakeoil.pem
Include /etc/letsencrypt/options-ssl-apache.conf Include /etc/certbot/options-ssl-apache.conf
</VirtualHost> </VirtualHost>
@@ -1,13 +1,13 @@
"""Test for letsencrypt_apache.augeas_configurator.""" """Test for certbot_apache.augeas_configurator."""
import os import os
import shutil import shutil
import unittest import unittest
import mock import mock
from letsencrypt import errors from certbot import errors
from letsencrypt_apache.tests import util from certbot_apache.tests import util
class AugeasConfiguratorTest(util.ApacheTest): class AugeasConfiguratorTest(util.ApacheTest):
@@ -1,11 +1,11 @@
"""Tests for letsencrypt_apache.parser.""" """Tests for certbot_apache.parser."""
import os import os
import shutil import shutil
import unittest import unittest
from letsencrypt import errors from certbot import errors
from letsencrypt_apache.tests import util from certbot_apache.tests import util
class ComplexParserTest(util.ParserTest): class ComplexParserTest(util.ParserTest):
@@ -88,7 +88,7 @@ class ComplexParserTest(util.ParserTest):
def verify_fnmatch(self, arg, hit=True): def verify_fnmatch(self, arg, hit=True):
"""Test if Include was correctly parsed.""" """Test if Include was correctly parsed."""
from letsencrypt_apache import parser from certbot_apache import parser
self.parser.add_dir(parser.get_aug_path(self.parser.loc["default"]), self.parser.add_dir(parser.get_aug_path(self.parser.loc["default"]),
"Include", [arg]) "Include", [arg])
if hit: if hit:
@@ -1,5 +1,5 @@
# pylint: disable=too-many-public-methods # pylint: disable=too-many-public-methods
"""Test for letsencrypt_apache.configurator.""" """Test for certbot_apache.configurator."""
import os import os
import shutil import shutil
import socket import socket
@@ -9,15 +9,15 @@ import mock
from acme import challenges from acme import challenges
from letsencrypt import achallenges from certbot import achallenges
from letsencrypt import errors from certbot import errors
from letsencrypt.tests import acme_util from certbot.tests import acme_util
from letsencrypt_apache import configurator from certbot_apache import configurator
from letsencrypt_apache import obj from certbot_apache import obj
from letsencrypt_apache.tests import util from certbot_apache.tests import util
class MultipleVhostsTest(util.ApacheTest): class MultipleVhostsTest(util.ApacheTest):
@@ -38,7 +38,7 @@ class MultipleVhostsTest(util.ApacheTest):
def mocked_deploy_cert(*args, **kwargs): def mocked_deploy_cert(*args, **kwargs):
"""a helper to mock a deployed cert""" """a helper to mock a deployed cert"""
with mock.patch("letsencrypt_apache.configurator.ApacheConfigurator.enable_mod"): with mock.patch("certbot_apache.configurator.ApacheConfigurator.enable_mod"):
config.real_deploy_cert(*args, **kwargs) config.real_deploy_cert(*args, **kwargs)
self.config.deploy_cert = mocked_deploy_cert self.config.deploy_cert = mocked_deploy_cert
return self.config return self.config
@@ -48,14 +48,14 @@ class MultipleVhostsTest(util.ApacheTest):
shutil.rmtree(self.config_dir) shutil.rmtree(self.config_dir)
shutil.rmtree(self.work_dir) shutil.rmtree(self.work_dir)
@mock.patch("letsencrypt_apache.configurator.le_util.exe_exists") @mock.patch("certbot_apache.configurator.le_util.exe_exists")
def test_prepare_no_install(self, mock_exe_exists): def test_prepare_no_install(self, mock_exe_exists):
mock_exe_exists.return_value = False mock_exe_exists.return_value = False
self.assertRaises( self.assertRaises(
errors.NoInstallationError, self.config.prepare) errors.NoInstallationError, self.config.prepare)
@mock.patch("letsencrypt_apache.parser.ApacheParser") @mock.patch("certbot_apache.parser.ApacheParser")
@mock.patch("letsencrypt_apache.configurator.le_util.exe_exists") @mock.patch("certbot_apache.configurator.le_util.exe_exists")
def test_prepare_version(self, mock_exe_exists, _): def test_prepare_version(self, mock_exe_exists, _):
mock_exe_exists.return_value = True mock_exe_exists.return_value = True
self.config.version = None self.config.version = None
@@ -65,8 +65,8 @@ class MultipleVhostsTest(util.ApacheTest):
self.assertRaises( self.assertRaises(
errors.NotSupportedError, self.config.prepare) errors.NotSupportedError, self.config.prepare)
@mock.patch("letsencrypt_apache.parser.ApacheParser") @mock.patch("certbot_apache.parser.ApacheParser")
@mock.patch("letsencrypt_apache.configurator.le_util.exe_exists") @mock.patch("certbot_apache.configurator.le_util.exe_exists")
def test_prepare_old_aug(self, mock_exe_exists, _): def test_prepare_old_aug(self, mock_exe_exists, _):
mock_exe_exists.return_value = True mock_exe_exists.return_value = True
self.config.config_test = mock.Mock() self.config.config_test = mock.Mock()
@@ -76,7 +76,7 @@ class MultipleVhostsTest(util.ApacheTest):
errors.NotSupportedError, self.config.prepare) errors.NotSupportedError, self.config.prepare)
def test_add_parser_arguments(self): # pylint: disable=no-self-use def test_add_parser_arguments(self): # pylint: disable=no-self-use
from letsencrypt_apache.configurator import ApacheConfigurator from certbot_apache.configurator import ApacheConfigurator
# Weak test.. # Weak test..
ApacheConfigurator.add_parser_arguments(mock.MagicMock()) ApacheConfigurator.add_parser_arguments(mock.MagicMock())
@@ -85,10 +85,10 @@ class MultipleVhostsTest(util.ApacheTest):
mock_getutility.notification = mock.MagicMock(return_value=True) mock_getutility.notification = mock.MagicMock(return_value=True)
names = self.config.get_all_names() names = self.config.get_all_names()
self.assertEqual(names, set( self.assertEqual(names, set(
["letsencrypt.demo", "encryption-example.demo", "ip-172-30-0-17", "*.blue.purple.com"])) ["certbot.demo", "encryption-example.demo", "ip-172-30-0-17", "*.blue.purple.com"]))
@mock.patch("zope.component.getUtility") @mock.patch("zope.component.getUtility")
@mock.patch("letsencrypt_apache.configurator.socket.gethostbyaddr") @mock.patch("certbot_apache.configurator.socket.gethostbyaddr")
def test_get_all_names_addrs(self, mock_gethost, mock_getutility): def test_get_all_names_addrs(self, mock_gethost, mock_getutility):
mock_gethost.side_effect = [("google.com", "", ""), socket.error] mock_gethost.side_effect = [("google.com", "", ""), socket.error]
notification = mock.Mock() notification = mock.Mock()
@@ -106,7 +106,7 @@ class MultipleVhostsTest(util.ApacheTest):
self.assertEqual(len(names), 6) self.assertEqual(len(names), 6)
self.assertTrue("zombo.com" in names) self.assertTrue("zombo.com" in names)
self.assertTrue("google.com" in names) self.assertTrue("google.com" in names)
self.assertTrue("letsencrypt.demo" in names) self.assertTrue("certbot.demo" in names)
def test_add_servernames_alias(self): def test_add_servernames_alias(self):
self.config.parser.add_dir( self.config.parser.add_dir(
@@ -139,25 +139,25 @@ class MultipleVhostsTest(util.ApacheTest):
# Handle case of non-debian layout get_virtual_hosts # Handle case of non-debian layout get_virtual_hosts
with mock.patch( with mock.patch(
"letsencrypt_apache.configurator.ApacheConfigurator.conf" "certbot_apache.configurator.ApacheConfigurator.conf"
) as mock_conf: ) as mock_conf:
mock_conf.return_value = False mock_conf.return_value = False
vhs = self.config.get_virtual_hosts() vhs = self.config.get_virtual_hosts()
self.assertEqual(len(vhs), 7) self.assertEqual(len(vhs), 7)
@mock.patch("letsencrypt_apache.display_ops.select_vhost") @mock.patch("certbot_apache.display_ops.select_vhost")
def test_choose_vhost_none_avail(self, mock_select): def test_choose_vhost_none_avail(self, mock_select):
mock_select.return_value = None mock_select.return_value = None
self.assertRaises( self.assertRaises(
errors.PluginError, self.config.choose_vhost, "none.com") errors.PluginError, self.config.choose_vhost, "none.com")
@mock.patch("letsencrypt_apache.display_ops.select_vhost") @mock.patch("certbot_apache.display_ops.select_vhost")
def test_choose_vhost_select_vhost_ssl(self, mock_select): def test_choose_vhost_select_vhost_ssl(self, mock_select):
mock_select.return_value = self.vh_truth[1] mock_select.return_value = self.vh_truth[1]
self.assertEqual( self.assertEqual(
self.vh_truth[1], self.config.choose_vhost("none.com")) self.vh_truth[1], self.config.choose_vhost("none.com"))
@mock.patch("letsencrypt_apache.display_ops.select_vhost") @mock.patch("certbot_apache.display_ops.select_vhost")
def test_choose_vhost_select_vhost_non_ssl(self, mock_select): def test_choose_vhost_select_vhost_non_ssl(self, mock_select):
mock_select.return_value = self.vh_truth[0] mock_select.return_value = self.vh_truth[0]
chosen_vhost = self.config.choose_vhost("none.com") chosen_vhost = self.config.choose_vhost("none.com")
@@ -169,13 +169,13 @@ class MultipleVhostsTest(util.ApacheTest):
self.assertFalse(self.vh_truth[0].ssl) self.assertFalse(self.vh_truth[0].ssl)
self.assertTrue(chosen_vhost.ssl) self.assertTrue(chosen_vhost.ssl)
@mock.patch("letsencrypt_apache.display_ops.select_vhost") @mock.patch("certbot_apache.display_ops.select_vhost")
def test_choose_vhost_select_vhost_with_temp(self, mock_select): def test_choose_vhost_select_vhost_with_temp(self, mock_select):
mock_select.return_value = self.vh_truth[0] mock_select.return_value = self.vh_truth[0]
chosen_vhost = self.config.choose_vhost("none.com", temp=True) chosen_vhost = self.config.choose_vhost("none.com", temp=True)
self.assertEqual(self.vh_truth[0], chosen_vhost) self.assertEqual(self.vh_truth[0], chosen_vhost)
@mock.patch("letsencrypt_apache.display_ops.select_vhost") @mock.patch("certbot_apache.display_ops.select_vhost")
def test_choose_vhost_select_vhost_conflicting_non_ssl(self, mock_select): def test_choose_vhost_select_vhost_conflicting_non_ssl(self, mock_select):
mock_select.return_value = self.vh_truth[3] mock_select.return_value = self.vh_truth[3]
conflicting_vhost = obj.VirtualHost( conflicting_vhost = obj.VirtualHost(
@@ -203,7 +203,7 @@ class MultipleVhostsTest(util.ApacheTest):
def test_find_best_vhost(self): def test_find_best_vhost(self):
# pylint: disable=protected-access # pylint: disable=protected-access
self.assertEqual( self.assertEqual(
self.vh_truth[3], self.config._find_best_vhost("letsencrypt.demo")) self.vh_truth[3], self.config._find_best_vhost("certbot.demo"))
self.assertEqual( self.assertEqual(
self.vh_truth[0], self.vh_truth[0],
self.config._find_best_vhost("encryption-example.demo")) self.config._find_best_vhost("encryption-example.demo"))
@@ -224,7 +224,7 @@ class MultipleVhostsTest(util.ApacheTest):
# Assume only the two default vhosts. # Assume only the two default vhosts.
self.config.vhosts = [ self.config.vhosts = [
vh for vh in self.config.vhosts vh for vh in self.config.vhosts
if vh.name not in ["letsencrypt.demo", "encryption-example.demo"] if vh.name not in ["certbot.demo", "encryption-example.demo"]
and "*.blue.purple.com" not in vh.aliases and "*.blue.purple.com" not in vh.aliases
] ]
@@ -254,9 +254,9 @@ class MultipleVhostsTest(util.ApacheTest):
self.config.is_site_enabled, self.config.is_site_enabled,
"irrelevant") "irrelevant")
@mock.patch("letsencrypt.le_util.run_script") @mock.patch("certbot.le_util.run_script")
@mock.patch("letsencrypt.le_util.exe_exists") @mock.patch("certbot.le_util.exe_exists")
@mock.patch("letsencrypt_apache.parser.subprocess.Popen") @mock.patch("certbot_apache.parser.subprocess.Popen")
def test_enable_mod(self, mock_popen, mock_exe_exists, mock_run_script): def test_enable_mod(self, mock_popen, mock_exe_exists, mock_run_script):
mock_popen().communicate.return_value = ("Define: DUMP_RUN_CFG", "") mock_popen().communicate.return_value = ("Define: DUMP_RUN_CFG", "")
mock_popen().returncode = 0 mock_popen().returncode = 0
@@ -273,7 +273,7 @@ class MultipleVhostsTest(util.ApacheTest):
self.assertRaises( self.assertRaises(
errors.NotSupportedError, self.config.enable_mod, "ssl") errors.NotSupportedError, self.config.enable_mod, "ssl")
@mock.patch("letsencrypt.le_util.exe_exists") @mock.patch("certbot.le_util.exe_exists")
def test_enable_mod_no_disable(self, mock_exe_exists): def test_enable_mod_no_disable(self, mock_exe_exists):
mock_exe_exists.return_value = False mock_exe_exists.return_value = False
self.assertRaises( self.assertRaises(
@@ -636,8 +636,8 @@ class MultipleVhostsTest(util.ApacheTest):
self.config._add_name_vhost_if_necessary(self.vh_truth[0]) self.config._add_name_vhost_if_necessary(self.vh_truth[0])
self.assertEqual(self.config.save.call_count, 2) self.assertEqual(self.config.save.call_count, 2)
@mock.patch("letsencrypt_apache.configurator.tls_sni_01.ApacheTlsSni01.perform") @mock.patch("certbot_apache.configurator.tls_sni_01.ApacheTlsSni01.perform")
@mock.patch("letsencrypt_apache.configurator.ApacheConfigurator.restart") @mock.patch("certbot_apache.configurator.ApacheConfigurator.restart")
def test_perform(self, mock_restart, mock_perform): def test_perform(self, mock_restart, mock_perform):
# Only tests functionality specific to configurator.perform # Only tests functionality specific to configurator.perform
# Note: As more challenges are offered this will have to be expanded # Note: As more challenges are offered this will have to be expanded
@@ -656,7 +656,7 @@ class MultipleVhostsTest(util.ApacheTest):
self.assertEqual(mock_restart.call_count, 1) self.assertEqual(mock_restart.call_count, 1)
@mock.patch("letsencrypt_apache.configurator.ApacheConfigurator.restart") @mock.patch("certbot_apache.configurator.ApacheConfigurator.restart")
def test_cleanup(self, mock_restart): def test_cleanup(self, mock_restart):
_, achall1, achall2 = self.get_achalls() _, achall1, achall2 = self.get_achalls()
@@ -669,7 +669,7 @@ class MultipleVhostsTest(util.ApacheTest):
self.config.cleanup([achall2]) self.config.cleanup([achall2])
self.assertTrue(mock_restart.called) self.assertTrue(mock_restart.called)
@mock.patch("letsencrypt_apache.configurator.ApacheConfigurator.restart") @mock.patch("certbot_apache.configurator.ApacheConfigurator.restart")
def test_cleanup_no_errors(self, mock_restart): def test_cleanup_no_errors(self, mock_restart):
_, achall1, achall2 = self.get_achalls() _, achall1, achall2 = self.get_achalls()
@@ -681,7 +681,7 @@ class MultipleVhostsTest(util.ApacheTest):
self.config.cleanup([achall1, achall2]) self.config.cleanup([achall1, achall2])
self.assertTrue(mock_restart.called) self.assertTrue(mock_restart.called)
@mock.patch("letsencrypt.le_util.run_script") @mock.patch("certbot.le_util.run_script")
def test_get_version(self, mock_script): def test_get_version(self, mock_script):
mock_script.return_value = ( mock_script.return_value = (
"Server Version: Apache/2.4.2 (Debian)", "") "Server Version: Apache/2.4.2 (Debian)", "")
@@ -703,21 +703,21 @@ class MultipleVhostsTest(util.ApacheTest):
mock_script.side_effect = errors.SubprocessError("Can't find program") mock_script.side_effect = errors.SubprocessError("Can't find program")
self.assertRaises(errors.PluginError, self.config.get_version) self.assertRaises(errors.PluginError, self.config.get_version)
@mock.patch("letsencrypt_apache.configurator.le_util.run_script") @mock.patch("certbot_apache.configurator.le_util.run_script")
def test_restart(self, _): def test_restart(self, _):
self.config.restart() self.config.restart()
@mock.patch("letsencrypt_apache.configurator.le_util.run_script") @mock.patch("certbot_apache.configurator.le_util.run_script")
def test_restart_bad_process(self, mock_run_script): def test_restart_bad_process(self, mock_run_script):
mock_run_script.side_effect = [None, errors.SubprocessError] mock_run_script.side_effect = [None, errors.SubprocessError]
self.assertRaises(errors.MisconfigurationError, self.config.restart) self.assertRaises(errors.MisconfigurationError, self.config.restart)
@mock.patch("letsencrypt.le_util.run_script") @mock.patch("certbot.le_util.run_script")
def test_config_test(self, _): def test_config_test(self, _):
self.config.config_test() self.config.config_test()
@mock.patch("letsencrypt.le_util.run_script") @mock.patch("certbot.le_util.run_script")
def test_config_test_bad_process(self, mock_run_script): def test_config_test_bad_process(self, mock_run_script):
mock_run_script.side_effect = errors.SubprocessError mock_run_script.side_effect = errors.SubprocessError
@@ -747,7 +747,7 @@ class MultipleVhostsTest(util.ApacheTest):
self.assertTrue(isinstance(self.config.get_chall_pref(""), list)) self.assertTrue(isinstance(self.config.get_chall_pref(""), list))
def test_install_ssl_options_conf(self): def test_install_ssl_options_conf(self):
from letsencrypt_apache.configurator import install_ssl_options_conf from certbot_apache.configurator import install_ssl_options_conf
path = os.path.join(self.work_dir, "test_it") path = os.path.join(self.work_dir, "test_it")
install_ssl_options_conf(path) install_ssl_options_conf(path)
self.assertTrue(os.path.isfile(path)) self.assertTrue(os.path.isfile(path))
@@ -756,7 +756,7 @@ class MultipleVhostsTest(util.ApacheTest):
def test_supported_enhancements(self): def test_supported_enhancements(self):
self.assertTrue(isinstance(self.config.supported_enhancements(), list)) self.assertTrue(isinstance(self.config.supported_enhancements(), list))
@mock.patch("letsencrypt.le_util.exe_exists") @mock.patch("certbot.le_util.exe_exists")
def test_enhance_unknown_vhost(self, mock_exe): def test_enhance_unknown_vhost(self, mock_exe):
self.config.parser.modules.add("rewrite_module") self.config.parser.modules.add("rewrite_module")
mock_exe.return_value = True mock_exe.return_value = True
@@ -772,23 +772,23 @@ class MultipleVhostsTest(util.ApacheTest):
def test_enhance_unknown_enhancement(self): def test_enhance_unknown_enhancement(self):
self.assertRaises( self.assertRaises(
errors.PluginError, errors.PluginError,
self.config.enhance, "letsencrypt.demo", "unknown_enhancement") self.config.enhance, "certbot.demo", "unknown_enhancement")
@mock.patch("letsencrypt.le_util.run_script") @mock.patch("certbot.le_util.run_script")
@mock.patch("letsencrypt.le_util.exe_exists") @mock.patch("certbot.le_util.exe_exists")
def test_http_header_hsts(self, mock_exe, _): def test_http_header_hsts(self, mock_exe, _):
self.config.parser.update_runtime_variables = mock.Mock() self.config.parser.update_runtime_variables = mock.Mock()
self.config.parser.modules.add("mod_ssl.c") self.config.parser.modules.add("mod_ssl.c")
mock_exe.return_value = True mock_exe.return_value = True
# This will create an ssl vhost for letsencrypt.demo # This will create an ssl vhost for certbot.demo
self.config.enhance("letsencrypt.demo", "ensure-http-header", self.config.enhance("certbot.demo", "ensure-http-header",
"Strict-Transport-Security") "Strict-Transport-Security")
self.assertTrue("headers_module" in self.config.parser.modules) self.assertTrue("headers_module" in self.config.parser.modules)
# Get the ssl vhost for letsencrypt.demo # Get the ssl vhost for certbot.demo
ssl_vhost = self.config.assoc["letsencrypt.demo"] ssl_vhost = self.config.assoc["certbot.demo"]
# These are not immediately available in find_dir even with save() and # These are not immediately available in find_dir even with save() and
# load(). They must be found in sites-available # load(). They must be found in sites-available
@@ -803,7 +803,7 @@ class MultipleVhostsTest(util.ApacheTest):
# skip the enable mod # skip the enable mod
self.config.parser.modules.add("headers_module") self.config.parser.modules.add("headers_module")
# This will create an ssl vhost for letsencrypt.demo # This will create an ssl vhost for certbot.demo
self.config.enhance("encryption-example.demo", "ensure-http-header", self.config.enhance("encryption-example.demo", "ensure-http-header",
"Strict-Transport-Security") "Strict-Transport-Security")
@@ -812,21 +812,21 @@ class MultipleVhostsTest(util.ApacheTest):
self.config.enhance, "encryption-example.demo", self.config.enhance, "encryption-example.demo",
"ensure-http-header", "Strict-Transport-Security") "ensure-http-header", "Strict-Transport-Security")
@mock.patch("letsencrypt.le_util.run_script") @mock.patch("certbot.le_util.run_script")
@mock.patch("letsencrypt.le_util.exe_exists") @mock.patch("certbot.le_util.exe_exists")
def test_http_header_uir(self, mock_exe, _): def test_http_header_uir(self, mock_exe, _):
self.config.parser.update_runtime_variables = mock.Mock() self.config.parser.update_runtime_variables = mock.Mock()
self.config.parser.modules.add("mod_ssl.c") self.config.parser.modules.add("mod_ssl.c")
mock_exe.return_value = True mock_exe.return_value = True
# This will create an ssl vhost for letsencrypt.demo # This will create an ssl vhost for certbot.demo
self.config.enhance("letsencrypt.demo", "ensure-http-header", self.config.enhance("certbot.demo", "ensure-http-header",
"Upgrade-Insecure-Requests") "Upgrade-Insecure-Requests")
self.assertTrue("headers_module" in self.config.parser.modules) self.assertTrue("headers_module" in self.config.parser.modules)
# Get the ssl vhost for letsencrypt.demo # Get the ssl vhost for certbot.demo
ssl_vhost = self.config.assoc["letsencrypt.demo"] ssl_vhost = self.config.assoc["certbot.demo"]
# These are not immediately available in find_dir even with save() and # These are not immediately available in find_dir even with save() and
# load(). They must be found in sites-available # load(). They must be found in sites-available
@@ -841,7 +841,7 @@ class MultipleVhostsTest(util.ApacheTest):
# skip the enable mod # skip the enable mod
self.config.parser.modules.add("headers_module") self.config.parser.modules.add("headers_module")
# This will create an ssl vhost for letsencrypt.demo # This will create an ssl vhost for certbot.demo
self.config.enhance("encryption-example.demo", "ensure-http-header", self.config.enhance("encryption-example.demo", "ensure-http-header",
"Upgrade-Insecure-Requests") "Upgrade-Insecure-Requests")
@@ -850,15 +850,15 @@ class MultipleVhostsTest(util.ApacheTest):
self.config.enhance, "encryption-example.demo", self.config.enhance, "encryption-example.demo",
"ensure-http-header", "Upgrade-Insecure-Requests") "ensure-http-header", "Upgrade-Insecure-Requests")
@mock.patch("letsencrypt.le_util.run_script") @mock.patch("certbot.le_util.run_script")
@mock.patch("letsencrypt.le_util.exe_exists") @mock.patch("certbot.le_util.exe_exists")
def test_redirect_well_formed_http(self, mock_exe, _): def test_redirect_well_formed_http(self, mock_exe, _):
self.config.parser.update_runtime_variables = mock.Mock() self.config.parser.update_runtime_variables = mock.Mock()
mock_exe.return_value = True mock_exe.return_value = True
self.config.get_version = mock.Mock(return_value=(2, 2)) self.config.get_version = mock.Mock(return_value=(2, 2))
# This will create an ssl vhost for letsencrypt.demo # This will create an ssl vhost for certbot.demo
self.config.enhance("letsencrypt.demo", "redirect") self.config.enhance("certbot.demo", "redirect")
# These are not immediately available in find_dir even with save() and # These are not immediately available in find_dir even with save() and
# load(). They must be found in sites-available # load(). They must be found in sites-available
@@ -894,8 +894,8 @@ class MultipleVhostsTest(util.ApacheTest):
# pylint: disable=protected-access # pylint: disable=protected-access
self.assertTrue(self.config._is_rewrite_engine_on(self.vh_truth[3])) self.assertTrue(self.config._is_rewrite_engine_on(self.vh_truth[3]))
@mock.patch("letsencrypt.le_util.run_script") @mock.patch("certbot.le_util.run_script")
@mock.patch("letsencrypt.le_util.exe_exists") @mock.patch("certbot.le_util.exe_exists")
def test_redirect_with_existing_rewrite(self, mock_exe, _): def test_redirect_with_existing_rewrite(self, mock_exe, _):
self.config.parser.update_runtime_variables = mock.Mock() self.config.parser.update_runtime_variables = mock.Mock()
mock_exe.return_value = True mock_exe.return_value = True
@@ -907,8 +907,8 @@ class MultipleVhostsTest(util.ApacheTest):
"UnknownTarget"]) "UnknownTarget"])
self.config.save() self.config.save()
# This will create an ssl vhost for letsencrypt.demo # This will create an ssl vhost for certbot.demo
self.config.enhance("letsencrypt.demo", "redirect") self.config.enhance("certbot.demo", "redirect")
# These are not immediately available in find_dir even with save() and # These are not immediately available in find_dir even with save() and
# load(). They must be found in sites-available # load(). They must be found in sites-available
@@ -981,7 +981,7 @@ class MultipleVhostsTest(util.ApacheTest):
normal_target = "RewriteRule ^/(.*) http://www.a.com:1234/$1 [L,R]" normal_target = "RewriteRule ^/(.*) http://www.a.com:1234/$1 [L,R]"
self.assertFalse(self.config._sift_line(normal_target)) self.assertFalse(self.config._sift_line(normal_target))
@mock.patch("letsencrypt_apache.configurator.zope.component.getUtility") @mock.patch("certbot_apache.configurator.zope.component.getUtility")
def test_make_vhost_ssl_with_existing_rewrite_rule(self, mock_get_utility): def test_make_vhost_ssl_with_existing_rewrite_rule(self, mock_get_utility):
self.config.parser.modules.add("rewrite_module") self.config.parser.modules.add("rewrite_module")
@@ -1024,7 +1024,7 @@ class MultipleVhostsTest(util.ApacheTest):
challenges.TLSSNI01( challenges.TLSSNI01(
token="uqnaPzxtrndteOqtrXb0Asl5gOJfWAnnx6QJyvcmlDU"), token="uqnaPzxtrndteOqtrXb0Asl5gOJfWAnnx6QJyvcmlDU"),
"pending"), "pending"),
domain="letsencrypt.demo", account_key=account_key) domain="certbot.demo", account_key=account_key)
return account_key, achall1, achall2 return account_key, achall1, achall2
@@ -1,26 +1,26 @@
"""Test for letsencrypt_apache.configurator.""" """Test for certbot_apache.configurator."""
import mock import mock
import unittest import unittest
from letsencrypt_apache import constants from certbot_apache import constants
class ConstantsTest(unittest.TestCase): class ConstantsTest(unittest.TestCase):
@mock.patch("letsencrypt.le_util.get_os_info") @mock.patch("certbot.le_util.get_os_info")
def test_get_debian_value(self, os_info): def test_get_debian_value(self, os_info):
os_info.return_value = ('Debian', '', '') os_info.return_value = ('Debian', '', '')
self.assertEqual(constants.os_constant("vhost_root"), self.assertEqual(constants.os_constant("vhost_root"),
"/etc/apache2/sites-available") "/etc/apache2/sites-available")
@mock.patch("letsencrypt.le_util.get_os_info") @mock.patch("certbot.le_util.get_os_info")
def test_get_centos_value(self, os_info): def test_get_centos_value(self, os_info):
os_info.return_value = ('CentOS Linux', '', '') os_info.return_value = ('CentOS Linux', '', '')
self.assertEqual(constants.os_constant("vhost_root"), self.assertEqual(constants.os_constant("vhost_root"),
"/etc/httpd/conf.d") "/etc/httpd/conf.d")
@mock.patch("letsencrypt.le_util.get_os_info") @mock.patch("certbot.le_util.get_os_info")
def test_get_default_value(self, os_info): def test_get_default_value(self, os_info):
os_info.return_value = ('Nonexistent Linux', '', '') os_info.return_value = ('Nonexistent Linux', '', '')
self.assertEqual(constants.os_constant("vhost_root"), self.assertEqual(constants.os_constant("vhost_root"),
@@ -1,20 +1,20 @@
"""Test letsencrypt_apache.display_ops.""" """Test certbot_apache.display_ops."""
import sys import sys
import unittest import unittest
import mock import mock
import zope.component import zope.component
from letsencrypt.display import util as display_util from certbot.display import util as display_util
from letsencrypt import errors from certbot import errors
from letsencrypt_apache import obj from certbot_apache import obj
from letsencrypt_apache.tests import util from certbot_apache.tests import util
class SelectVhostTest(unittest.TestCase): class SelectVhostTest(unittest.TestCase):
"""Tests for letsencrypt_apache.display_ops.select_vhost.""" """Tests for certbot_apache.display_ops.select_vhost."""
def setUp(self): def setUp(self):
zope.component.provideUtility(display_util.FileDisplay(sys.stdout)) zope.component.provideUtility(display_util.FileDisplay(sys.stdout))
@@ -24,15 +24,15 @@ class SelectVhostTest(unittest.TestCase):
@classmethod @classmethod
def _call(cls, vhosts): def _call(cls, vhosts):
from letsencrypt_apache.display_ops import select_vhost from certbot_apache.display_ops import select_vhost
return select_vhost("example.com", vhosts) return select_vhost("example.com", vhosts)
@mock.patch("letsencrypt_apache.display_ops.zope.component.getUtility") @mock.patch("certbot_apache.display_ops.zope.component.getUtility")
def test_successful_choice(self, mock_util): def test_successful_choice(self, mock_util):
mock_util().menu.return_value = (display_util.OK, 3) mock_util().menu.return_value = (display_util.OK, 3)
self.assertEqual(self.vhosts[3], self._call(self.vhosts)) self.assertEqual(self.vhosts[3], self._call(self.vhosts))
@mock.patch("letsencrypt_apache.display_ops.zope.component.getUtility") @mock.patch("certbot_apache.display_ops.zope.component.getUtility")
def test_noninteractive(self, mock_util): def test_noninteractive(self, mock_util):
mock_util().menu.side_effect = errors.MissingCommandlineFlag("no vhost default") mock_util().menu.side_effect = errors.MissingCommandlineFlag("no vhost default")
try: try:
@@ -40,7 +40,7 @@ class SelectVhostTest(unittest.TestCase):
except errors.MissingCommandlineFlag as e: except errors.MissingCommandlineFlag as e:
self.assertTrue("VirtualHost directives" in e.message) self.assertTrue("VirtualHost directives" in e.message)
@mock.patch("letsencrypt_apache.display_ops.zope.component.getUtility") @mock.patch("certbot_apache.display_ops.zope.component.getUtility")
def test_more_info_cancel(self, mock_util): def test_more_info_cancel(self, mock_util):
mock_util().menu.side_effect = [ mock_util().menu.side_effect = [
(display_util.HELP, 1), (display_util.HELP, 1),
@@ -54,9 +54,9 @@ class SelectVhostTest(unittest.TestCase):
def test_no_vhosts(self): def test_no_vhosts(self):
self.assertEqual(self._call([]), None) self.assertEqual(self._call([]), None)
@mock.patch("letsencrypt_apache.display_ops.display_util") @mock.patch("certbot_apache.display_ops.display_util")
@mock.patch("letsencrypt_apache.display_ops.zope.component.getUtility") @mock.patch("certbot_apache.display_ops.zope.component.getUtility")
@mock.patch("letsencrypt_apache.display_ops.logger") @mock.patch("certbot_apache.display_ops.logger")
def test_small_display(self, mock_logger, mock_util, mock_display_util): def test_small_display(self, mock_logger, mock_util, mock_display_util):
mock_display_util.WIDTH = 20 mock_display_util.WIDTH = 20
mock_util().menu.return_value = (display_util.OK, 0) mock_util().menu.return_value = (display_util.OK, 0)
@@ -64,7 +64,7 @@ class SelectVhostTest(unittest.TestCase):
self.assertEqual(mock_logger.debug.call_count, 1) self.assertEqual(mock_logger.debug.call_count, 1)
@mock.patch("letsencrypt_apache.display_ops.zope.component.getUtility") @mock.patch("certbot_apache.display_ops.zope.component.getUtility")
def test_multiple_names(self, mock_util): def test_multiple_names(self, mock_util):
mock_util().menu.return_value = (display_util.OK, 5) mock_util().menu.return_value = (display_util.OK, 5)
@@ -1,4 +1,4 @@
"""Tests for letsencrypt_apache.obj.""" """Tests for certbot_apache.obj."""
import unittest import unittest
@@ -6,8 +6,8 @@ class VirtualHostTest(unittest.TestCase):
"""Test the VirtualHost class.""" """Test the VirtualHost class."""
def setUp(self): def setUp(self):
from letsencrypt_apache.obj import Addr from certbot_apache.obj import Addr
from letsencrypt_apache.obj import VirtualHost from certbot_apache.obj import VirtualHost
self.addr1 = Addr.fromstring("127.0.0.1") self.addr1 = Addr.fromstring("127.0.0.1")
self.addr2 = Addr.fromstring("127.0.0.1:443") self.addr2 = Addr.fromstring("127.0.0.1:443")
@@ -33,8 +33,8 @@ class VirtualHostTest(unittest.TestCase):
self.assertFalse(self.vhost1 != self.vhost1b) self.assertFalse(self.vhost1 != self.vhost1b)
def test_conflicts(self): def test_conflicts(self):
from letsencrypt_apache.obj import Addr from certbot_apache.obj import Addr
from letsencrypt_apache.obj import VirtualHost from certbot_apache.obj import VirtualHost
complex_vh = VirtualHost( complex_vh = VirtualHost(
"fp", "vhp", "fp", "vhp",
@@ -51,7 +51,7 @@ class VirtualHostTest(unittest.TestCase):
self.addr_default])) self.addr_default]))
def test_same_server(self): def test_same_server(self):
from letsencrypt_apache.obj import VirtualHost from certbot_apache.obj import VirtualHost
no_name1 = VirtualHost( no_name1 = VirtualHost(
"fp", "vhp", set([self.addr1]), False, False, None) "fp", "vhp", set([self.addr1]), False, False, None)
no_name2 = VirtualHost( no_name2 = VirtualHost(
@@ -74,7 +74,7 @@ class VirtualHostTest(unittest.TestCase):
class AddrTest(unittest.TestCase): class AddrTest(unittest.TestCase):
"""Test obj.Addr.""" """Test obj.Addr."""
def setUp(self): def setUp(self):
from letsencrypt_apache.obj import Addr from certbot_apache.obj import Addr
self.addr = Addr.fromstring("*:443") self.addr = Addr.fromstring("*:443")
self.addr1 = Addr.fromstring("127.0.0.1") self.addr1 = Addr.fromstring("127.0.0.1")
@@ -89,7 +89,7 @@ class AddrTest(unittest.TestCase):
self.assertTrue(self.addr2.is_wildcard()) self.assertTrue(self.addr2.is_wildcard())
def test_get_sni_addr(self): def test_get_sni_addr(self):
from letsencrypt_apache.obj import Addr from certbot_apache.obj import Addr
self.assertEqual( self.assertEqual(
self.addr.get_sni_addr("443"), Addr.fromstring("*:443")) self.addr.get_sni_addr("443"), Addr.fromstring("*:443"))
self.assertEqual( self.assertEqual(
@@ -1,4 +1,4 @@
"""Tests for letsencrypt_apache.parser.""" """Tests for certbot_apache.parser."""
import os import os
import shutil import shutil
import unittest import unittest
@@ -6,9 +6,9 @@ import unittest
import augeas import augeas
import mock import mock
from letsencrypt import errors from certbot import errors
from letsencrypt_apache.tests import util from certbot_apache.tests import util
class BasicParserTest(util.ParserTest): class BasicParserTest(util.ParserTest):
@@ -31,12 +31,12 @@ class BasicParserTest(util.ParserTest):
def test_parse_file(self): def test_parse_file(self):
"""Test parse_file. """Test parse_file.
letsencrypt.conf is chosen as the test file as it will not be certbot.conf is chosen as the test file as it will not be
included during the normal course of execution. included during the normal course of execution.
""" """
file_path = os.path.join( file_path = os.path.join(
self.config_path, "not-parsed-by-default", "letsencrypt.conf") self.config_path, "not-parsed-by-default", "certbot.conf")
self.parser._parse_file(file_path) # pylint: disable=protected-access self.parser._parse_file(file_path) # pylint: disable=protected-access
@@ -72,7 +72,7 @@ class BasicParserTest(util.ParserTest):
Path must be valid before attempting to add to augeas Path must be valid before attempting to add to augeas
""" """
from letsencrypt_apache.parser import get_aug_path from certbot_apache.parser import get_aug_path
# This makes sure that find_dir will work # This makes sure that find_dir will work
self.parser.modules.add("mod_ssl.c") self.parser.modules.add("mod_ssl.c")
@@ -86,7 +86,7 @@ class BasicParserTest(util.ParserTest):
self.assertTrue("IfModule" in matches[0]) self.assertTrue("IfModule" in matches[0])
def test_add_dir_to_ifmodssl_multiple(self): def test_add_dir_to_ifmodssl_multiple(self):
from letsencrypt_apache.parser import get_aug_path from certbot_apache.parser import get_aug_path
# This makes sure that find_dir will work # This makes sure that find_dir will work
self.parser.modules.add("mod_ssl.c") self.parser.modules.add("mod_ssl.c")
@@ -100,11 +100,11 @@ class BasicParserTest(util.ParserTest):
self.assertTrue("IfModule" in matches[0]) self.assertTrue("IfModule" in matches[0])
def test_get_aug_path(self): def test_get_aug_path(self):
from letsencrypt_apache.parser import get_aug_path from certbot_apache.parser import get_aug_path
self.assertEqual("/files/etc/apache", get_aug_path("/etc/apache")) self.assertEqual("/files/etc/apache", get_aug_path("/etc/apache"))
def test_set_locations(self): def test_set_locations(self):
with mock.patch("letsencrypt_apache.parser.os.path") as mock_path: with mock.patch("certbot_apache.parser.os.path") as mock_path:
mock_path.isfile.side_effect = [False, False] mock_path.isfile.side_effect = [False, False]
@@ -114,7 +114,7 @@ class BasicParserTest(util.ParserTest):
self.assertEqual(results["default"], results["listen"]) self.assertEqual(results["default"], results["listen"])
self.assertEqual(results["default"], results["name"]) self.assertEqual(results["default"], results["name"])
@mock.patch("letsencrypt_apache.parser.ApacheParser._get_runtime_cfg") @mock.patch("certbot_apache.parser.ApacheParser._get_runtime_cfg")
def test_update_runtime_variables(self, mock_cfg): def test_update_runtime_variables(self, mock_cfg):
mock_cfg.return_value = ( mock_cfg.return_value = (
'ServerRoot: "/etc/apache2"\n' 'ServerRoot: "/etc/apache2"\n'
@@ -139,7 +139,7 @@ class BasicParserTest(util.ParserTest):
self.parser.update_runtime_variables() self.parser.update_runtime_variables()
self.assertEqual(self.parser.variables, expected_vars) self.assertEqual(self.parser.variables, expected_vars)
@mock.patch("letsencrypt_apache.parser.ApacheParser._get_runtime_cfg") @mock.patch("certbot_apache.parser.ApacheParser._get_runtime_cfg")
def test_update_runtime_vars_bad_output(self, mock_cfg): def test_update_runtime_vars_bad_output(self, mock_cfg):
mock_cfg.return_value = "Define: TLS=443=24" mock_cfg.return_value = "Define: TLS=443=24"
self.parser.update_runtime_variables() self.parser.update_runtime_variables()
@@ -148,8 +148,8 @@ class BasicParserTest(util.ParserTest):
self.assertRaises( self.assertRaises(
errors.PluginError, self.parser.update_runtime_variables) errors.PluginError, self.parser.update_runtime_variables)
@mock.patch("letsencrypt_apache.constants.os_constant") @mock.patch("certbot_apache.constants.os_constant")
@mock.patch("letsencrypt_apache.parser.subprocess.Popen") @mock.patch("certbot_apache.parser.subprocess.Popen")
def test_update_runtime_vars_bad_ctl(self, mock_popen, mock_const): def test_update_runtime_vars_bad_ctl(self, mock_popen, mock_const):
mock_popen.side_effect = OSError mock_popen.side_effect = OSError
mock_const.return_value = "nonexistent" mock_const.return_value = "nonexistent"
@@ -157,7 +157,7 @@ class BasicParserTest(util.ParserTest):
errors.MisconfigurationError, errors.MisconfigurationError,
self.parser.update_runtime_variables) self.parser.update_runtime_variables)
@mock.patch("letsencrypt_apache.parser.subprocess.Popen") @mock.patch("certbot_apache.parser.subprocess.Popen")
def test_update_runtime_vars_bad_exit(self, mock_popen): def test_update_runtime_vars_bad_exit(self, mock_popen):
mock_popen().communicate.return_value = ("", "") mock_popen().communicate.return_value = ("", "")
mock_popen.returncode = -1 mock_popen.returncode = -1
@@ -177,9 +177,9 @@ class ParserInitTest(util.ApacheTest):
shutil.rmtree(self.config_dir) shutil.rmtree(self.config_dir)
shutil.rmtree(self.work_dir) shutil.rmtree(self.work_dir)
@mock.patch("letsencrypt_apache.parser.ApacheParser._get_runtime_cfg") @mock.patch("certbot_apache.parser.ApacheParser._get_runtime_cfg")
def test_unparsable(self, mock_cfg): def test_unparsable(self, mock_cfg):
from letsencrypt_apache.parser import ApacheParser from certbot_apache.parser import ApacheParser
mock_cfg.return_value = ('Define: TEST') mock_cfg.return_value = ('Define: TEST')
self.assertRaises( self.assertRaises(
errors.PluginError, errors.PluginError,
@@ -187,9 +187,9 @@ class ParserInitTest(util.ApacheTest):
"/dummy/vhostpath", version=(2, 2, 22)) "/dummy/vhostpath", version=(2, 2, 22))
def test_root_normalized(self): def test_root_normalized(self):
from letsencrypt_apache.parser import ApacheParser from certbot_apache.parser import ApacheParser
with mock.patch("letsencrypt_apache.parser.ApacheParser." with mock.patch("certbot_apache.parser.ApacheParser."
"update_runtime_variables"): "update_runtime_variables"):
path = os.path.join( path = os.path.join(
self.temp_dir, self.temp_dir,
@@ -201,8 +201,8 @@ class ParserInitTest(util.ApacheTest):
self.assertEqual(parser.root, self.config_path) self.assertEqual(parser.root, self.config_path)
def test_root_absolute(self): def test_root_absolute(self):
from letsencrypt_apache.parser import ApacheParser from certbot_apache.parser import ApacheParser
with mock.patch("letsencrypt_apache.parser.ApacheParser." with mock.patch("certbot_apache.parser.ApacheParser."
"update_runtime_variables"): "update_runtime_variables"):
parser = ApacheParser( parser = ApacheParser(
self.aug, os.path.relpath(self.config_path), self.aug, os.path.relpath(self.config_path),
@@ -211,8 +211,8 @@ class ParserInitTest(util.ApacheTest):
self.assertEqual(parser.root, self.config_path) self.assertEqual(parser.root, self.config_path)
def test_root_no_trailing_slash(self): def test_root_no_trailing_slash(self):
from letsencrypt_apache.parser import ApacheParser from certbot_apache.parser import ApacheParser
with mock.patch("letsencrypt_apache.parser.ApacheParser." with mock.patch("certbot_apache.parser.ApacheParser."
"update_runtime_variables"): "update_runtime_variables"):
parser = ApacheParser( parser = ApacheParser(
self.aug, self.config_path + os.path.sep, self.aug, self.config_path + os.path.sep,
@@ -16,8 +16,8 @@
# /usr/share/doc/apache2/README.Debian.gz for more info. # /usr/share/doc/apache2/README.Debian.gz for more info.
# If both key and certificate are stored in the same file, only the # If both key and certificate are stored in the same file, only the
# SSLCertificateFile directive is needed. # SSLCertificateFile directive is needed.
SSLCertificateFile /etc/apache2/certs/letsencrypt-cert_5.pem SSLCertificateFile /etc/apache2/certs/certbot-cert_5.pem
SSLCertificateKeyFile /etc/apache2/ssl/key-letsencrypt_15.pem SSLCertificateKeyFile /etc/apache2/ssl/key-certbot_15.pem
<FilesMatch "\.(cgi|shtml|phtml|php)$"> <FilesMatch "\.(cgi|shtml|phtml|php)$">
SSLOptions +StdEnvVars SSLOptions +StdEnvVars
@@ -1,8 +1,8 @@
<VirtualHost *:80> <VirtualHost *:80>
ServerName letsencrypt.demo ServerName certbot.demo
ServerAdmin webmaster@localhost ServerAdmin webmaster@localhost
DocumentRoot /var/www-letsencrypt-reworld/static/ DocumentRoot /var/www-certbot-reworld/static/
<Directory /> <Directory />
Options FollowSymLinks Options FollowSymLinks
AllowOverride None AllowOverride None
@@ -12,8 +12,8 @@
# /usr/share/doc/apache2/README.Debian.gz for more info. # /usr/share/doc/apache2/README.Debian.gz for more info.
# If both key and certificate are stored in the same file, only the # If both key and certificate are stored in the same file, only the
# SSLCertificateFile directive is needed. # SSLCertificateFile directive is needed.
SSLCertificateFile /etc/apache2/certs/letsencrypt-cert_5.pem SSLCertificateFile /etc/apache2/certs/certbot-cert_5.pem
SSLCertificateKeyFile /etc/apache2/ssl/key-letsencrypt_15.pem SSLCertificateKeyFile /etc/apache2/ssl/key-certbot_15.pem
#SSLOptions +FakeBasicAuth +ExportCertData +StrictRequire #SSLOptions +FakeBasicAuth +ExportCertData +StrictRequire
@@ -16,8 +16,8 @@
# /usr/share/doc/apache2/README.Debian.gz for more info. # /usr/share/doc/apache2/README.Debian.gz for more info.
# If both key and certificate are stored in the same file, only the # If both key and certificate are stored in the same file, only the
# SSLCertificateFile directive is needed. # SSLCertificateFile directive is needed.
SSLCertificateFile /etc/apache2/certs/letsencrypt-cert_5.pem SSLCertificateFile /etc/apache2/certs/certbot-cert_5.pem
SSLCertificateKeyFile /etc/apache2/ssl/key-letsencrypt_15.pem SSLCertificateKeyFile /etc/apache2/ssl/key-certbot_15.pem
#SSLOptions +FakeBasicAuth +ExportCertData +StrictRequire #SSLOptions +FakeBasicAuth +ExportCertData +StrictRequire

Some files were not shown because too many files have changed in this diff Show More