mirror of
https://github.com/certbot/certbot.git
synced 2026-07-30 16:14:44 +02:00
Move plugins to top-level
This commit is contained in:
+4
-4
@@ -9,8 +9,8 @@ recursive-include letsencrypt/client/tests/testdata *
|
|||||||
recursive-include acme/schemata *.json
|
recursive-include acme/schemata *.json
|
||||||
recursive-include acme/jose/testdata *
|
recursive-include acme/jose/testdata *
|
||||||
|
|
||||||
recursive-include letsencrypt/client/plugins/apache/tests/testdata *
|
recursive-include letsencrypt_apache/tests/testdata *
|
||||||
include letsencrypt/client/plugins/apache/options-ssl.conf
|
include letsencrypt_apache/options-ssl.conf
|
||||||
|
|
||||||
recursive-include letsencrypt/client/plugins/nginx/tests/testdata *
|
recursive-include letsencrypt_nginx/tests/testdata *
|
||||||
include letsencrypt/client/plugins/nginx/options-ssl.conf
|
include letsencrypt_nginx/options-ssl.conf
|
||||||
|
|||||||
@@ -1,29 +0,0 @@
|
|||||||
:mod:`letsencrypt.client.plugins.apache`
|
|
||||||
----------------------------------------
|
|
||||||
|
|
||||||
.. automodule:: letsencrypt.client.plugins.apache
|
|
||||||
:members:
|
|
||||||
|
|
||||||
:mod:`letsencrypt.client.plugins.apache.configurator`
|
|
||||||
=====================================================
|
|
||||||
|
|
||||||
.. automodule:: letsencrypt.client.plugins.apache.configurator
|
|
||||||
:members:
|
|
||||||
|
|
||||||
:mod:`letsencrypt.client.plugins.apache.dvsni`
|
|
||||||
==============================================
|
|
||||||
|
|
||||||
.. automodule:: letsencrypt.client.plugins.apache.dvsni
|
|
||||||
:members:
|
|
||||||
|
|
||||||
:mod:`letsencrypt.client.plugins.apache.obj`
|
|
||||||
============================================
|
|
||||||
|
|
||||||
.. automodule:: letsencrypt.client.plugins.apache.obj
|
|
||||||
:members:
|
|
||||||
|
|
||||||
:mod:`letsencrypt.client.plugins.apache.parser`
|
|
||||||
===============================================
|
|
||||||
|
|
||||||
.. automodule:: letsencrypt.client.plugins.apache.parser
|
|
||||||
:members:
|
|
||||||
@@ -1,35 +0,0 @@
|
|||||||
:mod:`letsencrypt.client.plugins.nginx`
|
|
||||||
----------------------------------------
|
|
||||||
|
|
||||||
.. automodule:: letsencrypt.client.plugins.nginx
|
|
||||||
:members:
|
|
||||||
|
|
||||||
:mod:`letsencrypt.client.plugins.nginx.configurator`
|
|
||||||
=====================================================
|
|
||||||
|
|
||||||
.. automodule:: letsencrypt.client.plugins.nginx.configurator
|
|
||||||
:members:
|
|
||||||
|
|
||||||
:mod:`letsencrypt.client.plugins.nginx.dvsni`
|
|
||||||
==============================================
|
|
||||||
|
|
||||||
.. automodule:: letsencrypt.client.plugins.nginx.dvsni
|
|
||||||
:members:
|
|
||||||
|
|
||||||
:mod:`letsencrypt.client.plugins.nginx.obj`
|
|
||||||
============================================
|
|
||||||
|
|
||||||
.. automodule:: letsencrypt.client.plugins.nginx.obj
|
|
||||||
:members:
|
|
||||||
|
|
||||||
:mod:`letsencrypt.client.plugins.nginx.parser`
|
|
||||||
===============================================
|
|
||||||
|
|
||||||
.. automodule:: letsencrypt.client.plugins.nginx.parser
|
|
||||||
:members:
|
|
||||||
|
|
||||||
:mod:`letsencrypt.client.plugins.nginx.nginxparser`
|
|
||||||
====================================================
|
|
||||||
|
|
||||||
.. automodule:: letsencrypt.client.plugins.nginx.nginxparser
|
|
||||||
:members:
|
|
||||||
@@ -9,6 +9,8 @@ Welcome to the Let's Encrypt client documentation!
|
|||||||
contributing
|
contributing
|
||||||
plugins
|
plugins
|
||||||
acme
|
acme
|
||||||
|
letsencrypt_apache
|
||||||
|
letsencrypt_nginx
|
||||||
|
|
||||||
.. toctree::
|
.. toctree::
|
||||||
:maxdepth: 1
|
:maxdepth: 1
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
:mod:`letsencrypt_apache`
|
||||||
|
-------------------------
|
||||||
|
|
||||||
|
.. automodule:: letsencrypt_apache
|
||||||
|
:members:
|
||||||
|
|
||||||
|
:mod:`letsencrypt_apache.configurator`
|
||||||
|
======================================
|
||||||
|
|
||||||
|
.. automodule:: letsencrypt_apache.configurator
|
||||||
|
:members:
|
||||||
|
|
||||||
|
:mod:`letsencrypt_apache.dvsni`
|
||||||
|
===============================
|
||||||
|
|
||||||
|
.. automodule:: letsencrypt_apache.dvsni
|
||||||
|
:members:
|
||||||
|
|
||||||
|
:mod:`letsencrypt_apache.obj`
|
||||||
|
=============================
|
||||||
|
|
||||||
|
.. automodule:: letsencrypt_apache.obj
|
||||||
|
:members:
|
||||||
|
|
||||||
|
:mod:`letsencrypt_apache.parser`
|
||||||
|
================================
|
||||||
|
|
||||||
|
.. automodule:: letsencrypt_apache.parser
|
||||||
|
:members:
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
:mod:`letsencrypt_nginx`
|
||||||
|
------------------------
|
||||||
|
|
||||||
|
.. automodule:: letsencrypt_nginx
|
||||||
|
:members:
|
||||||
|
|
||||||
|
:mod:`letsencrypt_nginx.configurator`
|
||||||
|
=====================================
|
||||||
|
|
||||||
|
.. automodule:: letsencrypt_nginx.configurator
|
||||||
|
:members:
|
||||||
|
|
||||||
|
:mod:`letsencrypt_nginx.dvsni`
|
||||||
|
==============================
|
||||||
|
|
||||||
|
.. automodule:: letsencrypt_nginx.dvsni
|
||||||
|
:members:
|
||||||
|
|
||||||
|
:mod:`letsencrypt_nginx.obj`
|
||||||
|
============================
|
||||||
|
|
||||||
|
.. automodule:: letsencrypt_nginx.obj
|
||||||
|
:members:
|
||||||
|
|
||||||
|
:mod:`letsencrypt_nginx.parser`
|
||||||
|
===============================
|
||||||
|
|
||||||
|
.. automodule:: letsencrypt_nginx.parser
|
||||||
|
:members:
|
||||||
|
|
||||||
|
:mod:`letsencrypt_nginx.nginxparser`
|
||||||
|
====================================
|
||||||
|
|
||||||
|
.. automodule:: letsencrypt_nginx.nginxparser
|
||||||
|
:members:
|
||||||
@@ -1 +0,0 @@
|
|||||||
"""Let's Encrypt client.plugins.apache."""
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
"""Let's Encrypt client.plugins.nginx."""
|
|
||||||
@@ -56,8 +56,7 @@ class DetermineAccountTest(unittest.TestCase):
|
|||||||
class RollbackTest(unittest.TestCase):
|
class RollbackTest(unittest.TestCase):
|
||||||
"""Test the rollback function."""
|
"""Test the rollback function."""
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
from letsencrypt.client.plugins.apache.configurator import (
|
from letsencrypt_apache.configurator import ApacheConfigurator
|
||||||
ApacheConfigurator)
|
|
||||||
self.m_install = mock.MagicMock(spec=ApacheConfigurator)
|
self.m_install = mock.MagicMock(spec=ApacheConfigurator)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
|||||||
@@ -10,9 +10,10 @@ import mock
|
|||||||
|
|
||||||
from letsencrypt.client import errors
|
from letsencrypt.client import errors
|
||||||
from letsencrypt.client import le_util
|
from letsencrypt.client import le_util
|
||||||
from letsencrypt.client.plugins.apache import configurator
|
|
||||||
from letsencrypt.client.display import util as display_util
|
from letsencrypt.client.display import util as display_util
|
||||||
|
|
||||||
|
from letsencrypt_apache import configurator
|
||||||
|
|
||||||
|
|
||||||
class RevokerBase(unittest.TestCase): # pylint: disable=too-few-public-methods
|
class RevokerBase(unittest.TestCase): # pylint: disable=too-few-public-methods
|
||||||
"""Base Class for Revoker Tests."""
|
"""Base Class for Revoker Tests."""
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
"""Let's Encrypt Apache plugin."""
|
||||||
+24
-34
@@ -18,10 +18,10 @@ from letsencrypt.client import errors
|
|||||||
from letsencrypt.client import interfaces
|
from letsencrypt.client import interfaces
|
||||||
from letsencrypt.client import le_util
|
from letsencrypt.client import le_util
|
||||||
|
|
||||||
from letsencrypt.client.plugins.apache import constants
|
from letsencrypt_apache import constants
|
||||||
from letsencrypt.client.plugins.apache import dvsni
|
from letsencrypt_apache import dvsni
|
||||||
from letsencrypt.client.plugins.apache import obj
|
from letsencrypt_apache import obj
|
||||||
from letsencrypt.client.plugins.apache import parser
|
from letsencrypt_apache import parser
|
||||||
|
|
||||||
|
|
||||||
# TODO: Augeas sections ie. <VirtualHost>, <IfModule> beginning and closing
|
# TODO: Augeas sections ie. <VirtualHost>, <IfModule> beginning and closing
|
||||||
@@ -69,12 +69,11 @@ class ApacheConfigurator(augeas_configurator.AugeasConfigurator):
|
|||||||
:type config: :class:`~letsencrypt.client.interfaces.IConfig`
|
:type config: :class:`~letsencrypt.client.interfaces.IConfig`
|
||||||
|
|
||||||
:ivar parser: Handles low level parsing
|
:ivar parser: Handles low level parsing
|
||||||
:type parser: :class:`~letsencrypt.client.plugins.apache.parser`
|
:type parser: :class:`~letsencrypt_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:`list` of :class:`~letsencrypt_apache.obj.VirtualHost`)
|
||||||
:class:`~letsencrypt.client.plugins.apache.obj.VirtualHost`)
|
|
||||||
|
|
||||||
:ivar dict assoc: Mapping between domains and vhosts
|
:ivar dict assoc: Mapping between domains and vhosts
|
||||||
|
|
||||||
@@ -222,7 +221,7 @@ class ApacheConfigurator(augeas_configurator.AugeasConfigurator):
|
|||||||
: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.client.plugins.apache.obj.VirtualHost`
|
:rtype: :class:`~letsencrypt_apache.obj.VirtualHost`
|
||||||
|
|
||||||
"""
|
"""
|
||||||
# Allows for domain names to be associated with a virtual host
|
# Allows for domain names to be associated with a virtual host
|
||||||
@@ -263,7 +262,7 @@ class ApacheConfigurator(augeas_configurator.AugeasConfigurator):
|
|||||||
:param str domain: domain name to associate
|
:param str domain: domain name to associate
|
||||||
|
|
||||||
:param vhost: virtual host to associate with domain
|
:param vhost: virtual host to associate with domain
|
||||||
:type vhost: :class:`~letsencrypt.client.plugins.apache.obj.VirtualHost`
|
:type vhost: :class:`~letsencrypt_apache.obj.VirtualHost`
|
||||||
|
|
||||||
"""
|
"""
|
||||||
self.assoc[domain] = vhost
|
self.assoc[domain] = vhost
|
||||||
@@ -300,7 +299,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.client.plugins.apache.obj.VirtualHost`
|
:type host: :class:`~letsencrypt_apache.obj.VirtualHost`
|
||||||
|
|
||||||
"""
|
"""
|
||||||
name_match = self.aug.match(("%s//*[self::directive=~regexp('%s')] | "
|
name_match = self.aug.match(("%s//*[self::directive=~regexp('%s')] | "
|
||||||
@@ -321,7 +320,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.client.plugins.apache.obj.VirtualHost`
|
:rtype: :class:`~letsencrypt_apache.obj.VirtualHost`
|
||||||
|
|
||||||
"""
|
"""
|
||||||
addrs = set()
|
addrs = set()
|
||||||
@@ -344,9 +343,8 @@ 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
|
:returns: List of :class:`~letsencrypt_apache.obj.VirtualHost`
|
||||||
:class:`~letsencrypt.client.plugins.apache.obj.VirtualHost` objects
|
objects found in configuration
|
||||||
found in configuration
|
|
||||||
:rtype: list
|
:rtype: list
|
||||||
|
|
||||||
"""
|
"""
|
||||||
@@ -423,7 +421,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 vhost: VirtualHost to check SNI compatibility
|
:param vhost: VirtualHost to check SNI compatibility
|
||||||
:type vhost: :class:`~letsencrypt.client.plugins.apache.obj.VirtualHost`
|
:type vhost: :class:`~letsencrypt_apache.obj.VirtualHost`
|
||||||
|
|
||||||
:param str default_addr: TODO - investigate function further
|
:param str default_addr: TODO - investigate function further
|
||||||
|
|
||||||
@@ -455,11 +453,10 @@ class ApacheConfigurator(augeas_configurator.AugeasConfigurator):
|
|||||||
.. 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:
|
:type nonssl_vhost: :class:`~letsencrypt_apache.obj.VirtualHost`
|
||||||
:class:`~letsencrypt.client.plugins.apache.obj.VirtualHost`
|
|
||||||
|
|
||||||
:returns: SSL vhost
|
:returns: SSL vhost
|
||||||
:rtype: :class:`~letsencrypt.client.plugins.apache.obj.VirtualHost`
|
:rtype: :class:`~letsencrypt_apache.obj.VirtualHost`
|
||||||
|
|
||||||
"""
|
"""
|
||||||
avail_fp = nonssl_vhost.filep
|
avail_fp = nonssl_vhost.filep
|
||||||
@@ -579,15 +576,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:
|
:type ssl_vhost: :class:`~letsencrypt_apache.obj.VirtualHost`
|
||||||
:class:`~letsencrypt.client.plugins.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,
|
:rtype: (bool, :class:`~letsencrypt_apache.obj.VirtualHost`)
|
||||||
:class:`~letsencrypt.client.plugins.apache.obj.VirtualHost`)
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
if not mod_loaded("rewrite_module", self.conf('ctl')):
|
if not mod_loaded("rewrite_module", self.conf('ctl')):
|
||||||
@@ -638,7 +633,7 @@ class ApacheConfigurator(augeas_configurator.AugeasConfigurator):
|
|||||||
-1 is also returned in case of no redirection/rewrite directives
|
-1 is also returned in case of no redirection/rewrite directives
|
||||||
|
|
||||||
:param vhost: vhost to check
|
:param vhost: vhost to check
|
||||||
:type vhost: :class:`~letsencrypt.client.plugins.apache.obj.VirtualHost`
|
:type vhost: :class:`~letsencrypt_apache.obj.VirtualHost`
|
||||||
|
|
||||||
:returns: Success, code value... see documentation
|
:returns: Success, code value... see documentation
|
||||||
:rtype: bool, int
|
:rtype: bool, int
|
||||||
@@ -670,12 +665,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:
|
:type ssl_vhost: :class:`~letsencrypt_apache.obj.VirtualHost`
|
||||||
:class:`~letsencrypt.client.plugins.apache.obj.VirtualHost`
|
|
||||||
|
|
||||||
:returns: tuple of the form
|
:returns: tuple of the form
|
||||||
(`success`,
|
(`success`, :class:`~letsencrypt_apache.obj.VirtualHost`)
|
||||||
:class:`~letsencrypt.client.plugins.apache.obj.VirtualHost`)
|
|
||||||
:rtype: tuple
|
:rtype: tuple
|
||||||
|
|
||||||
"""
|
"""
|
||||||
@@ -758,8 +751,7 @@ class ApacheConfigurator(augeas_configurator.AugeasConfigurator):
|
|||||||
if not conflict: returns space separated list of new host addrs
|
if not conflict: returns space separated list of new host addrs
|
||||||
|
|
||||||
:param ssl_vhost: SSL Vhost to check for possible port 80 redirection
|
:param ssl_vhost: SSL Vhost to check for possible port 80 redirection
|
||||||
:type ssl_vhost:
|
:type ssl_vhost: :class:`~letsencrypt_apache.obj.VirtualHost`
|
||||||
:class:`~letsencrypt.client.plugins.apache.obj.VirtualHost`
|
|
||||||
|
|
||||||
:returns: TODO
|
:returns: TODO
|
||||||
:rtype: TODO
|
:rtype: TODO
|
||||||
@@ -792,12 +784,10 @@ class ApacheConfigurator(augeas_configurator.AugeasConfigurator):
|
|||||||
Consider changing this into a dict check
|
Consider changing this into a dict check
|
||||||
|
|
||||||
:param ssl_vhost: ssl vhost to check
|
:param ssl_vhost: ssl vhost to check
|
||||||
:type ssl_vhost:
|
:type ssl_vhost: :class:`~letsencrypt_apache.obj.VirtualHost`
|
||||||
:class:`~letsencrypt.client.plugins.apache.obj.VirtualHost`
|
|
||||||
|
|
||||||
:returns: HTTP vhost or None if unsuccessful
|
:returns: HTTP vhost or None if unsuccessful
|
||||||
:rtype: :class:`~letsencrypt.client.plugins.apache.obj.VirtualHost`
|
:rtype: :class:`~letsencrypt_apache.obj.VirtualHost` or ``None``
|
||||||
or None
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
# _default_:443 check
|
# _default_:443 check
|
||||||
@@ -887,7 +877,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.client.plugins.apache.obj.VirtualHost`
|
:type vhost: :class:`~letsencrypt_apache.obj.VirtualHost`
|
||||||
|
|
||||||
:returns: Success
|
:returns: Success
|
||||||
:rtype: bool
|
:rtype: bool
|
||||||
@@ -13,7 +13,7 @@ CLI_DEFAULTS = dict(
|
|||||||
|
|
||||||
|
|
||||||
MOD_SSL_CONF = pkg_resources.resource_filename(
|
MOD_SSL_CONF = pkg_resources.resource_filename(
|
||||||
"letsencrypt.client.plugins.apache", "options-ssl.conf")
|
"letsencrypt_apache", "options-ssl.conf")
|
||||||
"""Path to the Apache mod_ssl config file found in the Let's Encrypt
|
"""Path to the Apache mod_ssl config file found in the Let's Encrypt
|
||||||
distribution."""
|
distribution."""
|
||||||
|
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from letsencrypt.client.plugins.apache import parser
|
from letsencrypt_apache import parser
|
||||||
|
|
||||||
|
|
||||||
class ApacheDvsni(object):
|
class ApacheDvsni(object):
|
||||||
+11
-14
@@ -1,4 +1,4 @@
|
|||||||
"""Test for letsencrypt.client.plugins.apache.configurator."""
|
"""Test for letsencrypt_apache.configurator."""
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import shutil
|
import shutil
|
||||||
@@ -12,14 +12,14 @@ from letsencrypt.client import achallenges
|
|||||||
from letsencrypt.client import errors
|
from letsencrypt.client import errors
|
||||||
from letsencrypt.client import le_util
|
from letsencrypt.client import le_util
|
||||||
|
|
||||||
from letsencrypt.client.plugins.apache import configurator
|
|
||||||
from letsencrypt.client.plugins.apache import obj
|
|
||||||
from letsencrypt.client.plugins.apache import parser
|
|
||||||
|
|
||||||
from letsencrypt.client.plugins.apache.tests import util
|
|
||||||
|
|
||||||
from letsencrypt.client.tests import acme_util
|
from letsencrypt.client.tests import acme_util
|
||||||
|
|
||||||
|
from letsencrypt_apache import configurator
|
||||||
|
from letsencrypt_apache import obj
|
||||||
|
from letsencrypt_apache import parser
|
||||||
|
|
||||||
|
from letsencrypt_apache.tests import util
|
||||||
|
|
||||||
|
|
||||||
class TwoVhost80Test(util.ApacheTest):
|
class TwoVhost80Test(util.ApacheTest):
|
||||||
"""Test two standard well configured HTTP vhosts."""
|
"""Test two standard well configured HTTP vhosts."""
|
||||||
@@ -27,7 +27,7 @@ class TwoVhost80Test(util.ApacheTest):
|
|||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TwoVhost80Test, self).setUp()
|
super(TwoVhost80Test, self).setUp()
|
||||||
|
|
||||||
with mock.patch("letsencrypt.client.plugins.apache.configurator."
|
with mock.patch("letsencrypt_apache.configurator."
|
||||||
"mod_loaded") as mock_load:
|
"mod_loaded") as mock_load:
|
||||||
mock_load.return_value = True
|
mock_load.return_value = True
|
||||||
self.config = util.get_apache_configurator(
|
self.config = util.get_apache_configurator(
|
||||||
@@ -150,10 +150,8 @@ class TwoVhost80Test(util.ApacheTest):
|
|||||||
|
|
||||||
self.assertEqual(len(self.config.vhosts), 5)
|
self.assertEqual(len(self.config.vhosts), 5)
|
||||||
|
|
||||||
@mock.patch("letsencrypt.client.plugins.apache.configurator."
|
@mock.patch("letsencrypt_apache.configurator.dvsni.ApacheDvsni.perform")
|
||||||
"dvsni.ApacheDvsni.perform")
|
@mock.patch("letsencrypt_apache.configurator.ApacheConfigurator.restart")
|
||||||
@mock.patch("letsencrypt.client.plugins.apache.configurator."
|
|
||||||
"ApacheConfigurator.restart")
|
|
||||||
def test_perform(self, mock_restart, mock_dvsni_perform):
|
def test_perform(self, mock_restart, mock_dvsni_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
|
||||||
@@ -186,8 +184,7 @@ class TwoVhost80Test(util.ApacheTest):
|
|||||||
|
|
||||||
self.assertEqual(mock_restart.call_count, 1)
|
self.assertEqual(mock_restart.call_count, 1)
|
||||||
|
|
||||||
@mock.patch("letsencrypt.client.plugins.apache.configurator."
|
@mock.patch("letsencrypt_apache.configurator.subprocess.Popen")
|
||||||
"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 = (
|
||||||
"Server Version: Apache/2.4.2 (Debian)", "")
|
"Server Version: Apache/2.4.2 (Debian)", "")
|
||||||
+9
-11
@@ -1,4 +1,4 @@
|
|||||||
"""Test for letsencrypt.client.plugins.apache.dvsni."""
|
"""Test for letsencrypt_apache.dvsni."""
|
||||||
import pkg_resources
|
import pkg_resources
|
||||||
import unittest
|
import unittest
|
||||||
import shutil
|
import shutil
|
||||||
@@ -10,12 +10,11 @@ from acme import challenges
|
|||||||
from letsencrypt.client import achallenges
|
from letsencrypt.client import achallenges
|
||||||
from letsencrypt.client import le_util
|
from letsencrypt.client import le_util
|
||||||
|
|
||||||
from letsencrypt.client.plugins.apache.obj import Addr
|
|
||||||
|
|
||||||
from letsencrypt.client.plugins.apache.tests import util
|
|
||||||
|
|
||||||
from letsencrypt.client.tests import acme_util
|
from letsencrypt.client.tests import acme_util
|
||||||
|
|
||||||
|
from letsencrypt_apache import obj
|
||||||
|
from letsencrypt_apache.tests import util
|
||||||
|
|
||||||
|
|
||||||
class DvsniPerformTest(util.ApacheTest):
|
class DvsniPerformTest(util.ApacheTest):
|
||||||
"""Test the ApacheDVSNI challenge."""
|
"""Test the ApacheDVSNI challenge."""
|
||||||
@@ -23,14 +22,14 @@ class DvsniPerformTest(util.ApacheTest):
|
|||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(DvsniPerformTest, self).setUp()
|
super(DvsniPerformTest, self).setUp()
|
||||||
|
|
||||||
with mock.patch("letsencrypt.client.plugins.apache.configurator."
|
with mock.patch("letsencrypt_apache.configurator."
|
||||||
"mod_loaded") as mock_load:
|
"mod_loaded") as mock_load:
|
||||||
mock_load.return_value = True
|
mock_load.return_value = True
|
||||||
config = util.get_apache_configurator(
|
config = util.get_apache_configurator(
|
||||||
self.config_path, self.config_dir, self.work_dir,
|
self.config_path, self.config_dir, self.work_dir,
|
||||||
self.ssl_options)
|
self.ssl_options)
|
||||||
|
|
||||||
from letsencrypt.client.plugins.apache import dvsni
|
from letsencrypt_apache import dvsni
|
||||||
self.sni = dvsni.ApacheDvsni(config)
|
self.sni = dvsni.ApacheDvsni(config)
|
||||||
|
|
||||||
rsa256_file = pkg_resources.resource_filename(
|
rsa256_file = pkg_resources.resource_filename(
|
||||||
@@ -80,8 +79,7 @@ class DvsniPerformTest(util.ApacheTest):
|
|||||||
nonce_domain=self.achalls[0].nonce_domain)
|
nonce_domain=self.achalls[0].nonce_domain)
|
||||||
achall.gen_cert_and_response.return_value = ("pem", response)
|
achall.gen_cert_and_response.return_value = ("pem", response)
|
||||||
|
|
||||||
with mock.patch("letsencrypt.client.plugins.apache.dvsni.open",
|
with mock.patch("letsencrypt_apache.dvsni.open", m_open, create=True):
|
||||||
m_open, create=True):
|
|
||||||
# pylint: disable=protected-access
|
# pylint: disable=protected-access
|
||||||
self.assertEqual(response, self.sni._setup_challenge_cert(
|
self.assertEqual(response, self.sni._setup_challenge_cert(
|
||||||
achall, "randomS1"))
|
achall, "randomS1"))
|
||||||
@@ -142,8 +140,8 @@ class DvsniPerformTest(util.ApacheTest):
|
|||||||
def test_mod_config(self):
|
def test_mod_config(self):
|
||||||
for achall in self.achalls:
|
for achall in self.achalls:
|
||||||
self.sni.add_chall(achall)
|
self.sni.add_chall(achall)
|
||||||
v_addr1 = [Addr(("1.2.3.4", "443")), Addr(("5.6.7.8", "443"))]
|
v_addr1 = [obj.Addr(("1.2.3.4", "443")), obj.Addr(("5.6.7.8", "443"))]
|
||||||
v_addr2 = [Addr(("127.0.0.1", "443"))]
|
v_addr2 = [obj.Addr(("127.0.0.1", "443"))]
|
||||||
ll_addr = []
|
ll_addr = []
|
||||||
ll_addr.append(v_addr1)
|
ll_addr.append(v_addr1)
|
||||||
ll_addr.append(v_addr2)
|
ll_addr.append(v_addr2)
|
||||||
+7
-7
@@ -1,11 +1,11 @@
|
|||||||
"""Test the helper objects in letsencrypt.client.plugins.apache.obj."""
|
"""Test the helper objects in letsencrypt_apache.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.client.plugins.apache.obj import Addr
|
from letsencrypt_apache.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:*")
|
self.addr2 = Addr.fromstring("192.168.1.1:*")
|
||||||
self.addr3 = Addr.fromstring("192.168.1.1:80")
|
self.addr3 = Addr.fromstring("192.168.1.1:80")
|
||||||
@@ -34,7 +34,7 @@ class AddrTest(unittest.TestCase):
|
|||||||
self.assertFalse(self.addr1 == 3333)
|
self.assertFalse(self.addr1 == 3333)
|
||||||
|
|
||||||
def test_set_inclusion(self):
|
def test_set_inclusion(self):
|
||||||
from letsencrypt.client.plugins.apache.obj import Addr
|
from letsencrypt_apache.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:*")
|
addr2b = Addr.fromstring("192.168.1.1:*")
|
||||||
@@ -46,15 +46,15 @@ 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.client.plugins.apache.obj import VirtualHost
|
from letsencrypt_apache.obj import VirtualHost
|
||||||
from letsencrypt.client.plugins.apache.obj import Addr
|
from letsencrypt_apache.obj import Addr
|
||||||
self.vhost1 = VirtualHost(
|
self.vhost1 = VirtualHost(
|
||||||
"filep", "vh_path",
|
"filep", "vh_path",
|
||||||
set([Addr.fromstring("localhost")]), False, False)
|
set([Addr.fromstring("localhost")]), False, False)
|
||||||
|
|
||||||
def test_eq(self):
|
def test_eq(self):
|
||||||
from letsencrypt.client.plugins.apache.obj import Addr
|
from letsencrypt_apache.obj import Addr
|
||||||
from letsencrypt.client.plugins.apache.obj import VirtualHost
|
from letsencrypt_apache.obj import VirtualHost
|
||||||
vhost1b = VirtualHost(
|
vhost1b = VirtualHost(
|
||||||
"filep", "vh_path",
|
"filep", "vh_path",
|
||||||
set([Addr.fromstring("localhost")]), False, False)
|
set([Addr.fromstring("localhost")]), False, False)
|
||||||
+10
-11
@@ -1,4 +1,4 @@
|
|||||||
"""Tests for letsencrypt.client.plugins.apache.parser."""
|
"""Tests for letsencrypt_apache.parser."""
|
||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
import sys
|
import sys
|
||||||
@@ -11,7 +11,7 @@ import zope.component
|
|||||||
from letsencrypt.client import errors
|
from letsencrypt.client import errors
|
||||||
from letsencrypt.client.display import util as display_util
|
from letsencrypt.client.display import util as display_util
|
||||||
|
|
||||||
from letsencrypt.client.plugins.apache.tests import util
|
from letsencrypt_apache.tests import util
|
||||||
|
|
||||||
|
|
||||||
class ApacheParserTest(util.ApacheTest):
|
class ApacheParserTest(util.ApacheTest):
|
||||||
@@ -22,7 +22,7 @@ class ApacheParserTest(util.ApacheTest):
|
|||||||
|
|
||||||
zope.component.provideUtility(display_util.FileDisplay(sys.stdout))
|
zope.component.provideUtility(display_util.FileDisplay(sys.stdout))
|
||||||
|
|
||||||
from letsencrypt.client.plugins.apache.parser import ApacheParser
|
from letsencrypt_apache.parser import ApacheParser
|
||||||
self.aug = augeas.Augeas(flags=augeas.Augeas.NONE)
|
self.aug = augeas.Augeas(flags=augeas.Augeas.NONE)
|
||||||
self.parser = ApacheParser(self.aug, self.config_path, self.ssl_options)
|
self.parser = ApacheParser(self.aug, self.config_path, self.ssl_options)
|
||||||
|
|
||||||
@@ -32,19 +32,19 @@ class ApacheParserTest(util.ApacheTest):
|
|||||||
shutil.rmtree(self.work_dir)
|
shutil.rmtree(self.work_dir)
|
||||||
|
|
||||||
def test_root_normalized(self):
|
def test_root_normalized(self):
|
||||||
from letsencrypt.client.plugins.apache.parser import ApacheParser
|
from letsencrypt_apache.parser import ApacheParser
|
||||||
path = os.path.join(self.temp_dir, "debian_apache_2_4/////"
|
path = os.path.join(self.temp_dir, "debian_apache_2_4/////"
|
||||||
"two_vhost_80/../two_vhost_80/apache2")
|
"two_vhost_80/../two_vhost_80/apache2")
|
||||||
parser = ApacheParser(self.aug, path, None)
|
parser = ApacheParser(self.aug, path, None)
|
||||||
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.client.plugins.apache.parser import ApacheParser
|
from letsencrypt_apache.parser import ApacheParser
|
||||||
parser = ApacheParser(self.aug, os.path.relpath(self.config_path), None)
|
parser = ApacheParser(self.aug, os.path.relpath(self.config_path), None)
|
||||||
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.client.plugins.apache.parser import ApacheParser
|
from letsencrypt_apache.parser import ApacheParser
|
||||||
parser = ApacheParser(self.aug, self.config_path + os.path.sep, None)
|
parser = ApacheParser(self.aug, self.config_path + os.path.sep, None)
|
||||||
self.assertEqual(parser.root, self.config_path)
|
self.assertEqual(parser.root, self.config_path)
|
||||||
|
|
||||||
@@ -67,7 +67,7 @@ class ApacheParserTest(util.ApacheTest):
|
|||||||
self.assertTrue(matches)
|
self.assertTrue(matches)
|
||||||
|
|
||||||
def test_find_dir(self):
|
def test_find_dir(self):
|
||||||
from letsencrypt.client.plugins.apache.parser import case_i
|
from letsencrypt_apache.parser import case_i
|
||||||
test = self.parser.find_dir(case_i("Listen"), "443")
|
test = self.parser.find_dir(case_i("Listen"), "443")
|
||||||
# This will only look in enabled hosts
|
# This will only look in enabled hosts
|
||||||
test2 = self.parser.find_dir(case_i("documentroot"))
|
test2 = self.parser.find_dir(case_i("documentroot"))
|
||||||
@@ -92,7 +92,7 @@ class ApacheParserTest(util.ApacheTest):
|
|||||||
Path must be valid before attempting to add to augeas
|
Path must be valid before attempting to add to augeas
|
||||||
|
|
||||||
"""
|
"""
|
||||||
from letsencrypt.client.plugins.apache.parser import get_aug_path
|
from letsencrypt_apache.parser import get_aug_path
|
||||||
self.parser.add_dir_to_ifmodssl(
|
self.parser.add_dir_to_ifmodssl(
|
||||||
get_aug_path(self.parser.loc["default"]),
|
get_aug_path(self.parser.loc["default"]),
|
||||||
"FakeDirective", "123")
|
"FakeDirective", "123")
|
||||||
@@ -103,12 +103,11 @@ class ApacheParserTest(util.ApacheTest):
|
|||||||
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.client.plugins.apache.parser import get_aug_path
|
from letsencrypt_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.client.plugins.apache.parser."
|
with mock.patch("letsencrypt_apache.parser.os.path") as mock_path:
|
||||||
"os.path") as mock_path:
|
|
||||||
|
|
||||||
mock_path.isfile.return_value = False
|
mock_path.isfile.return_value = False
|
||||||
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
"""Common utilities for letsencrypt.client.plugins.apache."""
|
"""Common utilities for letsencrypt_apache."""
|
||||||
import os
|
import os
|
||||||
import pkg_resources
|
import pkg_resources
|
||||||
import shutil
|
import shutil
|
||||||
@@ -7,9 +7,9 @@ import unittest
|
|||||||
|
|
||||||
import mock
|
import mock
|
||||||
|
|
||||||
from letsencrypt.client.plugins.apache import configurator
|
from letsencrypt_apache import configurator
|
||||||
from letsencrypt.client.plugins.apache import constants
|
from letsencrypt_apache import constants
|
||||||
from letsencrypt.client.plugins.apache import obj
|
from letsencrypt_apache import obj
|
||||||
|
|
||||||
|
|
||||||
class ApacheTest(unittest.TestCase): # pylint: disable=too-few-public-methods
|
class ApacheTest(unittest.TestCase): # pylint: disable=too-few-public-methods
|
||||||
@@ -38,7 +38,7 @@ def dir_setup(test_dir="debian_apache_2_4/two_vhost_80"):
|
|||||||
work_dir = tempfile.mkdtemp("work")
|
work_dir = tempfile.mkdtemp("work")
|
||||||
|
|
||||||
test_configs = pkg_resources.resource_filename(
|
test_configs = pkg_resources.resource_filename(
|
||||||
"letsencrypt.client.plugins.apache.tests", "testdata/%s" % test_dir)
|
"letsencrypt_apache.tests", "testdata/%s" % test_dir)
|
||||||
|
|
||||||
shutil.copytree(
|
shutil.copytree(
|
||||||
test_configs, os.path.join(temp_dir, test_dir), symlinks=True)
|
test_configs, os.path.join(temp_dir, test_dir), symlinks=True)
|
||||||
@@ -59,7 +59,7 @@ def get_apache_configurator(
|
|||||||
|
|
||||||
backups = os.path.join(work_dir, "backups")
|
backups = os.path.join(work_dir, "backups")
|
||||||
|
|
||||||
with mock.patch("letsencrypt.client.plugins.apache.configurator."
|
with mock.patch("letsencrypt_apache.configurator."
|
||||||
"subprocess.Popen") as mock_popen:
|
"subprocess.Popen") as mock_popen:
|
||||||
# This just states that the ssl module is already loaded
|
# This just states that the ssl module is already loaded
|
||||||
mock_popen().communicate.return_value = ("ssl_module", "")
|
mock_popen().communicate.return_value = ("ssl_module", "")
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
"""Let's Encrypt nginx plugin."""
|
||||||
+5
-5
@@ -20,9 +20,9 @@ from letsencrypt.client import reverter
|
|||||||
|
|
||||||
from letsencrypt.client.plugins import common
|
from letsencrypt.client.plugins import common
|
||||||
|
|
||||||
from letsencrypt.client.plugins.nginx import constants
|
from letsencrypt_nginx import constants
|
||||||
from letsencrypt.client.plugins.nginx import dvsni
|
from letsencrypt_nginx import dvsni
|
||||||
from letsencrypt.client.plugins.nginx import parser
|
from letsencrypt_nginx import parser
|
||||||
|
|
||||||
|
|
||||||
class NginxConfigurator(common.Plugin):
|
class NginxConfigurator(common.Plugin):
|
||||||
@@ -38,7 +38,7 @@ class NginxConfigurator(common.Plugin):
|
|||||||
:type config: :class:`~letsencrypt.client.interfaces.IConfig`
|
:type config: :class:`~letsencrypt.client.interfaces.IConfig`
|
||||||
|
|
||||||
:ivar parser: Handles low level parsing
|
:ivar parser: Handles low level parsing
|
||||||
:type parser: :class:`~letsencrypt.client.plugins.nginx.parser`
|
:type parser: :class:`~letsencrypt_nginx.parser`
|
||||||
|
|
||||||
:ivar str save_notes: Human-readable config change notes
|
:ivar str save_notes: Human-readable config change notes
|
||||||
|
|
||||||
@@ -166,7 +166,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.client.plugins.nginx.obj.VirtualHost`
|
:rtype: :class:`~letsencrypt_nginx.obj.VirtualHost`
|
||||||
|
|
||||||
"""
|
"""
|
||||||
vhost = None
|
vhost = None
|
||||||
@@ -11,6 +11,6 @@ CLI_DEFAULTS = dict(
|
|||||||
|
|
||||||
|
|
||||||
MOD_SSL_CONF = pkg_resources.resource_filename(
|
MOD_SSL_CONF = pkg_resources.resource_filename(
|
||||||
"letsencrypt.client.plugins.nginx", "options-ssl.conf")
|
"letsencrypt_nginx", "options-ssl.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 @@
|
|||||||
"""NginxDVSNI"""
|
"""NginxDVSNI"""
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from letsencrypt.client.plugins.apache.dvsni import ApacheDvsni
|
from letsencrypt_apache.dvsni import ApacheDvsni
|
||||||
|
|
||||||
|
|
||||||
class NginxDvsni(ApacheDvsni):
|
class NginxDvsni(ApacheDvsni):
|
||||||
@@ -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.client.plugins.apache.obj import Addr as ApacheAddr
|
from letsencrypt_apache.obj import Addr as ApacheAddr
|
||||||
|
|
||||||
|
|
||||||
class Addr(ApacheAddr):
|
class Addr(ApacheAddr):
|
||||||
@@ -6,8 +6,9 @@ import pyparsing
|
|||||||
import re
|
import re
|
||||||
|
|
||||||
from letsencrypt.client import errors
|
from letsencrypt.client import errors
|
||||||
from letsencrypt.client.plugins.nginx import obj
|
|
||||||
from letsencrypt.client.plugins.nginx.nginxparser import dump, load
|
from letsencrypt_nginx import obj
|
||||||
|
from letsencrypt_nginx import nginxparser
|
||||||
|
|
||||||
|
|
||||||
class NginxParser(object):
|
class NginxParser(object):
|
||||||
@@ -85,9 +86,8 @@ 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
|
:returns: List of :class:`~letsencrypt_nginx.obj.VirtualHost`
|
||||||
:class:`~letsencrypt.client.plugins.nginx.obj.VirtualHost` objects
|
objects found in configuration
|
||||||
found in configuration
|
|
||||||
:rtype: list
|
:rtype: list
|
||||||
|
|
||||||
"""
|
"""
|
||||||
@@ -159,7 +159,7 @@ class NginxParser(object):
|
|||||||
continue
|
continue
|
||||||
try:
|
try:
|
||||||
with open(item) as _file:
|
with open(item) as _file:
|
||||||
parsed = load(_file)
|
parsed = nginxparser.load(_file)
|
||||||
self.parsed[item] = parsed
|
self.parsed[item] = parsed
|
||||||
trees.append(parsed)
|
trees.append(parsed)
|
||||||
except IOError:
|
except IOError:
|
||||||
@@ -213,7 +213,7 @@ class NginxParser(object):
|
|||||||
filename = filename + os.path.extsep + ext
|
filename = filename + os.path.extsep + ext
|
||||||
try:
|
try:
|
||||||
with open(filename, 'w') as _file:
|
with open(filename, 'w') as _file:
|
||||||
dump(tree, _file)
|
nginxparser.dump(tree, _file)
|
||||||
except IOError:
|
except IOError:
|
||||||
logging.error("Could not open file for writing: %s", filename)
|
logging.error("Could not open file for writing: %s", filename)
|
||||||
|
|
||||||
+7
-12
@@ -1,4 +1,4 @@
|
|||||||
"""Test for letsencrypt.client.plugins.nginx.configurator."""
|
"""Test for letsencrypt_nginx.configurator."""
|
||||||
import shutil
|
import shutil
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
@@ -11,7 +11,7 @@ from letsencrypt.client import achallenges
|
|||||||
from letsencrypt.client import errors
|
from letsencrypt.client import errors
|
||||||
from letsencrypt.client import le_util
|
from letsencrypt.client import le_util
|
||||||
|
|
||||||
from letsencrypt.client.plugins.nginx.tests import util
|
from letsencrypt_nginx.tests import util
|
||||||
|
|
||||||
|
|
||||||
class NginxConfiguratorTest(util.NginxTest):
|
class NginxConfiguratorTest(util.NginxTest):
|
||||||
@@ -158,10 +158,8 @@ class NginxConfiguratorTest(util.NginxTest):
|
|||||||
('/etc/nginx/cert.pem', '/etc/nginx/key.pem', nginx_conf),
|
('/etc/nginx/cert.pem', '/etc/nginx/key.pem', nginx_conf),
|
||||||
]), self.config.get_all_certs_keys())
|
]), self.config.get_all_certs_keys())
|
||||||
|
|
||||||
@mock.patch("letsencrypt.client.plugins.nginx.configurator."
|
@mock.patch("letsencrypt_nginx.configurator.dvsni.NginxDvsni.perform")
|
||||||
"dvsni.NginxDvsni.perform")
|
@mock.patch("letsencrypt_nginx.configurator.NginxConfigurator.restart")
|
||||||
@mock.patch("letsencrypt.client.plugins.nginx.configurator."
|
|
||||||
"NginxConfigurator.restart")
|
|
||||||
def test_perform(self, mock_restart, mock_dvsni_perform):
|
def test_perform(self, mock_restart, mock_dvsni_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
|
||||||
@@ -195,8 +193,7 @@ class NginxConfiguratorTest(util.NginxTest):
|
|||||||
self.assertEqual(responses, dvsni_ret_val)
|
self.assertEqual(responses, dvsni_ret_val)
|
||||||
self.assertEqual(mock_restart.call_count, 1)
|
self.assertEqual(mock_restart.call_count, 1)
|
||||||
|
|
||||||
@mock.patch("letsencrypt.client.plugins.nginx.configurator."
|
@mock.patch("letsencrypt_nginx.configurator.subprocess.Popen")
|
||||||
"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",
|
||||||
@@ -251,16 +248,14 @@ class NginxConfiguratorTest(util.NginxTest):
|
|||||||
self.assertRaises(
|
self.assertRaises(
|
||||||
errors.LetsEncryptConfiguratorError, self.config.get_version)
|
errors.LetsEncryptConfiguratorError, self.config.get_version)
|
||||||
|
|
||||||
@mock.patch("letsencrypt.client.plugins.nginx.configurator."
|
@mock.patch("letsencrypt_nginx.configurator.subprocess.Popen")
|
||||||
"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.assertTrue(self.config.restart())
|
self.assertTrue(self.config.restart())
|
||||||
|
|
||||||
@mock.patch("letsencrypt.client.plugins.nginx.configurator."
|
@mock.patch("letsencrypt_nginx.configurator.subprocess.Popen")
|
||||||
"subprocess.Popen")
|
|
||||||
def test_config_test(self, mock_popen):
|
def test_config_test(self, mock_popen):
|
||||||
mocked = mock_popen()
|
mocked = mock_popen()
|
||||||
mocked.communicate.return_value = ('', '')
|
mocked.communicate.return_value = ('', '')
|
||||||
+5
-7
@@ -1,4 +1,4 @@
|
|||||||
"""Test for letsencrypt.client.plugins.nginx.dvsni."""
|
"""Test for letsencrypt_nginx.dvsni."""
|
||||||
import pkg_resources
|
import pkg_resources
|
||||||
import unittest
|
import unittest
|
||||||
import shutil
|
import shutil
|
||||||
@@ -11,7 +11,7 @@ from acme import messages2
|
|||||||
from letsencrypt.client import achallenges
|
from letsencrypt.client import achallenges
|
||||||
from letsencrypt.client import le_util
|
from letsencrypt.client import le_util
|
||||||
|
|
||||||
from letsencrypt.client.plugins.nginx.tests import util
|
from letsencrypt_nginx.tests import util
|
||||||
|
|
||||||
|
|
||||||
class DvsniPerformTest(util.NginxTest):
|
class DvsniPerformTest(util.NginxTest):
|
||||||
@@ -31,7 +31,7 @@ class DvsniPerformTest(util.NginxTest):
|
|||||||
|
|
||||||
auth_key = le_util.Key(rsa256_file, rsa256_pem)
|
auth_key = le_util.Key(rsa256_file, rsa256_pem)
|
||||||
|
|
||||||
from letsencrypt.client.plugins.nginx import dvsni
|
from letsencrypt_nginx import dvsni
|
||||||
self.sni = dvsni.NginxDvsni(config)
|
self.sni = dvsni.NginxDvsni(config)
|
||||||
|
|
||||||
self.achalls = [
|
self.achalls = [
|
||||||
@@ -67,8 +67,7 @@ class DvsniPerformTest(util.NginxTest):
|
|||||||
self.assertEqual(1, len(self.sni.achalls))
|
self.assertEqual(1, len(self.sni.achalls))
|
||||||
self.assertEqual([0], self.sni.indices)
|
self.assertEqual([0], self.sni.indices)
|
||||||
|
|
||||||
@mock.patch("letsencrypt.client.plugins.nginx.configurator."
|
@mock.patch("letsencrypt_nginx.configurator.NginxConfigurator.save")
|
||||||
"NginxConfigurator.save")
|
|
||||||
def test_perform0(self, mock_save):
|
def test_perform0(self, mock_save):
|
||||||
self.sni.add_chall(self.achalls[0])
|
self.sni.add_chall(self.achalls[0])
|
||||||
responses = self.sni.perform()
|
responses = self.sni.perform()
|
||||||
@@ -82,8 +81,7 @@ class DvsniPerformTest(util.NginxTest):
|
|||||||
# http://www.voidspace.org.uk/python/mock/helpers.html#mock.mock_open
|
# http://www.voidspace.org.uk/python/mock/helpers.html#mock.mock_open
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@mock.patch("letsencrypt.client.plugins.nginx.configurator."
|
@mock.patch("letsencrypt_nginx.configurator.NginxConfigurator.save")
|
||||||
"NginxConfigurator.save")
|
|
||||||
def test_perform1(self, mock_save):
|
def test_perform1(self, mock_save):
|
||||||
self.sni.add_chall(self.achalls[1])
|
self.sni.add_chall(self.achalls[1])
|
||||||
responses = self.sni.perform()
|
responses = self.sni.perform()
|
||||||
+4
-4
@@ -1,10 +1,10 @@
|
|||||||
"""Test for letsencrypt.client.plugins.nginx.nginxparser."""
|
"""Test for letsencrypt_nginx.nginxparser."""
|
||||||
import operator
|
import operator
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from letsencrypt.client.plugins.nginx.nginxparser import (RawNginxParser,
|
from letsencrypt_nginx.nginxparser import (
|
||||||
load, dumps, dump)
|
RawNginxParser, load, dumps, dump)
|
||||||
from letsencrypt.client.plugins.nginx.tests import util
|
from letsencrypt_nginx.tests import util
|
||||||
|
|
||||||
|
|
||||||
FIRST = operator.itemgetter(0)
|
FIRST = operator.itemgetter(0)
|
||||||
+8
-8
@@ -1,11 +1,11 @@
|
|||||||
"""Test the helper objects in letsencrypt.client.plugins.nginx.obj."""
|
"""Test the helper objects in letsencrypt_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.client.plugins.nginx.obj import Addr
|
from letsencrypt_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")
|
self.assertEqual(str(self.addr6), "80")
|
||||||
|
|
||||||
def test_eq(self):
|
def test_eq(self):
|
||||||
from letsencrypt.client.plugins.nginx.obj import Addr
|
from letsencrypt_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.client.plugins.nginx.obj import Addr
|
from letsencrypt_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.client.plugins.nginx.obj import VirtualHost
|
from letsencrypt_nginx.obj import VirtualHost
|
||||||
from letsencrypt.client.plugins.nginx.obj import Addr
|
from letsencrypt_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.client.plugins.nginx.obj import Addr
|
from letsencrypt_nginx.obj import Addr
|
||||||
from letsencrypt.client.plugins.nginx.obj import VirtualHost
|
from letsencrypt_nginx.obj import VirtualHost
|
||||||
vhost1b = VirtualHost(
|
vhost1b = VirtualHost(
|
||||||
"filep",
|
"filep",
|
||||||
set([Addr.fromstring("localhost blah")]), False, False,
|
set([Addr.fromstring("localhost blah")]), False, False,
|
||||||
+6
-5
@@ -1,4 +1,4 @@
|
|||||||
"""Tests for letsencrypt.client.plugins.nginx.parser."""
|
"""Tests for letsencrypt_nginx.parser."""
|
||||||
import glob
|
import glob
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
@@ -6,10 +6,11 @@ import shutil
|
|||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from letsencrypt.client.errors import LetsEncryptMisconfigurationError
|
from letsencrypt.client.errors import LetsEncryptMisconfigurationError
|
||||||
from letsencrypt.client.plugins.nginx import nginxparser
|
|
||||||
from letsencrypt.client.plugins.nginx import obj
|
from letsencrypt_nginx import nginxparser
|
||||||
from letsencrypt.client.plugins.nginx import parser
|
from letsencrypt_nginx import obj
|
||||||
from letsencrypt.client.plugins.nginx.tests import util
|
from letsencrypt_nginx import parser
|
||||||
|
from letsencrypt_nginx.tests import util
|
||||||
|
|
||||||
|
|
||||||
class NginxParserTest(util.NginxTest):
|
class NginxParserTest(util.NginxTest):
|
||||||
@@ -7,8 +7,8 @@ import unittest
|
|||||||
|
|
||||||
import mock
|
import mock
|
||||||
|
|
||||||
from letsencrypt.client.plugins.nginx import constants
|
from letsencrypt_nginx import constants
|
||||||
from letsencrypt.client.plugins.nginx import configurator
|
from letsencrypt_nginx import configurator
|
||||||
|
|
||||||
|
|
||||||
class NginxTest(unittest.TestCase): # pylint: disable=too-few-public-methods
|
class NginxTest(unittest.TestCase): # pylint: disable=too-few-public-methods
|
||||||
@@ -33,7 +33,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.client.plugins.nginx.tests", "testdata/%s" % filename)
|
"letsencrypt_nginx.tests", "testdata/%s" % filename)
|
||||||
|
|
||||||
|
|
||||||
def dir_setup(test_dir="debian_nginx/two_vhost_80"):
|
def dir_setup(test_dir="debian_nginx/two_vhost_80"):
|
||||||
@@ -43,7 +43,7 @@ def dir_setup(test_dir="debian_nginx/two_vhost_80"):
|
|||||||
work_dir = tempfile.mkdtemp("work")
|
work_dir = tempfile.mkdtemp("work")
|
||||||
|
|
||||||
test_configs = pkg_resources.resource_filename(
|
test_configs = pkg_resources.resource_filename(
|
||||||
"letsencrypt.client.plugins.nginx.tests", test_dir)
|
"letsencrypt_nginx.tests", test_dir)
|
||||||
|
|
||||||
shutil.copytree(
|
shutil.copytree(
|
||||||
test_configs, os.path.join(temp_dir, test_dir), symlinks=True)
|
test_configs, os.path.join(temp_dir, test_dir), symlinks=True)
|
||||||
@@ -6,5 +6,5 @@ dev = develop easy_install letsencrypt[dev,docs,testing]
|
|||||||
|
|
||||||
[nosetests]
|
[nosetests]
|
||||||
nocapture=1
|
nocapture=1
|
||||||
cover-package=letsencrypt,acme
|
cover-package=letsencrypt,acme,letsencrypt_apache,letsencrypt_nginx
|
||||||
cover-erase=1
|
cover-erase=1
|
||||||
|
|||||||
@@ -115,12 +115,12 @@ setup(
|
|||||||
'jws = letsencrypt.acme.jose.jws:CLI.run',
|
'jws = letsencrypt.acme.jose.jws:CLI.run',
|
||||||
],
|
],
|
||||||
'letsencrypt.plugins': [
|
'letsencrypt.plugins': [
|
||||||
'apache = letsencrypt.client.plugins.apache.configurator'
|
|
||||||
':ApacheConfigurator',
|
|
||||||
'nginx = letsencrypt.client.plugins.nginx.configurator'
|
|
||||||
':NginxConfigurator',
|
|
||||||
'standalone = letsencrypt.client.plugins.standalone.authenticator'
|
'standalone = letsencrypt.client.plugins.standalone.authenticator'
|
||||||
':StandaloneAuthenticator',
|
':StandaloneAuthenticator',
|
||||||
|
|
||||||
|
# to be moved to separate pypi packages
|
||||||
|
'apache = letsencrypt_apache.configurator:ApacheConfigurator',
|
||||||
|
'nginx = letsencrypt_nginx.configurator:NginxConfigurator',
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user