Back to index

plone3  3.1.7
Public Member Functions | Public Attributes
PlonePAS.tests.test_basic_ops.BasicOpsTestCase Class Reference
Inheritance diagram for PlonePAS.tests.test_basic_ops.BasicOpsTestCase:
Inheritance graph
[legend]
Collaboration diagram for PlonePAS.tests.test_basic_ops.BasicOpsTestCase:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def afterSetUp
def compareRoles
def createUser
def test_installed
def test_add
def test_edit
def test_edit_userDefinedRole
def test_del
def test_search
def test_setpw

Public Attributes

 acl_users

Detailed Description

Definition at line 33 of file test_basic_ops.py.


Member Function Documentation

Definition at line 35 of file test_basic_ops.py.

00035 
00036     def afterSetUp(self):
00037         self.loginAsPortalOwner()
00038         self.acl_users = self.portal.acl_users

Here is the call graph for this function:

def PlonePAS.tests.test_basic_ops.BasicOpsTestCase.compareRoles (   self,
  target,
  user,
  roles 
)
compareRoles(self, target, user, roles) => do not raise if
user has exactly the specified roles.

If target is None, test user roles (no local roles)

Definition at line 39 of file test_basic_ops.py.

00039 
00040     def compareRoles(self, target, user, roles):
00041         """
00042         compareRoles(self, target, user, roles) => do not raise if
00043         user has exactly the specified roles.
00044 
00045         If target is None, test user roles (no local roles)
00046         """
00047         u = self.acl_users.getUser(user)
00048         if not u:
00049             raise RuntimeError, "compareRoles: Invalid user: '%s'" % user
00050         non_roles = ('Authenticated', 'Anonymous', '')
00051         if target is None:
00052             user_roles = list(u.getRoles())
00053         else:
00054             user_roles = list(u.getRolesInContext(target))
00055         actual_roles = filter(lambda x: x not in non_roles, user_roles)
00056         actual_roles.sort()
00057         wished_roles = list(roles)
00058         wished_roles.sort()
00059         if actual_roles == wished_roles:
00060             return 1
00061         raise RuntimeError, ("User %s: Whished roles: %s BUT current "
00062                              "roles: %s" % (user, wished_roles, actual_roles))

Here is the call graph for this function:

Here is the caller graph for this function:

def PlonePAS.tests.test_basic_ops.BasicOpsTestCase.createUser (   self,
  login = "created_user",
  password = "secret",
  roles = [],
  groups = [],
  domains = () 
)

Definition at line 64 of file test_basic_ops.py.

00064 
00065                    roles=[], groups=[], domains=()):
00066         self.acl_users.userFolderAddUser(
00067             login,
00068             password,
00069             roles = roles,
00070             groups = groups,
00071             domains = domains,
00072             )

Here is the caller graph for this function:

Definition at line 76 of file test_basic_ops.py.

00076 
00077     def test_add(self):
00078         self.createUser()
00079         self.failUnless(self.acl_users.getUser("created_user"))

Here is the call graph for this function:

Definition at line 115 of file test_basic_ops.py.

00115 
00116     def test_del(self):
00117         self.createUser()
00118         self.failUnless(self.acl_users.getUser("created_user"))
00119         self.acl_users.userFolderDelUsers(['created_user'])
00120         self.failIf(self.acl_users.getUser("created_user"))

Here is the call graph for this function:

Definition at line 80 of file test_basic_ops.py.

00080 
00081     def test_edit(self):
00082         # this will fail unless the PAS role plugin is told it manages
00083         # the new role.
00084         self.createUser()
00085         self.compareRoles(None, "created_user", [])
00086         self.acl_users.userFolderEditUser(
00087             "created_user", # name
00088             "secret2", # password
00089             roles = ["Member"],
00090             groups = ["g1"],
00091             domains = (),
00092             )
00093         self.compareRoles(None, "created_user", ['Member'])

Here is the call graph for this function:

Definition at line 94 of file test_basic_ops.py.

00094 
00095     def test_edit_userDefinedRole(self):
00096        roleplugins = self.acl_users.plugins.listPlugins(IRolesPlugin)
00097         for id, plugin in roleplugins:
00098             try:
00099                 plugin.addRole('r1')
00100             except _SWALLOWABLE_PLUGIN_EXCEPTIONS:
00101                 pass
00102             else:
00103                 break
00104 
00105         self.createUser()
00106         self.compareRoles(None, "created_user", [])
00107         self.acl_users.userFolderEditUser(
00108             "created_user", # name
00109             "secret2", # password
00110             roles = ["r1"],
00111             groups = ["g1"],
00112             domains = (),
00113             )
00114         self.compareRoles(None, "created_user", ['r1'])

Here is the call graph for this function:

Definition at line 73 of file test_basic_ops.py.

00073 
00074     def test_installed(self):
00075         self.failUnless(IPluggableAuthService.providedBy(self.acl_users))

Definition at line 121 of file test_basic_ops.py.

00121 
00122     def test_search(self):
00123         self.createUser("created_user1")
00124         self.createUser("created_user2")
00125         mt = self.portal.portal_membership
00126         retlist = mt.searchForMembers(REQUEST=None, login="created_user1")
00127         usernames = [user.getUserName() for user in retlist]
00128        self.assertEquals(len(usernames), 1) 
00129         self.failUnless("created_user1" in usernames,
00130                         "'created_user1' not in %s" % usernames)

Here is the call graph for this function:

Definition at line 131 of file test_basic_ops.py.

00131 
00132     def test_setpw(self):
00133         # there is more than one place where one can set the password.
00134         # insane. anyway we have to check the patch in pas.py userSetPassword 
00135         # here its checked in the general setup using ZODBUserManager.
00136         self.createUser()
00137         uf = self.acl_users
00138         new_secret = 'new_secret'
00139         uf.userSetPassword('created_user', new_secret)
00140         
00141         # possible to authenticate with new password?
00142         from Products.PluggableAuthService.interfaces.plugins \
00143             import IAuthenticationPlugin
00144         authenticators = uf.plugins.listPlugins(IAuthenticationPlugin)
00145         credentials = {'login': 'created_user', 'password': new_secret}
00146         result = None
00147         for aid, authenticator in authenticators:
00148             result = authenticator.authenticateCredentials(credentials)
00149             if result is not None:
00150                 break
00151         self.failUnless(result)        
00152         
        

Here is the call graph for this function:


Member Data Documentation

Definition at line 37 of file test_basic_ops.py.


The documentation for this class was generated from the following file: