mirror of
https://github.com/certbot/certbot.git
synced 2026-08-01 02:44:21 +02:00
Support trailing periods in webroot-map
This commit is contained in:
+10
-3
@@ -1196,10 +1196,9 @@ def _plugins_parsing(helpful, plugins):
|
|||||||
"handle different domains; each domain will have the webroot path that"
|
"handle different domains; each domain will have the webroot path that"
|
||||||
" preceded it. For instance: `-w /var/www/example -d example.com -d "
|
" preceded it. For instance: `-w /var/www/example -d example.com -d "
|
||||||
"www.example.com -w /var/www/thing -d thing.net -d m.thing.net`")
|
"www.example.com -w /var/www/thing -d thing.net -d m.thing.net`")
|
||||||
parse_dict = lambda s: dict(json.loads(s))
|
|
||||||
# --webroot-map still has some awkward properties, so it is undocumented
|
# --webroot-map still has some awkward properties, so it is undocumented
|
||||||
helpful.add("webroot", "--webroot-map", default={}, type=parse_dict,
|
helpful.add("webroot", "--webroot-map", default={},
|
||||||
help=argparse.SUPPRESS)
|
action=WebrootMapProcessor, help=argparse.SUPPRESS)
|
||||||
|
|
||||||
|
|
||||||
class WebrootPathProcessor(argparse.Action): # pylint: disable=missing-docstring
|
class WebrootPathProcessor(argparse.Action): # pylint: disable=missing-docstring
|
||||||
@@ -1229,6 +1228,14 @@ class WebrootPathProcessor(argparse.Action): # pylint: disable=missing-docstring
|
|||||||
config.webroot_path.append(webroot)
|
config.webroot_path.append(webroot)
|
||||||
|
|
||||||
|
|
||||||
|
class WebrootMapProcessor(argparse.Action): # pylint: disable=missing-docstring
|
||||||
|
def __call__(self, parser, config, webroot_map_arg, option_string=None):
|
||||||
|
webroot_map = json.loads(webroot_map_arg)
|
||||||
|
for domain, webroot in webroot_map.iteritems():
|
||||||
|
domain = domain[:-1] if domain.endswith('.') else domain
|
||||||
|
config.webroot_map[domain] = webroot
|
||||||
|
|
||||||
|
|
||||||
class DomainFlagProcessor(argparse.Action): # pylint: disable=missing-docstring
|
class DomainFlagProcessor(argparse.Action): # pylint: disable=missing-docstring
|
||||||
def __call__(self, parser, config, domain_arg, option_string=None):
|
def __call__(self, parser, config, domain_arg, option_string=None):
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -379,9 +379,11 @@ class CLITest(unittest.TestCase): # pylint: disable=too-many-public-methods
|
|||||||
webroot_args = ['-d', 'stray.example.com'] + webroot_args
|
webroot_args = ['-d', 'stray.example.com'] + webroot_args
|
||||||
self.assertRaises(errors.Error, cli.prepare_and_parse_args, plugins, webroot_args)
|
self.assertRaises(errors.Error, cli.prepare_and_parse_args, plugins, webroot_args)
|
||||||
|
|
||||||
webroot_map_args = ['--webroot-map', '{"eg.com" : "/tmp"}']
|
webroot_map_args = ['--webroot-map',
|
||||||
|
'{"eg.com": "/tmp", "www.eg.com.": "/tmp"}']
|
||||||
namespace = cli.prepare_and_parse_args(plugins, webroot_map_args)
|
namespace = cli.prepare_and_parse_args(plugins, webroot_map_args)
|
||||||
self.assertEqual(namespace.webroot_map, {u"eg.com": u"/tmp"})
|
self.assertEqual(namespace.webroot_map,
|
||||||
|
{u"eg.com": u"/tmp", u"www.eg.com": u"/tmp"})
|
||||||
|
|
||||||
@mock.patch('letsencrypt.cli._suggest_donate')
|
@mock.patch('letsencrypt.cli._suggest_donate')
|
||||||
@mock.patch('letsencrypt.crypto_util.notAfter')
|
@mock.patch('letsencrypt.crypto_util.notAfter')
|
||||||
|
|||||||
Reference in New Issue
Block a user