s/letsencrypt/certbot letsencrypt-nginx tests

This commit is contained in:
Brad Warren
2016-04-13 16:45:54 -07:00
parent e3aba30ec4
commit a43fac3277
68 changed files with 158 additions and 158 deletions
+5
View File
@@ -0,0 +1,5 @@
include LICENSE.txt
include README.rst
recursive-include docs *
recursive-include certbot_nginx/tests/testdata *
include certbot_nginx/options-ssl-nginx.conf
@@ -13,19 +13,19 @@ import zope.interface
from acme import challenges from acme import challenges
from acme import crypto_util as acme_crypto_util from acme import crypto_util as acme_crypto_util
from letsencrypt import constants as core_constants from certbot import constants as core_constants
from letsencrypt import crypto_util from certbot import crypto_util
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 import reverter from certbot import reverter
from letsencrypt.plugins import common from certbot.plugins import common
from letsencrypt_nginx import constants from certbot_nginx import constants
from letsencrypt_nginx import tls_sni_01 from certbot_nginx import tls_sni_01
from letsencrypt_nginx import obj from certbot_nginx import obj
from letsencrypt_nginx import parser from certbot_nginx import parser
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@@ -41,15 +41,15 @@ class NginxConfigurator(common.Plugin):
config files modified by the configurator will lose all their comments. config files modified by the configurator will lose all their comments.
: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_nginx.parser` :type parser: :class:`~certbot_nginx.parser`
:ivar str save_notes: Human-readable config change notes :ivar str save_notes: Human-readable config 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`
:ivar tup version: version of Nginx :ivar tup version: version of Nginx
@@ -216,7 +216,7 @@ class NginxConfigurator(common.Plugin):
:param str target_name: domain name :param str target_name: domain name
:returns: ssl vhost associated with name :returns: ssl vhost associated with name
:rtype: :class:`~letsencrypt_nginx.obj.VirtualHost` :rtype: :class:`~certbot_nginx.obj.VirtualHost`
""" """
vhost = None vhost = None
@@ -333,7 +333,7 @@ class NginxConfigurator(common.Plugin):
the existing one? the existing one?
:param vhost: The vhost to add SSL to. :param vhost: The vhost to add SSL to.
:type vhost: :class:`~letsencrypt_nginx.obj.VirtualHost` :type vhost: :class:`~certbot_nginx.obj.VirtualHost`
""" """
snakeoil_cert, snakeoil_key = self._get_snakeoil_paths() snakeoil_cert, snakeoil_key = self._get_snakeoil_paths()
@@ -372,9 +372,9 @@ class NginxConfigurator(common.Plugin):
: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.
""" """
@@ -395,7 +395,7 @@ class NginxConfigurator(common.Plugin):
.. note:: This function saves the configuration .. note:: This function saves the configuration
:param vhost: Destination of traffic, an ssl enabled vhost :param vhost: Destination of traffic, an ssl enabled vhost
:type vhost: :class:`~letsencrypt_nginx.obj.VirtualHost` :type vhost: :class:`~certbot_nginx.obj.VirtualHost`
:param unused_options: Not currently used :param unused_options: Not currently used
:type unused_options: Not Available :type unused_options: Not Available
@@ -13,6 +13,6 @@ MOD_SSL_CONF_DEST = "options-ssl-nginx.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`."""
MOD_SSL_CONF_SRC = pkg_resources.resource_filename( MOD_SSL_CONF_SRC = pkg_resources.resource_filename(
"letsencrypt_nginx", "options-ssl-nginx.conf") "certbot_nginx", "options-ssl-nginx.conf")
"""Path to the nginx mod_ssl config file found in the Let's Encrypt """Path to the nginx mod_ssl config file found in the Let's Encrypt
distribution.""" distribution."""
@@ -1,7 +1,7 @@
"""Module contains classes used by the Nginx Configurator.""" """Module contains classes used by the Nginx Configurator."""
import re import re
from letsencrypt.plugins import common from certbot.plugins import common
class Addr(common.Addr): class Addr(common.Addr):
@@ -5,10 +5,10 @@ import os
import pyparsing import pyparsing
import re import re
from letsencrypt import errors from certbot import errors
from letsencrypt_nginx import obj from certbot_nginx import obj
from letsencrypt_nginx import nginxparser from certbot_nginx import nginxparser
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@@ -87,7 +87,7 @@ class NginxParser(object):
Technically this is a misnomer because Nginx does not have virtual Technically this is a misnomer because Nginx does not have virtual
hosts, it has 'server blocks'. hosts, it has 'server blocks'.
:returns: List of :class:`~letsencrypt_nginx.obj.VirtualHost` :returns: List of :class:`~certbot_nginx.obj.VirtualHost`
objects found in configuration objects found in configuration
:rtype: list :rtype: list
@@ -1,5 +1,5 @@
# pylint: disable=too-many-public-methods # pylint: disable=too-many-public-methods
"""Test for letsencrypt_nginx.configurator.""" """Test for certbot_nginx.configurator."""
import os import os
import shutil import shutil
import unittest import unittest
@@ -10,10 +10,10 @@ import OpenSSL
from acme import challenges from acme import challenges
from acme import messages from acme import messages
from letsencrypt import achallenges from certbot import achallenges
from letsencrypt import errors from certbot import errors
from letsencrypt_nginx.tests import util from certbot_nginx.tests import util
class NginxConfiguratorTest(util.NginxTest): class NginxConfiguratorTest(util.NginxTest):
@@ -30,7 +30,7 @@ class NginxConfiguratorTest(util.NginxTest):
shutil.rmtree(self.config_dir) shutil.rmtree(self.config_dir)
shutil.rmtree(self.work_dir) shutil.rmtree(self.work_dir)
@mock.patch("letsencrypt_nginx.configurator.le_util.exe_exists") @mock.patch("certbot_nginx.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(
@@ -40,8 +40,8 @@ class NginxConfiguratorTest(util.NginxTest):
self.assertEquals((1, 6, 2), self.config.version) self.assertEquals((1, 6, 2), self.config.version)
self.assertEquals(5, len(self.config.parser.parsed)) self.assertEquals(5, len(self.config.parser.parsed))
@mock.patch("letsencrypt_nginx.configurator.le_util.exe_exists") @mock.patch("certbot_nginx.configurator.le_util.exe_exists")
@mock.patch("letsencrypt_nginx.configurator.subprocess.Popen") @mock.patch("certbot_nginx.configurator.subprocess.Popen")
def test_prepare_initializes_version(self, mock_popen, mock_exe_exists): def test_prepare_initializes_version(self, mock_popen, mock_exe_exists):
mock_popen().communicate.return_value = ( mock_popen().communicate.return_value = (
"", "\n".join(["nginx version: nginx/1.6.2", "", "\n".join(["nginx version: nginx/1.6.2",
@@ -58,7 +58,7 @@ class NginxConfiguratorTest(util.NginxTest):
self.config.prepare() self.config.prepare()
self.assertEquals((1, 6, 2), self.config.version) self.assertEquals((1, 6, 2), self.config.version)
@mock.patch("letsencrypt_nginx.configurator.socket.gethostbyaddr") @mock.patch("certbot_nginx.configurator.socket.gethostbyaddr")
def test_get_all_names(self, mock_gethostbyaddr): def test_get_all_names(self, mock_gethostbyaddr):
mock_gethostbyaddr.return_value = ('155.225.50.69.nephoscale.net', [], []) mock_gethostbyaddr.return_value = ('155.225.50.69.nephoscale.net', [], [])
names = self.config.get_all_names() names = self.config.get_all_names()
@@ -263,8 +263,8 @@ class NginxConfiguratorTest(util.NginxTest):
('/etc/nginx/fullchain.pem', '/etc/nginx/key.pem', nginx_conf), ('/etc/nginx/fullchain.pem', '/etc/nginx/key.pem', nginx_conf),
]), self.config.get_all_certs_keys()) ]), self.config.get_all_certs_keys())
@mock.patch("letsencrypt_nginx.configurator.tls_sni_01.NginxTlsSni01.perform") @mock.patch("certbot_nginx.configurator.tls_sni_01.NginxTlsSni01.perform")
@mock.patch("letsencrypt_nginx.configurator.NginxConfigurator.restart") @mock.patch("certbot_nginx.configurator.NginxConfigurator.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
@@ -293,7 +293,7 @@ class NginxConfiguratorTest(util.NginxTest):
self.assertEqual(responses, expected) self.assertEqual(responses, expected)
self.assertEqual(mock_restart.call_count, 1) self.assertEqual(mock_restart.call_count, 1)
@mock.patch("letsencrypt_nginx.configurator.subprocess.Popen") @mock.patch("certbot_nginx.configurator.subprocess.Popen")
def test_get_version(self, mock_popen): def test_get_version(self, mock_popen):
mock_popen().communicate.return_value = ( mock_popen().communicate.return_value = (
"", "\n".join(["nginx version: nginx/1.4.2", "", "\n".join(["nginx version: nginx/1.4.2",
@@ -343,55 +343,55 @@ class NginxConfiguratorTest(util.NginxTest):
mock_popen.side_effect = OSError("Can't find program") mock_popen.side_effect = OSError("Can't find program")
self.assertRaises(errors.PluginError, self.config.get_version) self.assertRaises(errors.PluginError, self.config.get_version)
@mock.patch("letsencrypt_nginx.configurator.subprocess.Popen") @mock.patch("certbot_nginx.configurator.subprocess.Popen")
def test_nginx_restart(self, mock_popen): def test_nginx_restart(self, mock_popen):
mocked = mock_popen() mocked = mock_popen()
mocked.communicate.return_value = ('', '') mocked.communicate.return_value = ('', '')
mocked.returncode = 0 mocked.returncode = 0
self.config.restart() self.config.restart()
@mock.patch("letsencrypt_nginx.configurator.subprocess.Popen") @mock.patch("certbot_nginx.configurator.subprocess.Popen")
def test_nginx_restart_fail(self, mock_popen): def test_nginx_restart_fail(self, mock_popen):
mocked = mock_popen() mocked = mock_popen()
mocked.communicate.return_value = ('', '') mocked.communicate.return_value = ('', '')
mocked.returncode = 1 mocked.returncode = 1
self.assertRaises(errors.MisconfigurationError, self.config.restart) self.assertRaises(errors.MisconfigurationError, self.config.restart)
@mock.patch("letsencrypt_nginx.configurator.subprocess.Popen") @mock.patch("certbot_nginx.configurator.subprocess.Popen")
def test_no_nginx_start(self, mock_popen): def test_no_nginx_start(self, mock_popen):
mock_popen.side_effect = OSError("Can't find program") mock_popen.side_effect = OSError("Can't find program")
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
self.assertRaises(errors.MisconfigurationError, self.config.config_test) self.assertRaises(errors.MisconfigurationError, self.config.config_test)
@mock.patch("letsencrypt.reverter.Reverter.recovery_routine") @mock.patch("certbot.reverter.Reverter.recovery_routine")
def test_recovery_routine_throws_error_from_reverter(self, mock_recovery_routine): def test_recovery_routine_throws_error_from_reverter(self, mock_recovery_routine):
mock_recovery_routine.side_effect = errors.ReverterError("foo") mock_recovery_routine.side_effect = errors.ReverterError("foo")
self.assertRaises(errors.PluginError, self.config.recovery_routine) self.assertRaises(errors.PluginError, self.config.recovery_routine)
@mock.patch("letsencrypt.reverter.Reverter.view_config_changes") @mock.patch("certbot.reverter.Reverter.view_config_changes")
def test_view_config_changes_throws_error_from_reverter(self, mock_view_config_changes): def test_view_config_changes_throws_error_from_reverter(self, mock_view_config_changes):
mock_view_config_changes.side_effect = errors.ReverterError("foo") mock_view_config_changes.side_effect = errors.ReverterError("foo")
self.assertRaises(errors.PluginError, self.config.view_config_changes) self.assertRaises(errors.PluginError, self.config.view_config_changes)
@mock.patch("letsencrypt.reverter.Reverter.rollback_checkpoints") @mock.patch("certbot.reverter.Reverter.rollback_checkpoints")
def test_rollback_checkpoints_throws_error_from_reverter(self, mock_rollback_checkpoints): def test_rollback_checkpoints_throws_error_from_reverter(self, mock_rollback_checkpoints):
mock_rollback_checkpoints.side_effect = errors.ReverterError("foo") mock_rollback_checkpoints.side_effect = errors.ReverterError("foo")
self.assertRaises(errors.PluginError, self.config.rollback_checkpoints) self.assertRaises(errors.PluginError, self.config.rollback_checkpoints)
@mock.patch("letsencrypt.reverter.Reverter.revert_temporary_config") @mock.patch("certbot.reverter.Reverter.revert_temporary_config")
def test_revert_challenge_config_throws_error_from_reverter(self, mock_revert_temporary_config): def test_revert_challenge_config_throws_error_from_reverter(self, mock_revert_temporary_config):
mock_revert_temporary_config.side_effect = errors.ReverterError("foo") mock_revert_temporary_config.side_effect = errors.ReverterError("foo")
self.assertRaises(errors.PluginError, self.config.revert_challenge_config) self.assertRaises(errors.PluginError, self.config.revert_challenge_config)
@mock.patch("letsencrypt.reverter.Reverter.add_to_checkpoint") @mock.patch("certbot.reverter.Reverter.add_to_checkpoint")
def test_save_throws_error_from_reverter(self, mock_add_to_checkpoint): def test_save_throws_error_from_reverter(self, mock_add_to_checkpoint):
mock_add_to_checkpoint.side_effect = errors.ReverterError("foo") mock_add_to_checkpoint.side_effect = errors.ReverterError("foo")
self.assertRaises(errors.PluginError, self.config.save) self.assertRaises(errors.PluginError, self.config.save)
@@ -1,12 +1,12 @@
"""Test for letsencrypt_nginx.nginxparser.""" """Test for certbot_nginx.nginxparser."""
import operator import operator
import unittest import unittest
from pyparsing import ParseException from pyparsing import ParseException
from letsencrypt_nginx.nginxparser import ( from certbot_nginx.nginxparser import (
RawNginxParser, loads, load, dumps, dump) RawNginxParser, loads, load, dumps, dump)
from letsencrypt_nginx.tests import util from certbot_nginx.tests import util
FIRST = operator.itemgetter(0) FIRST = operator.itemgetter(0)
@@ -1,11 +1,11 @@
"""Test the helper objects in letsencrypt_nginx.obj.""" """Test the helper objects in certbot_nginx.obj."""
import unittest import unittest
class AddrTest(unittest.TestCase): class AddrTest(unittest.TestCase):
"""Test the Addr class.""" """Test the Addr class."""
def setUp(self): def setUp(self):
from letsencrypt_nginx.obj import Addr from certbot_nginx.obj import Addr
self.addr1 = Addr.fromstring("192.168.1.1") self.addr1 = Addr.fromstring("192.168.1.1")
self.addr2 = Addr.fromstring("192.168.1.1:* ssl") self.addr2 = Addr.fromstring("192.168.1.1:* ssl")
self.addr3 = Addr.fromstring("192.168.1.1:80") self.addr3 = Addr.fromstring("192.168.1.1:80")
@@ -56,14 +56,14 @@ class AddrTest(unittest.TestCase):
self.assertEqual(str(self.addr6), "80 default_server") self.assertEqual(str(self.addr6), "80 default_server")
def test_eq(self): def test_eq(self):
from letsencrypt_nginx.obj import Addr from certbot_nginx.obj import Addr
new_addr1 = Addr.fromstring("192.168.1.1 spdy") new_addr1 = Addr.fromstring("192.168.1.1 spdy")
self.assertEqual(self.addr1, new_addr1) self.assertEqual(self.addr1, new_addr1)
self.assertNotEqual(self.addr1, self.addr2) self.assertNotEqual(self.addr1, self.addr2)
self.assertFalse(self.addr1 == 3333) self.assertFalse(self.addr1 == 3333)
def test_set_inclusion(self): def test_set_inclusion(self):
from letsencrypt_nginx.obj import Addr from certbot_nginx.obj import Addr
set_a = set([self.addr1, self.addr2]) set_a = set([self.addr1, self.addr2])
addr1b = Addr.fromstring("192.168.1.1") addr1b = Addr.fromstring("192.168.1.1")
addr2b = Addr.fromstring("192.168.1.1:* ssl") addr2b = Addr.fromstring("192.168.1.1:* ssl")
@@ -75,16 +75,16 @@ class AddrTest(unittest.TestCase):
class VirtualHostTest(unittest.TestCase): class VirtualHostTest(unittest.TestCase):
"""Test the VirtualHost class.""" """Test the VirtualHost class."""
def setUp(self): def setUp(self):
from letsencrypt_nginx.obj import VirtualHost from certbot_nginx.obj import VirtualHost
from letsencrypt_nginx.obj import Addr from certbot_nginx.obj import Addr
self.vhost1 = VirtualHost( self.vhost1 = VirtualHost(
"filep", "filep",
set([Addr.fromstring("localhost")]), False, False, set([Addr.fromstring("localhost")]), False, False,
set(['localhost']), []) set(['localhost']), [])
def test_eq(self): def test_eq(self):
from letsencrypt_nginx.obj import Addr from certbot_nginx.obj import Addr
from letsencrypt_nginx.obj import VirtualHost from certbot_nginx.obj import VirtualHost
vhost1b = VirtualHost( vhost1b = VirtualHost(
"filep", "filep",
set([Addr.fromstring("localhost blah")]), False, False, set([Addr.fromstring("localhost blah")]), False, False,
@@ -1,16 +1,16 @@
"""Tests for letsencrypt_nginx.parser.""" """Tests for certbot_nginx.parser."""
import glob import glob
import os import os
import re import re
import shutil import shutil
import unittest import unittest
from letsencrypt import errors from certbot import errors
from letsencrypt_nginx import nginxparser from certbot_nginx import nginxparser
from letsencrypt_nginx import obj from certbot_nginx import obj
from letsencrypt_nginx import parser from certbot_nginx import parser
from letsencrypt_nginx.tests import util from certbot_nginx.tests import util
class NginxParserTest(util.NginxTest): class NginxParserTest(util.NginxTest):
@@ -1,4 +1,4 @@
"""Tests for letsencrypt_nginx.tls_sni_01""" """Tests for certbot_nginx.tls_sni_01"""
import unittest import unittest
import shutil import shutil
@@ -6,14 +6,14 @@ 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.plugins import common_test from certbot.plugins import common_test
from letsencrypt.tests import acme_util from certbot.tests import acme_util
from letsencrypt_nginx import obj from certbot_nginx import obj
from letsencrypt_nginx.tests import util from certbot_nginx.tests import util
class TlsSniPerformTest(util.NginxTest): class TlsSniPerformTest(util.NginxTest):
@@ -47,7 +47,7 @@ class TlsSniPerformTest(util.NginxTest):
config = util.get_nginx_configurator( config = util.get_nginx_configurator(
self.config_path, self.config_dir, self.work_dir) self.config_path, self.config_dir, self.work_dir)
from letsencrypt_nginx import tls_sni_01 from certbot_nginx import tls_sni_01
self.sni = tls_sni_01.NginxTlsSni01(config) self.sni = tls_sni_01.NginxTlsSni01(config)
def tearDown(self): def tearDown(self):
@@ -55,7 +55,7 @@ class TlsSniPerformTest(util.NginxTest):
shutil.rmtree(self.config_dir) shutil.rmtree(self.config_dir)
shutil.rmtree(self.work_dir) shutil.rmtree(self.work_dir)
@mock.patch("letsencrypt_nginx.configurator" @mock.patch("certbot_nginx.configurator"
".NginxConfigurator.choose_vhost") ".NginxConfigurator.choose_vhost")
def test_perform(self, mock_choose): def test_perform(self, mock_choose):
self.sni.add_chall(self.achalls[1]) self.sni.add_chall(self.achalls[1])
@@ -67,7 +67,7 @@ class TlsSniPerformTest(util.NginxTest):
responses = self.sni.perform() responses = self.sni.perform()
self.assertEqual([], responses) self.assertEqual([], responses)
@mock.patch("letsencrypt_nginx.configurator.NginxConfigurator.save") @mock.patch("certbot_nginx.configurator.NginxConfigurator.save")
def test_perform1(self, mock_save): def test_perform1(self, mock_save):
self.sni.add_chall(self.achalls[0]) self.sni.add_chall(self.achalls[0])
response = self.achalls[0].response(self.account_key) response = self.achalls[0].response(self.account_key)
@@ -1,4 +1,4 @@
"""Common utilities for letsencrypt_nginx.""" """Common utilities for certbot_nginx."""
import os import os
import pkg_resources import pkg_resources
import unittest import unittest
@@ -8,14 +8,14 @@ import zope.component
from acme import jose from acme import jose
from letsencrypt import configuration from certbot import configuration
from letsencrypt.tests import test_util from certbot.tests import test_util
from letsencrypt.plugins import common from certbot.plugins import common
from letsencrypt_nginx import constants from certbot_nginx import constants
from letsencrypt_nginx import configurator from certbot_nginx import configurator
class NginxTest(unittest.TestCase): # pylint: disable=too-few-public-methods class NginxTest(unittest.TestCase): # pylint: disable=too-few-public-methods
@@ -24,7 +24,7 @@ class NginxTest(unittest.TestCase): # pylint: disable=too-few-public-methods
super(NginxTest, self).setUp() super(NginxTest, self).setUp()
self.temp_dir, self.config_dir, self.work_dir = common.dir_setup( self.temp_dir, self.config_dir, self.work_dir = common.dir_setup(
"etc_nginx", "letsencrypt_nginx.tests") "etc_nginx", "certbot_nginx.tests")
self.ssl_options = common.setup_ssl_options( self.ssl_options = common.setup_ssl_options(
self.config_dir, constants.MOD_SSL_CONF_SRC, self.config_dir, constants.MOD_SSL_CONF_SRC,
@@ -39,7 +39,7 @@ class NginxTest(unittest.TestCase): # pylint: disable=too-few-public-methods
def get_data_filename(filename): def get_data_filename(filename):
"""Gets the filename of a test data file.""" """Gets the filename of a test data file."""
return pkg_resources.resource_filename( return pkg_resources.resource_filename(
"letsencrypt_nginx.tests", os.path.join( "certbot_nginx.tests", os.path.join(
"testdata", "etc_nginx", filename)) "testdata", "etc_nginx", filename))
@@ -49,9 +49,9 @@ def get_nginx_configurator(
backups = os.path.join(work_dir, "backups") backups = os.path.join(work_dir, "backups")
with mock.patch("letsencrypt_nginx.configurator.NginxConfigurator." with mock.patch("certbot_nginx.configurator.NginxConfigurator."
"config_test"): "config_test"):
with mock.patch("letsencrypt_nginx.configurator.le_util." with mock.patch("certbot_nginx.configurator.le_util."
"exe_exists") as mock_exe_exists: "exe_exists") as mock_exe_exists:
mock_exe_exists.return_value = True mock_exe_exists.return_value = True
config = configurator.NginxConfigurator( config = configurator.NginxConfigurator(
@@ -4,11 +4,11 @@ import itertools
import logging import logging
import os import os
from letsencrypt import errors from certbot import errors
from letsencrypt.plugins import common from certbot.plugins import common
from letsencrypt_nginx import obj from certbot_nginx import obj
from letsencrypt_nginx import nginxparser from certbot_nginx import nginxparser
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@@ -21,7 +21,7 @@ class NginxTlsSni01(common.TLSSNI01):
:type configurator: :class:`~nginx.configurator.NginxConfigurator` :type configurator: :class:`~nginx.configurator.NginxConfigurator`
:ivar list achalls: Annotated :ivar list achalls: Annotated
class:`~letsencrypt.achallenges.KeyAuthorizationAnnotatedChallenge` class:`~certbot.achallenges.KeyAuthorizationAnnotatedChallenge`
challenges challenges
:param list indices: Meant to hold indices of challenges in a :param list indices: Meant to hold indices of challenges in a
@@ -39,7 +39,7 @@ class NginxTlsSni01(common.TLSSNI01):
def perform(self): def perform(self):
"""Perform a challenge on Nginx. """Perform a challenge on Nginx.
:returns: list of :class:`letsencrypt.acme.challenges.TLSSNI01Response` :returns: list of :class:`certbot.acme.challenges.TLSSNI01Response`
:rtype: list :rtype: list
""" """
@@ -83,7 +83,7 @@ class NginxTlsSni01(common.TLSSNI01):
"""Modifies Nginx config to include challenge server blocks. """Modifies Nginx config to include challenge server blocks.
:param list ll_addrs: list of lists of :param list ll_addrs: list of lists of
:class:`letsencrypt_nginx.obj.Addr` to apply :class:`certbot_nginx.obj.Addr` to apply
:raises .MisconfigurationError: :raises .MisconfigurationError:
Unable to find a suitable HTTP block in which to include Unable to find a suitable HTTP block in which to include
@@ -130,7 +130,7 @@ class NginxTlsSni01(common.TLSSNI01):
:param achall: Annotated TLS-SNI-01 challenge :param achall: Annotated TLS-SNI-01 challenge
:type achall: :type achall:
:class:`letsencrypt.achallenges.KeyAuthorizationAnnotatedChallenge` :class:`certbot.achallenges.KeyAuthorizationAnnotatedChallenge`
:param list addrs: addresses of challenged domain :param list addrs: addresses of challenged domain
:class:`list` of type :class:`~nginx.obj.Addr` :class:`list` of type :class:`~nginx.obj.Addr`
@@ -87,9 +87,9 @@ qthelp:
@echo @echo
@echo "Build finished; now you can run "qcollectiongenerator" with the" \ @echo "Build finished; now you can run "qcollectiongenerator" with the" \
".qhcp project file in $(BUILDDIR)/qthelp, like this:" ".qhcp project file in $(BUILDDIR)/qthelp, like this:"
@echo "# qcollectiongenerator $(BUILDDIR)/qthelp/letsencrypt-nginx.qhcp" @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/certbot-nginx.qhcp"
@echo "To view the help file:" @echo "To view the help file:"
@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/letsencrypt-nginx.qhc" @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/certbot-nginx.qhc"
applehelp: applehelp:
$(SPHINXBUILD) -b applehelp $(ALLSPHINXOPTS) $(BUILDDIR)/applehelp $(SPHINXBUILD) -b applehelp $(ALLSPHINXOPTS) $(BUILDDIR)/applehelp
@@ -104,8 +104,8 @@ devhelp:
@echo @echo
@echo "Build finished." @echo "Build finished."
@echo "To view the help file:" @echo "To view the help file:"
@echo "# mkdir -p $$HOME/.local/share/devhelp/letsencrypt-nginx" @echo "# mkdir -p $$HOME/.local/share/devhelp/certbot-nginx"
@echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/letsencrypt-nginx" @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/certbot-nginx"
@echo "# devhelp" @echo "# devhelp"
epub: epub:
+5
View File
@@ -0,0 +1,5 @@
:mod:`certbot_nginx.nginxparser`
------------------------------------
.. automodule:: certbot_nginx.nginxparser
:members:
+5
View File
@@ -0,0 +1,5 @@
:mod:`certbot_nginx.obj`
----------------------------
.. automodule:: certbot_nginx.obj
:members:
+5
View File
@@ -0,0 +1,5 @@
:mod:`certbot_nginx.parser`
-------------------------------
.. automodule:: certbot_nginx.parser
:members:
+5
View File
@@ -0,0 +1,5 @@
:mod:`certbot_nginx.tls_sni_01`
-----------------------------------
.. automodule:: certbot_nginx.tls_sni_01
:members:
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# #
# letsencrypt-nginx documentation build configuration file, created by # certbot-nginx documentation build configuration file, created by
# sphinx-quickstart on Sun Oct 18 13:39:39 2015. # sphinx-quickstart on Sun Oct 18 13:39:39 2015.
# #
# This file is execfile()d with the current directory set to its # This file is execfile()d with the current directory set to its
@@ -58,7 +58,7 @@ source_suffix = '.rst'
master_doc = 'index' master_doc = 'index'
# General information about the project. # General information about the project.
project = u'letsencrypt-nginx' project = u'certbot-nginx'
copyright = u'2014-2015, Let\'s Encrypt Project' copyright = u'2014-2015, Let\'s Encrypt Project'
author = u'Let\'s Encrypt Project' author = u'Let\'s Encrypt Project'
@@ -220,7 +220,7 @@ html_static_path = ['_static']
#html_search_scorer = 'scorer.js' #html_search_scorer = 'scorer.js'
# Output file base name for HTML help builder. # Output file base name for HTML help builder.
htmlhelp_basename = 'letsencrypt-nginxdoc' htmlhelp_basename = 'certbot-nginxdoc'
# -- Options for LaTeX output --------------------------------------------- # -- Options for LaTeX output ---------------------------------------------
@@ -242,7 +242,7 @@ latex_elements = {
# (source start file, target name, title, # (source start file, target name, title,
# author, documentclass [howto, manual, or own class]). # author, documentclass [howto, manual, or own class]).
latex_documents = [ latex_documents = [
(master_doc, 'letsencrypt-nginx.tex', u'letsencrypt-nginx Documentation', (master_doc, 'certbot-nginx.tex', u'certbot-nginx Documentation',
u'Let\'s Encrypt Project', 'manual'), u'Let\'s Encrypt Project', 'manual'),
] ]
@@ -272,7 +272,7 @@ latex_documents = [
# One entry per manual page. List of tuples # One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section). # (source start file, name, description, authors, manual section).
man_pages = [ man_pages = [
(master_doc, 'letsencrypt-nginx', u'letsencrypt-nginx Documentation', (master_doc, 'certbot-nginx', u'certbot-nginx Documentation',
[author], 1) [author], 1)
] ]
@@ -286,8 +286,8 @@ man_pages = [
# (source start file, target name, title, author, # (source start file, target name, title, author,
# dir menu entry, description, category) # dir menu entry, description, category)
texinfo_documents = [ texinfo_documents = [
(master_doc, 'letsencrypt-nginx', u'letsencrypt-nginx Documentation', (master_doc, 'certbot-nginx', u'certbot-nginx Documentation',
author, 'letsencrypt-nginx', 'One line description of project.', author, 'certbot-nginx', 'One line description of project.',
'Miscellaneous'), 'Miscellaneous'),
] ]
@@ -307,5 +307,5 @@ texinfo_documents = [
intersphinx_mapping = { intersphinx_mapping = {
'python': ('https://docs.python.org/', None), 'python': ('https://docs.python.org/', None),
'acme': ('https://acme-python.readthedocs.org/en/latest/', None), 'acme': ('https://acme-python.readthedocs.org/en/latest/', None),
'letsencrypt': ('https://letsencrypt.readthedocs.org/en/latest/', None), 'certbot': ('https://letsencrypt.readthedocs.org/en/latest/', None),
} }
@@ -1,9 +1,9 @@
.. letsencrypt-nginx documentation master file, created by .. certbot-nginx documentation master file, created by
sphinx-quickstart on Sun Oct 18 13:39:39 2015. sphinx-quickstart on Sun Oct 18 13:39:39 2015.
You can adapt this file completely to your liking, but it should at least You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive. contain the root `toctree` directive.
Welcome to letsencrypt-nginx's documentation! Welcome to certbot-nginx's documentation!
============================================= =============================================
Contents: Contents:
@@ -18,7 +18,7 @@ Contents:
api api
.. automodule:: letsencrypt_nginx .. automodule:: certbot_nginx
:members: :members:
@@ -127,9 +127,9 @@ if "%1" == "qthelp" (
echo. echo.
echo.Build finished; now you can run "qcollectiongenerator" with the ^ echo.Build finished; now you can run "qcollectiongenerator" with the ^
.qhcp project file in %BUILDDIR%/qthelp, like this: .qhcp project file in %BUILDDIR%/qthelp, like this:
echo.^> qcollectiongenerator %BUILDDIR%\qthelp\letsencrypt-nginx.qhcp echo.^> qcollectiongenerator %BUILDDIR%\qthelp\certbot-nginx.qhcp
echo.To view the help file: echo.To view the help file:
echo.^> assistant -collectionFile %BUILDDIR%\qthelp\letsencrypt-nginx.ghc echo.^> assistant -collectionFile %BUILDDIR%\qthelp\certbot-nginx.ghc
goto end goto end
) )
@@ -9,4 +9,4 @@
-e acme -e acme
-e . -e .
-e letsencrypt-nginx[docs] -e certbot-nginx[docs]
@@ -9,7 +9,7 @@ version = '0.6.0.dev0'
# Please update tox.ini when modifying dependency version requirements # Please update tox.ini when modifying dependency version requirements
install_requires = [ install_requires = [
'acme=={0}'.format(version), 'acme=={0}'.format(version),
'letsencrypt=={0}'.format(version), 'certbot=={0}'.format(version),
'PyOpenSSL', 'PyOpenSSL',
'pyparsing>=1.5.5', # Python3 support; perhaps unnecessary? 'pyparsing>=1.5.5', # Python3 support; perhaps unnecessary?
# For pkg_resources. >=1.0 so pip resolves it to a version cryptography # For pkg_resources. >=1.0 so pip resolves it to a version cryptography
@@ -29,7 +29,7 @@ docs_extras = [
] ]
setup( setup(
name='letsencrypt-nginx', name='certbot-nginx',
version=version, version=version,
description="Nginx plugin for Let's Encrypt client", description="Nginx plugin for Let's Encrypt client",
url='https://github.com/letsencrypt/letsencrypt', url='https://github.com/letsencrypt/letsencrypt',
@@ -61,9 +61,9 @@ setup(
'docs': docs_extras, 'docs': docs_extras,
}, },
entry_points={ entry_points={
'letsencrypt.plugins': [ 'certbot.plugins': [
'nginx = letsencrypt_nginx.configurator:NginxConfigurator', 'nginx = certbot_nginx.configurator:NginxConfigurator',
], ],
}, },
test_suite='letsencrypt_nginx', test_suite='certbot_nginx',
) )
@@ -6,19 +6,19 @@
export PATH="/usr/sbin:$PATH" # /usr/sbin/nginx export PATH="/usr/sbin:$PATH" # /usr/sbin/nginx
nginx_root="$root/nginx" nginx_root="$root/nginx"
mkdir $nginx_root mkdir $nginx_root
root="$nginx_root" ./letsencrypt-nginx/tests/boulder-integration.conf.sh > $nginx_root/nginx.conf root="$nginx_root" ./certbot-nginx/tests/boulder-integration.conf.sh > $nginx_root/nginx.conf
killall nginx || true killall nginx || true
nginx -c $nginx_root/nginx.conf nginx -c $nginx_root/nginx.conf
letsencrypt_test_nginx () { certbot_test_nginx () {
letsencrypt_test \ certbot_test \
--configurator nginx \ --configurator nginx \
--nginx-server-root $nginx_root \ --nginx-server-root $nginx_root \
"$@" "$@"
} }
letsencrypt_test_nginx --domains nginx.wtf run certbot_test_nginx --domains nginx.wtf run
echo | openssl s_client -connect localhost:5001 \ echo | openssl s_client -connect localhost:5001 \
| openssl x509 -out $root/nginx.pem | openssl x509 -out $root/nginx.pem
diff -q $root/nginx.pem $root/conf/live/nginx.wtf/cert.pem diff -q $root/nginx.pem $root/conf/live/nginx.wtf/cert.pem
-5
View File
@@ -1,5 +0,0 @@
include LICENSE.txt
include README.rst
recursive-include docs *
recursive-include letsencrypt_nginx/tests/testdata *
include letsencrypt_nginx/options-ssl-nginx.conf
@@ -1,5 +0,0 @@
:mod:`letsencrypt_nginx.nginxparser`
------------------------------------
.. automodule:: letsencrypt_nginx.nginxparser
:members:
-5
View File
@@ -1,5 +0,0 @@
:mod:`letsencrypt_nginx.obj`
----------------------------
.. automodule:: letsencrypt_nginx.obj
:members:
-5
View File
@@ -1,5 +0,0 @@
:mod:`letsencrypt_nginx.parser`
-------------------------------
.. automodule:: letsencrypt_nginx.parser
:members:
@@ -1,5 +0,0 @@
:mod:`letsencrypt_nginx.tls_sni_01`
-----------------------------------
.. automodule:: letsencrypt_nginx.tls_sni_01
:members:
+2 -2
View File
@@ -1,8 +1,8 @@
"""Manual test of display functions.""" """Manual test of display functions."""
import sys import sys
from letsencrypt.display import util from certbot.display import util
from letsencrypt.tests.display import util_test from certbot.tests.display import util_test
def test_visual(displayer, choices): def test_visual(displayer, choices):
+4 -4
View File
@@ -11,14 +11,14 @@ store_flags="--config-dir $root/conf --work-dir $root/work"
store_flags="$store_flags --logs-dir $root/logs" store_flags="$store_flags --logs-dir $root/logs"
export root store_flags export root store_flags
letsencrypt_test () { certbot_test () {
letsencrypt_test_no_force_renew \ certbot_test_no_force_renew \
--renew-by-default \ --renew-by-default \
"$@" "$@"
} }
letsencrypt_test_no_force_renew () { certbot_test_no_force_renew () {
letsencrypt \ certbot \
--server "${SERVER:-http://localhost:4000/directory}" \ --server "${SERVER:-http://localhost:4000/directory}" \
--no-verify-ssl \ --no-verify-ssl \
--tls-sni-01-port 5001 \ --tls-sni-01-port 5001 \
+3 -3
View File
@@ -11,9 +11,9 @@ export LETSENCRYPT_PATH=`pwd`
cd $GOPATH/src/github.com/letsencrypt/boulder/ cd $GOPATH/src/github.com/letsencrypt/boulder/
# boulder's integration-test.py has code that knows to start and wait for the # boulder's integration-test.py has code that knows to start and wait for the
# boulder processes to start reliably and then will run the letsencrypt # boulder processes to start reliably and then will run the certbot
# boulder-interation.sh on its own. The --letsencrypt flag says to run only the # boulder-interation.sh on its own. The --letsencrypt flag says to run only the
# letsencrypt tests (instead of any other client tests it might run). We're # certbot tests (instead of any other client tests it might run). We're
# going to want to define a more robust interaction point between the boulder # going to want to define a more robust interaction point between the boulder
# and letsencrypt tests, but that will be better built off of this. # and certbot tests, but that will be better built off of this.
python test/integration-test.py --letsencrypt python test/integration-test.py --letsencrypt
+6 -6
View File
@@ -19,8 +19,8 @@ commands =
nosetests -v certbot nosetests -v certbot
pip install -e certbot-apache pip install -e certbot-apache
nosetests -v certbot_apache nosetests -v certbot_apache
pip install -e letsencrypt-nginx pip install -e certbot-nginx
nosetests -v letsencrypt_nginx nosetests -v certbot_nginx
pip install -e letshelp-letsencrypt pip install -e letshelp-letsencrypt
nosetests -v letshelp_letsencrypt nosetests -v letshelp_letsencrypt
@@ -54,7 +54,7 @@ commands =
[testenv:cover] [testenv:cover]
basepython = python2.7 basepython = python2.7
commands = commands =
pip install -e acme[dev] -e .[dev] -e certbot-apache -e letsencrypt-nginx -e letshelp-letsencrypt pip install -e acme[dev] -e .[dev] -e certbot-apache -e certbot-nginx -e letshelp-letsencrypt
./tox.cover.sh ./tox.cover.sh
[testenv:lint] [testenv:lint]
@@ -64,19 +64,19 @@ basepython = python2.7
# duplicate code checking; if one of the commands fails, others will # duplicate code checking; if one of the commands fails, others will
# continue, but tox return code will reflect previous error # continue, but tox return code will reflect previous error
commands = commands =
pip install -e acme[dev] -e .[dev] -e certbot-apache -e letsencrypt-nginx -e letsencrypt-compatibility-test -e letshelp-letsencrypt pip install -e acme[dev] -e .[dev] -e certbot-apache -e certbot-nginx -e letsencrypt-compatibility-test -e letshelp-letsencrypt
./pep8.travis.sh ./pep8.travis.sh
pylint --rcfile=.pylintrc certbot pylint --rcfile=.pylintrc certbot
pylint --rcfile=acme/.pylintrc acme/acme pylint --rcfile=acme/.pylintrc acme/acme
pylint --rcfile=.pylintrc certbot-apache/certbot_apache pylint --rcfile=.pylintrc certbot-apache/certbot_apache
pylint --rcfile=.pylintrc letsencrypt-nginx/letsencrypt_nginx pylint --rcfile=.pylintrc certbot-nginx/certbot_nginx
pylint --rcfile=.pylintrc letsencrypt-compatibility-test/letsencrypt_compatibility_test pylint --rcfile=.pylintrc letsencrypt-compatibility-test/letsencrypt_compatibility_test
pylint --rcfile=.pylintrc letshelp-letsencrypt/letshelp_letsencrypt pylint --rcfile=.pylintrc letshelp-letsencrypt/letshelp_letsencrypt
[testenv:apacheconftest] [testenv:apacheconftest]
#basepython = python2.7 #basepython = python2.7
commands = commands =
pip install -e acme -e .[dev] -e certbot-apache -e letsencrypt-nginx -e letsencrypt-compatibility-test -e letshelp-letsencrypt pip install -e acme -e .[dev] -e certbot-apache -e certbot-nginx -e letsencrypt-compatibility-test -e letshelp-letsencrypt
{toxinidir}/certbot-apache/certbot_apache/tests/apache-conf-files/apache-conf-test --debian-modules {toxinidir}/certbot-apache/certbot_apache/tests/apache-conf-files/apache-conf-test --debian-modules