Raise ValueError if algorithm is not MD5 or SHA.
Initial patch by Mathieu Dupuy.
import StringIO
import urllib2
-from urllib2 import Request, OpenerDirector
+from urllib2 import Request, OpenerDirector, AbstractDigestAuthHandler
try:
import ssl
else:
self.assertTrue(False)
+ def test_unsupported_algorithm(self):
+ handler = AbstractDigestAuthHandler()
+ with self.assertRaises(ValueError) as exc:
+ handler.get_algorithm_impls('invalid')
+ self.assertEqual(
+ str(exc.exception),
+ "Unsupported digest authentication algorithm 'invalid'"
+ )
+
+
class RequestTests(unittest.TestCase):
def setUp(self):
elif algorithm == 'SHA':
H = lambda x: hashlib.sha1(x).hexdigest()
# XXX MD5-sess
+ else:
+ raise ValueError("Unsupported digest authentication "
+ "algorithm %r" % algorithm.lower())
KD = lambda s, d: H("%s:%s" % (s, d))
return H, KD
Library
-------
+- Issue #2202: Fix UnboundLocalError in
+ AbstractDigestAuthHandler.get_algorithm_impls. Initial patch by Mathieu Dupuy.
+
- Issue #26475: Fixed debugging output for regular expressions with the (?x)
flag.