Ejemplo n.º 1
0
 def assert_set_cookie__invalid_max_age(self) -> None:
     response = FakeResponse(
         "200 OK", [("Set-Cookie", "Foo=Bar; Max-Age=INVALID")]
     )
     with assert_succeeds(AssertionError):
         response.assert_set_cookie("Foo", "Bar")
     with assert_raises(AssertionError):
         response.assert_set_cookie("Foo", "Bar", max_age=1234)
Ejemplo n.º 2
0
 def assert_set_cookie__no_http_only(self) -> None:
     response = FakeResponse("200 OK", [("Set-Cookie", "Foo=Bar")])
     with assert_succeeds(AssertionError):
         response.assert_set_cookie("Foo", "Bar")
     with assert_raises(AssertionError):
         response.assert_set_cookie("Foo", "Bar", http_only=True)
     with assert_succeeds(AssertionError):
         response.assert_set_cookie("Foo", "Bar", http_only=False)
Ejemplo n.º 3
0
 def assert_set_cookie__has_secure(self) -> None:
     response = FakeResponse("200 OK", [("Set-Cookie", "Foo=Bar; Secure")])
     with assert_succeeds(AssertionError):
         response.assert_set_cookie("Foo", "Bar")
     with assert_succeeds(AssertionError):
         response.assert_set_cookie("Foo", "Bar", secure=True)
     with assert_raises(AssertionError):
         response.assert_set_cookie("Foo", "Bar", secure=False)
Ejemplo n.º 4
0
 def assert_set_cookie__wrong_value(self) -> None:
     response = FakeResponse("200 OK", [("Set-Cookie", "Foo=Wrong")])
     with assert_raises(AssertionError):
         response.assert_set_cookie("Foo", "Bar")
Ejemplo n.º 5
0
 def assert_set_cookie__no_cookie_header(self) -> None:
     response = FakeResponse("200 OK", [])
     with assert_raises(AssertionError):
         response.assert_set_cookie("Foo", "Bar")
Ejemplo n.º 6
0
 def assert_set_cookie__simple_match(self) -> None:
     response = FakeResponse(
         "200 OK", [("Set-Cookie", "Foo=Bar; Secure; Max-Age=1234")]
     )
     with assert_succeeds(AssertionError):
         response.assert_set_cookie("Foo", "Bar")