mirror of
https://github.com/certbot/certbot.git
synced 2026-08-01 08:08:00 +02:00
Fix ApacheConf init and mock correct test object
This commit is contained in:
@@ -126,16 +126,12 @@ class ApacheConfigurator(augeas_configurator.AugeasConfigurator):
|
|||||||
"""
|
"""
|
||||||
def __init__(self, server_root=CONFIG.SERVER_ROOT, dir=None, version=None):
|
def __init__(self, server_root=CONFIG.SERVER_ROOT, dir=None, version=None):
|
||||||
"""Initialize an Apache Configurator."""
|
"""Initialize an Apache Configurator."""
|
||||||
# The top 3 are the only ones that need to be
|
if not dir:
|
||||||
# defined for Augeas Configurator
|
dir = {"backup": CONFIG.BACKUP_DIR,
|
||||||
if dir:
|
"temp": CONFIG.TEMP_CHECKPOINT_DIR,
|
||||||
self.dir = dir
|
"progress": CONFIG.IN_PROGRESS_DIR,
|
||||||
else:
|
"config": CONFIG.CONFIG_DIR,
|
||||||
self.dir = {"backup": CONFIG.BACKUP_DIR,
|
"work": CONFIG.WORK_DIR}
|
||||||
"temp": CONFIG.TEMP_CHECKPOINT_DIR,
|
|
||||||
"progress": CONFIG.IN_PROGRESS_DIR,
|
|
||||||
"config": CONFIG.CONFIG_DIR,
|
|
||||||
"work": CONFIG.WORK_DIR}
|
|
||||||
|
|
||||||
super(ApacheConfigurator, self).__init__(dir)
|
super(ApacheConfigurator, self).__init__(dir)
|
||||||
|
|
||||||
@@ -1558,6 +1554,8 @@ def check_ssl_loaded():
|
|||||||
logger.error("This may be caused by an Apache Configuration Error")
|
logger.error("This may be caused by an Apache Configuration Error")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
print "%%%%%%%% PROC:", proc
|
||||||
|
|
||||||
if "ssl_module" in proc:
|
if "ssl_module" in proc:
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|||||||
@@ -48,12 +48,12 @@ class TwoVhost80(unittest.TestCase):
|
|||||||
"""Standard two http vhosts that are well configured."""
|
"""Standard two http vhosts that are well configured."""
|
||||||
|
|
||||||
@mock.patch("letsencrypt.client.apache_configurator."
|
@mock.patch("letsencrypt.client.apache_configurator."
|
||||||
"subprocess.Popen.communicate")
|
"subprocess.Popen")
|
||||||
def setUp(self, mock_subprocess):
|
def setUp(self, mock_Popen):
|
||||||
"""Run before each and every tests."""
|
"""Run before each and every tests."""
|
||||||
|
|
||||||
# This just states that the ssl module is already loaded
|
# This just states that the ssl module is already loaded
|
||||||
mock_subprocess.return_value = ("ssl_module", "")
|
mock_Popen.return_value = my_Popen()
|
||||||
|
|
||||||
# Final slash is currently important
|
# Final slash is currently important
|
||||||
self.config_path = os.path.join(TEMP_DIR, "two_vhost_80/apache2/")
|
self.config_path = os.path.join(TEMP_DIR, "two_vhost_80/apache2/")
|
||||||
@@ -258,5 +258,11 @@ def debug_file(filepath):
|
|||||||
with open(filepath, 'r')as file_d:
|
with open(filepath, 'r')as file_d:
|
||||||
print file_d.read()
|
print file_d.read()
|
||||||
|
|
||||||
|
|
||||||
|
# I am sure there is a cleaner way to do this... but it works
|
||||||
|
class my_Popen(object):
|
||||||
|
def communicate(self):
|
||||||
|
return "ssl_module", ""
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|||||||
Reference in New Issue
Block a user