diff --git a/certbot/plugins/standalone.py b/certbot/plugins/standalone.py index f3cd4b49d..0195b2726 100644 --- a/certbot/plugins/standalone.py +++ b/certbot/plugins/standalone.py @@ -13,6 +13,7 @@ import zope.interface from acme import challenges from acme import standalone as acme_standalone +from certbot import cli from certbot import errors from certbot import interfaces @@ -120,10 +121,11 @@ def supported_challenges_validator(data): It should be passed as `type` argument to `add_argument`. """ - sys.stderr.write( - "WARNING: The standalone specific " - "supported challenges flag is deprecated\n") - sys.stderr.write("Please use the --preferred-challenges flag instead.\n") + if cli.set_by_cli("standalone_supported_challenges"): + sys.stderr.write( + "WARNING: The standalone specific " + "supported challenges flag is deprecated.\n" + "Please use the --preferred-challenges flag instead.\n") challs = data.split(",") # tls-sni-01 was dvsni during private beta diff --git a/certbot/plugins/standalone_test.py b/certbot/plugins/standalone_test.py index eb6631732..1dfa3950a 100644 --- a/certbot/plugins/standalone_test.py +++ b/certbot/plugins/standalone_test.py @@ -67,10 +67,25 @@ class ServerManagerTest(unittest.TestCase): class SupportedChallengesValidatorTest(unittest.TestCase): """Tests for plugins.standalone.supported_challenges_validator.""" + def setUp(self): + self.set_by_cli_patch = mock.patch( + "certbot.plugins.standalone.cli.set_by_cli") + self.stderr_patch = mock.patch("certbot.plugins.standalone.sys.stderr") + + self.set_by_cli_patch.start().return_value = True + self.stderr = self.stderr_patch.start() + + def tearDown(self): + self.set_by_cli_patch.stop() + self.stderr_patch.stop() + def _call(self, data): from certbot.plugins.standalone import ( supported_challenges_validator) - return supported_challenges_validator(data) + return_value = supported_challenges_validator(data) + self.assertTrue(self.stderr.write.called) # pylint: disable=no-member + self.stderr.write.reset_mock() # pylint: disable=no-member + return return_value def test_correct(self): self.assertEqual("tls-sni-01", self._call("tls-sni-01"))