Skip to content

Commit

Permalink
tests: Dereference LocalProxy before serialization
Browse files Browse the repository at this point in the history
  • Loading branch information
V02460 committed Oct 20, 2024
1 parent 5bdc111 commit d282c1a
Showing 1 changed file with 25 additions and 5 deletions.
30 changes: 25 additions & 5 deletions tests/flask/test_oauth2/test_jwt_access_token.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,31 +49,51 @@ def create_resource_protector(app, validator):
@require_oauth()
def protected():
user = db.session.get(User, current_token['sub'])
return jsonify(id=user.id, username=user.username, token=current_token)
return jsonify(
id=user.id,
username=user.username,
token=current_token._get_current_object(),
)

@app.route('/protected-by-scope')
@require_oauth('profile')
def protected_by_scope():
user = db.session.get(User, current_token['sub'])
return jsonify(id=user.id, username=user.username, token=current_token)
return jsonify(
id=user.id,
username=user.username,
token=current_token._get_current_object(),
)

@app.route('/protected-by-groups')
@require_oauth(groups=['admins'])
def protected_by_groups():
user = db.session.get(User, current_token['sub'])
return jsonify(id=user.id, username=user.username, token=current_token)
return jsonify(
id=user.id,
username=user.username,
token=current_token._get_current_object(),
)

@app.route('/protected-by-roles')
@require_oauth(roles=['student'])
def protected_by_roles():
user = db.session.get(User, current_token['sub'])
return jsonify(id=user.id, username=user.username, token=current_token)
return jsonify(
id=user.id,
username=user.username,
token=current_token._get_current_object(),
)

@app.route('/protected-by-entitlements')
@require_oauth(entitlements=['captain'])
def protected_by_entitlements():
user = db.session.get(User, current_token['sub'])
return jsonify(id=user.id, username=user.username, token=current_token)
return jsonify(
id=user.id,
username=user.username,
token=current_token._get_current_object(),
)

return require_oauth

Expand Down

0 comments on commit d282c1a

Please sign in to comment.