mirror of
https://github.com/certbot/certbot.git
synced 2026-07-31 02:14:33 +02:00
Merge branch 'master' of github.com:certbot/certbot into max_retries_exceeded
This commit is contained in:
@@ -87,8 +87,6 @@ class NginxConfigurator(common.Plugin):
|
|||||||
|
|
||||||
description = "Nginx Web Server plugin - Alpha"
|
description = "Nginx Web Server plugin - Alpha"
|
||||||
|
|
||||||
hidden = True
|
|
||||||
|
|
||||||
DEFAULT_LISTEN_PORT = '80'
|
DEFAULT_LISTEN_PORT = '80'
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
|||||||
@@ -108,11 +108,19 @@ def choose_plugin(prepared, question):
|
|||||||
opts = [plugin_ep.description_with_name +
|
opts = [plugin_ep.description_with_name +
|
||||||
(" [Misconfigured]" if plugin_ep.misconfigured else "")
|
(" [Misconfigured]" if plugin_ep.misconfigured else "")
|
||||||
for plugin_ep in prepared]
|
for plugin_ep in prepared]
|
||||||
|
names = set(plugin_ep.name for plugin_ep in prepared)
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
disp = z_util(interfaces.IDisplay)
|
disp = z_util(interfaces.IDisplay)
|
||||||
code, index = disp.menu(
|
if "CERTBOT_AUTO" in os.environ and names == set(("apache", "nginx")):
|
||||||
question, opts, force_interactive=True)
|
# 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:
|
if code == display_util.OK:
|
||||||
plugin_ep = prepared[index]
|
plugin_ep = prepared[index]
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
"""Tests for letsencrypt.plugins.selection"""
|
"""Tests for letsencrypt.plugins.selection"""
|
||||||
|
import os
|
||||||
import sys
|
import sys
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
@@ -115,6 +116,7 @@ class ChoosePluginTest(unittest.TestCase):
|
|||||||
False))
|
False))
|
||||||
self.mock_apache = mock.Mock(
|
self.mock_apache = mock.Mock(
|
||||||
description_with_name="a", misconfigured=True)
|
description_with_name="a", misconfigured=True)
|
||||||
|
self.mock_apache.name = "apache"
|
||||||
self.mock_stand = mock.Mock(
|
self.mock_stand = mock.Mock(
|
||||||
description_with_name="s", misconfigured=False)
|
description_with_name="s", misconfigured=False)
|
||||||
self.mock_stand.init().more_info.return_value = "standalone"
|
self.mock_stand.init().more_info.return_value = "standalone"
|
||||||
@@ -146,3 +148,26 @@ class ChoosePluginTest(unittest.TestCase):
|
|||||||
def test_no_choice(self, mock_util):
|
def test_no_choice(self, mock_util):
|
||||||
mock_util().menu.return_value = (display_util.CANCEL, 0)
|
mock_util().menu.return_value = (display_util.CANCEL, 0)
|
||||||
self.assertTrue(self._call() is None)
|
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
|
||||||
|
|||||||
Reference in New Issue
Block a user