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

Method test_custom_secure_protocols

Lib/test/test_http_cookiejar.py:1222–1247  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1220 self.assertFalse(req.has_header("Cookie"))
1221
1222 def test_custom_secure_protocols(self):
1223 pol = DefaultCookiePolicy(secure_protocols=["foos"])
1224 c = CookieJar(policy=pol)
1225
1226 headers = ["Set-Cookie: session=narf; secure; path=/"]
1227 req = urllib.request.Request("https://www.acme.com/")
1228 res = FakeResponse(headers, "https://www.acme.com/")
1229 c.extract_cookies(res, req)
1230 self.assertEqual(len(c), 1)
1231
1232 # test https removed from secure protocol list
1233 req = urllib.request.Request("https://www.acme.com/")
1234 c.add_cookie_header(req)
1235 self.assertFalse(req.has_header("Cookie"))
1236
1237 req = urllib.request.Request("http://www.acme.com/")
1238 c.add_cookie_header(req)
1239 self.assertFalse(req.has_header("Cookie"))
1240
1241 req = urllib.request.Request("foos://www.acme.com/")
1242 c.add_cookie_header(req)
1243 self.assertTrue(req.has_header("Cookie"))
1244
1245 req = urllib.request.Request("foo://www.acme.com/")
1246 c.add_cookie_header(req)
1247 self.assertFalse(req.has_header("Cookie"))
1248
1249 def test_quote_cookie_value(self):
1250 c = CookieJar(policy=DefaultCookiePolicy(rfc2965=True))

Callers

nothing calls this directly

Calls 9

extract_cookiesMethod · 0.95
add_cookie_headerMethod · 0.95
has_headerMethod · 0.95
DefaultCookiePolicyClass · 0.90
CookieJarClass · 0.90
FakeResponseClass · 0.85
assertFalseMethod · 0.80
assertTrueMethod · 0.80
assertEqualMethod · 0.45

Tested by

no test coverage detected