Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update CI #23

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ python:
- "3.2"
- "3.3"
- "3.4"
- "3.5.0b3"
- "3.5-dev"
- "3.5"
- "3.6"
- "3.7-dev"
- "nightly"
- "pypy"
- "pypy3"
Expand Down
2 changes: 1 addition & 1 deletion requirements/tests.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
-r production.txt
timecop
freezegun
16 changes: 8 additions & 8 deletions tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""
import six
import time
import timecop
import freezegun as fg
from unittest import TestCase

from onetimepass import (
Expand Down Expand Up @@ -188,7 +188,7 @@ def test_generating_current_totp_and_validating(self):
created HOTP for proper interval
"""
secret = b'MFRGGZDFMZTWQ2LK'
with timecop.freeze(time.time()):
with fg.freeze_time():
hotp = get_hotp(secret=secret, intervals_no=int(time.time())//30,)
totp = get_totp(secret=secret)
self.assertEqual(hotp, totp)
Expand All @@ -198,7 +198,7 @@ def test_generating_current_totp_as_string(self):
Check if the TOTP also works seamlessly when generated as string
"""
secret = b'MFRGGZDFMZTWQ2LK'
with timecop.freeze(time.time()):
with fg.freeze_time():
hotp = get_hotp(
secret=secret,
intervals_no=int(time.time())//30,
Expand All @@ -213,7 +213,7 @@ def test_generating_totp_at_specific_clock(self):
which is basically the same as hotp
"""
secret = b'MFRGGZDFMZTWQ2LK'
with timecop.freeze(time.time()):
with fg.freeze_time():
hotp = get_hotp(secret=secret, intervals_no=int(time.time())//30,)
totp = get_totp(secret=secret, clock=None)
self.assertEqual(hotp, totp)
Expand All @@ -232,7 +232,7 @@ def test_validating_totp_with_a_window(self):
validate if a totp token falls within a certain window
"""
secret = b'MFRGGZDFMZTWQ2LK'
with timecop.freeze(time.time()):
with fg.freeze_time():
totp = get_totp(secret=secret, clock=(int(time.time()-30)))
self.assertFalse(valid_totp(totp, secret))
self.assertTrue(valid_totp(totp, secret, window=1))
Expand All @@ -256,15 +256,15 @@ def test_validating_totp_for_same_secret(self):
Check if validating TOTP generated for the same secret works
"""
secret = b'MFRGGZDFMZTWQ2LK'
with timecop.freeze(time.time()):
with fg.freeze_time():
self.assertTrue(valid_totp(get_totp(secret), secret))

def test_validating_invalid_totp_for_same_secret(self):
"""
Test case when the same secret is used, but the token differs
"""
secret = b'MFRGGZDFMZTWQ2LK'
with timecop.freeze(time.time()):
with fg.freeze_time():
self.assertFalse(valid_totp(get_totp(secret)+1, secret))

def test_validating_correct_hotp_as_totp(self):
Expand All @@ -273,5 +273,5 @@ def test_validating_correct_hotp_as_totp(self):
very big interval number (matching Unix epoch timestamp)
"""
secret = b'MFRGGZDFMZTWQ2LK'
with timecop.freeze(time.time()):
with fg.freeze_time():
self.assertFalse(valid_totp(get_hotp(secret, 1), secret))