Fix _is_expired_token issues (#47)
This commit is contained in:
committed by
Sergey Petrov
parent
c272fa8bf2
commit
bbe8528acf
@@ -57,7 +57,7 @@ class TokenCredentials(Credentials):
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _is_expired_token(issue_date):
|
def _is_expired_token(issue_date):
|
||||||
return time.time() < issue_date + DEFAULT_TOKEN_LIFETIME
|
return time.time() > issue_date + DEFAULT_TOKEN_LIFETIME
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _get_signing_key(key_path):
|
def _get_signing_key(key_path):
|
||||||
|
|||||||
@@ -1 +1,2 @@
|
|||||||
|
freezegun
|
||||||
mock; python_version < '3.3'
|
mock; python_version < '3.3'
|
||||||
|
|||||||
@@ -6,6 +6,8 @@
|
|||||||
|
|
||||||
from unittest import TestCase, main
|
from unittest import TestCase, main
|
||||||
|
|
||||||
|
from freezegun import freeze_time
|
||||||
|
|
||||||
import time
|
import time
|
||||||
|
|
||||||
from apns2.credentials import TokenCredentials
|
from apns2.credentials import TokenCredentials
|
||||||
@@ -28,12 +30,14 @@ class TokenCredentialsTestCase(TestCase):
|
|||||||
self.team_id)
|
self.team_id)
|
||||||
self.lasting_header = self.normal_creds.get_authorization_header(
|
self.lasting_header = self.normal_creds.get_authorization_header(
|
||||||
self.topics[0])
|
self.topics[0])
|
||||||
self.expiring_creds = \
|
|
||||||
TokenCredentials(self.key_path, self.key_id,
|
with freeze_time('2012-01-14'):
|
||||||
self.team_id,
|
self.expiring_creds = \
|
||||||
token_lifetime=self.token_lifetime)
|
TokenCredentials(self.key_path, self.key_id,
|
||||||
self.expiring_header = self.expiring_creds.get_authorization_header(
|
self.team_id,
|
||||||
self.topics[0])
|
token_lifetime=self.token_lifetime)
|
||||||
|
self.expiring_header = self.expiring_creds.get_authorization_header(
|
||||||
|
self.topics[0])
|
||||||
|
|
||||||
def test_create_multiple_topics(self):
|
def test_create_multiple_topics(self):
|
||||||
h1 = self.normal_creds.get_authorization_header(self.topics[0])
|
h1 = self.normal_creds.get_authorization_header(self.topics[0])
|
||||||
|
|||||||
Reference in New Issue
Block a user