Back to index

plone3  3.1.7
Public Member Functions | Public Attributes | Static Public Attributes
GroupUserFolder.tests.testGroupUserFolderAPI.TestGroupUserFolderAPI Class Reference
Inheritance diagram for GroupUserFolder.tests.testGroupUserFolderAPI.TestGroupUserFolderAPI:
Inheritance graph
[legend]
Collaboration diagram for GroupUserFolder.tests.testGroupUserFolderAPI.TestGroupUserFolderAPI:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def test10GRUFMethods
def test_getUserNames
def test_getUserIds
def test_getUser
def test_hasUsers
def test_getUsers
def test_getUserById
def test_getUserByName
def test_getPureUserNames
def test_getPureUserIds
def test_getPureUsers
def test_getPureUser
def test_getGroupNames
def test_getGroupIds
def test_getGroups
def test_getGroup
def test_getGroupById
def test_getGroupByName
def test_userFolderAddUser
def test_userFolderEditUser
def test_userFolderUpdateUser
def test_userFolderDelUsers
def test_userFolderAddGroup
def test_userFolderEditGroup
def test_userFolderUpdateGroup
def test_userFolderDelGroups
def test_userSetRoles
def test_userAddRole
def test_userRemoveRole
def test_userSetPassword
def test_userGetDomains
def test_userSetDomains
def test_userAddDomain
def test_userRemoveDomain
def test_userSetGroups
def test_userAddGroup
def test_userRemoveGroup
def test_searchUsersByAttribute
def test_searchUsersByName
def test_searchUsersById
def test_searchGroupsByAttribute
def test_searchGroupsByName
def test_searchGroupsById
def test_setRolesOnUsers
def test_setRolesOnGroups
def test_getUsersOfRole
def test_getRolesOfUser
def test_userFolderGetRoles
def test_userFolderAddRole
def test_userFolderDelRoles
def test_getMemberIds
def test_getUserMemberIds
def test_getGroupMemberIds
def test_addMember
def test_removeMember
def test_setMembers
def test_hasMember
def test_getRealId
def test_acquireLocalRoles
def test_isLocalRoleAcquired
def test_getAllLocalRoles
def gruf_setup
def gruf_sources_setup
def security_context_setup
def security_context_setup_users
def test01Interfaces
def test02TestCaseCompletude
def test03ClassSecurityInfo

Public Attributes

 gruf_folder
 gruf
 lr
 sublr
 sublr2
 sublr3
 subsublr2
 subsublr3

Static Public Attributes

tuple klasses

Detailed Description

Definition at line 60 of file testGroupUserFolderAPI.py.


Member Function Documentation

gruf_setup(self,) => Basic gruf setup

Definition at line 86 of file GRUFTestCase.py.

00086 
00087     def gruf_setup(self,):
00088         """
00089         gruf_setup(self,) => Basic gruf setup
00090         """
00091         # Replace default acl_user by a GRUF one
00092         self.folder.manage_delObjects(['acl_users'])
00093         self.folder.manage_addProduct['OFSP'].manage_addFolder('testFolder')
00094         self.gruf_folder = self.folder.testFolder
00095         self.gruf_folder.manage_addProduct['GroupUserFolder'].manage_addGroupUserFolder()
00096         self.gruf = self.gruf_folder.acl_users
00097 

Here is the caller graph for this function:

gruf_sources_setup(self,) => this method installs the required sources inside GRUF.
One can override this in a test case to install other sources and make another bunch of unit tests
For example, for LDAPUserFolder, use manage_addProduct/LDAPUserFolder/addLDAPUserFolder

Reimplemented in GroupUserFolder.tests.testLDAPGroupFolder.TestLDAPUserFolderGroups, and GroupUserFolder.tests.testLDAPUserFolder.TestLDAPUserFolderBasics.

Definition at line 98 of file GRUFTestCase.py.

00098 
00099     def gruf_sources_setup(self,):
00100         """
00101         gruf_sources_setup(self,) => this method installs the required sources inside GRUF.
00102         One can override this in a test case to install other sources and make another bunch of unit tests
00103         For example, for LDAPUserFolder, use manage_addProduct/LDAPUserFolder/addLDAPUserFolder
00104         """
00105         # Use this to replace the default user source
00106         self.gruf.replaceUserSource("Users", "manage_addProduct/OFSP/manage_addUserFolder")
00107 
00108         # Use this to replace the default group source
00109         self.gruf.replaceUserSource("Groups", "manage_addProduct/OFSP/manage_addUserFolder")
00110 
00111         # add a second (empty) user source
00112         self.gruf.addUserSource("manage_addProduct/OFSP/manage_addUserFolder")

Build a complex security environment

It creates:
  * 3 roles, r1, r2 and r3
  * 3 groups: g1, g2, g3
  * n users as follows (roles are between parenthesis)

      !   g1    ! g2(r1)     ! g3(r2)     ! g4(r2,r3)  !  Resulting roles !
  ------------!---------!------------!------------!------------!------------------!
  u1          !         !            !            !            !   => (no role)   !
  u2          !   X     !            !            !            !   => (no role)   !
  u3          !   X     !      X     !            !            !   => r1          !
  u4          !   X     !      X     !      X     !            !   => r1,r2       !
  u5(r1)      !         !      X     !      X     !            !   => r1,r2       !
  u6(r1)      !         !            !      X     !            !   => r1,r2       !
  u7(r1)      !         !            !            !     X      !   => r1,r2,r3    !
  ---------------------------------------------------------------------------------

It also creates a 'lr' folder in which g1 group and u3 and u6 are granted r3 role.


And then, it creates nested groups as follow (-> = belongs to group...):

     u/g   !  belongs to... ! resulting roles                     !
 ----------!----------------!-------------------------------------!
  ng1      !   g1           ! (no role)                           !
  ng2      !   g2, g3       ! r1, r2                              !
  ng3      !   g2, ng2      ! r1, r2                              !
  ng4(r3)  !   g2, ng2      ! r1, r2, r3                          !
  ng5      !   g2, ng4      ! r1, r2, r3                          !
  ng6      !   ng5, ng6     ! r1, r2, r3 (no circ. ref)           !
  u8       !   ng1          ! (no role)                           !
  u9       !   g1, ng2      ! r1, r2                              !
  u10      !   ng2, ng3     ! r1, r2                              !
  u11(r3)  !   ng2, ng3     ! r1, r2, r3                          !
  u12      !   ng5, ng6     ! r1, r2, r3                          !
 -----------------------------------------------------------------!

 Plus we have the following local roles matrix (roles inside parenthesis are implicitly
 user-defined, roles inside brackets are implicitly lr-defined).

 folder
   |
   |-- acl_users (GRUF)
   |
   |                                          r1    r2    r3
   |                             /--
   |                             | group_g1               x
   |-- lr                        | u3        (x)          x
       |                         | u6        (x)   (x)    x
       |                         \--
       |
       |                         /--
       |                         | group_g1              [x]
       |-- sublr                 | u3        (x)    x    [x]
       |                         | u6        (x)    x*   [x]
       |                         \--
       |
       |                         /--
       |                         | group_g1              [x]
       |-- sublr2                | u3        (x)    x    [x]
       |   |                     | u6        (x)    x*   [x]
       |   |                     \--
       |   |
       |   |                     /--
       |   |                     | group_g1              [x]
       |   |-- subsublr2         | u3        (x)   [x]   [x]
       |                         | u6        (x)  [(x)]  [x]
       |                         \--
       |
 (now we block local roles under this branch)
       |
       |                         /--
       |                         | group_g1              
       |-- sublr3                | u3        (x)    x    
   |                     | u6        (x)    x*   
   |                     \--
   |
   |                     /--
   |                     | group_g1              
   |-- subsublr3         | u3        (x)   [x]   
                         | u6        (x)  [(x)]  
                         \--
                         
*: u6 will have r2 as a localrole AND a userdefined role.

Definition at line 113 of file GRUFTestCase.py.

00113 
00114     def security_context_setup(self,):
00115         """
00116         Build a complex security environment
00117 
00118         It creates:
00119           * 3 roles, r1, r2 and r3
00120           * 3 groups: g1, g2, g3
00121           * n users as follows (roles are between parenthesis)
00122 
00123                       !   g1    ! g2(r1)     ! g3(r2)     ! g4(r2,r3)  !  Resulting roles !
00124           ------------!---------!------------!------------!------------!------------------!
00125           u1          !         !            !            !            !   => (no role)   !
00126           u2          !   X     !            !            !            !   => (no role)   !
00127           u3          !   X     !      X     !            !            !   => r1          !
00128           u4          !   X     !      X     !      X     !            !   => r1,r2       !
00129           u5(r1)      !         !      X     !      X     !            !   => r1,r2       !
00130           u6(r1)      !         !            !      X     !            !   => r1,r2       !
00131           u7(r1)      !         !            !            !     X      !   => r1,r2,r3    !
00132           ---------------------------------------------------------------------------------
00133 
00134         It also creates a 'lr' folder in which g1 group and u3 and u6 are granted r3 role.
00135 
00136 
00137         And then, it creates nested groups as follow (-> = belongs to group...):
00138 
00139              u/g   !  belongs to... ! resulting roles                     !
00140          ----------!----------------!-------------------------------------!
00141           ng1      !   g1           ! (no role)                           !
00142           ng2      !   g2, g3       ! r1, r2                              !
00143           ng3      !   g2, ng2      ! r1, r2                              !
00144           ng4(r3)  !   g2, ng2      ! r1, r2, r3                          !
00145           ng5      !   g2, ng4      ! r1, r2, r3                          !
00146           ng6      !   ng5, ng6     ! r1, r2, r3 (no circ. ref)           !
00147           u8       !   ng1          ! (no role)                           !
00148           u9       !   g1, ng2      ! r1, r2                              !
00149           u10      !   ng2, ng3     ! r1, r2                              !
00150           u11(r3)  !   ng2, ng3     ! r1, r2, r3                          !
00151           u12      !   ng5, ng6     ! r1, r2, r3                          !
00152          -----------------------------------------------------------------!
00153 
00154          Plus we have the following local roles matrix (roles inside parenthesis are implicitly
00155          user-defined, roles inside brackets are implicitly lr-defined).
00156 
00157          folder
00158            |
00159            |-- acl_users (GRUF)
00160            |
00161            |                                          r1    r2    r3
00162            |                             /--
00163            |                             | group_g1               x
00164            |-- lr                        | u3        (x)          x
00165                |                         | u6        (x)   (x)    x
00166                |                         \--
00167                |
00168                |                         /--
00169                |                         | group_g1              [x]
00170                |-- sublr                 | u3        (x)    x    [x]
00171                |                         | u6        (x)    x*   [x]
00172                |                         \--
00173                |
00174                |                         /--
00175                |                         | group_g1              [x]
00176                |-- sublr2                | u3        (x)    x    [x]
00177                |   |                     | u6        (x)    x*   [x]
00178                |   |                     \--
00179                |   |
00180                |   |                     /--
00181                |   |                     | group_g1              [x]
00182                |   |-- subsublr2         | u3        (x)   [x]   [x]
00183                |                         | u6        (x)  [(x)]  [x]
00184                |                         \--
00185                |
00186          (now we block local roles under this branch)
00187                |
00188                |                         /--
00189                |                         | group_g1              
00190                |-- sublr3                | u3        (x)    x    
00191                    |                     | u6        (x)    x*   
00192                    |                     \--
00193                    |
00194                    |                     /--
00195                    |                     | group_g1              
00196                    |-- subsublr3         | u3        (x)   [x]   
00197                                          | u6        (x)  [(x)]  
00198                                          \--
00199                                          
00200         *: u6 will have r2 as a localrole AND a userdefined role.
00201         """
00202         # Create a few roles
00203         self.gruf.userFolderAddRole("r1")
00204         self.gruf.userFolderAddRole("r2")
00205         self.gruf.userFolderAddRole("r3")
00206 
00207         # Set View permission on those roles
00208         permissions = self.gruf_folder.ac_inherited_permissions(1)
00209         for ip in range(len(permissions)):
00210             name, value = permissions[ip][:2]
00211             if name == "View":
00212                 break
00213         p=Permission.Permission(name,value, self.gruf_folder)
00214         p.setRoles(("r1", "r2", "r3", ))
00215 
00216         # Setup users and groups
00217         self.security_context_setup_groups()
00218         self.security_context_setup_users()
00219         
00220         # Create a few folders to play with
00221         self.gruf_folder.manage_addProduct['OFSP'].manage_addFolder('lr')
00222         lr = self.gruf_folder.lr
00223         lr.manage_addProduct['OFSP'].manage_addFolder("sublr")
00224         sublr = self.gruf_folder.lr.sublr
00225         lr.manage_addProduct['OFSP'].manage_addFolder("sublr2")
00226         sublr2 = self.gruf_folder.lr.sublr2
00227         sublr2.manage_addProduct['OFSP'].manage_addFolder("subsublr2")
00228         subsublr2 = self.gruf_folder.lr.sublr2.subsublr2
00229         lr.manage_addProduct['OFSP'].manage_addFolder("sublr3")
00230         sublr3 = self.gruf_folder.lr.sublr3
00231         sublr3.manage_addProduct['OFSP'].manage_addFolder("subsublr3")
00232         subsublr3 = self.gruf_folder.lr.sublr3.subsublr3
00233         self.gruf._acquireLocalRoles(sublr3, 0)
00234         lr.manage_addLocalRoles("group_g1", ("r3", ))
00235         lr.manage_addLocalRoles("u3", ("r3", ))
00236         lr.manage_addLocalRoles("u6", ("r3", ))
00237         sublr.manage_addLocalRoles("u3", ("r2", ))
00238         sublr.manage_addLocalRoles("u6", ("r2", ))
00239         sublr2.manage_addLocalRoles("u3", ("r2", ))
00240         sublr2.manage_addLocalRoles("u6", ("r2", ))
00241         sublr3.manage_addLocalRoles("u3", ("r2", ))
00242         sublr3.manage_addLocalRoles("u6", ("r2", ))
00243         self.lr = lr
00244         self.sublr = sublr
00245         self.sublr2 = sublr2
00246         self.sublr3 = sublr3
00247         self.subsublr2 = subsublr2
00248         self.subsublr3 = subsublr3
00249 

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 250 of file GRUFTestCase.py.

00250 
00251     def security_context_setup_users(self,):
00252         # Create a manager and a few users
00253         self.gruf.userFolderAddUser('manager', 'secret', ('Manager',), (), (), )
00254         self.gruf.userFolderAddUser('u1', 'secret', (), (), (), )
00255         self.gruf.userFolderAddUser('u2', 'secret', (), (), ('g1', ), )
00256         self.gruf.userFolderAddUser('u3', 'secret', (), (), ('g1', 'g2'), )
00257         self.gruf.userFolderAddUser('u4', 'secret', (), (), ('g1', 'g2', 'g3'), )
00258         self.gruf.userFolderAddUser('u5', 'secret', ('r1', ), (), ('g2', 'g3'), )
00259         self.gruf.userFolderAddUser('u6', 'secret', ('r1', ), (), ('g3', ), )
00260         self.gruf.userFolderAddUser('u7', 'secret', ('r1', ), (), ('g4', ), )
00261 
00262         # Create nested-groups users
00263         self.gruf.userFolderAddUser('u8', 'secret', (), (), ('ng1', ), )        
00264         self.gruf.userFolderAddUser('u9', 'secret', (), (), ('g1', 'ng2', ), )
00265         self.gruf.userFolderAddUser('u10', 'secret', (), (), ('ng2', 'ng3', ), )        
        self.gruf.userFolderAddUser('u11', 'secret', ('r3', ), (), ('ng2', 'ng3', ), )        

Here is the caller graph for this function:

Test that interfaces are okay

Definition at line 81 of file testInterface.py.

00081 
00082     def test01Interfaces(self,):
00083         """
00084         Test that interfaces are okay
00085         """
00086         # Check interface for each and every class
00087         ignore = getattr(self, "ignore_interfaces", [])
00088         for klass in self.klasses:
00089             intfs = getattr(klass, "__implements__", None)
00090             self.failUnless(intfs, "'%s' class doesn't implement an interface!" % (klass.__name__, ))
00091 
00092             # Flatten interfaces
00093             intfs = flattenList(intfs)
00094 
00095             # Check each and everyone
00096             for intf in intfs:
00097                 if intf in ignore:
00098                     continue
00099                 self.failUnless(
00100                     Verify.verifyClass(
00101                     intf,
00102                     klass,
00103                     ),
00104                     "'%s' class doesn't implement '%s' interface correctly." % (klass.__name__, intf.__name__, ),
00105                     )
00106 

Here is the call graph for this function:

Check that the test case is complete : each interface entry xxx must be associated
to a test_xxx method in the test class.

Definition at line 107 of file testInterface.py.

00107 
00108     def test02TestCaseCompletude(self,):
00109         """
00110         Check that the test case is complete : each interface entry xxx must be associated
00111         to a test_xxx method in the test class.
00112         """
00113         not_defined = []
00114         tests = dir(self)
00115         count = 0
00116         
00117         # Check interface for each and every class
00118         ignore = getattr(self, "ignore_interfaces", [])
00119         for klass in self.klasses:
00120             intfs = getattr(klass, "__implements__", None)
00121             self.failUnless(intfs, "'%s' class doesn't implement an interface!" % (klass.__name__, ))
00122 
00123             # Flatten interfaces
00124             intfs = flattenInterfaces(intfs)
00125 
00126             # Check each and every interface
00127             for intf in intfs:
00128                 if intf in ignore:
00129                     continue
00130                 for name in intf.names():
00131                     count += 1
00132                     if not "test_%s" % (name,) in tests:
00133                         not_defined.append("%s.%s" % (klass.__name__, name))
00134 
00135 
00136         # Raise in case some tests are missing
00137         if not_defined:
00138             raise RuntimeError, "%d (over %d) MISSING TESTS:\n%s do not have a test associated." % (
00139                 len(not_defined),
00140                 count,
00141                 string.join(not_defined, ", "),
00142                 )
00143         
        

Here is the call graph for this function:

This method tests that each and every method has a ClassSecurityInfo() declaration
XXX This doesn't walk through inheritance :(

Reimplemented in GroupUserFolder.tests.testUserAPI.TestUserFolderAPI.

Definition at line 144 of file testInterface.py.

00144 
00145     def test03ClassSecurityInfo(self):
00146         """
00147         This method tests that each and every method has a ClassSecurityInfo() declaration
00148         XXX This doesn't walk through inheritance :(
00149         """
00150         not_defined = []
00151         count = 0
00152         
00153         # Check interface for each and every class
00154         ignore = getattr(self, "ignore_interfaces", [])
00155         for klass in self.klasses:
00156             dict = dir(klass)
00157             intfs = getattr(klass, "__implements__", None)
00158             self.failUnless(intfs, "'%s' class doesn't implement an interface!" % (klass.__name__, ))
00159 
00160             # Flatten interfaces
00161             intfs = flattenInterfaces(intfs)
00162             
00163             # Now check the resulting class to see if the mapping was made
00164             # correctly. Note that this uses carnal knowledge of the internal
00165             # structures used to store this information!
00166             # Check each method of every interface
00167             for intf in intfs:
00168                 if intf in ignore:
00169                     continue
00170                 for name in intf.names():
00171                     count += 1
00172                     if not "%s__roles__" % (name,) in dict:
00173                         not_defined.append("%s.%s" % (klass.__name__, name))
00174 
00175         # Raise in case some tests are missing
00176         if not_defined:
00177             raise RuntimeError, "%d (over %d) MISSING SECURITY DECLARATIONS:\n%s do not have a security declaration associated." % (
00178                 len(not_defined),
00179                 count,
00180                 string.join(not_defined, ", "),
00181                 )
00182         

Here is the call graph for this function:

We test that GRUF's API is well protected

Definition at line 66 of file testGroupUserFolderAPI.py.

00066 
00067     def test10GRUFMethods(self,):
00068         """
00069         We test that GRUF's API is well protected
00070         """
00071         self.assertRaises(Unauthorized, self.gruf_folder.restrictedTraverse, 'acl_users/getGRUFPhysicalRoot')
00072         self.assertRaises(Unauthorized, self.gruf_folder.restrictedTraverse, 'acl_users/getGRUFPhysicalRoot')

We block LR acquisition on sublr2.
See GRUFTestCase to understand what happens (basically, roles in brackets
will be removed from sublr2).

Definition at line 871 of file testGroupUserFolderAPI.py.

00871 
00872     def test_acquireLocalRoles(self,):
00873         """
00874         We block LR acquisition on sublr2.
00875         See GRUFTestCase to understand what happens (basically, roles in brackets
00876         will be removed from sublr2).
00877         """
00878         # Initial check
00879         self.failUnless(self.compareRoles(self.sublr2, "u2", ("r3", )))
00880         self.failUnless(self.compareRoles(self.sublr2, "u3", ("r1", "r2", "r3", )))
00881         self.failUnless(self.compareRoles(self.sublr2, "u6", ("r1", "r2", "r3", )))
00882         self.failUnless(self.compareRoles(self.subsublr2, "u2", ("r3", )))
00883         self.failUnless(self.compareRoles(self.subsublr2, "u3", ("r1", "r2", "r3", )))
00884         self.failUnless(self.compareRoles(self.subsublr2, "u6", ("r1", "r2", "r3", )))
00885         
00886         # Disable LR acquisition on sublr2 and test the stuff
00887         self.gruf._acquireLocalRoles(self.sublr2, 0)
00888         self.failUnless(self.compareRoles(self.sublr2, "u2", ()))
00889         self.failUnless(self.compareRoles(self.sublr2, "u3", ("r1", "r2", )))
00890         self.failUnless(self.compareRoles(self.sublr2, "u6", ("r1", "r2", )))
00891         self.failUnless(self.compareRoles(self.subsublr2, "u2", ()))
00892         self.failUnless(self.compareRoles(self.subsublr2, "u3", ("r1", "r2", )))
00893         self.failUnless(self.compareRoles(self.subsublr2, "u6", ("r1", "r2", )))

Here is the call graph for this function:

Add a member to a group

Definition at line 820 of file testGroupUserFolderAPI.py.

00820 
00821     def test_addMember(self):
00822         """Add a member to a group
00823         """
00824         self.failUnless("u1" not in self.gruf.getMemberIds("ng3"))
00825         self.gruf.addMember("ng3", "u1")
00826         self.failUnless("u1" in self.gruf.getMemberIds("ng3"))

Definition at line 910 of file testGroupUserFolderAPI.py.

00910 
00911     def test_getAllLocalRoles(self):
00912         # Allowed patterns
00913         normal_allowed = {
00914             'group_g1': ['r3', ],
00915             'u6': ['r2', 'r3', ],
00916             'test_user_1_': ['Owner', ],
00917             'u3': ['r2', 'r3', ],
00918             }
00919         blocked_allowed = {
00920             'u6': ['r2', ],
00921             'test_user_1_': ['Owner', ],
00922             'u3': ['r2', ],
00923             }
00924 
00925         # Normal behaviour
00926         ob = self.sublr2
00927         allowed = self.gruf._getAllLocalRoles(ob)
00928         self.failUnlessEqual(allowed, normal_allowed)
00929 
00930         # LR-blocking behaviour
00931         ob = self.sublr2
00932         self.gruf._acquireLocalRoles(ob, 0)
00933         allowed = self.gruf._getAllLocalRoles(ob)
00934         self.failUnlessEqual(allowed, blocked_allowed)
00935 

Definition at line 280 of file testGroupUserFolderAPI.py.

00280 
00281     def test_getGroup(self):
00282         # Check name access
00283         grp = self.gruf.getGroup("g1")
00284         self.failUnless(grp.__class__.__name__ == "GRUFGroup")
00285         self.failUnless(grp.getId() == "group_g1")
00286 
00287         # Check id access
00288         grp = self.gruf.getGroup("group_g1")
00289         self.failUnless(grp.isGroup())
00290         self.failUnless(grp.getId() == "group_g1")
00291         self.failUnless(grp.__class__.__name__ == "GRUFGroup")
00292 
00293         # Prevent user access
00294         usr = self.gruf.getGroup("u1")
00295         self.failUnless(usr is None)

Definition at line 296 of file testGroupUserFolderAPI.py.

00296 
00297     def test_getGroupById(self):
00298         # Id access
00299         grp = self.gruf.getGroupById("group_g1")
00300         self.failUnless(grp.getId() == "group_g1")
00301 
00302         # Prevent name access
00303         grp = self.gruf.getGroupById("g1", default = None)
00304         self.failUnless(grp is None)
00305 
00306         # Prevent user access
00307         grp = self.gruf.getGroupById("u1", default = None)
00308         self.failUnless(grp is None)
00309 
00310         # Check raise if user/group not found
00311         self.failUnlessEqual(
00312             self.gruf.getGroupById("ZORGLUB"),
00313             None,
00314             )
00315         self.failUnless(self.gruf.getGroupById("ZORGLUB", default = "bla") == "bla")

Definition at line 316 of file testGroupUserFolderAPI.py.

00316 
00317     def test_getGroupByName(self):
00318         # Name access
00319         grp = self.gruf.getGroupByName("g1")
00320         self.failUnless(grp.getId() == "group_g1")
00321 
00322         # Allow id access
00323         grp = self.gruf.getGroupByName("group_g1", default = None)
00324         self.failUnless(grp.getId() == "group_g1")
00325 
00326         # Prevent user access
00327         self.failUnless(self.gruf.getGroupByName("u1", default = None) is None)
00328 
00329         # Check raise if user/group not found
00330         self.failUnlessEqual(
00331             self.gruf.getGroupByName("ZORGLUB"),
00332             None,
00333             )
00334         self.failUnless(self.gruf.getGroupByName("ZORGLUB", default = "bla") == "bla")

Reimplemented in GroupUserFolder.tests.testLDAPGroupFolder.TestLDAPUserFolderGroups, and GroupUserFolder.tests.testLDAPGroupFolder.TestLDAPUserFolderGroups.

Definition at line 250 of file testGroupUserFolderAPI.py.

00250 
00251     def test_getGroupIds(self,):
00252         un = self.gruf.getGroupIds()
00253         users = [
00254             'group_g1', 'group_g2', "group_g3", "group_g4",
00255             "group_ng1", "group_ng2", "group_ng3", "group_ng4", "group_ng5",
00256             "group_extranet", "group_intranet", "group_compta",
00257             ]
00258         un.sort()
00259         users.sort()
00260         for u in users:
00261             self.failUnless(u in un, "Invalid users list: '%s' is not in acl_users." % (u,))
00262         for u in un:
00263             self.failUnless(u in users, "Invalid users list: '%s' is in acl_users but shouldn't be there." % (u,))
00264 

Definition at line 808 of file testGroupUserFolderAPI.py.

00808 
00809     def test_getGroupMemberIds(self,):
00810         should_be = [
00811             'group_ng2',
00812             'group_ng3',
00813             'group_ng4',
00814             'group_ng5',
00815             ]
00816         should_be.sort()
00817         users = list(self.gruf.getGroupMemberIds("g3"))
00818         users.sort()
00819         self.failUnless(users == should_be, (users, should_be, ))

Same as getUserNames() but without pure users.

Reimplemented in GroupUserFolder.tests.testLDAPGroupFolder.TestLDAPUserFolderGroups, and GroupUserFolder.tests.testLDAPGroupFolder.TestLDAPUserFolderGroups.

Definition at line 234 of file testGroupUserFolderAPI.py.

00234 
00235     def test_getGroupNames(self):
00236         """Same as getUserNames() but without pure users.
00237         """
00238         un = self.gruf.getGroupNames()
00239         users = [
00240             'g1', 'g2', "g3", "g4",
00241             "ng1", "ng2", "ng3", "ng4", "ng5",
00242             "extranet", "intranet", "compta",
00243             ]
00244         un.sort()
00245         users.sort()
00246         for u in users:
00247             self.failUnless(u in un, "Invalid users list: '%s' is not in acl_users." % (u,))
00248         for u in un:
00249             self.failUnless(u in users, "Invalid users list: '%s' is in acl_users but shouldn't be there." % (u,))

Reimplemented in GroupUserFolder.tests.testLDAPGroupFolder.TestLDAPUserFolderGroups, and GroupUserFolder.tests.testLDAPGroupFolder.TestLDAPUserFolderGroups.

Definition at line 265 of file testGroupUserFolderAPI.py.

00265 
00266     def test_getGroups(self):
00267         objects = self.gruf.getGroups()
00268         un = map(lambda x: x.getId(), objects)
00269         users = [
00270             'group_g1', 'group_g2', "group_g3", "group_g4",
00271             "group_ng1", "group_ng2", "group_ng3", "group_ng4", "group_ng5",
00272             "group_extranet", "group_intranet", "group_compta",
00273             ]
00274         un.sort()
00275         users.sort()
00276         for u in users:
00277             self.failUnless(u in un, "Invalid users list: '%s' is not in acl_users." % (u,))
00278         for u in un:
00279             self.failUnless(u in users, "Invalid users list: '%s' is in acl_users but shouldn't be there." % (u,))

Definition at line 775 of file testGroupUserFolderAPI.py.

00775 
00776     def test_getMemberIds(self,):
00777         should_be = [
00778             'group_ng2',
00779             'group_ng3',
00780             'group_ng4',
00781             'group_ng5',
00782             'u9',
00783             'u5',
00784             'u4',
00785             'u6',
00786             'u11',
00787             'u10',
00788             ]
00789         should_be.sort()
00790         users = list(self.gruf.getMemberIds("g3"))
00791         users.sort()
00792         self.failUnless(users == should_be, (users, should_be))

Definition at line 220 of file testGroupUserFolderAPI.py.

00220 
00221     def test_getPureUser(self,):
00222         u = self.gruf.getPureUser("u1")
00223         self.failUnless(u)
00224         u = self.gruf.getPureUser("g1")
00225         self.failUnless(not u)
00226         u = self.gruf.getPureUser("group_g1")
00227         self.failUnless(not u)
00228         u = self.gruf.getPureUser("group_u1")
00229         self.failUnless(not u)
00230         u = self.gruf.getPureUser("u4")
00231         self.failUnless(u)
        
Same as getUserIds() but without groups

Definition at line 188 of file testGroupUserFolderAPI.py.

00188 
00189     def test_getPureUserIds(self,):
00190         """Same as getUserIds() but without groups
00191         """
00192         un = self.gruf.getPureUserIds()
00193         users = [
00194             "manager",
00195             "u1", "u2", "u3", "u4", "u5", "u6", "u7", "u8", "u9", "u10", "u11",
00196             ]
00197         un.sort()
00198         users.sort()
00199         for u in users:
00200             self.failUnless(u in un, "Invalid users list: '%s' is not in acl_users." % (u,))
00201         for u in un:
00202             self.failUnless(u in users, "Invalid users list: '%s' is in acl_users but shouldn't be there." % (u,))

Same as getUserNames() but without groups

Definition at line 173 of file testGroupUserFolderAPI.py.

00173 
00174     def test_getPureUserNames(self):
00175         """Same as getUserNames() but without groups
00176         """
00177         un = self.gruf.getPureUserNames()
00178         users = [
00179             "manager",
00180             "u1", "u2", "u3", "u4", "u5", "u6", "u7", "u8", "u9", "u10", "u11",
00181             ]
00182         un.sort()
00183         users.sort()
00184         for u in users:
00185             self.failUnless(u in un, "Invalid users list: '%s' is not in acl_users." % (u,))
00186         for u in un:
00187             self.failUnless(u in users, "Invalid users list: '%s' is in acl_users but shouldn't be there." % (u,))

Same as getUsers() but without groups.

Reimplemented in GroupUserFolder.tests.testLDAPUserFolder.TestLDAPUserFolderAPI.

Definition at line 203 of file testGroupUserFolderAPI.py.

00203 
00204     def test_getPureUsers(self):
00205         """Same as getUsers() but without groups.
00206         """
00207         # Fetch pure users
00208         users = [
00209             "manager",
00210             "u1", "u2", "u3", "u4", "u5", "u6", "u7", "u8", "u9", "u10", "u11",
00211             ]
00212         objects = self.gruf.getPureUsers()
00213         un = map(lambda x: x.getId(), objects)
00214         un.sort()
00215         users.sort()
00216         for u in users:
00217             self.failUnless(u in un, "Invalid users list: '%s' is not in acl_users." % (u, ))
00218         for u in un:
00219             self.failUnless(u in users, "Invalid users list: '%s' is in acl_users but shouldn't be there." % (u,))

Test group id without group prefix

Definition at line 863 of file testGroupUserFolderAPI.py.

00863 
00864     def test_getRealId(self,):
00865         """Test group id without group prefix"""
00866         g = self.gruf.getUser("group_ng2")
00867         self.failUnless(g.getRealId() == "ng2")
00868         u = self.gruf.getUser("u1")
00869         self.failUnless(u.getRealId() == "u1")

Definition at line 717 of file testGroupUserFolderAPI.py.

00717 
00718     def test_getRolesOfUser(self):
00719         self.failUnless("r1" in self.gruf.getRolesOfUser("u3"), self.gruf.getRolesOfUser("u3"), )

Definition at line 109 of file testGroupUserFolderAPI.py.

00109 
00110     def test_getUser(self):
00111         # Check id access
00112         usr = self.gruf.getUser("u1")
00113         self.failUnless(usr.__class__.__name__ == "GRUFUser")
00114         self.failUnless(usr.getUserName() == "u1")
00115         grp = self.gruf.getUser("group_g1")
00116         self.failUnless(grp.__class__.__name__ == "GRUFGroup")
00117         self.failUnless(grp.isGroup())
00118         self.failUnless(grp.getId() == "group_g1")
00119 
00120         # Check name access for groups
00121         grp = self.gruf.getUser("g1")
00122         self.failUnless(grp.__class__.__name__ == "GRUFGroup")
00123         self.failUnless(grp.isGroup())
00124         self.failUnless(grp.getId() == "group_g1")

Definition at line 145 of file testGroupUserFolderAPI.py.

00145 
00146     def test_getUserById(self):
00147         # Check user & group access
00148         self.failUnless(self.gruf.getUserById("u1").getUserName() == "u1")
00149         self.failUnless(self.gruf.getUserById("group_g1").getId() == "group_g1")
00150 
00151         # Prohibit direct group access
00152         self.failUnless(self.gruf.getUserById("g1", default = None) is None)
00153 
00154         # check exception raising & default values
00155         ret = self.gruf.getUserById("ZORGLUB")
00156         self.failUnlessEqual(ret, None, "getUserById should return None")
00157         self.failUnless(self.gruf.getUserById("ZORGLUB", default = "bla") == "bla")

Definition at line 158 of file testGroupUserFolderAPI.py.

00158 
00159     def test_getUserByName(self):
00160         # Check user & group access
00161         self.failUnless(self.gruf.getUserByName("u1").getUserName() == "u1")
00162         self.failUnless(self.gruf.getUserByName("g1").getId() == "group_g1")
00163 
00164         # Check group id access
00165         self.failUnless(self.gruf.getUserByName("group_g1", None).getId() == "group_g1")
00166 
00167         # Check exception raising
00168         ret = self.gruf.getUserByName("ZORGLUB")
00169         self.failUnlessEqual(ret, None, "getUserByName should return None")
00170         self.failUnless(self.gruf.getUserByName("ZORGLUB", default = "bla") == "bla")

Reimplemented in GroupUserFolder.tests.testLDAPGroupFolder.TestLDAPUserFolderGroups.

Definition at line 93 of file testGroupUserFolderAPI.py.

00093 
00094     def test_getUserIds(self):
00095         un = self.gruf.getUserIds()
00096         users = [
00097             'group_g1', 'group_g2', "group_g3", "group_g4",
00098             "group_ng1", "group_ng2", "group_ng3", "group_ng4", "group_ng5",
00099             "manager",
00100             "u1", "u2", "u3", "u4", "u5", "u6", "u7", "u8", "u9", "u10", "u11",
00101             "group_extranet", "group_intranet", "group_compta",
00102             ]
00103         un.sort()
00104         users.sort()
00105         for u in users:
00106             self.failUnless(u in un, "Invalid users list: '%s' is not in acl_users." % (u,))
00107         for u in un:
00108             self.failUnless(u in users, "Invalid users list: '%s' is in acl_users but shouldn't be there." % (u,))
                
This tests nested groups

Definition at line 793 of file testGroupUserFolderAPI.py.

00793 
00794     def test_getUserMemberIds(self,):
00795         """This tests nested groups"""
00796         should_be = [
00797             'u9',
00798             'u5',
00799             'u4',
00800             'u6',
00801             'u11',
00802             'u10',
00803             ]
00804         should_be.sort()
00805         users = list(self.gruf.getUserMemberIds("g3"))
00806         users.sort()
00807         self.failUnless(users == should_be, (users, should_be, ))
        

Reimplemented in GroupUserFolder.tests.testLDAPGroupFolder.TestLDAPUserFolderGroups.

Definition at line 77 of file testGroupUserFolderAPI.py.

00077 
00078     def test_getUserNames(self):
00079         un = self.gruf.getUserNames()
00080         users = [
00081             'g1', 'g2', "g3", "g4",
00082             "ng1", "ng2", "ng3", "ng4", "ng5",
00083             "manager",
00084             "u1", "u2", "u3", "u4", "u5", "u6", "u7", "u8", "u9", "u10", "u11",
00085             "extranet", "intranet", "compta",
00086             ]
00087         un.sort()
00088         users.sort()
00089         for u in users:
00090             self.failUnless(u in un, "Invalid users list: '%s' is not in acl_users." % (u,))
00091         for u in un:
00092             self.failUnless(u in users, "Invalid users list: '%s' is in acl_users but shouldn't be there." % (u,))

Reimplemented in GroupUserFolder.tests.testLDAPUserFolder.TestLDAPUserFolderAPI.

Definition at line 128 of file testGroupUserFolderAPI.py.

00128 
00129     def test_getUsers(self):
00130         objects = self.gruf.getUsers()
00131         un = map(lambda x: x.getId(), objects)
00132         users = [
00133             'group_g1', 'group_g2', "group_g3", "group_g4",
00134             "group_ng1", "group_ng2", "group_ng3", "group_ng4", "group_ng5",
00135             "manager",
00136             "u1", "u2", "u3", "u4", "u5", "u6", "u7", "u8", "u9", "u10", "u11",
00137             "group_extranet", "group_intranet", "group_compta",
00138             ]
00139         un.sort()
00140         users.sort()
00141         for u in users:
00142             self.failUnless(u in un, "Invalid users list: '%s' is not in acl_users." % (u,))
00143         for u in un:
00144             self.failUnless(u in users, "Invalid users list: '%s' is in acl_users but shouldn't be there." % (u,))

Reimplemented in GroupUserFolder.tests.testLDAPGroupFolder.TestLDAPUserFolderGroups.

Definition at line 697 of file testGroupUserFolderAPI.py.

00697 
00698     def test_getUsersOfRole(self):
00699         should_be = [
00700             'group_ng2','group_ng3',
00701             'group_ng4',
00702             'group_ng5',
00703             'u9',
00704             'u5',
00705             'u4',
00706             'u7',
00707             'u6',
00708             'u11',
00709             'u10',
00710             'group_g3',
00711             'group_g4',
00712             ]
00713         should_be.sort()
00714         users = list(self.gruf.getUsersOfRole("r2"))
00715         users.sort()
00716         self.failUnless(users == should_be, (should_be, users, ))

Definition at line 852 of file testGroupUserFolderAPI.py.

00852 
00853     def test_hasMember(self,):
00854         self.failUnless(not self.gruf.hasMember("ng3", "u1"))
00855         self.failUnless(not self.gruf.hasMember("group_ng3", "u1"))
00856         self.gruf.addMember("ng3", "u1")
00857         self.failUnless(self.gruf.hasMember("ng3", "u1"))
00858         self.failUnless(self.gruf.hasMember("group_ng3", "u1"))
00859         self.gruf.removeMember("ng3", "u1")
00860         self.failUnless(not self.gruf.hasMember("ng3", "u1"))
00861         self.failUnless(not self.gruf.hasMember("group_ng3", "u1"))

Definition at line 125 of file testGroupUserFolderAPI.py.

00125 
00126     def test_hasUsers(self):
00127         self.failUnlessEqual(self.gruf.hasUsers(), 1, "GRUF should always return 1 on hasUsers but didn't.")

Definition at line 894 of file testGroupUserFolderAPI.py.

00894 
00895     def test_isLocalRoleAcquired(self,):
00896         self.gruf._acquireLocalRoles(self.sublr2, 0)
00897         self.failUnless(not self.gruf.isLocalRoleAcquired(self.sublr2))
00898         self.failUnless(self.gruf.isLocalRoleAcquired(self.subsublr2))
00899         self.gruf._acquireLocalRoles(self.subsublr2, 0)
00900         self.failUnless(not self.gruf.isLocalRoleAcquired(self.sublr2))
00901         self.failUnless(not self.gruf.isLocalRoleAcquired(self.subsublr2))
00902         self.gruf._acquireLocalRoles(self.sublr2, 1)
00903         self.failUnless(self.gruf.isLocalRoleAcquired(self.sublr2))
00904         self.failUnless(not self.gruf.isLocalRoleAcquired(self.subsublr2))
00905         self.gruf._acquireLocalRoles(self.subsublr2, 1)
00906         self.failUnless(self.gruf.isLocalRoleAcquired(self.sublr2))
00907         self.failUnless(self.gruf.isLocalRoleAcquired(self.subsublr2))

Remove a member from a group

Definition at line 827 of file testGroupUserFolderAPI.py.

00827 
00828     def test_removeMember(self):
00829         """Remove a member from a group
00830         """
00831         self.failUnless("u1" not in self.gruf.getMemberIds("ng3"))
00832         self.gruf.addMember("ng3", "u1")
00833         self.failUnless("u1" in self.gruf.getMemberIds("ng3"))
00834         self.gruf.removeMember("ng3", "u1")
00835         self.failUnless("u1" not in self.gruf.getMemberIds("ng3"))

Definition at line 624 of file testGroupUserFolderAPI.py.

00624 
00625     def test_searchGroupsByAttribute(self,):
00626         # Not suitable for regular UFs
00627         self.failUnlessRaises(
00628             NotImplementedError,
00629             self.gruf.searchGroupsByAttribute,
00630             "a",
00631             "b",
00632             )

Definition at line 658 of file testGroupUserFolderAPI.py.

00658 
00659     def test_searchGroupsById(self,):
00660         # Simple match
00661         self.failUnlessEqual(
00662             self.gruf.searchGroupsById("g5"),
00663             ["group_ng5",],
00664             )
00665 
00666         # Different case matching
00667         self.failUnlessEqual(
00668             self.gruf.searchGroupsById("G5"),
00669             ["group_ng5",],
00670             )
00671 
00672         # Multiple (different case) matching
00673         s = self.gruf.searchGroupsById("G1")
00674         s.sort()
00675         self.failUnlessEqual(
00676             s,
00677             ["group_g1", "group_ng1", ]
00678             )

Definition at line 633 of file testGroupUserFolderAPI.py.

00633 
00634     def test_searchGroupsByName(self,):
00635         # Simple match
00636         lst = self.gruf.searchGroupsByName("g3")
00637         lst.sort()
00638         self.failUnlessEqual(
00639             lst,
00640             ["group_g3", "group_ng3", ],
00641             )
00642 
00643         # Different case matching
00644         lst = self.gruf.searchGroupsByName("g3")
00645         lst.sort()
00646         self.failUnlessEqual(
00647             lst,
00648             ["group_g3", "group_ng3", ],
00649             )
00650 
00651         # Multiple (different case) matching
00652         s = self.gruf.searchGroupsByName("1")
00653         s.sort()
00654         self.failUnlessEqual(
00655             s,
00656             ["group_g1", "group_ng1", ]
00657             )

Reimplemented in GroupUserFolder.tests.testLDAPUserFolder.TestLDAPUserFolderAPI.

Definition at line 573 of file testGroupUserFolderAPI.py.

00573 
00574     def test_searchUsersByAttribute(self,):
00575         # Not suitable for regular UFs
00576         self.failUnlessRaises(
00577             NotImplementedError,
00578             self.gruf.searchUsersByAttribute,
00579             "a",
00580             "b",
00581             )

Definition at line 603 of file testGroupUserFolderAPI.py.

00603 
00604     def test_searchUsersById(self,):
00605         # Simple match
00606         self.failUnlessEqual(
00607             self.gruf.searchUsersById("u3"),
00608             ["u3",],
00609             )
00610 
00611         # Different case matching
00612         self.failUnlessEqual(
00613             self.gruf.searchUsersById("U3"),
00614             ["u3",],
00615             )
00616 
00617         # Multiple (different case) matching
00618         s = self.gruf.searchUsersById("U")
00619         s.sort()
00620         self.failUnlessEqual(
00621             s,
00622             ['u1', 'u10', 'u11', 'u2', 'u3', 'u4', 'u5', 'u6', 'u7', 'u8', 'u9', ],
00623             )

Definition at line 582 of file testGroupUserFolderAPI.py.

00582 
00583     def test_searchUsersByName(self,):
00584         # Simple match
00585         self.failUnlessEqual(
00586             self.gruf.searchUsersByName("u3"),
00587             ["u3",],
00588             )
00589 
00590         # Different case matching
00591         self.failUnlessEqual(
00592             self.gruf.searchUsersByName("U3"),
00593             ["u3",],
00594             )
00595 
00596         # Multiple (different case) matching
00597         s = self.gruf.searchUsersByName("U")
00598         s.sort()
00599         self.failUnlessEqual(
00600             s,
00601             ['u1', 'u10', 'u11', 'u2', 'u3', 'u4', 'u5', 'u6', 'u7', 'u8', 'u9', ],
00602             )

Set the members of the group

Definition at line 836 of file testGroupUserFolderAPI.py.

00836 
00837     def test_setMembers(self):
00838         """Set the members of the group
00839         """
00840         member_ids = self.gruf.getMemberIds("ng3")
00841         self.gruf.addMember("ng3", "u1")
00842         self.gruf.addMember("ng3", "u2")
00843         self.failIf("u1" not in self.gruf.getMemberIds("ng3"))
00844         self.failIf("u2" not in self.gruf.getMemberIds("ng3"))
00845         self.failIf("u3" in self.gruf.getMemberIds("ng3"))
00846 
00847         self.gruf.setMembers("ng3", (member_ids + ["u2", "u3"]))
00848 
00849         self.failIf("u1" in self.gruf.getMemberIds("ng3"))
00850         self.failIf("u2" not in self.gruf.getMemberIds("ng3"))
00851         self.failIf("u3" not in self.gruf.getMemberIds("ng3"))

Same as test_setRolesOnUsers but with groups

Definition at line 691 of file testGroupUserFolderAPI.py.

00691 
00692     def test_setRolesOnGroups(self,):
00693         """Same as test_setRolesOnUsers but with groups"""
00694         self.gruf.setRolesOnUsers(["r1", "r2", "r3", ], ["g1", "g2", ])
00695         self.compareRoles(None, "g1", ["r1", "r2", "r3", ])
00696         self.compareRoles(None, "g2", ["r1", "r2", "r3", ])

Here is the call graph for this function:

Set a common set of roles for a bunch of user atoms.

Reimplemented in GroupUserFolder.tests.testLDAPGroupFolder.TestLDAPUserFolderGroups.

Definition at line 681 of file testGroupUserFolderAPI.py.

00681 
00682     def test_setRolesOnUsers(self):
00683         """Set a common set of roles for a bunch of user atoms.
00684         """
00685         self.gruf.setRolesOnUsers(["r1", "r2", "r3", ], ["u1", "u2", ])
00686         self.compareRoles(None, "u1", ["r1", "r2", "r3", ])
00687         self.compareRoles(None, "u2", ["r1", "r2", "r3", ])
00688         self.gruf.setRolesOnUsers([], ["u2", ])
00689         self.compareRoles(None, "u1", ["r1", "r2", "r3", ])
00690         self.compareRoles(None, "u2", [])

Here is the call graph for this function:

Definition at line 523 of file testGroupUserFolderAPI.py.

00523 
00524     def test_userAddDomain(self):
00525         ""

Definition at line 543 of file testGroupUserFolderAPI.py.

00543 
00544     def test_userAddGroup(self):
00545         # Test user
00546         self.gruf.userFolderAddUser(
00547             name = "created_user",
00548             password = "secret",
00549             groups = ["g2", ],
00550             roles = (),
00551             domains = (),
00552             )
00553         self.gruf.userAddGroup(
00554             "created_user",
00555             "g1",
00556             )
00557         self.compareGroups("created_user", ["g1", "g2", ], )

Definition at line 477 of file testGroupUserFolderAPI.py.

00477 
00478     def test_userAddRole(self):
00479         self.gruf.userAddRole("u1", "r1", )
00480         self.gruf.userAddRole("u1", "r2", )
00481         self.compareRoles(None, "u1", ["r1", "r2", ], )

Here is the call graph for this function:

Definition at line 390 of file testGroupUserFolderAPI.py.

00390 
00391     def test_userFolderAddGroup(self):
00392         self.gruf.userFolderAddGroup(
00393             name = "created_group",
00394             roles = [],
00395             groups = [],
00396             )
00397         self.failUnless(self.gruf.getGroup("created_group"))
00398         self.gruf.userFolderAddGroup(
00399             name = "group_test_prefix",
00400             roles = [],
00401             groups = [],
00402             )
00403         self.failUnless(self.gruf.getGroup("group_test_prefix"))
00404         self.failUnless(self.gruf.getGroup("group_test_prefix").isGroup())
00405 
00406         # Prevent group_group_xxx names
00407         self.failUnless(self.gruf.getGroupById("group_group_test_prefix", None) is None)
        

Here is the call graph for this function:

Definition at line 739 of file testGroupUserFolderAPI.py.

00739 
00740     def test_userFolderAddRole(self):
00741         self.gruf.userFolderAddRole("r9")
00742         self.failUnless(
00743             "r9" in self.gruf.userFolderGetRoles(),
00744             )

Definition at line 337 of file testGroupUserFolderAPI.py.

00337 
00338     def test_userFolderAddUser(self):
00339         self.gruf.userFolderAddUser(
00340             name = "created_user",
00341             password = "secret",
00342             roles = [],
00343             groups = [],
00344             domains = (),
00345             )
00346         self.failUnless(self.gruf.getUser("created_user"))
00347         self.gruf.userFolderAddUser(
00348             name = "group_test_prefix",
00349             password = "secret",
00350             roles = [],
00351             groups = [],
00352             domains = (),
00353             )
00354         self.failUnless(self.gruf.getUser("group_test_prefix"))
00355         self.failIf(self.gruf.getUser("group_test_prefix").isGroup())
        

Here is the call graph for this function:

Definition at line 460 of file testGroupUserFolderAPI.py.

00460 
00461     def test_userFolderDelGroups(self):
00462         self.gruf.userFolderAddGroup(
00463             name = "created_group",
00464             roles = [],
00465             groups = [],
00466             )
00467         self.gruf.userFolderDelGroups(['created_group', ])
00468         self.failUnless(self.gruf.getGroup("created_group") is None)

Delete roles.
The removed roles will be removed from the UserFolder's users and groups as well,
so this method can be very time consuming with a large number of users.

Reimplemented in GroupUserFolder.tests.testLDAPGroupFolder.TestLDAPUserFolderGroups.

Definition at line 745 of file testGroupUserFolderAPI.py.

00745 
00746     def test_userFolderDelRoles(self):
00747         """Delete roles.
00748         The removed roles will be removed from the UserFolder's users and groups as well,
00749         so this method can be very time consuming with a large number of users.
00750         """
00751         # Add a role and set it to a few groups
00752         self.gruf.userFolderAddRole("r9")
00753         self.failUnless(
00754             "r9" in self.gruf.userFolderGetRoles(),
00755             )
00756         self.gruf.userAddRole("g2", "r9")
00757         self.gruf.userAddRole("u1", "r9")
00758         self.failUnless(
00759             "r9" in self.gruf.getRolesOfUser("u1")
00760             )
00761         self.failUnless(
00762             "r9" in self.gruf.getRolesOfUser("u4")
00763             )
00764 
00765         # Now, remove it
00766         self.gruf.userFolderDelRoles(['r9', ])
00767         self.failUnless(
00768             "r9" not in self.gruf.getRolesOfUser("u1")
00769             )
00770         self.failUnless(
00771             "r9" not in self.gruf.getRolesOfUser("u4")
00772             )

Definition at line 379 of file testGroupUserFolderAPI.py.

00379 
00380     def test_userFolderDelUsers(self):
00381         self.gruf.userFolderAddUser(
00382             name = "created_user",
00383             password = "secret",
00384             roles = [],
00385             domains = (),
00386             groups = [],
00387             )
00388         self.gruf.userFolderDelUsers(['created_user', ])
00389         self.failUnless(self.gruf.getUser("created_user") is None)

Definition at line 408 of file testGroupUserFolderAPI.py.

00408 
00409     def test_userFolderEditGroup(self):
00410         self.gruf.userFolderAddGroup(
00411             name = "created_group",
00412             roles = [],
00413             groups = [],
00414             )
00415         self.gruf.userFolderEditGroup(
00416             name = "created_group",
00417             roles = ["r1", ],
00418             groups = ["group_g1", ],
00419             )
00420         self.compareRoles(None, "created_group", ['r1',], )
00421         self.failUnless(
00422             "g1" in self.gruf.getGroupByName("created_group").getAllGroupNames(),
00423             self.gruf.getGroupByName("created_group").getAllGroupNames(),
00424             )
00425         self.gruf.userFolderEditGroup(
00426             name = "created_group",
00427             roles = ["r1", ],
00428             groups = ["g2", ],
00429             )
00430         self.failUnless(
00431             "g2" in self.gruf.getGroupByName("created_group").getAllGroupNames(),
00432             self.gruf.getGroupByName("created_group").getAllGroupNames(),
00433             )
        

Here is the call graph for this function:

Reimplemented in GroupUserFolder.tests.testLDAPGroupFolder.TestLDAPUserFolderGroups.

Definition at line 356 of file testGroupUserFolderAPI.py.

00356 
00357     def test_userFolderEditUser(self):
00358         self.gruf.userFolderEditUser(
00359             name = "u1",
00360             password = "secret2",
00361             roles = ["r1", ],
00362             groups = ["g1", ],
00363             domains = (),
00364             )
00365         self.compareRoles(None, "u1", ['r1',], )

Here is the call graph for this function:

Test existing roles

Definition at line 720 of file testGroupUserFolderAPI.py.

00720 
00721     def test_userFolderGetRoles(self,):
00722         """
00723         Test existing roles
00724         """
00725         should_be =  [
00726             'Anonymous',
00727             'Authenticated',
00728             'Manager',
00729             'Owner',
00730             'r1',
00731             'r2',
00732             'r3',
00733             'test_role_1_',
00734             ]
00735         should_be.sort()
00736         roles = list(self.gruf.userFolderGetRoles())
00737         roles.sort()
00738         self.failUnless(roles == should_be)

Definition at line 434 of file testGroupUserFolderAPI.py.

00434 
00435     def test_userFolderUpdateGroup(self):
00436         self.gruf.userFolderAddGroup(
00437             name = "created_group",
00438             roles = [],
00439             groups = [],
00440             )
00441         self.gruf.userFolderUpdateGroup(
00442             name = "created_group",
00443             roles = ["r1", ],
00444             groups = ["group_g1", ],
00445             )
00446         self.compareRoles(None, "created_group", ['r1',], )
00447         self.failUnless(
00448             "g1" in self.gruf.getGroupByName("created_group").getAllGroupNames(),
00449             self.gruf.getGroupByName("created_group").getAllGroupNames(),
00450             )
00451         self.gruf.userFolderUpdateGroup(
00452             name = "created_group",
00453             roles = ["r1", ],
00454             groups = None,
00455             )
00456         self.failUnless(
00457             "g1" in self.gruf.getGroupByName("created_group").getAllGroupNames(),
00458             self.gruf.getGroupByName("created_group").getAllGroupNames(),
00459             )

Here is the call graph for this function:

Definition at line 366 of file testGroupUserFolderAPI.py.

00366 
00367     def test_userFolderUpdateUser(self):
00368         self.gruf.userFolderUpdateUser(
00369             name = "u5",
00370             roles = ["r2", ],
00371             )
00372         self.compareRoles(None, "u5", ['r1', 'r2',], )
00373         self.compareGroups("u5", ['g2', 'g3'], )
00374         self.gruf.userFolderUpdateUser(
00375             name = "u6",
00376             roles = None,
00377             )
00378         self.compareRoles(None, "u6", ['r1', 'r2', ], )

Here is the call graph for this function:

Definition at line 509 of file testGroupUserFolderAPI.py.

00509 
00510     def test_userGetDomains(self):
00511         ""

Definition at line 526 of file testGroupUserFolderAPI.py.

00526 
00527     def test_userRemoveDomain(self):
00528         ""

Remove the group of a user atom

Definition at line 558 of file testGroupUserFolderAPI.py.

00558 
00559     def test_userRemoveGroup(self):
00560         """Remove the group of a user atom
00561         """
00562         self.gruf.userFolderAddUser(
00563             name = "created_user",
00564             password = "secret",
00565             groups = ["g2", "g1", ],
00566             domains = (),
00567             roles = (),
00568             )
00569         self.gruf.userRemoveGroup("created_user", "g1", )
00570         self.compareGroups("created_user", ["g2", ], )

Remove the role of a user atom

Definition at line 482 of file testGroupUserFolderAPI.py.

00482 
00483     def test_userRemoveRole(self):
00484         """Remove the role of a user atom
00485         """
00486         self.gruf.userSetRoles("u1", ["r1", "r2", ], )
00487         self.compareRoles(None, "u1", ["r1", "r2", ], )
00488         self.gruf.userRemoveRole("u1", "r1", )
00489         self.compareRoles(None, "u1", ["r2", ], )

Here is the call graph for this function:

Reimplemented in GroupUserFolder.tests.testLDAPUserFolder.TestLDAPUserFolderAPI.

Definition at line 512 of file testGroupUserFolderAPI.py.

00512 
00513     def test_userSetDomains(self):
00514         ""
00515         u = self.gruf.getUser("u1")
00516         self.failUnless(not self.gruf.userGetDomains("u1"))
00517         self.gruf.userSetDomains("u1", ["d1", "d2", "d3", ])
00518         self.failUnless(self.gruf.userGetDomains("u1") == ("d1", "d2", "d3", ))
00519         self.gruf.userSetDomains("u1", [])
00520         self.failUnless(self.gruf.userGetDomains("u1") == ())
00521         self.gruf.userSetDomains("u1", ["xxx"])
00522         self.failUnless(self.gruf.userGetDomains("u1") == ("xxx", ))

Definition at line 529 of file testGroupUserFolderAPI.py.

00529 
00530     def test_userSetGroups(self):
00531         # Test user
00532         self.gruf.userFolderAddUser(
00533             name = "created_user",
00534             password = "secret",
00535             domains = (),
00536             roles = (),
00537             groups = [],
00538             )
00539         self.gruf.userSetGroups("created_user", ["g1", "g2", ], )
00540         self.compareGroups("created_user", ["g1", "g2", ], )
00541         self.gruf.userSetGroups("created_user", [], )
00542         self.compareGroups("created_user", [], )

Test user password setting

Definition at line 490 of file testGroupUserFolderAPI.py.

00490 
00491     def test_userSetPassword(self):
00492         """Test user password setting
00493         """
00494         # Regular user password
00495         user = self.gruf.getUser('u1')
00496         self.failUnless(self.gruf.authenticate("u1", 'secret', self.app.REQUEST))
00497         self.gruf.userSetPassword("u1", "bloub")
00498         user = self.gruf.getUser('u1')
00499         self.failUnless(not self.gruf.authenticate("u1", 'secret', self.app.REQUEST))
00500         self.failUnless(self.gruf.authenticate("u1", 'bloub', self.app.REQUEST))
00501 
00502         # Group password changing must fail
00503         try: self.gruf.userSetPassword("g1", "bloub")
00504         except ValueError: pass                # ok
00505         else: raise "AssertionError", "Should raise"
00506         try: self.gruf.userSetPassword("group_g1", "bloub")
00507         except ValueError: pass                # ok
00508         else: raise "AssertionError", "Should raise"

Definition at line 471 of file testGroupUserFolderAPI.py.

00471 
00472     def test_userSetRoles(self):
00473         self.gruf.userSetRoles("u1", ["r1", "r2", ], )
00474         self.compareRoles(None, "u1", ["r1", "r2", ], )
00475         self.gruf.userSetRoles("u1", [], )
00476         self.compareRoles(None, "u1", [], )

Here is the call graph for this function:


Member Data Documentation

Definition at line 95 of file GRUFTestCase.py.

Definition at line 93 of file GRUFTestCase.py.

Initial value:
(        # tell which classes to check
        GroupUserFolder.GroupUserFolder,
        )

Definition at line 62 of file testGroupUserFolderAPI.py.

Definition at line 242 of file GRUFTestCase.py.

Definition at line 243 of file GRUFTestCase.py.

Definition at line 244 of file GRUFTestCase.py.

Definition at line 245 of file GRUFTestCase.py.

Definition at line 246 of file GRUFTestCase.py.

Definition at line 247 of file GRUFTestCase.py.


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