async def post(self, request, *args, **kwargs): user = await authenticate(request, *args, **kwargs) access_token, _ = await self.responses.get_access_token_output( request, user, self.config, self.instance ) cookie = Cookie('access_token', access_token) cookie['path'] = '/' headers = { 'Set-Cookie': cookie, } return redirect('/home', headers=headers)
def test_cookie_expires_illegal_instance_type(expires): c = Cookie("test_cookie", "value") with pytest.raises(expected_exception=TypeError) as e: c["expires"] = expires assert e.message == "Cookie 'expires' property must be a datetime"
def test_cookie_set_unknown_property(): c = Cookie("test_cookie", "value") with pytest.raises(expected_exception=KeyError) as e: c["invalid"] = "value" assert e.message == "Unknown cookie property"
def test_cookie_illegal_key_format(): with pytest.raises(expected_exception=KeyError) as e: Cookie("testå", "test") assert e.message == "Cookie key contains illegal characters"
def test_cookie_reserved_cookie(): with pytest.raises(expected_exception=KeyError) as e: Cookie("domain", "testdomain.com") assert e.message == "Cookie name is a reserved word"