Exemplo n.º 1
0
 def test_missing_token(self):
     jwt_auth = auth.JwtRequestLoader(flask.current_app)
     with mock.patch.dict(
             flask.current_app.config,
             JWT_TOKEN_LOCATION='query_string',
             JWT_QUERY_STRING_NAME='jwt',
     ):
         with flask.current_app.test_request_context('/'):
             assert jwt_auth.get_authenticated_user() is None
Exemplo n.º 2
0
 def test_bad_token(self):
     jwt_auth = auth.JwtRequestLoader(flask.current_app)
     with mock.patch.dict(
             flask.current_app.config,
             JWT_TOKEN_LOCATION='query_string',
             JWT_QUERY_STRING_NAME='jwt',
     ):
         with flask.current_app.test_request_context('/?jwt=notgoodatall'):
             with pytest.raises(jwt.exceptions.DecodeError):
                 jwt_auth.get_authenticated_user()
 def test_user_verified(self):
     user = User.testing_create()
     jwt_auth = auth.JwtRequestLoader(flask.current_app)
     token = jwt_auth.create_access_token(user)
     with mock.patch.dict(
         flask.current_app.config,
         JWT_TOKEN_LOCATION='query_string',
         JWT_QUERY_STRING_NAME='jwt',
     ):
         with flask.current_app.test_request_context('/?jwt={}'.format(token)):
             assert jwt_auth.get_authenticated_user() is user
Exemplo n.º 4
0
 def test_create_access_token(self):
     user = User.testing_create()
     jwt_auth = auth.JwtRequestLoader(flask.current_app)
     token = jwt_auth.create_access_token(user)
     assert flask_jwt_extended.decode_token(
         token)['sub'] == user.session_key