From f6c605cd15344e579a18e2aebd8f192ea4c5b43b Mon Sep 17 00:00:00 2001 From: Peter Eckersley Date: Wed, 21 Sep 2016 16:43:35 -0700 Subject: [PATCH] Add tests for the --preferred-challenges cli parser --- certbot/tests/cli_test.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/certbot/tests/cli_test.py b/certbot/tests/cli_test.py index 2c6e32705..fdfb9dcc8 100644 --- a/certbot/tests/cli_test.py +++ b/certbot/tests/cli_test.py @@ -423,6 +423,18 @@ class CLITest(unittest.TestCase): # pylint: disable=too-many-public-methods namespace = parse(long_args) self.assertEqual(namespace.domains, ['example.com', 'another.net']) + def test_preferred_challenges(self): + from acme.challenges import HTTP01, TLSSNI01, DNS01 + parse = self._get_argument_parser() + + short_args = ['--preferred-challenges', 'http, tls-sni-01, dns'] + namespace = parse(short_args) + + self.assertEqual(namespace.pref_challs, [HTTP01, TLSSNI01, DNS01]) + + short_args = ['--preferred-challenges', 'jumping-over-the-moon'] + self.assertRaises(argparse.ArgumentTypeError, parse, short_args) + def test_server_flag(self): parse = self._get_argument_parser() namespace = parse('--server example.com'.split())