From c73acb993acfc08f542b886eb426d6156a6a0a13 Mon Sep 17 00:00:00 2001 From: Barry Warsaw Date: Fri, 8 Apr 2011 20:09:13 -0400 Subject: add_member() - As the most common interface for adding new members (and users), adapt the password storing bit to storing only encrypted passwords in the database. schema.cfg: - Remove the creator_pw_file and site_pw_file as they are obsolete. - Add password_schema key for defining the default password encryption scheme. mailman.sql, user.py: - Store the password as a binary blob instead of as unicode text. --- src/mailman/app/tests/test_membership.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'src/mailman/app/tests') diff --git a/src/mailman/app/tests/test_membership.py b/src/mailman/app/tests/test_membership.py index b0e1bae5d..2b69c7f39 100644 --- a/src/mailman/app/tests/test_membership.py +++ b/src/mailman/app/tests/test_membership.py @@ -31,6 +31,7 @@ from zope.component import getUtility from mailman.app.lifecycle import create_list from mailman.app.membership import add_member +from mailman.config import config from mailman.core.constants import system_preferences from mailman.interfaces.bans import IBanManager from mailman.interfaces.member import DeliveryMode, MembershipIsBannedError @@ -124,8 +125,35 @@ class AddMemberTest(unittest.TestCase): self.assertEqual(member.address.email, 'anne@example.com') + +class AddMemberPasswordTest(unittest.TestCase): + layer = ConfigLayer + + def setUp(self): + self._mlist = create_list('test@example.com') + # The default ssha scheme introduces a random salt, which is + # inappropriate for unit tests. + config.push('password scheme', """ + [passwords] + password_scheme: sha + """) + + def tearDown(self): + config.pop('password scheme') + reset_the_world() + + def test_add_member_password(self): + # Test that the password stored with the new user is encrypted. + member = add_member(self._mlist, 'anne@example.com', + 'Anne Person', 'abc', DeliveryMode.regular, + system_preferences.preferred_language) + self.assertEqual( + member.user.password, '{SHA}qZk-NkcGgWq6PiVxeFDCbJzQ2J0=') + + def test_suite(): suite = unittest.TestSuite() suite.addTest(unittest.makeSuite(AddMemberTest)) + suite.addTest(unittest.makeSuite(AddMemberPasswordTest)) return suite -- cgit v1.2.3-70-g09d2