Exemplo n.º 1
0
def test_cookie_extract(flask_app: Flask, authenticator: Auth0Authenticator,
                        access_token: str):
    cookie_name = "TestCookie"
    authenticator.header_authentication = False
    authenticator.cookie_authentication = True
    authenticator.cookie_name = cookie_name
    header = dump_cookie(cookie_name, access_token)
    with flask_app.test_request_context(headers={"COOKIE": header}):
        token = authenticator._get_token()
        assert token == access_token
Exemplo n.º 2
0
def test_no_token(flask_app: Flask, authenticator: Auth0Authenticator):
    with flask_app.test_request_context():
        with pytest.raises(Exception, match=r"Missing token"):
            authenticator._get_token()
Exemplo n.º 3
0
def test_header_extract(flask_app: Flask, authenticator: Auth0Authenticator,
                        access_token: str):
    with flask_app.test_request_context(
            headers={"Authorization": f"Bearer {access_token}"}):
        token = authenticator._get_token()
        assert token == access_token