summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMads Jensen <mje@inducks.org>2017-09-28 21:53:59 +0200
committerTim Graham <timograham@gmail.com>2017-09-29 09:28:25 -0400
commit3e72f4b7b6ff92a78c546115c5ff6fe63661dece (patch)
tree07b93615adcbadf2cbf65a14dc7db3b04737ddf3
parent776f6902d900a146d78279d10959caacdbe0c0e9 (diff)
Completed test coverage for BasePasswordHasher.
-rw-r--r--tests/auth_tests/test_hashers.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/auth_tests/test_hashers.py b/tests/auth_tests/test_hashers.py
index f00e2720b9..b03046c0b1 100644
--- a/tests/auth_tests/test_hashers.py
+++ b/tests/auth_tests/test_hashers.py
@@ -431,6 +431,8 @@ class TestUtilsHashPass(SimpleTestCase):
class BasePasswordHasherTests(SimpleTestCase):
+ not_implemented_msg = 'subclasses of BasePasswordHasher must provide %s() method'
+
def setUp(self):
self.hasher = BasePasswordHasher()
@@ -445,6 +447,33 @@ class BasePasswordHasherTests(SimpleTestCase):
with self.assertRaisesMessage(ValueError, msg):
PlainHasher()._load_library()
+ def test_attributes(self):
+ self.assertIsNone(self.hasher.algorithm)
+ self.assertIsNone(self.hasher.library)
+
+ def test_encode(self):
+ msg = self.not_implemented_msg % 'an encode'
+ with self.assertRaisesMessage(NotImplementedError, msg):
+ self.hasher.encode('password', 'salt')
+
+ def test_harden_runtime(self):
+ msg = 'subclasses of BasePasswordHasher should provide a harden_runtime() method'
+ with self.assertWarns(Warning, msg=msg):
+ self.hasher.harden_runtime('password', 'encoded')
+
+ def test_must_update(self):
+ self.assertIs(self.hasher.must_update('encoded'), False)
+
+ def test_safe_summary(self):
+ msg = self.not_implemented_msg % 'a safe_summary'
+ with self.assertRaisesMessage(NotImplementedError, msg):
+ self.hasher.safe_summary('encoded')
+
+ def test_verify(self):
+ msg = self.not_implemented_msg % 'a verify'
+ with self.assertRaisesMessage(NotImplementedError, msg):
+ self.hasher.verify('password', 'encoded')
+
@skipUnless(argon2, "argon2-cffi not installed")
@override_settings(PASSWORD_HASHERS=PASSWORD_HASHERS)