diff options
author | Joona Hoikkala <joona@kuori.org> | 2015-12-11 13:41:21 +0300 |
---|---|---|
committer | Joona Hoikkala <joona@kuori.org> | 2015-12-11 13:41:21 +0300 |
commit | 4d31a8cb390778a35207bb0133b21a46c91de2dc (patch) | |
tree | 8529a9003959b36fbce409d64c922ea484ced23a /letsencrypt-apache | |
parent | 48b1240451b3dafd9228baa400633317df784654 (diff) |
Sane error message in case user tries to use apache-handle-sites functionality in non-supported environment.
Diffstat (limited to 'letsencrypt-apache')
-rw-r--r-- | letsencrypt-apache/letsencrypt_apache/configurator.py | 6 | ||||
-rw-r--r-- | letsencrypt-apache/letsencrypt_apache/tests/configurator_test.py | 4 |
2 files changed, 10 insertions, 0 deletions
diff --git a/letsencrypt-apache/letsencrypt_apache/configurator.py b/letsencrypt-apache/letsencrypt_apache/configurator.py index 3e6881739..d67e7bc18 100644 --- a/letsencrypt-apache/letsencrypt_apache/configurator.py +++ b/letsencrypt-apache/letsencrypt_apache/configurator.py @@ -1119,6 +1119,12 @@ class ApacheConfigurator(augeas_configurator.AugeasConfigurator): """ enabled_dir = os.path.join(self.parser.root, "sites-enabled") + if not os.path.isdir(enabled_dir): + error_msg = ("Directory '{0}' does not exist. Please ensure " + "that the values for --apache-handle-sites and " + "--apache-server-root are correct for your " + "environment.".format(enabled_dir)) + raise errors.ConfigurationError(error_msg) for entry in os.listdir(enabled_dir): try: if filecmp.cmp(avail_fp, os.path.join(enabled_dir, entry)): diff --git a/letsencrypt-apache/letsencrypt_apache/tests/configurator_test.py b/letsencrypt-apache/letsencrypt_apache/tests/configurator_test.py index e16dff173..064111d4a 100644 --- a/letsencrypt-apache/letsencrypt_apache/tests/configurator_test.py +++ b/letsencrypt-apache/letsencrypt_apache/tests/configurator_test.py @@ -219,6 +219,10 @@ class TwoVhost80Test(util.ApacheTest): self.assertFalse(self.config.is_site_enabled(self.vh_truth[1].filep)) self.assertTrue(self.config.is_site_enabled(self.vh_truth[2].filep)) self.assertTrue(self.config.is_site_enabled(self.vh_truth[3].filep)) + with mock.patch("os.path.isdir") as mock_isdir: + mock_isdir.return_value = False + with (self.assertRaises(errors.ConfigurationError)): + self.config.is_site_enabled("irrelevant") @mock.patch("letsencrypt.le_util.run_script") @mock.patch("letsencrypt.le_util.exe_exists") |