From 5801007738cc02323fecacf3748ae324668de2f8 Mon Sep 17 00:00:00 2001 From: Samuel Dion-Girardeau Date: Mon, 24 Oct 2016 19:21:08 -0400 Subject: [PATCH] Add tests for password expiration --- tests.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests.py b/tests.py index a90b292..1726068 100644 --- a/tests.py +++ b/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