Remove the need for extra processing to support --csr + --webroot

This commit is contained in:
Brad Warren
2016-04-01 17:07:54 -07:00
parent 82efffdf62
commit 1acd50a0ce
3 changed files with 11 additions and 15 deletions
+4 -10
View File
@@ -302,10 +302,7 @@ class HelpfulArgumentParser(object):
return parsed_args
def handle_csr(self, parsed_args):
"""
Process a --csr flag. This needs to happen early enough that the
webroot plugin can know about the calls to add_domains.
"""
"""Process a --csr flag."""
if parsed_args.verb != "certonly":
raise errors.Error("Currently, a CSR file may only be specified "
"when obtaining a new or replacement "
@@ -327,9 +324,6 @@ class HelpfulArgumentParser(object):
logger.debug("PEM CSR parse error %s", traceback.format_exc())
raise errors.Error("Failed to parse CSR file: {0}".format(parsed_args.csr[0]))
for d in domains:
add_domains(parsed_args, d)
if not domains:
# TODO: add CN to domains instead:
raise errors.Error(
@@ -337,11 +331,11 @@ class HelpfulArgumentParser(object):
% parsed_args.csr[0])
parsed_args.actual_csr = (csr, typ)
csr_domains, config_domains = set(domains), set(parsed_args.domains)
if csr_domains != config_domains:
# If CSR domains are not a superset of the domains provided by the CLI
if set(parsed_args.domains) - set(domains):
raise errors.ConfigurationError(
"Inconsistent domain requests:\nFrom the CSR: {0}\nFrom command line/config: {1}"
.format(", ".join(csr_domains), ", ".join(config_domains)))
.format(", ".join(domains), ", ".join(parsed_args.domains)))
def determine_verb(self):
+6
View File
@@ -67,7 +67,13 @@ to serve all files under specified web root ({0})."""
pass
def perform(self, achalls): # pylint: disable=missing-docstring
if self.conf("path"):
webroot_path = self.conf("path")[-1]
for achall in achalls:
self.conf("map").setdefault(achall.domain, webroot_path)
self._create_challenge_dirs()
return [self._perform_single(achall) for achall in achalls]
def _create_challenge_dirs(self):
+1 -5
View File
@@ -135,8 +135,7 @@ class ClientTest(unittest.TestCase):
# FIXME move parts of this to test_cli.py...
@mock.patch("letsencrypt.client.logger")
@mock.patch("letsencrypt.cli.add_domains")
def test_obtain_certificate_from_csr(self, mock_add_domains, mock_logger):
def test_obtain_certificate_from_csr(self, mock_logger):
self._mock_obtain_certificate()
from letsencrypt import cli
test_csr = le_util.CSR(form="der", file=None, data=CSR_SAN)
@@ -150,9 +149,6 @@ class ClientTest(unittest.TestCase):
mock_parser = mock.MagicMock(cli.HelpfulArgumentParser)
cli.HelpfulArgumentParser.handle_csr(mock_parser, mock_parsed_args)
# make sure cli processing occurred
cli_processed = (call[0][1] for call in mock_add_domains.call_args_list)
self.assertEqual(set(cli_processed), set(("example.com", "www.example.com")))
# Now provoke an inconsistent domains error...
mock_parsed_args.domains.append("hippopotamus.io")
self.assertRaises(errors.ConfigurationError,