Skip to content

Commit

Permalink
Specify api test header
Browse files Browse the repository at this point in the history
  • Loading branch information
Filienko committed Aug 14, 2024
1 parent 04ba266 commit a73661c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,17 @@ def test_validate_jwt(self, mock_decode, mock_jwk_client):
self.assertEqual(response.status_code, 200)

# Test valid token
response = self.client.get('/', headers={'Authorization': 'Bearer valid_token'})
response = self.client.get('/', headers={'Authorization': 'Bearer valid_token', 'Content-Type': 'application/json'})
self.assertEqual(response.status_code, 200)

# Test missing token
response = self.client.get('/')
response = self.client.get('/', headers={'Content-Type': 'application/json'})
self.assertEqual(response.status_code, 400)
self.assertEqual(response.json['message'], "token missing")

# Test expired token
mock_decode.side_effect = jwt.exceptions.ExpiredSignatureError()
response = self.client.get('/', headers={'Authorization': 'Bearer expired_token'})
response = self.client.get('/', headers={'Authorization': 'Bearer expired_token', 'Content-Type': 'application/json'})
self.assertEqual(response.status_code, 401)
self.assertEqual(response.json['message'], "token expired")

Expand Down

0 comments on commit a73661c

Please sign in to comment.