Skip to content

Commit 242d4ed

Browse files
Use flask app_context for decode_token
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
1 parent fec2a31 commit 242d4ed

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

tests/test_auth.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,9 @@ def _test_invalid_request_data(self, endpoint, expected_status=400):
4747
assert response.status_code == 415
4848

4949
def _decode_token(self, token):
50-
return decode_token(token, allow_expired=False)
51-
50+
# Needs Flask app context for secret/algorithms from current_app.config
51+
with self.client.application.app_context():
52+
return decode_token(token, allow_expired=False)
5253
def _assert_jwt_structure(self, token, expected_sub, expected_type, fresh=False):
5354
assert token.count(".") == 2, f"Token does not have three segments: {token}"
5455
payload = self._decode_token(token)

0 commit comments

Comments
 (0)