mirror of
https://github.com/certbot/certbot.git
synced 2026-08-02 08:03:19 +02:00
Remove deprecated options as early as possible using an explicit list (#8617)
* Remove deprecated options as early as possible using an explicit list * add deprecated options to cli init import list * use correct dict comprehension syntax for py3 * lint * add test for renewal reconstitution code * add test to ensure we're not saving deprecated values * comment code
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
"""Tests for certbot._internal.renewal"""
|
||||
import copy
|
||||
|
||||
import unittest
|
||||
|
||||
try:
|
||||
@@ -98,6 +100,23 @@ class RenewalTest(test_util.ConfigTestCase):
|
||||
|
||||
assert self.config.elliptic_curve == 'secp256r1'
|
||||
|
||||
@test_util.patch_get_utility()
|
||||
@mock.patch('certbot._internal.renewal.cli.set_by_cli')
|
||||
def test_remove_deprecated_config_elements(self, mock_set_by_cli, unused_mock_get_utility):
|
||||
mock_set_by_cli.return_value = False
|
||||
config = configuration.NamespaceConfig(self.config)
|
||||
config.certname = "sample-renewal-deprecated-option"
|
||||
|
||||
rc_path = test_util.make_lineage(
|
||||
self.config.config_dir, 'sample-renewal-deprecated-option.conf')
|
||||
|
||||
from certbot._internal import renewal
|
||||
lineage_config = copy.deepcopy(self.config)
|
||||
renewal_candidate = renewal._reconstitute(lineage_config, rc_path)
|
||||
# This means that manual_public_ip_logging_ok was not modified in the config based on its
|
||||
# value in the renewal conf file
|
||||
self.assertTrue(isinstance(lineage_config.manual_public_ip_logging_ok, mock.MagicMock))
|
||||
|
||||
|
||||
class RestoreRequiredConfigElementsTest(test_util.ConfigTestCase):
|
||||
"""Tests for certbot._internal.renewal.restore_required_config_elements."""
|
||||
|
||||
@@ -77,6 +77,17 @@ class RelevantValuesTest(unittest.TestCase):
|
||||
|
||||
self.assertEqual(self._call(self.values), expected_relevant_values)
|
||||
|
||||
@mock.patch("certbot._internal.cli.set_by_cli")
|
||||
def test_deprecated_item(self, unused_mock_set_by_cli):
|
||||
# deprecated items should never be relevant to store
|
||||
expected_relevant_values = self.values.copy()
|
||||
self.values["manual_public_ip_logging_ok"] = None
|
||||
self.assertEqual(self._call(self.values), expected_relevant_values)
|
||||
self.values["manual_public_ip_logging_ok"] = True
|
||||
self.assertEqual(self._call(self.values), expected_relevant_values)
|
||||
self.values["manual_public_ip_logging_ok"] = False
|
||||
self.assertEqual(self._call(self.values), expected_relevant_values)
|
||||
|
||||
|
||||
class BaseRenewableCertTest(test_util.ConfigTestCase):
|
||||
"""Base class for setting up Renewable Cert tests.
|
||||
|
||||
Reference in New Issue
Block a user