Exemple #1
0
def save_message(message: Message) -> Response:
    response = Response(HTTP_302,
                        content="",
                        headers={
                            "location": app.reverse_uri("index"),
                        })
    response.set_cookie(Cookie("message", message.message))
    return response
Exemple #2
0
def test_responses_can_set_cookies():
    # Given that I have a Response instance
    response = Response(HTTP_200)

    # When I call set_cookie on it with a couple valid cookies
    response.set_cookie(Cookie("a", "b"))
    response.set_cookie(Cookie("c", "d"))

    # Then both cookies should be added to its headers
    assert response.headers.get_all("set-cookie") == ["a=b", "c=d"]
Exemple #3
0
 def test_auth(jwt: JWT):
     cookie_name = "molten_auth_cookie"
     cookie_value = jwt.encode({"sub": 123456, "name": "spiderman"})
     auth_response = Response(HTTP_200)
     auth_response.set_cookie(Cookie(cookie_name, cookie_value))
     return auth_response