mirror of
https://github.com/python/cpython.git
synced 2025-08-03 00:23:06 +00:00
#2136: allow single quotes in realm spec.
This commit is contained in:
parent
d346475a0c
commit
331243270d
3 changed files with 14 additions and 4 deletions
|
@ -911,13 +911,14 @@ class HandlerTests(unittest.TestCase):
|
|||
self.assertEqual([(handlers[0], "http_open")],
|
||||
[tup[0:2] for tup in o.calls])
|
||||
|
||||
def test_basic_auth(self):
|
||||
def test_basic_auth(self, quote_char='"'):
|
||||
opener = OpenerDirector()
|
||||
password_manager = MockPasswordManager()
|
||||
auth_handler = urllib2.HTTPBasicAuthHandler(password_manager)
|
||||
realm = "ACME Widget Store"
|
||||
http_handler = MockHTTPHandler(
|
||||
401, 'WWW-Authenticate: Basic realm="%s"\r\n\r\n' % realm)
|
||||
401, 'WWW-Authenticate: Basic realm=%s%s%s\r\n\r\n' %
|
||||
(quote_char, realm, quote_char) )
|
||||
opener.add_handler(auth_handler)
|
||||
opener.add_handler(http_handler)
|
||||
self._test_basic_auth(opener, auth_handler, "Authorization",
|
||||
|
@ -926,6 +927,9 @@ class HandlerTests(unittest.TestCase):
|
|||
"http://acme.example.com/protected",
|
||||
)
|
||||
|
||||
def test_basic_auth_with_single_quoted_realm(self):
|
||||
self.test_basic_auth(quote_char="'")
|
||||
|
||||
def test_proxy_basic_auth(self):
|
||||
opener = OpenerDirector()
|
||||
ph = urllib2.ProxyHandler(dict(http="proxy.example.com:3128"))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue