mirror of
https://github.com/certbot/certbot.git
synced 2026-08-01 16:19:13 +02:00
When in doubt, use the config root
This commit is contained in:
@@ -597,7 +597,7 @@ class ApacheParser(object):
|
|||||||
.. todo:: Make sure that files are included
|
.. todo:: Make sure that files are included
|
||||||
|
|
||||||
"""
|
"""
|
||||||
default = self._set_user_config_file()
|
default = self.loc["root"]
|
||||||
|
|
||||||
temp = os.path.join(self.root, "ports.conf")
|
temp = os.path.join(self.root, "ports.conf")
|
||||||
if os.path.isfile(temp):
|
if os.path.isfile(temp):
|
||||||
@@ -618,23 +618,6 @@ class ApacheParser(object):
|
|||||||
|
|
||||||
raise errors.NoInstallationError("Could not find configuration root")
|
raise errors.NoInstallationError("Could not find configuration root")
|
||||||
|
|
||||||
def _set_user_config_file(self):
|
|
||||||
"""Set the appropriate user configuration file
|
|
||||||
|
|
||||||
.. todo:: This will have to be updated for other distros versions
|
|
||||||
|
|
||||||
:param str root: pathname which contains the user config
|
|
||||||
|
|
||||||
"""
|
|
||||||
# Basic check to see if httpd.conf exists and
|
|
||||||
# in hierarchy via direct include
|
|
||||||
# httpd.conf was very common as a user file in Apache 2.2
|
|
||||||
if (os.path.isfile(os.path.join(self.root, "httpd.conf")) and
|
|
||||||
self.find_dir("Include", "httpd.conf", self.loc["root"])):
|
|
||||||
return os.path.join(self.root, "httpd.conf")
|
|
||||||
else:
|
|
||||||
return os.path.join(self.root, "apache2.conf")
|
|
||||||
|
|
||||||
|
|
||||||
def case_i(string):
|
def case_i(string):
|
||||||
"""Returns case insensitive regex.
|
"""Returns case insensitive regex.
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ class BasicParserTest(util.ParserTest):
|
|||||||
def test_set_locations(self):
|
def test_set_locations(self):
|
||||||
with mock.patch("letsencrypt_apache.parser.os.path") as mock_path:
|
with mock.patch("letsencrypt_apache.parser.os.path") as mock_path:
|
||||||
|
|
||||||
mock_path.isfile.side_effect = [True, False, False]
|
mock_path.isfile.side_effect = [False, False]
|
||||||
|
|
||||||
# pylint: disable=protected-access
|
# pylint: disable=protected-access
|
||||||
results = self.parser._set_locations()
|
results = self.parser._set_locations()
|
||||||
@@ -114,16 +114,6 @@ class BasicParserTest(util.ParserTest):
|
|||||||
self.assertEqual(results["default"], results["listen"])
|
self.assertEqual(results["default"], results["listen"])
|
||||||
self.assertEqual(results["default"], results["name"])
|
self.assertEqual(results["default"], results["name"])
|
||||||
|
|
||||||
def test_set_user_config_file(self):
|
|
||||||
# pylint: disable=protected-access
|
|
||||||
path = os.path.join(self.parser.root, "httpd.conf")
|
|
||||||
open(path, 'w').close()
|
|
||||||
self.parser.add_dir(self.parser.loc["default"], "Include",
|
|
||||||
"httpd.conf")
|
|
||||||
|
|
||||||
self.assertEqual(
|
|
||||||
path, self.parser._set_user_config_file())
|
|
||||||
|
|
||||||
@mock.patch("letsencrypt_apache.parser.ApacheParser._get_runtime_cfg")
|
@mock.patch("letsencrypt_apache.parser.ApacheParser._get_runtime_cfg")
|
||||||
def test_update_runtime_variables(self, mock_cfg):
|
def test_update_runtime_variables(self, mock_cfg):
|
||||||
mock_cfg.return_value = (
|
mock_cfg.return_value = (
|
||||||
|
|||||||
Reference in New Issue
Block a user