diff options
author | Berker Peksag <berker.peksag@gmail.com> | 2016-03-06 16:16:40 +0200 |
---|---|---|
committer | Berker Peksag <berker.peksag@gmail.com> | 2016-03-06 16:16:40 +0200 |
commit | aecc893b71bf403c9b3abd4fc162a37104aedd68 (patch) | |
tree | 628a58bc148f35a23d3b81aadbfb893d88059ded /Lib/test/test_urllib2.py | |
parent | e3eea3eca53b23b48e39513be74f94455be44fa3 (diff) | |
download | cpython-aecc893b71bf403c9b3abd4fc162a37104aedd68.tar.gz |
Issue #2202: Fix UnboundLocalError in AbstractDigestAuthHandler.get_algorithm_impls
Raise ValueError if algorithm is not MD5 or SHA.
Initial patch by Mathieu Dupuy.
Diffstat (limited to 'Lib/test/test_urllib2.py')
-rw-r--r-- | Lib/test/test_urllib2.py | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/Lib/test/test_urllib2.py b/Lib/test/test_urllib2.py index a5281d864c..008c751f9c 100644 --- a/Lib/test/test_urllib2.py +++ b/Lib/test/test_urllib2.py @@ -13,7 +13,8 @@ import urllib.request # proxy config data structure but is testable on all platforms. from urllib.request import (Request, OpenerDirector, HTTPBasicAuthHandler, HTTPPasswordMgrWithPriorAuth, _parse_proxy, - _proxy_bypass_macosx_sysconf) + _proxy_bypass_macosx_sysconf, + AbstractDigestAuthHandler) from urllib.parse import urlparse import urllib.error import http.client @@ -1680,6 +1681,15 @@ class MiscTests(unittest.TestCase): self.assertRaises(ValueError, _parse_proxy, 'file:/ftp.example.com'), + 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): class PutRequest(Request): |