Added None check and according test

This commit is contained in:
Joona Hoikkala 2016-08-10 00:25:35 +03:00
parent c29e8c3332
commit f4948855f0
No known key found for this signature in database
GPG key ID: C14AAE0F5ADCB854
2 changed files with 11 additions and 1 deletions

View file

@ -538,6 +538,9 @@ class ApacheConfigurator(augeas_configurator.AugeasConfigurator):
is_ssl = True
filename = get_file_path(self.aug.get("/augeas/files%s/path" % get_file_path(path)))
if filename is None:
return None
if self.conf("handle-sites"):
is_enabled = self.is_site_enabled(filename)
else:
@ -1802,7 +1805,10 @@ def get_file_path(vhost_path):
"""
# Strip off /files/
avail_fp = vhost_path[7:].split("/")
try:
avail_fp = vhost_path[7:].split("/")
except TypeError:
return None
last_good = ""
# Loop through the path parts and validate after every addition
for p in avail_fp:

View file

@ -125,6 +125,10 @@ class MultipleVhostsTest(util.ApacheTest):
self.assertTrue("google.com" in names)
self.assertTrue("certbot.demo" in names)
def test_get_bad_path(self):
from certbot_apache.configurator import get_file_path
self.assertEqual(get_file_path(None), None)
def test_bad_servername_alias(self):
ssl_vh1 = obj.VirtualHost(
"fp1", "ap1", set([obj.Addr(("*", "443"))]),