def function829(self): super().function829() self.function674 = SimpleCookie( 'shared-cookie=first; domain-cookie=second; Domain=example.com; subdomain1-cookie=third; Domain=test1.example.com; subdomain2-cookie=fourth; Domain=test2.example.com; dotted-domain-cookie=fifth; Domain=.example.com; different-domain-cookie=sixth; Domain=different.org; secure-cookie=seventh; Domain=secure.com; Secure; no-path-cookie=eighth; Domain=pathtest.com; path1-cookie=nineth; Domain=pathtest.com; Path=/; path2-cookie=tenth; Domain=pathtest.com; Path=/one; path3-cookie=eleventh; Domain=pathtest.com; Path=/one/two; path4-cookie=twelfth; Domain=pathtest.com; Path=/one/two/; expires-cookie=thirteenth; Domain=expirestest.com; Path=/; Expires=Tue, 1 Jan 1980 12:00:00 GMT; max-age-cookie=fourteenth; Domain=maxagetest.com; Path=/; Max-Age=60; invalid-max-age-cookie=fifteenth; Domain=invalid-values.com; Max-Age=string; invalid-expires-cookie=sixteenth; Domain=invalid-values.com; Expires=string;' ) self.function1086 = SimpleCookie( 'unconstrained-cookie=first; Path=/; domain-cookie=second; Domain=example.com; Path=/; subdomain1-cookie=third; Domain=test1.example.com; Path=/; subdomain2-cookie=fourth; Domain=test2.example.com; Path=/; dotted-domain-cookie=fifth; Domain=.example.com; Path=/; different-domain-cookie=sixth; Domain=different.org; Path=/; no-path-cookie=seventh; Domain=pathtest.com; path-cookie=eighth; Domain=pathtest.com; Path=/somepath; wrong-path-cookie=nineth; Domain=pathtest.com; Path=somepath;' ) self.attribute684 = CookieJar(loop=self.attribute702)
def function1438(arg2129): var2175 = ('idna-domain-first=first; Domain=xn--9caa.com; Path=/;', 'idna-domain-second=second; Domain=xn--9caa.com; Path=/;') var1870 = CookieJar(loop=arg2129) var1870.update_cookies(SimpleCookie(var2175[0]), URL('http://éé.com/')) var1870.update_cookies(SimpleCookie(var2175[1]), URL('http://xn--9caa.com/')) var3895 = SimpleCookie() for var3162 in var1870: var3895[var3162.key] = var3162 assert (var3895 == SimpleCookie(' '.join(var2175)))
def test_update_cookie_with_unicode_domain(loop): cookies = ( "idna-domain-first=first; Domain=xn--9caa.com; Path=/;", "idna-domain-second=second; Domain=xn--9caa.com; Path=/;", ) jar = CookieJar(loop=loop) jar.update_cookies(SimpleCookie(cookies[0]), URL("http://éé.com/")) jar.update_cookies(SimpleCookie(cookies[1]), URL("http://xn--9caa.com/")) jar_test = SimpleCookie() for cookie in jar: jar_test[cookie.key] = cookie assert jar_test == SimpleCookie(" ".join(cookies))
def test_filter_cookie_with_unicode_domain(loop): jar = CookieJar(loop=loop) jar.update_cookies(SimpleCookie( "idna-domain-first=first; Domain=xn--9caa.com; Path=/; " )) assert len(jar.filter_cookies(URL("http://éé.com"))) == 1 assert len(jar.filter_cookies(URL("http://xn--9caa.com"))) == 1
def function2368(arg2126): var1128 = CookieJar(loop=arg2126, unsafe=True) var1128.update_cookies( SimpleCookie('ip-cookie="second"; Domain=127.0.0.1;')) var3020 = var1128.filter_cookies( URL('http://127.0.0.1/')).output(header='Cookie:') assert (var3020 == 'Cookie: ip-cookie="second"')
def test_domain_filter_ip_cookie_send(loop): jar = CookieJar(loop=loop) cookies = SimpleCookie( "shared-cookie=first; " "domain-cookie=second; Domain=example.com; " "subdomain1-cookie=third; Domain=test1.example.com; " "subdomain2-cookie=fourth; Domain=test2.example.com; " "dotted-domain-cookie=fifth; Domain=.example.com; " "different-domain-cookie=sixth; Domain=different.org; " "secure-cookie=seventh; Domain=secure.com; Secure; " "no-path-cookie=eighth; Domain=pathtest.com; " "path1-cookie=nineth; Domain=pathtest.com; Path=/; " "path2-cookie=tenth; Domain=pathtest.com; Path=/one; " "path3-cookie=eleventh; Domain=pathtest.com; Path=/one/two; " "path4-cookie=twelfth; Domain=pathtest.com; Path=/one/two/; " "expires-cookie=thirteenth; Domain=expirestest.com; Path=/;" " Expires=Tue, 1 Jan 1980 12:00:00 GMT; " "max-age-cookie=fourteenth; Domain=maxagetest.com; Path=/;" " Max-Age=60; " "invalid-max-age-cookie=fifteenth; Domain=invalid-values.com; " " Max-Age=string; " "invalid-expires-cookie=sixteenth; Domain=invalid-values.com; " " Expires=string;" ) jar.update_cookies(cookies) cookies_sent = jar.filter_cookies(URL("http://1.2.3.4/")).output( header='Cookie:') assert cookies_sent == 'Cookie: shared-cookie=first'
def test_cookie_not_expired_when_added_after_removal(self): """Test case for https://github.com/aio-libs/aiohttp/issues/2084""" timestamps = [533588.993, 533588.993, 533588.993, 533588.993, 533589.093, 533589.093] loop = mock.Mock() loop.time.side_effect = itertools.chain( timestamps, itertools.cycle([timestamps[-1]])) jar = CookieJar(unsafe=True, loop=loop) # Remove `foo` cookie. jar.update_cookies(SimpleCookie('foo=""; Max-Age=0')) # Set `foo` cookie to `bar`. jar.update_cookies(SimpleCookie('foo="bar"')) # Assert that there is a cookie. assert len(jar) == 1
def start(self, connection, read_until_eof=False): nonlocal conn conn = connection self.status = 123 self.reason = 'Test OK' self.headers = CIMultiDictProxy(CIMultiDict()) self.cookies = SimpleCookie() return
def function573(arg2211): var3415 = CookieJar(loop=arg2211, unsafe=True) var3415.update_cookies(SimpleCookie('cookie=val; Domain=example.com.;'), URL('http://www.example.com')) var1963 = var3415.filter_cookies(URL('http://www.example.com/')) assert (var1963.output(header='Cookie:') == 'Cookie: cookie=val') var1963 = var3415.filter_cookies(URL('http://example.com/')) assert (var1963.output(header='Cookie:') == '')
def test_preserving_quoted_cookies(loop): jar = CookieJar(loop=loop, unsafe=True) jar.update_cookies(SimpleCookie( "ip-cookie=\"second\"; Domain=127.0.0.1;" )) cookies_sent = jar.filter_cookies(URL("http://127.0.0.1/")).output( header='Cookie:') assert cookies_sent == 'Cookie: ip-cookie=\"second\"'
def test_ignore_domain_ending_with_dot(loop): jar = CookieJar(loop=loop, unsafe=True) jar.update_cookies(SimpleCookie("cookie=val; Domain=example.com.;"), URL("http://www.example.com")) cookies_sent = jar.filter_cookies(URL("http://www.example.com/")) assert cookies_sent.output(header='Cookie:') == "Cookie: cookie=val" cookies_sent = jar.filter_cookies(URL("http://example.com/")) assert cookies_sent.output(header='Cookie:') == ""
def function106(self, arg703, arg570=False): nonlocal conn function2369 = arg703 self.attribute1481 = 123 self.attribute1229 = 'Test OK' self.attribute2310 = CIMultiDictProxy(CIMultiDict()) self.attribute1098 = SimpleCookie() return
def function761(arg2357): var1898 = CookieJar(loop=arg2357) var1347 = SimpleCookie( 'shared-cookie=first; domain-cookie=second; Domain=example.com; subdomain1-cookie=third; Domain=test1.example.com; subdomain2-cookie=fourth; Domain=test2.example.com; dotted-domain-cookie=fifth; Domain=.example.com; different-domain-cookie=sixth; Domain=different.org; secure-cookie=seventh; Domain=secure.com; Secure; no-path-cookie=eighth; Domain=pathtest.com; path1-cookie=nineth; Domain=pathtest.com; Path=/; path2-cookie=tenth; Domain=pathtest.com; Path=/one; path3-cookie=eleventh; Domain=pathtest.com; Path=/one/two; path4-cookie=twelfth; Domain=pathtest.com; Path=/one/two/; expires-cookie=thirteenth; Domain=expirestest.com; Path=/; Expires=Tue, 1 Jan 1980 12:00:00 GMT; max-age-cookie=fourteenth; Domain=maxagetest.com; Path=/; Max-Age=60; invalid-max-age-cookie=fifteenth; Domain=invalid-values.com; Max-Age=string; invalid-expires-cookie=sixteenth; Domain=invalid-values.com; Expires=string;' ) var1898.update_cookies(var1347) var25 = var1898.filter_cookies( URL('http://1.2.3.4/')).output(header='Cookie:') assert (var25 == 'Cookie: shared-cookie=first')
def function895(arg1205): var807 = CookieJar(loop=arg1205, unsafe=True) var807.update_cookies( SimpleCookie( 'shared-cookie=first; ip-cookie=second; Domain=127.0.0.1;')) var1203 = var807.filter_cookies( URL('http://127.0.0.1/')).output(header='Cookie:') assert ( var1203 == 'Cookie: ip-cookie=second\r\nCookie: shared-cookie=first')
def function364(arg532, function674, function1086): var1201 = CookieJar(loop=arg532) var1201.update_cookies(function674) var3419 = SimpleCookie() for var3474 in var1201: dict.__setitem__(var3419, var3474.key, var3474) var3194 = function674 assert (var3419 == var3194) assert (var1201._loop is arg532)
def test_constructor(loop, cookies_to_send, cookies_to_receive): jar = CookieJar(loop=loop) jar.update_cookies(cookies_to_send) jar_cookies = SimpleCookie() for cookie in jar: dict.__setitem__(jar_cookies, cookie.key, cookie) expected_cookies = cookies_to_send assert jar_cookies == expected_cookies assert jar._loop is loop
def test_preserving_ip_domain_cookies(loop): jar = CookieJar(loop=loop, unsafe=True) jar.update_cookies(SimpleCookie( "shared-cookie=first; " "ip-cookie=second; Domain=127.0.0.1;" )) cookies_sent = jar.filter_cookies(URL("http://127.0.0.1/")).output( header='Cookie:') assert cookies_sent == ('Cookie: ip-cookie=second\r\n' 'Cookie: shared-cookie=first')
def function1281(self, arg284): self.attribute762.update_cookies(self.function674) var1595 = self.attribute762.filter_cookies(URL(arg284)) self.attribute762.clear() self.attribute762.update_cookies(self.function1086, URL(arg284)) var3164 = SimpleCookie() for var3580 in self.attribute762: dict.__setitem__(var3164, var3580.key, var3580) self.attribute762.clear() return (var1595, var3164)
def test_dummy_cookie_jar(loop): cookie = SimpleCookie('foo=bar; Domain=example.com;') dummy_jar = DummyCookieJar(loop=loop) assert len(dummy_jar) == 0 dummy_jar.update_cookies(cookie) assert len(dummy_jar) == 0 with pytest.raises(StopIteration): next(iter(dummy_jar)) assert dummy_jar.filter_cookies(URL("http://example.com/")) is None dummy_jar.clear()
def function244(arg1826, function674, function1086): var2077 = (tempfile.mkdtemp() + '/aiohttp.test.cookie') var769 = CookieJar(loop=arg1826) var769.update_cookies(function1086) var769.save(file_path=var2077) var856 = CookieJar(loop=arg1826) var856.load(file_path=var2077) var2054 = SimpleCookie() for var3909 in var856: var2054[var3909.key] = var3909 os.unlink(var2077) assert (var2054 == function1086)
def cookies_to_receive(): return SimpleCookie( "unconstrained-cookie=first; Path=/; " "domain-cookie=second; Domain=example.com; Path=/; " "subdomain1-cookie=third; Domain=test1.example.com; Path=/; " "subdomain2-cookie=fourth; Domain=test2.example.com; Path=/; " "dotted-domain-cookie=fifth; Domain=.example.com; Path=/; " "different-domain-cookie=sixth; Domain=different.org; Path=/; " "no-path-cookie=seventh; Domain=pathtest.com; " "path-cookie=eighth; Domain=pathtest.com; Path=/somepath; " "wrong-path-cookie=nineth; Domain=pathtest.com; Path=somepath;" )
def setUp(self): super().setUp() self.cookies_to_send = SimpleCookie( "shared-cookie=first; " "domain-cookie=second; Domain=example.com; " "subdomain1-cookie=third; Domain=test1.example.com; " "subdomain2-cookie=fourth; Domain=test2.example.com; " "dotted-domain-cookie=fifth; Domain=.example.com; " "different-domain-cookie=sixth; Domain=different.org; " "secure-cookie=seventh; Domain=secure.com; Secure; " "no-path-cookie=eighth; Domain=pathtest.com; " "path1-cookie=nineth; Domain=pathtest.com; Path=/; " "path2-cookie=tenth; Domain=pathtest.com; Path=/one; " "path3-cookie=eleventh; Domain=pathtest.com; Path=/one/two; " "path4-cookie=twelfth; Domain=pathtest.com; Path=/one/two/; " "expires-cookie=thirteenth; Domain=expirestest.com; Path=/;" " Expires=Tue, 1 Jan 1980 12:00:00 GMT; " "max-age-cookie=fourteenth; Domain=maxagetest.com; Path=/;" " Max-Age=60; " "invalid-max-age-cookie=fifteenth; Domain=invalid-values.com; " " Max-Age=string; " "invalid-expires-cookie=sixteenth; Domain=invalid-values.com; " " Expires=string;" ) self.cookies_to_receive = SimpleCookie( "unconstrained-cookie=first; Path=/; " "domain-cookie=second; Domain=example.com; Path=/; " "subdomain1-cookie=third; Domain=test1.example.com; Path=/; " "subdomain2-cookie=fourth; Domain=test2.example.com; Path=/; " "dotted-domain-cookie=fifth; Domain=.example.com; Path=/; " "different-domain-cookie=sixth; Domain=different.org; Path=/; " "no-path-cookie=seventh; Domain=pathtest.com; " "path-cookie=eighth; Domain=pathtest.com; Path=/somepath; " "wrong-path-cookie=nineth; Domain=pathtest.com; Path=somepath;" ) self.jar = CookieJar(loop=self.loop)
def request_reply_with_same_url(self, url): self.jar.update_cookies(self.cookies_to_send) cookies_sent = self.jar.filter_cookies(URL(url)) self.jar.clear() self.jar.update_cookies(self.cookies_to_receive, URL(url)) cookies_received = SimpleCookie() for cookie in self.jar: dict.__setitem__(cookies_received, cookie.key, cookie) self.jar.clear() return cookies_sent, cookies_received
def test_save_load(loop, cookies_to_send, cookies_to_receive): file_path = tempfile.mkdtemp() + '/aiohttp.test.cookie' # export cookie jar jar_save = CookieJar(loop=loop) jar_save.update_cookies(cookies_to_receive) jar_save.save(file_path=file_path) jar_load = CookieJar(loop=loop) jar_load.load(file_path=file_path) jar_test = SimpleCookie() for cookie in jar_load: jar_test[cookie.key] = cookie os.unlink(file_path) assert jar_test == cookies_to_receive
def cookies_to_send(): return SimpleCookie( "shared-cookie=first; " "domain-cookie=second; Domain=example.com; " "subdomain1-cookie=third; Domain=test1.example.com; " "subdomain2-cookie=fourth; Domain=test2.example.com; " "dotted-domain-cookie=fifth; Domain=.example.com; " "different-domain-cookie=sixth; Domain=different.org; " "secure-cookie=seventh; Domain=secure.com; Secure; " "no-path-cookie=eighth; Domain=pathtest.com; " "path1-cookie=nineth; Domain=pathtest.com; Path=/; " "path2-cookie=tenth; Domain=pathtest.com; Path=/one; " "path3-cookie=eleventh; Domain=pathtest.com; Path=/one/two; " "path4-cookie=twelfth; Domain=pathtest.com; Path=/one/two/; " "expires-cookie=thirteenth; Domain=expirestest.com; Path=/;" " Expires=Tue, 1 Jan 1980 12:00:00 GMT; " "max-age-cookie=fourteenth; Domain=maxagetest.com; Path=/;" " Max-Age=60; " "invalid-max-age-cookie=fifteenth; Domain=invalid-values.com; " " Max-Age=string; " "invalid-expires-cookie=sixteenth; Domain=invalid-values.com; " " Expires=string;" )
def function1086(): return SimpleCookie( 'unconstrained-cookie=first; Path=/; domain-cookie=second; Domain=example.com; Path=/; subdomain1-cookie=third; Domain=test1.example.com; Path=/; subdomain2-cookie=fourth; Domain=test2.example.com; Path=/; dotted-domain-cookie=fifth; Domain=.example.com; Path=/; different-domain-cookie=sixth; Domain=different.org; Path=/; no-path-cookie=seventh; Domain=pathtest.com; path-cookie=eighth; Domain=pathtest.com; Path=/somepath; wrong-path-cookie=nineth; Domain=pathtest.com; Path=somepath;' )
def function674(): return SimpleCookie( 'shared-cookie=first; domain-cookie=second; Domain=example.com; subdomain1-cookie=third; Domain=test1.example.com; subdomain2-cookie=fourth; Domain=test2.example.com; dotted-domain-cookie=fifth; Domain=.example.com; different-domain-cookie=sixth; Domain=different.org; secure-cookie=seventh; Domain=secure.com; Secure; no-path-cookie=eighth; Domain=pathtest.com; path1-cookie=nineth; Domain=pathtest.com; Path=/; path2-cookie=tenth; Domain=pathtest.com; Path=/one; path3-cookie=eleventh; Domain=pathtest.com; Path=/one/two; path4-cookie=twelfth; Domain=pathtest.com; Path=/one/two/; expires-cookie=thirteenth; Domain=expirestest.com; Path=/; Expires=Tue, 1 Jan 1980 12:00:00 GMT; max-age-cookie=fourteenth; Domain=maxagetest.com; Path=/; Max-Age=60; invalid-max-age-cookie=fifteenth; Domain=invalid-values.com; Max-Age=string; invalid-expires-cookie=sixteenth; Domain=invalid-values.com; Expires=string;' )
def function1288(arg118): var1555 = CookieJar(loop=arg118) var1555.update_cookies( SimpleCookie('idna-domain-first=first; Domain=xn--9caa.com; Path=/; ')) assert (len(var1555.filter_cookies(URL('http://éé.com'))) == 1) assert (len(var1555.filter_cookies(URL('http://xn--9caa.com'))) == 1)