mirror of
https://github.com/certbot/certbot.git
synced 2026-06-03 22:08:07 -04:00
Merge branch 'master' of github.com:certbot/certbot into max_retries_exceeded
This commit is contained in:
commit
d49d7c57ea
3 changed files with 35 additions and 4 deletions
|
|
@ -87,8 +87,6 @@ class NginxConfigurator(common.Plugin):
|
|||
|
||||
description = "Nginx Web Server plugin - Alpha"
|
||||
|
||||
hidden = True
|
||||
|
||||
DEFAULT_LISTEN_PORT = '80'
|
||||
|
||||
@classmethod
|
||||
|
|
|
|||
|
|
@ -108,11 +108,19 @@ def choose_plugin(prepared, question):
|
|||
opts = [plugin_ep.description_with_name +
|
||||
(" [Misconfigured]" if plugin_ep.misconfigured else "")
|
||||
for plugin_ep in prepared]
|
||||
names = set(plugin_ep.name for plugin_ep in prepared)
|
||||
|
||||
while True:
|
||||
disp = z_util(interfaces.IDisplay)
|
||||
code, index = disp.menu(
|
||||
question, opts, force_interactive=True)
|
||||
if "CERTBOT_AUTO" in os.environ and names == set(("apache", "nginx")):
|
||||
# The possibility of being offered exactly apache and nginx here
|
||||
# is new interactivity brought by https://github.com/certbot/certbot/issues/4079,
|
||||
# so set apache as a default for those kinds of non-interactive use
|
||||
# (the user will get a warning to set --non-interactive or --force-interactive)
|
||||
apache_idx = [n for n, p in enumerate(prepared) if p.name == "apache"][0]
|
||||
code, index = disp.menu(question, opts, default=apache_idx)
|
||||
else:
|
||||
code, index = disp.menu(question, opts, force_interactive=True)
|
||||
|
||||
if code == display_util.OK:
|
||||
plugin_ep = prepared[index]
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
"""Tests for letsencrypt.plugins.selection"""
|
||||
import os
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
|
|
@ -115,6 +116,7 @@ class ChoosePluginTest(unittest.TestCase):
|
|||
False))
|
||||
self.mock_apache = mock.Mock(
|
||||
description_with_name="a", misconfigured=True)
|
||||
self.mock_apache.name = "apache"
|
||||
self.mock_stand = mock.Mock(
|
||||
description_with_name="s", misconfigured=False)
|
||||
self.mock_stand.init().more_info.return_value = "standalone"
|
||||
|
|
@ -146,3 +148,26 @@ class ChoosePluginTest(unittest.TestCase):
|
|||
def test_no_choice(self, mock_util):
|
||||
mock_util().menu.return_value = (display_util.CANCEL, 0)
|
||||
self.assertTrue(self._call() is None)
|
||||
|
||||
@test_util.patch_get_utility("certbot.plugins.selection.z_util")
|
||||
def test_new_interaction_avoidance(self, mock_util):
|
||||
mock_nginx = mock.Mock(
|
||||
description_with_name="n", misconfigured=False)
|
||||
mock_nginx.init().more_info.return_value = "nginx plugin"
|
||||
mock_nginx.name = "nginx"
|
||||
self.plugins[1] = mock_nginx
|
||||
mock_util().menu.return_value = (display_util.CANCEL, 0)
|
||||
|
||||
unset_cb_auto = os.environ.get("CERTBOT_AUTO") is None
|
||||
if unset_cb_auto:
|
||||
os.environ["CERTBOT_AUTO"] = "foo"
|
||||
try:
|
||||
self._call()
|
||||
finally:
|
||||
if unset_cb_auto:
|
||||
del os.environ["CERTBOT_AUTO"]
|
||||
|
||||
self.assertTrue("default" in mock_util().menu.call_args[1])
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main() # pragma: no cover
|
||||
|
|
|
|||
Loading…
Reference in a new issue