mirror of
https://github.com/certbot/certbot.git
synced 2026-08-01 18:56:55 +02:00
raise ValueError instead of raw Exception
This commit is contained in:
@@ -273,13 +273,11 @@ class StandaloneAuthenticator(object):
|
|||||||
if self.child_pid or self.tasks:
|
if self.child_pid or self.tasks:
|
||||||
# We should not be willing to continue with perform
|
# We should not be willing to continue with perform
|
||||||
# if there were existing pending challenges.
|
# if there were existing pending challenges.
|
||||||
# TODO: Specify a correct exception subclass.
|
raise ValueError(".perform() was called with pending tasks!")
|
||||||
raise Exception(".perform() was called with pending tasks!")
|
|
||||||
results_if_success = []
|
results_if_success = []
|
||||||
results_if_failure = []
|
results_if_failure = []
|
||||||
if not chall_list or not isinstance(chall_list, list):
|
if not chall_list or not isinstance(chall_list, list):
|
||||||
# TODO: Specify a correct exception subclass.
|
raise ValueError(".perform() was called without challenge list")
|
||||||
raise Exception(".perform() was called without challenge list")
|
|
||||||
for chall in chall_list:
|
for chall in chall_list:
|
||||||
if isinstance(chall, challenge_util.DvsniChall):
|
if isinstance(chall, challenge_util.DvsniChall):
|
||||||
# We will attempt to do it
|
# We will attempt to do it
|
||||||
@@ -296,8 +294,7 @@ class StandaloneAuthenticator(object):
|
|||||||
results_if_success.append(False)
|
results_if_success.append(False)
|
||||||
results_if_failure.append(False)
|
results_if_failure.append(False)
|
||||||
if not self.tasks:
|
if not self.tasks:
|
||||||
# TODO: Specify a correct exception subclass.
|
raise ValueError("nothing for .perform() to do")
|
||||||
raise Exception("nothing for .perform() to do")
|
|
||||||
# Try to do the authentication; note that this creates
|
# Try to do the authentication; note that this creates
|
||||||
# the listener subprocess via os.fork()
|
# the listener subprocess via os.fork()
|
||||||
if self.start_listener(constants.DVSNI_CHALLENGE_PORT, key):
|
if self.start_listener(constants.DVSNI_CHALLENGE_PORT, key):
|
||||||
|
|||||||
@@ -240,18 +240,18 @@ class PerformTest(unittest.TestCase):
|
|||||||
self.authenticator.tasks = {"foononce.acme.invalid": "cert_data"}
|
self.authenticator.tasks = {"foononce.acme.invalid": "cert_data"}
|
||||||
extra_challenge = challenge_util.DvsniChall("a", "b", "c", "d")
|
extra_challenge = challenge_util.DvsniChall("a", "b", "c", "d")
|
||||||
self.assertRaises(
|
self.assertRaises(
|
||||||
Exception, self.authenticator.perform, [extra_challenge])
|
ValueError, self.authenticator.perform, [extra_challenge])
|
||||||
|
|
||||||
def test_perform_without_challenge_list(self):
|
def test_perform_without_challenge_list(self):
|
||||||
extra_challenge = challenge_util.DvsniChall("a", "b", "c", "d")
|
extra_challenge = challenge_util.DvsniChall("a", "b", "c", "d")
|
||||||
# This is wrong because a challenge must be specified.
|
# This is wrong because a challenge must be specified.
|
||||||
self.assertRaises(Exception, self.authenticator.perform, [])
|
self.assertRaises(ValueError, self.authenticator.perform, [])
|
||||||
# This is wrong because it must be a list, not a bare challenge.
|
# This is wrong because it must be a list, not a bare challenge.
|
||||||
self.assertRaises(
|
self.assertRaises(
|
||||||
Exception, self.authenticator.perform, extra_challenge)
|
ValueError, self.authenticator.perform, extra_challenge)
|
||||||
# This is wrong because the list must contain at least one challenge.
|
# This is wrong because the list must contain at least one challenge.
|
||||||
self.assertRaises(
|
self.assertRaises(
|
||||||
Exception, self.authenticator.perform, range(20))
|
ValueError, self.authenticator.perform, range(20))
|
||||||
|
|
||||||
|
|
||||||
class StartListenerTest(unittest.TestCase):
|
class StartListenerTest(unittest.TestCase):
|
||||||
|
|||||||
Reference in New Issue
Block a user