예제 #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)
예제 #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)
예제 #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)
예제 #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")
예제 #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")
예제 #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")