Add tests for password expiration

This commit is contained in:
Samuel Dion-Girardeau 2016-10-24 19:21:08 -04:00
parent dc364bb75e
commit 5801007738

View file

@ -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