def test_create_jwt_with_encode_key_override(app): jwt_manager = JWTManager(app) @jwt_manager.encode_key_loader def custom(claims): return 'custom_encode_key' with app.test_request_context(): jwt_manager._create_jwt('foo')
def test_decode_jwt_with_key_override_mismatch(app): jwt_manager = JWTManager(app) @jwt_manager.encode_key_loader def encode_key(claims): return 'custom_encode_key' @jwt_manager.decode_key_loader def decode_key(claims): return 'wrong_decode_key' with app.test_request_context(): token = jwt_manager._create_jwt('foo') with pytest.raises(pyjwt.InvalidSignatureError): decode_jwt(token)