[CMF-checkins] CVS: Products/CMFCore/tests -
test_MemberDataTool.py:1.5.14.1
Florent Guillaume
fg at nuxeo.com
Fri Apr 15 13:25:21 EDT 2005
Update of /cvs-repository/Products/CMFCore/tests
In directory cvs.zope.org:/tmp/cvs-serv14094/CMFCore/tests
Modified Files:
Tag: CMF-1_5-branch
test_MemberDataTool.py
Log Message:
MemberDataTool: setSecurityProfile (called by MembershipTool's
setPassword) now uses the userFolderEditUser() API of the user folder to
change user information.
=== Products/CMFCore/tests/test_MemberDataTool.py 1.5 => 1.5.14.1 ===
--- Products/CMFCore/tests/test_MemberDataTool.py:1.5 Mon Apr 26 08:14:17 2004
+++ Products/CMFCore/tests/test_MemberDataTool.py Fri Apr 15 13:25:20 2005
@@ -3,11 +3,51 @@
import Zope
Zope.startup()
from Interface.Verify import verifyClass
+import Acquisition
from Products.CMFCore.MemberDataTool import MemberDataTool
from Products.CMFCore.MemberDataTool import MemberData
+class DummyUserFolder(Acquisition.Implicit):
+
+ def __init__(self):
+ self._users = {}
+
+ def _addUser(self, user):
+ self._users[user.getUserName()] = user
+
+ def userFolderEditUser(self, name, password, roles, domains):
+ user = self._users[name]
+ if password is not None:
+ user.__ = password
+ # Emulate AccessControl.User's stupid behavior (should test None)
+ user.roles = tuple(roles)
+ user.domains = tuple(domains)
+
+
+class DummyUser(Acquisition.Implicit):
+
+ def __init__(self, name, password, roles, domains):
+ self.name = name
+ self.__ = password
+ self.roles = tuple(roles)
+ self.domains = tuple(domains)
+
+ def getUserName(self):
+ return self.name
+
+ def getRoles(self):
+ return self.roles + ('Authenticated',)
+
+ def getDomains(self):
+ return self.domains
+
+
+class DummyMemberDataTool(Acquisition.Implicit):
+ pass
+
+
class MemberDataToolTests(TestCase):
def test_deleteMemberData(self):
@@ -35,6 +75,25 @@
verifyClass(IMemberData, MemberData)
+ def test_setSecurityProfile(self):
+ mdtool = DummyMemberDataTool()
+ aclu = DummyUserFolder()
+ user = DummyUser('bob', 'pw', ['Role'], ['domain'])
+ aclu._addUser(user)
+ user = user.__of__(aclu)
+ member = MemberData(None, 'bob').__of__(mdtool).__of__(user)
+ member.setSecurityProfile(password='newpw')
+ self.assertEqual(user.__, 'newpw')
+ self.assertEqual(list(user.roles), ['Role'])
+ self.assertEqual(list(user.domains), ['domain'])
+ member.setSecurityProfile(roles=['NewRole'])
+ self.assertEqual(user.__, 'newpw')
+ self.assertEqual(list(user.roles), ['NewRole'])
+ self.assertEqual(list(user.domains), ['domain'])
+ member.setSecurityProfile(domains=['newdomain'])
+ self.assertEqual(user.__, 'newpw')
+ self.assertEqual(list(user.roles), ['NewRole'])
+ self.assertEqual(list(user.domains), ['newdomain'])
def test_suite():
return TestSuite((
More information about the CMF-checkins
mailing list