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

Commit

Permalink
fix: disallow negative ttls
Browse files Browse the repository at this point in the history
Closes #1276
  • Loading branch information
pjenvey committed Aug 14, 2018
1 parent 2d61a0e commit 3d9b671
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
6 changes: 6 additions & 0 deletions autopush/tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -1058,6 +1058,12 @@ def test_ttl_expired(self):
assert result is None
yield self.shut_down(client)

@inlineCallbacks
def test_ttl_neg(self):
client = yield self.quick_register()
yield client.send_notification(ttl=-1, status=400)
yield self.shut_down(client)

@inlineCallbacks
def test_ttl_batch_expired_and_good_one(self):
data = str(uuid.uuid4())
Expand Down
5 changes: 5 additions & 0 deletions autopush/web/webpush.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,11 @@ def validate_topic(self, value):
raise InvalidRequest("Topic must be URL and Filename safe Base"
"64 alphabet", errno=113)

@validates('ttl')
def validate_ttl(self, value):
if value is not None and value < 0:
raise InvalidRequest("TTL must be greater than 0", errno=114)

@post_load
def cap_ttl(self, d):
if 'ttl' in d:
Expand Down

0 comments on commit 3d9b671

Please sign in to comment.