summaryrefslogtreecommitdiff
path: root/src/mailman/utilities/tests/test_passwords.py
diff options
context:
space:
mode:
authorBarry Warsaw2011-04-08 22:02:49 -0400
committerBarry Warsaw2011-04-08 22:02:49 -0400
commit25b407e24fe21dc46a4f9efa77734d55e0ed4bdd (patch)
treed129f8727bac75263c08d84b5138bef8f693ffef /src/mailman/utilities/tests/test_passwords.py
parentc73acb993acfc08f542b886eb426d6156a6a0a13 (diff)
downloadmailman-25b407e24fe21dc46a4f9efa77734d55e0ed4bdd.tar.gz
mailman-25b407e24fe21dc46a4f9efa77734d55e0ed4bdd.tar.zst
mailman-25b407e24fe21dc46a4f9efa77734d55e0ed4bdd.zip
Diffstat (limited to 'src/mailman/utilities/tests/test_passwords.py')
-rw-r--r--src/mailman/utilities/tests/test_passwords.py34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/mailman/utilities/tests/test_passwords.py b/src/mailman/utilities/tests/test_passwords.py
index 7b6989779..c9b3d2e91 100644
--- a/src/mailman/utilities/tests/test_passwords.py
+++ b/src/mailman/utilities/tests/test_passwords.py
@@ -170,6 +170,40 @@ class TestPasswordGeneration(unittest.TestCase):
self.assertTrue(vowel in 'aeiou', vowel)
self.assertTrue(consonant not in 'aeiou', consonant)
+ def test_encrypt_password_plaintext_default_scheme(self):
+ # Test that a plain text password gets encrypted.
+ self.assertEqual(passwords.encrypt_password('abc'),
+ '{CLEARTEXT}abc')
+
+ def test_encrypt_password_plaintext(self):
+ # Test that a plain text password gets encrypted with the given scheme.
+ scheme = passwords.Schemes.sha
+ self.assertEqual(passwords.encrypt_password('abc', scheme),
+ '{SHA}qZk-NkcGgWq6PiVxeFDCbJzQ2J0=')
+
+ def test_encrypt_password_plaintext_by_scheme_name(self):
+ # Test that a plain text password gets encrypted with the given
+ # scheme, which is given by name.
+ self.assertEqual(passwords.encrypt_password('abc', 'cleartext'),
+ '{CLEARTEXT}abc')
+
+ def test_encrypt_password_already_encrypted_default_scheme(self):
+ # Test that a password which is already encrypted is return unchanged.
+ self.assertEqual(passwords.encrypt_password('{SHA}abc'), '{SHA}abc')
+
+ def test_encrypt_password_already_encrypted(self):
+ # Test that a password which is already encrypted is return unchanged,
+ # ignoring any requested scheme.
+ scheme = passwords.Schemes.cleartext
+ self.assertEqual(passwords.encrypt_password('{SHA}abc', scheme),
+ '{SHA}abc')
+
+ def test_encrypt_password_password_value_error(self):
+ self.assertRaises(ValueError, passwords.encrypt_password, 7)
+
+ def test_encrypt_password_scheme_value_error(self):
+ self.assertRaises(ValueError, passwords.encrypt_password, 'abc', 'foo')
+
def test_suite():