Skip to content
This repository has been archived by the owner on Jul 13, 2023. It is now read-only.

Commit

Permalink
fix: handle TypeErrors too
Browse files Browse the repository at this point in the history
Closes #1326
  • Loading branch information
pjenvey committed Apr 26, 2019
1 parent ffe5331 commit 72566f4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
10 changes: 9 additions & 1 deletion autopush/tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -772,7 +772,15 @@ def test_basic_delivery_with_invalid_vapid_exp(self):
payload={"aud": "https://pusher_origin.example.com",
"exp": '@',
"sub": "mailto:admin@example.com"})
vapid_info['crypto-key'] = "invalid"
yield client.send_notification(
data=data,
vapid=vapid_info,
status=401)

vapid_info = _get_vapid(
payload={"aud": "https://pusher_origin.example.com",
"exp": ['@'],
"sub": "mailto:admin@example.com"})
yield client.send_notification(
data=data,
vapid=vapid_info,
Expand Down
2 changes: 1 addition & 1 deletion autopush/web/webpush.py
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ def validate_auth(self, d):

try:
jwt_expires = int(jwt['exp'])
except ValueError:
except (ValueError, TypeError):
raise InvalidRequest("Invalid bearer token: Invalid expiration",
status_code=401, errno=109,
headers={"www-authenticate": PREF_SCHEME})
Expand Down

0 comments on commit 72566f4

Please sign in to comment.