NamespaceConfig.simple_http_port.

This commit is contained in:
Jakub Warmuz
2015-09-26 17:43:59 +00:00
parent daa459f277
commit a874654e34
3 changed files with 22 additions and 2 deletions
+18
View File
@@ -4,6 +4,8 @@ import urlparse
import zope.interface import zope.interface
from acme import challenges
from letsencrypt import constants from letsencrypt import constants
from letsencrypt import interfaces from letsencrypt import interfaces
@@ -34,6 +36,13 @@ class NamespaceConfig(object):
def __init__(self, namespace): def __init__(self, namespace):
self.namespace = namespace self.namespace = namespace
# XXX: breaks renewer in some bizarre way
#if self.no_simple_http_tls and (
# self.simple_http_port == self.dvsni_port):
# raise errors.Error(
# "Trying to run SimpleHTTP non-TLS and DVSNI "
# "on the same port ({0})".format(self.dvsni_port))
def __getattr__(self, name): def __getattr__(self, name):
return getattr(self.namespace, name) return getattr(self.namespace, name)
@@ -69,6 +78,15 @@ class NamespaceConfig(object):
return os.path.join( return os.path.join(
self.namespace.work_dir, constants.TEMP_CHECKPOINT_DIR) self.namespace.work_dir, constants.TEMP_CHECKPOINT_DIR)
@property
def simple_http_port(self): # pylint: disable=missing-docstring
if self.namespace.simple_http_port is not None:
return self.namespace.simple_http_port
if self.no_simple_http_tls:
return challenges.SimpleHTTPResponse.PORT
else:
return challenges.SimpleHTTPResponse.TLS_PORT
class RenewerConfiguration(object): class RenewerConfiguration(object):
"""Configuration wrapper for renewer.""" """Configuration wrapper for renewer."""
+2 -1
View File
@@ -11,7 +11,8 @@ class NamespaceConfigTest(unittest.TestCase):
def setUp(self): def setUp(self):
self.namespace = mock.MagicMock( self.namespace = mock.MagicMock(
config_dir='/tmp/config', work_dir='/tmp/foo', foo='bar', config_dir='/tmp/config', work_dir='/tmp/foo', foo='bar',
server='https://acme-server.org:443/new') server='https://acme-server.org:443/new',
dvsni_port='1234', simple_http_port='4321')
from letsencrypt.configuration import NamespaceConfig from letsencrypt.configuration import NamespaceConfig
self.config = NamespaceConfig(self.namespace) self.config = NamespaceConfig(self.namespace)
+2 -1
View File
@@ -39,7 +39,8 @@ class BaseRenewableCertTest(unittest.TestCase):
self.tempdir = tempfile.mkdtemp() self.tempdir = tempfile.mkdtemp()
self.cli_config = configuration.RenewerConfiguration( self.cli_config = configuration.RenewerConfiguration(
namespace=mock.MagicMock(config_dir=self.tempdir)) namespace=mock.MagicMock(
config_dir=self.tempdir, no_simple_http_tls=False))
# TODO: maybe provide RenewerConfiguration.make_dirs? # TODO: maybe provide RenewerConfiguration.make_dirs?
os.makedirs(os.path.join(self.tempdir, "live", "example.org")) os.makedirs(os.path.join(self.tempdir, "live", "example.org"))
os.makedirs(os.path.join(self.tempdir, "archive", "example.org")) os.makedirs(os.path.join(self.tempdir, "archive", "example.org"))