mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
Issue #2202: Fix UnboundLocalError in AbstractDigestAuthHandler.get_algorithm_impls
Raise ValueError if algorithm is not MD5 or SHA. Initial patch by Mathieu Dupuy.
This commit is contained in:
parent
8cc859c103
commit
e88dd1c32c
3 changed files with 17 additions and 1 deletions
|
@ -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):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue