Beispiel #1
0
 def test_cookie_jar_can_render_multiple_cookies_with_different_options(self):
     cookiejar = CookieJar()
     cookiejar.add("cookie1", "name", path="/")
     self.assertEqual(
         cookiejar.render_response(),
         [("Set-Cookie", "cookie1=name;HttpOnly;Path=/;")],
     )
Beispiel #2
0
 def test_cookie_can_load(self):
     cookiejar = CookieJar()
     cookiejar.add("cookie1", "name", http_only=False)
     cookiejar.load("csrf_token=tok")
     self.assertEqual(cookiejar.render_response(),
                      [("Set-Cookie", "cookie1=name;")])
     self.assertEqual(cookiejar.get("csrf_token").value, "tok")
Beispiel #3
0
 def test_cookie_with_expired_already(self):
     cookiejar = CookieJar()
     time = cookie_expire_time("expired")
     cookiejar.add("cookie1", "name", path="/", expires=time, timezone="GMT")
     self.assertEqual(
         cookiejar.render_response(),
         [("Set-Cookie", f"cookie1=name;HttpOnly;Expires={time} GMT;Path=/;")],
     )
Beispiel #4
0
 def test_cookie_jar_can_render_multiple_cookies(self):
     cookiejar = CookieJar()
     cookiejar.add("cookie1", "name", http_only=False)
     cookiejar.add("cookie2", "name", http_only=False)
     self.assertEqual(
         cookiejar.render_response(),
         [("Set-Cookie", "cookie1=name;"), ("Set-Cookie", "cookie2=name;")],
     )
Beispiel #5
0
 def test_cookie_can_make_secure_cookies(self):
     cookiejar = CookieJar()
     cookiejar.add("cookie1", "name", http_only=False, secure=True)
     self.assertEqual(
         cookiejar.render_response(), [("Set-Cookie", "cookie1=name;Secure;Path=/;")]
     )
Beispiel #6
0
 def test_cookie_jar_can_render_cookie_string(self):
     cookiejar = CookieJar()
     cookiejar.add("cookie", "name", http_only=False)
     self.assertEqual(
         cookiejar.render_response(), [("Set-Cookie", "cookie=name;Path=/;")]
     )