示例#1
0
    def setUp(self):
        self.loop = asyncio.new_event_loop()
        asyncio.set_event_loop(None)

        # N.B. those need to be overriden in child test cases
        self.jar = helpers.CookieJar(loop=self.loop)
        # Cookies to send from client to server as "Cookie" header
        self.cookies_to_send = http.cookies.SimpleCookie()
        # Cookies received from the server as "Set-Cookie" header
        self.cookies_to_receive = http.cookies.SimpleCookie()
示例#2
0
    def setUp(self):
        super().setUp()
        self.cookies_to_send = http.cookies.SimpleCookie(
            "shared-cookie=first; "
            "ip-cookie=second; Domain=127.0.0.1;")

        self.cookies_to_receive = http.cookies.SimpleCookie(
            "shared-cookie=first; "
            "ip-cookie=second; Domain=127.0.0.1;")

        self.jar = helpers.CookieJar(loop=self.loop, unsafe=True)
示例#3
0
    def setUp(self):
        # Cookies to send from client to server as "Cookie" header
        self.cookies_to_send = http.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;")

        # Cookies received from the server as "Set-Cookie" header
        self.cookies_to_receive = http.cookies.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.loop = asyncio.new_event_loop()
        asyncio.set_event_loop(None)

        self.jar = helpers.CookieJar(loop=self.loop)
示例#4
0
 def test_constructor(self):
     jar = helpers.CookieJar(self.cookies_to_send, self.loop)
     self.assertEqual(jar.cookies, self.cookies_to_send)
     self.assertEqual(jar._loop, self.loop)
示例#5
0
 def test_constructor(self):
     jar = helpers.CookieJar(loop=self.loop)
     jar.update_cookies(self.cookies_to_send)
     self.assertEqual(jar.cookies, self.cookies_to_send)
     self.assertIs(jar._loop, self.loop)