mirror of
https://github.com/certbot/certbot.git
synced 2026-08-01 16:19:13 +02:00
Merge pull request #1547 from letsencrypt/cli
Implement --webroot and --manual
This commit is contained in:
+11
-2
@@ -69,6 +69,7 @@ USAGE = SHORT_USAGE + """Choice of server plugins for obtaining and installing c
|
|||||||
%s
|
%s
|
||||||
--standalone Run a standalone webserver for authentication
|
--standalone Run a standalone webserver for authentication
|
||||||
%s
|
%s
|
||||||
|
--webroot Place files in a server's webroot folder for authentication
|
||||||
|
|
||||||
OR use different servers to obtain (authenticate) the cert and then install it:
|
OR use different servers to obtain (authenticate) the cert and then install it:
|
||||||
|
|
||||||
@@ -80,7 +81,7 @@ More detailed help:
|
|||||||
the available topics are:
|
the available topics are:
|
||||||
|
|
||||||
all, automation, paths, security, testing, or any of the subcommands or
|
all, automation, paths, security, testing, or any of the subcommands or
|
||||||
plugins (certonly, install, nginx, apache, standalone, etc)
|
plugins (certonly, install, nginx, apache, standalone, webroot, etc)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
@@ -380,7 +381,7 @@ def diagnose_configurator_problem(cfg_type, requested, plugins):
|
|||||||
raise errors.PluginSelectionError(msg)
|
raise errors.PluginSelectionError(msg)
|
||||||
|
|
||||||
|
|
||||||
def choose_configurator_plugins(args, config, plugins, verb):
|
def choose_configurator_plugins(args, config, plugins, verb): # pylint: disable=too-many-branches
|
||||||
"""
|
"""
|
||||||
Figure out which configurator we're going to use
|
Figure out which configurator we're going to use
|
||||||
|
|
||||||
@@ -408,6 +409,10 @@ def choose_configurator_plugins(args, config, plugins, verb):
|
|||||||
req_auth = set_configurator(req_auth, "apache")
|
req_auth = set_configurator(req_auth, "apache")
|
||||||
if args.standalone:
|
if args.standalone:
|
||||||
req_auth = set_configurator(req_auth, "standalone")
|
req_auth = set_configurator(req_auth, "standalone")
|
||||||
|
if args.webroot:
|
||||||
|
req_auth = set_configurator(req_auth, "webroot")
|
||||||
|
if args.manual:
|
||||||
|
req_auth = set_configurator(req_auth, "manual")
|
||||||
logger.debug("Requested authenticator %s and installer %s", req_auth, req_inst)
|
logger.debug("Requested authenticator %s and installer %s", req_auth, req_inst)
|
||||||
|
|
||||||
# Try to meet the user's request and/or ask them to pick plugins
|
# Try to meet the user's request and/or ask them to pick plugins
|
||||||
@@ -1026,6 +1031,10 @@ def _plugins_parsing(helpful, plugins):
|
|||||||
help="Obtain and install certs using Nginx")
|
help="Obtain and install certs using Nginx")
|
||||||
helpful.add("plugins", "--standalone", action="store_true",
|
helpful.add("plugins", "--standalone", action="store_true",
|
||||||
help='Obtain certs using a "standalone" webserver.')
|
help='Obtain certs using a "standalone" webserver.')
|
||||||
|
helpful.add("plugins", "--manual", action="store_true",
|
||||||
|
help='Provide laborious manual instructions for obtaining a cert')
|
||||||
|
helpful.add("plugins", "--webroot", action="store_true",
|
||||||
|
help='Obtain certs by placing files in a webroot directory.')
|
||||||
|
|
||||||
# things should not be reorder past/pre this comment:
|
# things should not be reorder past/pre this comment:
|
||||||
# plugins_group should be displayed in --help before plugin
|
# plugins_group should be displayed in --help before plugin
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ from letsencrypt import errors
|
|||||||
from letsencrypt import le_util
|
from letsencrypt import le_util
|
||||||
|
|
||||||
from letsencrypt.plugins import disco
|
from letsencrypt.plugins import disco
|
||||||
|
from letsencrypt.plugins import manual
|
||||||
|
|
||||||
from letsencrypt.tests import renewer_test
|
from letsencrypt.tests import renewer_test
|
||||||
from letsencrypt.tests import test_util
|
from letsencrypt.tests import test_util
|
||||||
@@ -201,6 +202,16 @@ class CLITest(unittest.TestCase): # pylint: disable=too-many-public-methods
|
|||||||
self.assertTrue("Could not find configuration root" in ret)
|
self.assertTrue("Could not find configuration root" in ret)
|
||||||
self.assertTrue("NoInstallationError" in ret)
|
self.assertTrue("NoInstallationError" in ret)
|
||||||
|
|
||||||
|
args = ["certonly", "--webroot"]
|
||||||
|
ret, _, _, _ = self._call(args)
|
||||||
|
self.assertTrue("--webroot-path must be set" in ret)
|
||||||
|
|
||||||
|
with mock.patch("letsencrypt.cli._init_le_client") as mock_init:
|
||||||
|
with mock.patch("letsencrypt.cli._auth_from_domains"):
|
||||||
|
self._call(["certonly", "--manual", "-d", "foo.bar"])
|
||||||
|
auth = mock_init.call_args[0][2]
|
||||||
|
self.assertTrue(isinstance(auth, manual.Authenticator))
|
||||||
|
|
||||||
with MockedVerb("certonly") as mock_certonly:
|
with MockedVerb("certonly") as mock_certonly:
|
||||||
self._call(["auth", "--standalone"])
|
self._call(["auth", "--standalone"])
|
||||||
self.assertEqual(1, mock_certonly.call_count)
|
self.assertEqual(1, mock_certonly.call_count)
|
||||||
|
|||||||
Reference in New Issue
Block a user