Merge pull request #39 from samueldg/test/password_expiration
Add tests for password expiration
This commit is contained in:
commit
addd1495a3
1 changed files with 12 additions and 0 deletions
12
tests.py
12
tests.py
|
@ -1,3 +1,4 @@
|
||||||
|
import time
|
||||||
import unittest
|
import unittest
|
||||||
from unittest import TestCase
|
from unittest import TestCase
|
||||||
|
|
||||||
|
@ -48,6 +49,17 @@ class SnapPassTestCase(TestCase):
|
||||||
"/", data={'password': 'foo', 'ttl': 'hour'}, method='POST'):
|
"/", data={'password': 'foo', 'ttl': 'hour'}, method='POST'):
|
||||||
self.assertEqual((3600, 'foo'), snappass.clean_input())
|
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):
|
class SnapPassRoutesTestCase(TestCase):
|
||||||
# noinspection PyPep8Naming
|
# noinspection PyPep8Naming
|
||||||
|
|
Loading…
Reference in a new issue