mirror of
https://github.com/certbot/certbot.git
synced 2026-08-01 19:02:52 +02:00
Merge pull request #2669 from letsencrypt/no-configurator-conflict
Fix set_by_cli and configurator
This commit is contained in:
+1
-1
@@ -168,7 +168,7 @@ def set_configurator(previously, now):
|
|||||||
:param str previously: previously identified request for the installer/authenticator
|
:param str previously: previously identified request for the installer/authenticator
|
||||||
:param str requested: the request currently being processed
|
:param str requested: the request currently being processed
|
||||||
"""
|
"""
|
||||||
if now is None:
|
if not now:
|
||||||
# we're not actually setting anything
|
# we're not actually setting anything
|
||||||
return previously
|
return previously
|
||||||
if previously:
|
if previously:
|
||||||
|
|||||||
@@ -52,6 +52,9 @@ class CLITest(unittest.TestCase): # pylint: disable=too-many-public-methods
|
|||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
shutil.rmtree(self.tmp_dir)
|
shutil.rmtree(self.tmp_dir)
|
||||||
|
# Reset globals in cli
|
||||||
|
# pylint: disable=protected-access
|
||||||
|
cli._parser = cli._set_by_cli.detector = None
|
||||||
|
|
||||||
def _call(self, args):
|
def _call(self, args):
|
||||||
"Run the cli with output streams and actual client mocked out"
|
"Run the cli with output streams and actual client mocked out"
|
||||||
@@ -135,7 +138,6 @@ class CLITest(unittest.TestCase): # pylint: disable=too-many-public-methods
|
|||||||
out = self._help_output(['-h'])
|
out = self._help_output(['-h'])
|
||||||
self.assertTrue(cli.usage_strings(plugins)[0] in out)
|
self.assertTrue(cli.usage_strings(plugins)[0] in out)
|
||||||
|
|
||||||
|
|
||||||
def _cli_missing_flag(self, args, message):
|
def _cli_missing_flag(self, args, message):
|
||||||
"Ensure that a particular error raises a missing cli flag error containing message"
|
"Ensure that a particular error raises a missing cli flag error containing message"
|
||||||
exc = None
|
exc = None
|
||||||
@@ -682,8 +684,8 @@ class CLITest(unittest.TestCase): # pylint: disable=too-many-public-methods
|
|||||||
with open(os.path.join(renewer_configs_dir, 'test.conf'), 'w') as f:
|
with open(os.path.join(renewer_configs_dir, 'test.conf'), 'w') as f:
|
||||||
f.write("My contents don't matter")
|
f.write("My contents don't matter")
|
||||||
|
|
||||||
def _test_renew_common(self, renewalparams=None, error_expected=False,
|
def _test_renew_common(self, renewalparams=None, names=None,
|
||||||
names=None, assert_oc_called=None):
|
assert_oc_called=None, **kwargs):
|
||||||
self._make_dummy_renewal_config()
|
self._make_dummy_renewal_config()
|
||||||
with mock.patch('letsencrypt.storage.RenewableCert') as mock_rc:
|
with mock.patch('letsencrypt.storage.RenewableCert') as mock_rc:
|
||||||
mock_lineage = mock.MagicMock()
|
mock_lineage = mock.MagicMock()
|
||||||
@@ -694,8 +696,9 @@ class CLITest(unittest.TestCase): # pylint: disable=too-many-public-methods
|
|||||||
mock_lineage.names.return_value = names
|
mock_lineage.names.return_value = names
|
||||||
mock_rc.return_value = mock_lineage
|
mock_rc.return_value = mock_lineage
|
||||||
with mock.patch('letsencrypt.main.obtain_cert') as mock_obtain_cert:
|
with mock.patch('letsencrypt.main.obtain_cert') as mock_obtain_cert:
|
||||||
self._test_renewal_common(True, None, error_expected=error_expected,
|
kwargs.setdefault('args', ['renew'])
|
||||||
args=['renew'], renew=False)
|
self._test_renewal_common(True, None, renew=False, **kwargs)
|
||||||
|
|
||||||
if assert_oc_called is not None:
|
if assert_oc_called is not None:
|
||||||
if assert_oc_called:
|
if assert_oc_called:
|
||||||
self.assertTrue(mock_obtain_cert.called)
|
self.assertTrue(mock_obtain_cert.called)
|
||||||
@@ -718,7 +721,7 @@ class CLITest(unittest.TestCase): # pylint: disable=too-many-public-methods
|
|||||||
def test_renew_with_nonetype_http01(self):
|
def test_renew_with_nonetype_http01(self):
|
||||||
renewalparams = {'authenticator': 'webroot',
|
renewalparams = {'authenticator': 'webroot',
|
||||||
'http01_port': 'None'}
|
'http01_port': 'None'}
|
||||||
self._test_renew_common(renewalparams=renewalparams, error_expected=False,
|
self._test_renew_common(renewalparams=renewalparams,
|
||||||
assert_oc_called=True)
|
assert_oc_called=True)
|
||||||
|
|
||||||
def test_renew_with_bad_domain(self):
|
def test_renew_with_bad_domain(self):
|
||||||
@@ -727,6 +730,12 @@ class CLITest(unittest.TestCase): # pylint: disable=too-many-public-methods
|
|||||||
self._test_renew_common(renewalparams=renewalparams, error_expected=True,
|
self._test_renew_common(renewalparams=renewalparams, error_expected=True,
|
||||||
names=names, assert_oc_called=False)
|
names=names, assert_oc_called=False)
|
||||||
|
|
||||||
|
def test_renew_with_configurator(self):
|
||||||
|
renewalparams = {'authenticator': 'webroot'}
|
||||||
|
self._test_renew_common(
|
||||||
|
renewalparams=renewalparams, assert_oc_called=True,
|
||||||
|
args='renew --configurator apache'.split())
|
||||||
|
|
||||||
def test_renew_plugin_config_restoration(self):
|
def test_renew_plugin_config_restoration(self):
|
||||||
renewalparams = {'authenticator': 'webroot',
|
renewalparams = {'authenticator': 'webroot',
|
||||||
'webroot_path': 'None',
|
'webroot_path': 'None',
|
||||||
|
|||||||
Reference in New Issue
Block a user