mirror of
https://github.com/certbot/certbot.git
synced 2026-07-30 16:14:44 +02:00
add webroot_path parsing functions to webroot.py
This commit is contained in:
@@ -57,8 +57,6 @@ to serve all files under specified web root ({0})."""
|
|||||||
"--webroot-path and --domains, or --webroot-map. Run with "
|
"--webroot-path and --domains, or --webroot-map. Run with "
|
||||||
" --help webroot for examples.")
|
" --help webroot for examples.")
|
||||||
for name, path in path_map.items():
|
for name, path in path_map.items():
|
||||||
if not os.path.isdir(path):
|
|
||||||
raise errors.PluginError(path + " does not exist or is not a directory")
|
|
||||||
self.full_roots[name] = os.path.join(path, challenges.HTTP01.URI_ROOT_PATH)
|
self.full_roots[name] = os.path.join(path, challenges.HTTP01.URI_ROOT_PATH)
|
||||||
|
|
||||||
logger.debug("Creating root challenges validation dir at %s",
|
logger.debug("Creating root challenges validation dir at %s",
|
||||||
@@ -157,3 +155,31 @@ to serve all files under specified web root ({0})."""
|
|||||||
root_path)
|
root_path)
|
||||||
else:
|
else:
|
||||||
raise
|
raise
|
||||||
|
|
||||||
|
|
||||||
|
def _match_webroot_with_domains(args_or_config):
|
||||||
|
"""Applies the most recent webroot path to all unmatched domains.
|
||||||
|
|
||||||
|
:param args_or_config: parsed command line arguments
|
||||||
|
:type args_or_config: argparse.Namespace or
|
||||||
|
configuration.NamespaceConfig
|
||||||
|
|
||||||
|
"""
|
||||||
|
webroot_path = args_or_config.webroot_path[-1]
|
||||||
|
for domain in args_or_config.domains:
|
||||||
|
args_or_config.webroot_map.set_default(domain, webroot_path)
|
||||||
|
|
||||||
|
|
||||||
|
def _validate_webroot(webroot_path):
|
||||||
|
"""Validates and returns the absolute path of webroot_path.
|
||||||
|
|
||||||
|
:param str webroot_path: path to the webroot directory
|
||||||
|
|
||||||
|
:returns: absolute path of webroot_path
|
||||||
|
:rtype: str
|
||||||
|
|
||||||
|
"""
|
||||||
|
if not os.path.isdir(webroot_path):
|
||||||
|
raise errors.PluginError(webroot_path + " does not exist or is not a directory")
|
||||||
|
|
||||||
|
return os.path.abspath(webroot_path)
|
||||||
|
|||||||
@@ -55,11 +55,6 @@ class AuthenticatorTest(unittest.TestCase):
|
|||||||
self.auth.add_parser_arguments(add)
|
self.auth.add_parser_arguments(add)
|
||||||
self.assertEqual(0, add.call_count) # args moved to cli.py!
|
self.assertEqual(0, add.call_count) # args moved to cli.py!
|
||||||
|
|
||||||
def test_prepare_bad_root(self):
|
|
||||||
self.config.webroot_path = os.path.join(self.path, "null")
|
|
||||||
self.config.webroot_map["thing.com"] = self.config.webroot_path
|
|
||||||
self.assertRaises(errors.PluginError, self.auth.prepare)
|
|
||||||
|
|
||||||
def test_prepare_missing_root(self):
|
def test_prepare_missing_root(self):
|
||||||
self.config.webroot_path = None
|
self.config.webroot_path = None
|
||||||
self.config.webroot_map = {}
|
self.config.webroot_map = {}
|
||||||
|
|||||||
Reference in New Issue
Block a user