mirror of
https://github.com/certbot/certbot.git
synced 2026-01-24 19:22:07 +03:00
Support trailing periods in webroot-map
This commit is contained in:
@@ -1196,10 +1196,9 @@ def _plugins_parsing(helpful, plugins):
|
||||
"handle different domains; each domain will have the webroot path that"
|
||||
" 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`")
|
||||
parse_dict = lambda s: dict(json.loads(s))
|
||||
# --webroot-map still has some awkward properties, so it is undocumented
|
||||
helpful.add("webroot", "--webroot-map", default={}, type=parse_dict,
|
||||
help=argparse.SUPPRESS)
|
||||
helpful.add("webroot", "--webroot-map", default={},
|
||||
action=WebrootMapProcessor, help=argparse.SUPPRESS)
|
||||
|
||||
|
||||
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)
|
||||
|
||||
|
||||
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
|
||||
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
|
||||
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)
|
||||
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.crypto_util.notAfter')
|
||||
|
||||
Reference in New Issue
Block a user