MCPcopy Index your code
hub / github.com/python/cpython / test_proxy_https_proxy_authorization

Method test_proxy_https_proxy_authorization

Lib/test/test_urllib2.py:1508–1529  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1506
1507 @unittest.skipUnless(hasattr(http.client, 'HTTPSConnection'), 'HTTPSConnection required for HTTPS tests.')
1508 def test_proxy_https_proxy_authorization(self):
1509 o = OpenerDirector()
1510 ph = urllib.request.ProxyHandler(dict(https='proxy.example.com:3128'))
1511 o.add_handler(ph)
1512 https_handler = MockHTTPSHandler()
1513 o.add_handler(https_handler)
1514 req = Request("https://www.example.com/")
1515 req.add_header("Proxy-Authorization", "FooBar")
1516 req.add_header("User-Agent", "Grail")
1517 self.assertEqual(req.host, "www.example.com")
1518 self.assertIsNone(req._tunnel_host)
1519 o.open(req)
1520 # Verify Proxy-Authorization gets tunneled to request.
1521 # httpsconn req_headers do not have the Proxy-Authorization header but
1522 # the req will have.
1523 self.assertNotIn(("Proxy-Authorization", "FooBar"),
1524 https_handler.httpconn.req_headers)
1525 self.assertIn(("User-Agent", "Grail"),
1526 https_handler.httpconn.req_headers)
1527 self.assertIsNotNone(req._tunnel_host)
1528 self.assertEqual(req.host, "proxy.example.com:3128")
1529 self.assertEqual(req.get_header("Proxy-authorization"), "FooBar")
1530
1531 @unittest.skipUnless(os.name == "nt", "only relevant for Windows")
1532 def test_winreg_proxy_bypass(self):

Callers

nothing calls this directly

Calls 12

add_handlerMethod · 0.95
add_headerMethod · 0.95
openMethod · 0.95
get_headerMethod · 0.95
OpenerDirectorClass · 0.90
RequestClass · 0.90
MockHTTPSHandlerClass · 0.85
assertIsNoneMethod · 0.80
assertNotInMethod · 0.80
assertInMethod · 0.80
assertIsNotNoneMethod · 0.80
assertEqualMethod · 0.45

Tested by

no test coverage detected