Move plugins to top-level

This commit is contained in:
Jakub Warmuz 2015-05-10 10:47:58 +00:00
parent 3a6bd7123d
commit d408ec5a95
No known key found for this signature in database
GPG key ID: 2A7BAD3A489B52EA
99 changed files with 199 additions and 219 deletions

View file

@ -9,8 +9,8 @@ recursive-include letsencrypt/client/tests/testdata *
recursive-include acme/schemata *.json
recursive-include acme/jose/testdata *
recursive-include letsencrypt/client/plugins/apache/tests/testdata *
include letsencrypt/client/plugins/apache/options-ssl.conf
recursive-include letsencrypt_apache/tests/testdata *
include letsencrypt_apache/options-ssl.conf
recursive-include letsencrypt/client/plugins/nginx/tests/testdata *
include letsencrypt/client/plugins/nginx/options-ssl.conf
recursive-include letsencrypt_nginx/tests/testdata *
include letsencrypt_nginx/options-ssl.conf

View file

@ -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:

View file

@ -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:

View file

@ -9,6 +9,8 @@ Welcome to the Let's Encrypt client documentation!
contributing
plugins
acme
letsencrypt_apache
letsencrypt_nginx
.. toctree::
:maxdepth: 1

View file

@ -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:

View file

@ -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:

View file

@ -1 +0,0 @@
"""Let's Encrypt client.plugins.apache."""

View file

@ -1 +0,0 @@
"""Let's Encrypt client.plugins.nginx."""

View file

@ -56,8 +56,7 @@ class DetermineAccountTest(unittest.TestCase):
class RollbackTest(unittest.TestCase):
"""Test the rollback function."""
def setUp(self):
from letsencrypt.client.plugins.apache.configurator import (
ApacheConfigurator)
from letsencrypt_apache.configurator import ApacheConfigurator
self.m_install = mock.MagicMock(spec=ApacheConfigurator)
@classmethod

View file

@ -10,9 +10,10 @@ import mock
from letsencrypt.client import errors
from letsencrypt.client import le_util
from letsencrypt.client.plugins.apache import configurator
from letsencrypt.client.display import util as display_util
from letsencrypt_apache import configurator
class RevokerBase(unittest.TestCase): # pylint: disable=too-few-public-methods
"""Base Class for Revoker Tests."""

View file

@ -0,0 +1 @@
"""Let's Encrypt Apache plugin."""

View file

@ -18,10 +18,10 @@ from letsencrypt.client import errors
from letsencrypt.client import interfaces
from letsencrypt.client import le_util
from letsencrypt.client.plugins.apache import constants
from letsencrypt.client.plugins.apache import dvsni
from letsencrypt.client.plugins.apache import obj
from letsencrypt.client.plugins.apache import parser
from letsencrypt_apache import constants
from letsencrypt_apache import dvsni
from letsencrypt_apache import obj
from letsencrypt_apache import parser
# 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`
: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 list vhosts: All vhosts found in the configuration
(:class:`list` of
:class:`~letsencrypt.client.plugins.apache.obj.VirtualHost`)
(:class:`list` of :class:`~letsencrypt_apache.obj.VirtualHost`)
:ivar dict assoc: Mapping between domains and vhosts
@ -222,7 +221,7 @@ class ApacheConfigurator(augeas_configurator.AugeasConfigurator):
:param str target_name: domain 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
@ -263,7 +262,7 @@ class ApacheConfigurator(augeas_configurator.AugeasConfigurator):
:param str domain: domain name to associate
: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
@ -300,7 +299,7 @@ class ApacheConfigurator(augeas_configurator.AugeasConfigurator):
"""Helper function for get_virtual_hosts().
: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')] | "
@ -321,7 +320,7 @@ class ApacheConfigurator(augeas_configurator.AugeasConfigurator):
:param str path: Augeas path to virtual host
:returns: newly created vhost
:rtype: :class:`~letsencrypt.client.plugins.apache.obj.VirtualHost`
:rtype: :class:`~letsencrypt_apache.obj.VirtualHost`
"""
addrs = set()
@ -344,9 +343,8 @@ class ApacheConfigurator(augeas_configurator.AugeasConfigurator):
def get_virtual_hosts(self):
"""Returns list of virtual hosts found in the Apache configuration.
:returns: List of
:class:`~letsencrypt.client.plugins.apache.obj.VirtualHost` objects
found in configuration
:returns: List of :class:`~letsencrypt_apache.obj.VirtualHost`
objects found in configuration
:rtype: list
"""
@ -423,7 +421,7 @@ class ApacheConfigurator(augeas_configurator.AugeasConfigurator):
"""Checks to see if the server is ready for SNI challenges.
: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
@ -455,11 +453,10 @@ class ApacheConfigurator(augeas_configurator.AugeasConfigurator):
.. note:: This function saves the configuration
:param nonssl_vhost: Valid VH that doesn't have SSLEngine on
:type nonssl_vhost:
:class:`~letsencrypt.client.plugins.apache.obj.VirtualHost`
:type nonssl_vhost: :class:`~letsencrypt_apache.obj.VirtualHost`
:returns: SSL vhost
:rtype: :class:`~letsencrypt.client.plugins.apache.obj.VirtualHost`
:rtype: :class:`~letsencrypt_apache.obj.VirtualHost`
"""
avail_fp = nonssl_vhost.filep
@ -579,15 +576,13 @@ class ApacheConfigurator(augeas_configurator.AugeasConfigurator):
.. note:: This function saves the configuration
:param ssl_vhost: Destination of traffic, an ssl enabled vhost
:type ssl_vhost:
:class:`~letsencrypt.client.plugins.apache.obj.VirtualHost`
:type ssl_vhost: :class:`~letsencrypt_apache.obj.VirtualHost`
:param unused_options: Not currently used
:type unused_options: Not Available
:returns: Success, general_vhost (HTTP vhost)
:rtype: (bool,
:class:`~letsencrypt.client.plugins.apache.obj.VirtualHost`)
:rtype: (bool, :class:`~letsencrypt_apache.obj.VirtualHost`)
"""
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
: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
:rtype: bool, int
@ -670,12 +665,10 @@ class ApacheConfigurator(augeas_configurator.AugeasConfigurator):
"""Creates an http_vhost specifically to redirect for the ssl_vhost.
:param ssl_vhost: ssl vhost
:type ssl_vhost:
:class:`~letsencrypt.client.plugins.apache.obj.VirtualHost`
:type ssl_vhost: :class:`~letsencrypt_apache.obj.VirtualHost`
:returns: tuple of the form
(`success`,
:class:`~letsencrypt.client.plugins.apache.obj.VirtualHost`)
(`success`, :class:`~letsencrypt_apache.obj.VirtualHost`)
:rtype: tuple
"""
@ -758,8 +751,7 @@ class ApacheConfigurator(augeas_configurator.AugeasConfigurator):
if not conflict: returns space separated list of new host addrs
:param ssl_vhost: SSL Vhost to check for possible port 80 redirection
:type ssl_vhost:
:class:`~letsencrypt.client.plugins.apache.obj.VirtualHost`
:type ssl_vhost: :class:`~letsencrypt_apache.obj.VirtualHost`
:returns: TODO
:rtype: TODO
@ -792,12 +784,10 @@ class ApacheConfigurator(augeas_configurator.AugeasConfigurator):
Consider changing this into a dict check
:param ssl_vhost: ssl vhost to check
:type ssl_vhost:
:class:`~letsencrypt.client.plugins.apache.obj.VirtualHost`
:type ssl_vhost: :class:`~letsencrypt_apache.obj.VirtualHost`
:returns: HTTP vhost or None if unsuccessful
:rtype: :class:`~letsencrypt.client.plugins.apache.obj.VirtualHost`
or None
:rtype: :class:`~letsencrypt_apache.obj.VirtualHost` or ``None``
"""
# _default_:443 check
@ -887,7 +877,7 @@ class ApacheConfigurator(augeas_configurator.AugeasConfigurator):
.. todo:: Make sure link is not broken...
:param vhost: vhost to enable
:type vhost: :class:`~letsencrypt.client.plugins.apache.obj.VirtualHost`
:type vhost: :class:`~letsencrypt_apache.obj.VirtualHost`
:returns: Success
:rtype: bool

View file

@ -13,7 +13,7 @@ CLI_DEFAULTS = dict(
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
distribution."""

View file

@ -2,7 +2,7 @@
import logging
import os
from letsencrypt.client.plugins.apache import parser
from letsencrypt_apache import parser
class ApacheDvsni(object):

View file

@ -1,4 +1,4 @@
"""Test for letsencrypt.client.plugins.apache.configurator."""
"""Test for letsencrypt_apache.configurator."""
import os
import re
import shutil
@ -12,14 +12,14 @@ from letsencrypt.client import achallenges
from letsencrypt.client import errors
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_apache import configurator
from letsencrypt_apache import obj
from letsencrypt_apache import parser
from letsencrypt_apache.tests import util
class TwoVhost80Test(util.ApacheTest):
"""Test two standard well configured HTTP vhosts."""
@ -27,7 +27,7 @@ class TwoVhost80Test(util.ApacheTest):
def setUp(self):
super(TwoVhost80Test, self).setUp()
with mock.patch("letsencrypt.client.plugins.apache.configurator."
with mock.patch("letsencrypt_apache.configurator."
"mod_loaded") as mock_load:
mock_load.return_value = True
self.config = util.get_apache_configurator(
@ -150,10 +150,8 @@ class TwoVhost80Test(util.ApacheTest):
self.assertEqual(len(self.config.vhosts), 5)
@mock.patch("letsencrypt.client.plugins.apache.configurator."
"dvsni.ApacheDvsni.perform")
@mock.patch("letsencrypt.client.plugins.apache.configurator."
"ApacheConfigurator.restart")
@mock.patch("letsencrypt_apache.configurator.dvsni.ApacheDvsni.perform")
@mock.patch("letsencrypt_apache.configurator.ApacheConfigurator.restart")
def test_perform(self, mock_restart, mock_dvsni_perform):
# Only tests functionality specific to configurator.perform
# 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)
@mock.patch("letsencrypt.client.plugins.apache.configurator."
"subprocess.Popen")
@mock.patch("letsencrypt_apache.configurator.subprocess.Popen")
def test_get_version(self, mock_popen):
mock_popen().communicate.return_value = (
"Server Version: Apache/2.4.2 (Debian)", "")

View file

@ -1,4 +1,4 @@
"""Test for letsencrypt.client.plugins.apache.dvsni."""
"""Test for letsencrypt_apache.dvsni."""
import pkg_resources
import unittest
import shutil
@ -10,12 +10,11 @@ from acme import challenges
from letsencrypt.client import achallenges
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_apache import obj
from letsencrypt_apache.tests import util
class DvsniPerformTest(util.ApacheTest):
"""Test the ApacheDVSNI challenge."""
@ -23,14 +22,14 @@ class DvsniPerformTest(util.ApacheTest):
def setUp(self):
super(DvsniPerformTest, self).setUp()
with mock.patch("letsencrypt.client.plugins.apache.configurator."
with mock.patch("letsencrypt_apache.configurator."
"mod_loaded") as mock_load:
mock_load.return_value = True
config = util.get_apache_configurator(
self.config_path, self.config_dir, self.work_dir,
self.ssl_options)
from letsencrypt.client.plugins.apache import dvsni
from letsencrypt_apache import dvsni
self.sni = dvsni.ApacheDvsni(config)
rsa256_file = pkg_resources.resource_filename(
@ -80,8 +79,7 @@ class DvsniPerformTest(util.ApacheTest):
nonce_domain=self.achalls[0].nonce_domain)
achall.gen_cert_and_response.return_value = ("pem", response)
with mock.patch("letsencrypt.client.plugins.apache.dvsni.open",
m_open, create=True):
with mock.patch("letsencrypt_apache.dvsni.open", m_open, create=True):
# pylint: disable=protected-access
self.assertEqual(response, self.sni._setup_challenge_cert(
achall, "randomS1"))
@ -142,8 +140,8 @@ class DvsniPerformTest(util.ApacheTest):
def test_mod_config(self):
for achall in self.achalls:
self.sni.add_chall(achall)
v_addr1 = [Addr(("1.2.3.4", "443")), Addr(("5.6.7.8", "443"))]
v_addr2 = [Addr(("127.0.0.1", "443"))]
v_addr1 = [obj.Addr(("1.2.3.4", "443")), obj.Addr(("5.6.7.8", "443"))]
v_addr2 = [obj.Addr(("127.0.0.1", "443"))]
ll_addr = []
ll_addr.append(v_addr1)
ll_addr.append(v_addr2)

View file

@ -1,11 +1,11 @@
"""Test the helper objects in letsencrypt.client.plugins.apache.obj."""
"""Test the helper objects in letsencrypt_apache.obj."""
import unittest
class AddrTest(unittest.TestCase):
"""Test the Addr class."""
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.addr2 = Addr.fromstring("192.168.1.1:*")
self.addr3 = Addr.fromstring("192.168.1.1:80")
@ -34,7 +34,7 @@ class AddrTest(unittest.TestCase):
self.assertFalse(self.addr1 == 3333)
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])
addr1b = 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):
"""Test the VirtualHost class."""
def setUp(self):
from letsencrypt.client.plugins.apache.obj import VirtualHost
from letsencrypt.client.plugins.apache.obj import Addr
from letsencrypt_apache.obj import VirtualHost
from letsencrypt_apache.obj import Addr
self.vhost1 = VirtualHost(
"filep", "vh_path",
set([Addr.fromstring("localhost")]), False, False)
def test_eq(self):
from letsencrypt.client.plugins.apache.obj import Addr
from letsencrypt.client.plugins.apache.obj import VirtualHost
from letsencrypt_apache.obj import Addr
from letsencrypt_apache.obj import VirtualHost
vhost1b = VirtualHost(
"filep", "vh_path",
set([Addr.fromstring("localhost")]), False, False)

View file

@ -1,4 +1,4 @@
"""Tests for letsencrypt.client.plugins.apache.parser."""
"""Tests for letsencrypt_apache.parser."""
import os
import shutil
import sys
@ -11,7 +11,7 @@ import zope.component
from letsencrypt.client import errors
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):
@ -22,7 +22,7 @@ class ApacheParserTest(util.ApacheTest):
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.parser = ApacheParser(self.aug, self.config_path, self.ssl_options)
@ -32,19 +32,19 @@ class ApacheParserTest(util.ApacheTest):
shutil.rmtree(self.work_dir)
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/////"
"two_vhost_80/../two_vhost_80/apache2")
parser = ApacheParser(self.aug, path, None)
self.assertEqual(parser.root, self.config_path)
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)
self.assertEqual(parser.root, self.config_path)
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)
self.assertEqual(parser.root, self.config_path)
@ -67,7 +67,7 @@ class ApacheParserTest(util.ApacheTest):
self.assertTrue(matches)
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")
# This will only look in enabled hosts
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
"""
from letsencrypt.client.plugins.apache.parser import get_aug_path
from letsencrypt_apache.parser import get_aug_path
self.parser.add_dir_to_ifmodssl(
get_aug_path(self.parser.loc["default"]),
"FakeDirective", "123")
@ -103,12 +103,11 @@ class ApacheParserTest(util.ApacheTest):
self.assertTrue("IfModule" in matches[0])
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"))
def test_set_locations(self):
with mock.patch("letsencrypt.client.plugins.apache.parser."
"os.path") as mock_path:
with mock.patch("letsencrypt_apache.parser.os.path") as mock_path:
mock_path.isfile.return_value = False

View file

@ -1,4 +1,4 @@
"""Common utilities for letsencrypt.client.plugins.apache."""
"""Common utilities for letsencrypt_apache."""
import os
import pkg_resources
import shutil
@ -7,9 +7,9 @@ import unittest
import mock
from letsencrypt.client.plugins.apache import configurator
from letsencrypt.client.plugins.apache import constants
from letsencrypt.client.plugins.apache import obj
from letsencrypt_apache import configurator
from letsencrypt_apache import constants
from letsencrypt_apache import obj
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")
test_configs = pkg_resources.resource_filename(
"letsencrypt.client.plugins.apache.tests", "testdata/%s" % test_dir)
"letsencrypt_apache.tests", "testdata/%s" % test_dir)
shutil.copytree(
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")
with mock.patch("letsencrypt.client.plugins.apache.configurator."
with mock.patch("letsencrypt_apache.configurator."
"subprocess.Popen") as mock_popen:
# This just states that the ssl module is already loaded
mock_popen().communicate.return_value = ("ssl_module", "")

View file

@ -0,0 +1 @@
"""Let's Encrypt nginx plugin."""

View file

@ -20,9 +20,9 @@ from letsencrypt.client import reverter
from letsencrypt.client.plugins import common
from letsencrypt.client.plugins.nginx import constants
from letsencrypt.client.plugins.nginx import dvsni
from letsencrypt.client.plugins.nginx import parser
from letsencrypt_nginx import constants
from letsencrypt_nginx import dvsni
from letsencrypt_nginx import parser
class NginxConfigurator(common.Plugin):
@ -38,7 +38,7 @@ class NginxConfigurator(common.Plugin):
:type config: :class:`~letsencrypt.client.interfaces.IConfig`
: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
@ -166,7 +166,7 @@ class NginxConfigurator(common.Plugin):
:param str target_name: domain name
:returns: ssl vhost associated with name
:rtype: :class:`~letsencrypt.client.plugins.nginx.obj.VirtualHost`
:rtype: :class:`~letsencrypt_nginx.obj.VirtualHost`
"""
vhost = None

View file

@ -11,6 +11,6 @@ CLI_DEFAULTS = dict(
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
distribution."""

View file

@ -1,7 +1,7 @@
"""NginxDVSNI"""
import logging
from letsencrypt.client.plugins.apache.dvsni import ApacheDvsni
from letsencrypt_apache.dvsni import ApacheDvsni
class NginxDvsni(ApacheDvsni):

View file

@ -1,7 +1,7 @@
"""Module contains classes used by the Nginx Configurator."""
import re
from letsencrypt.client.plugins.apache.obj import Addr as ApacheAddr
from letsencrypt_apache.obj import Addr as ApacheAddr
class Addr(ApacheAddr):

View file

@ -6,8 +6,9 @@ import pyparsing
import re
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):
@ -85,9 +86,8 @@ class NginxParser(object):
Technically this is a misnomer because Nginx does not have virtual
hosts, it has 'server blocks'.
:returns: List of
:class:`~letsencrypt.client.plugins.nginx.obj.VirtualHost` objects
found in configuration
:returns: List of :class:`~letsencrypt_nginx.obj.VirtualHost`
objects found in configuration
:rtype: list
"""
@ -159,7 +159,7 @@ class NginxParser(object):
continue
try:
with open(item) as _file:
parsed = load(_file)
parsed = nginxparser.load(_file)
self.parsed[item] = parsed
trees.append(parsed)
except IOError:
@ -213,7 +213,7 @@ class NginxParser(object):
filename = filename + os.path.extsep + ext
try:
with open(filename, 'w') as _file:
dump(tree, _file)
nginxparser.dump(tree, _file)
except IOError:
logging.error("Could not open file for writing: %s", filename)

View file

@ -1,4 +1,4 @@
"""Test for letsencrypt.client.plugins.nginx.configurator."""
"""Test for letsencrypt_nginx.configurator."""
import shutil
import unittest
@ -11,7 +11,7 @@ from letsencrypt.client import achallenges
from letsencrypt.client import errors
from letsencrypt.client import le_util
from letsencrypt.client.plugins.nginx.tests import util
from letsencrypt_nginx.tests import util
class NginxConfiguratorTest(util.NginxTest):
@ -158,10 +158,8 @@ class NginxConfiguratorTest(util.NginxTest):
('/etc/nginx/cert.pem', '/etc/nginx/key.pem', nginx_conf),
]), self.config.get_all_certs_keys())
@mock.patch("letsencrypt.client.plugins.nginx.configurator."
"dvsni.NginxDvsni.perform")
@mock.patch("letsencrypt.client.plugins.nginx.configurator."
"NginxConfigurator.restart")
@mock.patch("letsencrypt_nginx.configurator.dvsni.NginxDvsni.perform")
@mock.patch("letsencrypt_nginx.configurator.NginxConfigurator.restart")
def test_perform(self, mock_restart, mock_dvsni_perform):
# Only tests functionality specific to configurator.perform
# 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(mock_restart.call_count, 1)
@mock.patch("letsencrypt.client.plugins.nginx.configurator."
"subprocess.Popen")
@mock.patch("letsencrypt_nginx.configurator.subprocess.Popen")
def test_get_version(self, mock_popen):
mock_popen().communicate.return_value = (
"", "\n".join(["nginx version: nginx/1.4.2",
@ -251,16 +248,14 @@ class NginxConfiguratorTest(util.NginxTest):
self.assertRaises(
errors.LetsEncryptConfiguratorError, self.config.get_version)
@mock.patch("letsencrypt.client.plugins.nginx.configurator."
"subprocess.Popen")
@mock.patch("letsencrypt_nginx.configurator.subprocess.Popen")
def test_nginx_restart(self, mock_popen):
mocked = mock_popen()
mocked.communicate.return_value = ('', '')
mocked.returncode = 0
self.assertTrue(self.config.restart())
@mock.patch("letsencrypt.client.plugins.nginx.configurator."
"subprocess.Popen")
@mock.patch("letsencrypt_nginx.configurator.subprocess.Popen")
def test_config_test(self, mock_popen):
mocked = mock_popen()
mocked.communicate.return_value = ('', '')

View file

@ -1,4 +1,4 @@
"""Test for letsencrypt.client.plugins.nginx.dvsni."""
"""Test for letsencrypt_nginx.dvsni."""
import pkg_resources
import unittest
import shutil
@ -11,7 +11,7 @@ from acme import messages2
from letsencrypt.client import achallenges
from letsencrypt.client import le_util
from letsencrypt.client.plugins.nginx.tests import util
from letsencrypt_nginx.tests import util
class DvsniPerformTest(util.NginxTest):
@ -31,7 +31,7 @@ class DvsniPerformTest(util.NginxTest):
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.achalls = [
@ -67,8 +67,7 @@ class DvsniPerformTest(util.NginxTest):
self.assertEqual(1, len(self.sni.achalls))
self.assertEqual([0], self.sni.indices)
@mock.patch("letsencrypt.client.plugins.nginx.configurator."
"NginxConfigurator.save")
@mock.patch("letsencrypt_nginx.configurator.NginxConfigurator.save")
def test_perform0(self, mock_save):
self.sni.add_chall(self.achalls[0])
responses = self.sni.perform()
@ -82,8 +81,7 @@ class DvsniPerformTest(util.NginxTest):
# http://www.voidspace.org.uk/python/mock/helpers.html#mock.mock_open
pass
@mock.patch("letsencrypt.client.plugins.nginx.configurator."
"NginxConfigurator.save")
@mock.patch("letsencrypt_nginx.configurator.NginxConfigurator.save")
def test_perform1(self, mock_save):
self.sni.add_chall(self.achalls[1])
responses = self.sni.perform()

View file

@ -1,10 +1,10 @@
"""Test for letsencrypt.client.plugins.nginx.nginxparser."""
"""Test for letsencrypt_nginx.nginxparser."""
import operator
import unittest
from letsencrypt.client.plugins.nginx.nginxparser import (RawNginxParser,
load, dumps, dump)
from letsencrypt.client.plugins.nginx.tests import util
from letsencrypt_nginx.nginxparser import (
RawNginxParser, load, dumps, dump)
from letsencrypt_nginx.tests import util
FIRST = operator.itemgetter(0)

View file

@ -1,11 +1,11 @@
"""Test the helper objects in letsencrypt.client.plugins.nginx.obj."""
"""Test the helper objects in letsencrypt_nginx.obj."""
import unittest
class AddrTest(unittest.TestCase):
"""Test the Addr class."""
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.addr2 = Addr.fromstring("192.168.1.1:* ssl")
self.addr3 = Addr.fromstring("192.168.1.1:80")
@ -56,14 +56,14 @@ class AddrTest(unittest.TestCase):
self.assertEqual(str(self.addr6), "80")
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")
self.assertEqual(self.addr1, new_addr1)
self.assertNotEqual(self.addr1, self.addr2)
self.assertFalse(self.addr1 == 3333)
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])
addr1b = Addr.fromstring("192.168.1.1")
addr2b = Addr.fromstring("192.168.1.1:* ssl")
@ -75,16 +75,16 @@ class AddrTest(unittest.TestCase):
class VirtualHostTest(unittest.TestCase):
"""Test the VirtualHost class."""
def setUp(self):
from letsencrypt.client.plugins.nginx.obj import VirtualHost
from letsencrypt.client.plugins.nginx.obj import Addr
from letsencrypt_nginx.obj import VirtualHost
from letsencrypt_nginx.obj import Addr
self.vhost1 = VirtualHost(
"filep",
set([Addr.fromstring("localhost")]), False, False,
set(['localhost']), [])
def test_eq(self):
from letsencrypt.client.plugins.nginx.obj import Addr
from letsencrypt.client.plugins.nginx.obj import VirtualHost
from letsencrypt_nginx.obj import Addr
from letsencrypt_nginx.obj import VirtualHost
vhost1b = VirtualHost(
"filep",
set([Addr.fromstring("localhost blah")]), False, False,

View file

@ -1,4 +1,4 @@
"""Tests for letsencrypt.client.plugins.nginx.parser."""
"""Tests for letsencrypt_nginx.parser."""
import glob
import os
import re
@ -6,10 +6,11 @@ import shutil
import unittest
from letsencrypt.client.errors import LetsEncryptMisconfigurationError
from letsencrypt.client.plugins.nginx import nginxparser
from letsencrypt.client.plugins.nginx import obj
from letsencrypt.client.plugins.nginx import parser
from letsencrypt.client.plugins.nginx.tests import util
from letsencrypt_nginx import nginxparser
from letsencrypt_nginx import obj
from letsencrypt_nginx import parser
from letsencrypt_nginx.tests import util
class NginxParserTest(util.NginxTest):

View file

@ -7,8 +7,8 @@ import unittest
import mock
from letsencrypt.client.plugins.nginx import constants
from letsencrypt.client.plugins.nginx import configurator
from letsencrypt_nginx import constants
from letsencrypt_nginx import configurator
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):
"""Gets the filename of a test data file."""
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"):
@ -43,7 +43,7 @@ def dir_setup(test_dir="debian_nginx/two_vhost_80"):
work_dir = tempfile.mkdtemp("work")
test_configs = pkg_resources.resource_filename(
"letsencrypt.client.plugins.nginx.tests", test_dir)
"letsencrypt_nginx.tests", test_dir)
shutil.copytree(
test_configs, os.path.join(temp_dir, test_dir), symlinks=True)

View file

@ -6,5 +6,5 @@ dev = develop easy_install letsencrypt[dev,docs,testing]
[nosetests]
nocapture=1
cover-package=letsencrypt,acme
cover-package=letsencrypt,acme,letsencrypt_apache,letsencrypt_nginx
cover-erase=1

View file

@ -115,12 +115,12 @@ setup(
'jws = letsencrypt.acme.jose.jws:CLI.run',
],
'letsencrypt.plugins': [
'apache = letsencrypt.client.plugins.apache.configurator'
':ApacheConfigurator',
'nginx = letsencrypt.client.plugins.nginx.configurator'
':NginxConfigurator',
'standalone = letsencrypt.client.plugins.standalone.authenticator'
':StandaloneAuthenticator',
# to be moved to separate pypi packages
'apache = letsencrypt_apache.configurator:ApacheConfigurator',
'nginx = letsencrypt_nginx.configurator:NginxConfigurator',
],
},

View file

@ -27,4 +27,4 @@ commands =
basepython = python2.7
commands =
pip install -e .[dev]
pylint --rcfile=.pylintrc letsencrypt acme
pylint --rcfile=.pylintrc letsencrypt acme letsencrypt_apache letsencrypt_nginx