From f810de1674792a4e345e44917bfad102fb86ae6c Mon Sep 17 00:00:00 2001 From: Brad Warren Date: Mon, 20 Mar 2017 17:57:09 -0700 Subject: [PATCH] Save hyphenated plugin params for renewal (#4281) * fix plugin namespace check * Add test to prevent regressions (cherry picked from commit b7d282309d9e28221ab557264966d42f4b383529) --- certbot/storage.py | 10 ++++++---- certbot/tests/storage_test.py | 9 +++++++++ 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/certbot/storage.py b/certbot/storage.py index dacc73c4c94..a1462b72dd5 100644 --- a/certbot/storage.py +++ b/certbot/storage.py @@ -19,6 +19,9 @@ from certbot import error_handler from certbot import util +from certbot.plugins import common as plugins_common +from certbot.plugins import disco as plugins_disco + logger = logging.getLogger(__name__) ALL_FOUR = ("cert", "privkey", "chain", "fullchain") @@ -179,13 +182,12 @@ def _relevant(option): :rtype: bool """ - # The list() here produces a list of the plugin names as strings. from certbot import renewal - from certbot.plugins import disco as plugins_disco - plugins = list(plugins_disco.PluginsRegistry.find_all()) + plugins = plugins_disco.PluginsRegistry.find_all() + namespaces = [plugins_common.dest_namespace(plugin) for plugin in plugins] return (option in renewal.CONFIG_ITEMS or - any(option.startswith(x + "_") for x in plugins)) + any(option.startswith(namespace) for namespace in namespaces)) def relevant_values(all_values): diff --git a/certbot/tests/storage_test.py b/certbot/tests/storage_test.py index f52f31d3d6a..f7bde012d03 100644 --- a/certbot/tests/storage_test.py +++ b/certbot/tests/storage_test.py @@ -581,6 +581,15 @@ def test_relevant_values_str(self): self.assertEqual( self._test_relevant_values_common(values), values) + @mock.patch("certbot.cli.set_by_cli") + @mock.patch("certbot.plugins.disco.PluginsRegistry.find_all") + def test_relevant_values_namespace(self, mock_find_all, mock_set_by_cli): + mock_set_by_cli.return_value = True + mock_find_all.return_value = ["certbot-foo:bar"] + values = {"certbot_foo:bar_baz": 42} + self.assertEqual( + self._test_relevant_values_common(values), values) + @mock.patch("certbot.storage.relevant_values") def test_new_lineage(self, mock_rv): """Test for new_lineage() class method."""