From 3a29e55bf7cfb89d5da4c2cec458be46d1f2bee2 Mon Sep 17 00:00:00 2001 From: Jakub Warmuz Date: Wed, 10 Dec 2014 14:31:43 +0100 Subject: [PATCH] Accept names in VH.__init__ --- letsencrypt/client/apache_configurator.py | 8 +--- .../client/tests/apache_configurator_test.py | 38 +++++++++---------- 2 files changed, 20 insertions(+), 26 deletions(-) diff --git a/letsencrypt/client/apache_configurator.py b/letsencrypt/client/apache_configurator.py index 9f2a3c269..cbaa97b87 100644 --- a/letsencrypt/client/apache_configurator.py +++ b/letsencrypt/client/apache_configurator.py @@ -57,19 +57,15 @@ class VH(object): """ - def __init__(self, filep, path, addrs, ssl, enabled): + def __init__(self, filep, path, addrs, ssl, enabled, names=None): """Initialize a VH.""" self.filep = filep self.path = path self.addrs = addrs - self.names = [] + self.names = [] if names is None else names self.ssl = ssl self.enabled = enabled - def set_names(self, list_of_names): - """Set names.""" - self.names = list_of_names - def add_name(self, name): """Add name to vhost.""" self.names.append(name) diff --git a/letsencrypt/client/tests/apache_configurator_test.py b/letsencrypt/client/tests/apache_configurator_test.py index bc8fa3337..91e7945f7 100644 --- a/letsencrypt/client/tests/apache_configurator_test.py +++ b/letsencrypt/client/tests/apache_configurator_test.py @@ -64,26 +64,24 @@ class TwoVhost80Test(unittest.TestCase): prefix = os.path.join( self.temp_dir, "two_vhost_80/apache2/sites-available") aug_pre = "/files" + prefix - self.vh_truth = [] - self.vh_truth.append(apache_configurator.VH( - os.path.join(prefix, "encryption-example.conf"), - os.path.join(aug_pre, "encryption-example.conf/VirtualHost"), - ["*:80"], False, True)) - self.vh_truth.append(apache_configurator.VH( - os.path.join(prefix, "default-ssl.conf"), - os.path.join(aug_pre, "default-ssl.conf/IfModule/VirtualHost"), - ["_default_:443"], True, False)) - self.vh_truth.append(apache_configurator.VH( - os.path.join(prefix, "000-default.conf"), - os.path.join(aug_pre, "000-default.conf/VirtualHost"), - ["*:80"], False, True)) - self.vh_truth.append(apache_configurator.VH( - os.path.join(prefix, "letsencrypt.conf"), - os.path.join(aug_pre, "letsencrypt.conf/VirtualHost"), - ["*:80"], False, True)) - self.vh_truth[0].add_name("encryption-example.demo") - self.vh_truth[2].add_name("ip-172-30-0-17") - self.vh_truth[3].add_name("letsencrypt.demo") + self.vh_truth = [ + apache_configurator.VH( + os.path.join(prefix, "encryption-example.conf"), + os.path.join(aug_pre, "encryption-example.conf/VirtualHost"), + ["*:80"], False, True, ["encryption-example.demo"]), + apache_configurator.VH( + os.path.join(prefix, "default-ssl.conf"), + os.path.join(aug_pre, "default-ssl.conf/IfModule/VirtualHost"), + ["_default_:443"], True, False), + apache_configurator.VH( + os.path.join(prefix, "000-default.conf"), + os.path.join(aug_pre, "000-default.conf/VirtualHost"), + ["*:80"], False, True, ["ip-172-30-0-17"]), + apache_configurator.VH( + os.path.join(prefix, "letsencrypt.conf"), + os.path.join(aug_pre, "letsencrypt.conf/VirtualHost"), + ["*:80"], False, True, ["letsencrypt.demo"]), + ] def tearDown(self): shutil.rmtree(self.temp_dir)