Пример #1
0
 def testUserDeleteUser(self):
     usermanager = IMembraneUserManagement(self.member)
     self.failUnless('testuser' in self.portal.objectIds())
     usermanager.doDeleteUser('testuser')
     self.failIf('testuser' in self.portal.objectIds())
     # login as the new user should fail now
     logout()
     self.assertRaises(ValueError, login, self.portal, 'testuser')
Пример #2
0
 def testUserChangePassword(self):
     usermanager = IMembraneUserManagement(self.member)
     userauth = IMembraneUserAuth(self.member)
     authcred = userauth.authenticateCredentials
     # Verify the current credentials
     credentials = {'login': '******', 'password': '******'}
     self.failUnlessEqual(authcred(credentials),
                          (userauth.getUserId(), self.member.getUserName()))
     usermanager.doChangeUser('testuser', 'pass2')
     credentials = {'login': '******', 'password': '******'}
     self.failUnlessEqual(authcred(credentials),
                          (userauth.getUserId(), self.member.getUserName()))
 def testIMembraneUserManagement(self):
     """Test the functionality of the IMembraneUserManagement interface."""
     from Products.membrane.interfaces import IMembraneUserManagement
     from Products.membrane.at.interfaces import IUserAuthentication
     
     user = IMembraneUserManagement(self.person);
     auth = IUserAuthentication(self.person);
      
     #test setting password directly, verify that verifyCredentials works as expected
     fsd_tool = getToolByName(self.portal, TOOLNAME)
     self.person.setPassword('secret1')
     if fsd_tool.getUseInternalPassword():
         self.failUnless(auth.verifyCredentials({'login':'******','password':'******'}), "failed to verify correct login and password, setting password directly")
     else:
         self.failIf(auth.verifyCredentials({'login':'******','password':'******'}), "internal password not used, method should return none, setting password directly.  Value returned: %s" % returnval)
     
     # now set password using the userChanger method and verify that it worked
     user.doChangeUser('abc123', 'secret2')
     fsd_tool = getToolByName(self.portal, TOOLNAME)
     if fsd_tool.getUseInternalPassword():
         self.failUnless(auth.verifyCredentials({'login':'******','password':'******'}), "failed to verify correct login and password, testing doChangeUser()")
     else:
         self.failIf(auth.verifyCredentials({'login':'******','password':'******'}), "internal password not used, method should return none, testing doChangeUser().  Value returned: %s" % returnval)
     
     # set password and some other value with doChangeUser, using keywords
     self.failIf(self.person.getEmail(), "email already set, and it shouldn't be: %s" % self.person.getEmail())
     user.doChangeUser('abc123','secret', email='*****@*****.**')
     self.failUnlessEqual(self.person.getEmail(), '*****@*****.**', msg="failed to update email via doChangeUser(): %s" % self.person.getEmail())
     
     # now try to delete the user
     self.failUnless(hasattr(self.directory,'abc123'), "directory does not have person")
     user.doDeleteUser('abc123')
     self.failIf(hasattr(self.directory,'abc123'), "directory still contains person")
     
     # we should not be able to log in as this person anymore
     self.logout()
     try:
         self.login('abc123')
     except AttributeError:
         pass
     else:
         self.fail("still able to login: %s" % self.portal.portal_membership.getAuthenticatedMember().id)
 def testIMembraneUserManagement(self):
     """Test the functionality of the IMembraneUserManagement interface."""
     from Products.membrane.interfaces import IMembraneUserManagement
     from Products.membrane.at.interfaces import IUserAuthentication
     
     user = IMembraneUserManagement(self.person);
     auth = IUserAuthentication(self.person);
      
     #test setting password directly, verify that verifyCredentials works as expected
     fsd_tool = getToolByName(self.portal, TOOLNAME)
     self.person.setPassword('secret1')
     if fsd_tool.getUseInternalPassword():
         self.failUnless(auth.verifyCredentials({'login':'******','password':'******'}), "failed to verify correct login and password, setting password directly")
     else:
         self.failIf(auth.verifyCredentials({'login':'******','password':'******'}), "internal password not used, method should return none, setting password directly.  Value returned: %s" % returnval)
     
     # now set password using the userChanger method and verify that it worked
     user.doChangeUser('abc123', 'secret2')
     fsd_tool = getToolByName(self.portal, TOOLNAME)
     if fsd_tool.getUseInternalPassword():
         self.failUnless(auth.verifyCredentials({'login':'******','password':'******'}), "failed to verify correct login and password, testing doChangeUser()")
     else:
         self.failIf(auth.verifyCredentials({'login':'******','password':'******'}), "internal password not used, method should return none, testing doChangeUser().  Value returned: %s" % returnval)
     
     # set password and some other value with doChangeUser, using keywords
     self.failIf(self.person.getEmail(), "email already set, and it shouldn't be: %s" % self.person.getEmail())
     user.doChangeUser('abc123','secret', email='*****@*****.**')
     self.failUnlessEqual(self.person.getEmail(), '*****@*****.**', msg="failed to update email via doChangeUser(): %s" % self.person.getEmail())
     
     # now try to delete the user
     self.failUnless(hasattr(self.directory,'abc123'), "directory does not have person")
     user.doDeleteUser('abc123')
     self.failIf(hasattr(self.directory,'abc123'), "directory still contains person")
     
     # we should not be able to log in as this person anymore
     self.logout()
     try:
         self.login('abc123')
     except AttributeError:
         pass
     else:
         self.fail("still able to login: %s" % self.portal.portal_membership.getAuthenticatedMember().id)
Пример #5
0
 def testUserChangeOtherData(self):
     usermanager = IMembraneUserManagement(self.member)
     usermanager.doChangeUser('testuser', 'pass2', mobilePhone='555-1212')
     self.failUnlessEqual(self.member.getMobilePhone(), '555-1212')