Add tests for password expiration
This commit is contained in:
parent
dc364bb75e
commit
5801007738
1 changed files with 12 additions and 0 deletions
12
tests.py
12
tests.py
|
@ -1,3 +1,4 @@
|
|||
import time
|
||||
import unittest
|
||||
from unittest import TestCase
|
||||
|
||||
|
@ -48,6 +49,17 @@ class SnapPassTestCase(TestCase):
|
|||
"/", data={'password': 'foo', 'ttl': 'hour'}, method='POST'):
|
||||
self.assertEqual((3600, 'foo'), snappass.clean_input())
|
||||
|
||||
def test_password_before_expiration(self):
|
||||
password = 'fidelio'
|
||||
key = snappass.set_password(password, 1)
|
||||
self.assertEqual(password, snappass.get_password(key))
|
||||
|
||||
def test_password_after_expiration(self):
|
||||
password = 'open sesame'
|
||||
key = snappass.set_password(password, 1)
|
||||
time.sleep(1.5)
|
||||
self.assertEqual(None, snappass.get_password(key))
|
||||
|
||||
|
||||
class SnapPassRoutesTestCase(TestCase):
|
||||
# noinspection PyPep8Naming
|
||||
|
|
Loading…
Reference in a new issue