Back to index

plone3  3.1.7
Public Member Functions | Private Member Functions
PluggableAuthService.tests.test_PropertiedUser.PropertiedUserTests Class Reference
Inheritance diagram for PluggableAuthService.tests.test_PropertiedUser.PropertiedUserTests:
Inheritance graph
[legend]
Collaboration diagram for PluggableAuthService.tests.test_PropertiedUser.PropertiedUserTests:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def test_empty
def test_groups
def test_username
def test_roles
def test_addPropertysheet
def test_getRolesInContext_no_local
def test_getRolesInContext_group_match
def test_getRolesInContext_group_overlap
def test_getRolesInContext_group_nomatch
def test_getRolesInContext_acquisition
def test_getRolesInContext_weslayan
def test_allowed_not_even_god_should
def test_allowed_anonymous
def test_allowed_authenticated
def test_allowed_authenticated_required_but_anonymous
def test_allowed_global_roles_ok
def test_allowed_global_roles_not_ok
def test_allowed_local_roles_on_user_ok
def test_allowed_local_roles_on_user_not_ok
def test_allowed_local_roles_on_group_ok
def test_allowed_acquisition
def test_allowed_weslayan

Private Member Functions

def _getTargetClass
def _makeOne

Detailed Description

Definition at line 37 of file test_PropertiedUser.py.


Member Function Documentation

Definition at line 39 of file test_PropertiedUser.py.

00039 
00040     def _getTargetClass( self ):
00041 
00042         from Products.PluggableAuthService.PropertiedUser \
00043             import PropertiedUser
00044 
00045         return PropertiedUser

def PluggableAuthService.tests.test_PropertiedUser.PropertiedUserTests._makeOne (   self,
  id = 'testing',
  login = None,
  args,
  kw 
) [private]

Definition at line 46 of file test_PropertiedUser.py.

00046 
00047     def _makeOne( self, id='testing', login=None, *args, **kw ):
00048 
00049         return self._getTargetClass()( id, login, *args, **kw )

Definition at line 86 of file test_PropertiedUser.py.

00086 
00087     def test_addPropertysheet( self ):
00088 
00089         user = self._makeOne()
00090 
00091         user.addPropertysheet( 'one', { 'a' : 0, 'b' : 'jabber' } )
00092 
00093         ids = user.listPropertysheets()
00094 
00095         self.assertEqual( len( ids ), 1 )
00096         self.assertEqual( ids[ 0 ], 'one' )
00097 
00098         sheet = user.getPropertysheet( 'one' )
00099 
00100         self.assertEqual( len( sheet.propertyMap() ), 2 )
00101         self.assertEqual( sheet.getPropertyType( 'a' ), 'int' )
00102         self.assertEqual( sheet.getPropertyType( 'b' ), 'string' )
00103         self.assertEqual( sheet.getId(), 'one' )
00104 
00105         sheet = user[ 'one' ]
00106 
00107         self.assertEqual( len( sheet.propertyMap() ), 2 )
00108         self.assertEqual( sheet.getPropertyType( 'a' ), 'int' )
00109         self.assertEqual( sheet.getPropertyType( 'b' ), 'string' )
00110 
00111         self.assertRaises( KeyError, user.getPropertysheet, 'another'  )

Definition at line 255 of file test_PropertiedUser.py.

00255 
00256     def test_allowed_acquisition( self ):
00257 
00258         groups = ( 'Group A', 'Group B' )
00259         user = self._makeOne()
00260         user._addGroups( groups )
00261 
00262         faux_container = FauxProtected( { 'Group A' : ( 'Manager', ) } )
00263         faux_contained = FauxProtected( { 'Group C' : ( 'Manager', 'Owner' ) }
00264                                       ).__of__( faux_container )
00265 
00266         self.failUnless( user.allowed( faux_contained, ( 'Manager', ) ) )

Definition at line 201 of file test_PropertiedUser.py.

00201 
00202     def test_allowed_anonymous( self ):
00203 
00204         user = self._makeOne()
00205 
00206         self.failUnless( user.allowed( None, ('Anonymous',) ) )

Definition at line 207 of file test_PropertiedUser.py.

00207 
00208     def test_allowed_authenticated( self ):
00209 
00210         user = self._makeOne()
00211 
00212         self.failUnless( user.allowed( None, ('Authenticated',) ) )

Definition at line 213 of file test_PropertiedUser.py.

00213 
00214     def test_allowed_authenticated_required_but_anonymous( self ):
00215 
00216         user = self._makeOne('Anonymous User')
00217 
00218         self.failIf( user.allowed( None, ('Authenticated',) ) )

Definition at line 226 of file test_PropertiedUser.py.

00226 
00227     def test_allowed_global_roles_not_ok( self ):
00228 
00229         user = self._makeOne()
00230         user._addRoles( ( 'Role 1', 'Role 2' ) )
00231 
00232         self.failIf( user.allowed( None, ( 'Role 3', ) ) )

Definition at line 219 of file test_PropertiedUser.py.

00219 
00220     def test_allowed_global_roles_ok( self ):
00221 
00222         user = self._makeOne()
00223         user._addRoles( ( 'Role 1', 'Role 2' ) )
00224 
00225         self.failUnless( user.allowed( None, ( 'Role 1', ) ) )

Definition at line 247 of file test_PropertiedUser.py.

00247 
00248     def test_allowed_local_roles_on_group_ok( self ):
00249 
00250         user = self._makeOne( 'user' )
00251         user._addGroups( ( 'Group 1', 'Group 2' ) )
00252         object = FauxProtected( { 'Group 1' : ( 'Role 1', ) } )
00253 
00254         self.failUnless( user.allowed( object, ( 'Role 1', ) ) )

Definition at line 240 of file test_PropertiedUser.py.

00240 
00241     def test_allowed_local_roles_on_user_not_ok( self ):
00242 
00243         user = self._makeOne( 'user' )
00244         object = FauxProtected( { 'user' : ( 'Role 1', ) } )
00245 
00246         self.failIf( user.allowed( object, ( 'Role 2', ) ) )

Definition at line 233 of file test_PropertiedUser.py.

00233 
00234     def test_allowed_local_roles_on_user_ok( self ):
00235 
00236         user = self._makeOne( 'user' )
00237         object = FauxProtected( { 'user' : ( 'Role 1', ) } )
00238 
00239         self.failUnless( user.allowed( object, ( 'Role 1', ) ) )

Definition at line 194 of file test_PropertiedUser.py.

00194 
00195     def test_allowed_not_even_god_should( self ):
00196 
00197         from AccessControl.PermissionRole import _what_not_even_god_should_do
00198         user = self._makeOne()
00199 
00200         self.failIf( user.allowed( None, _what_not_even_god_should_do ) )

Definition at line 267 of file test_PropertiedUser.py.

00267 
00268     def test_allowed_weslayan( self ):
00269 
00270         # Test "methodish" checks.
00271 
00272         groups = ( 'Group A', 'Group B' )
00273         user = self._makeOne()
00274         user._addGroups( groups )
00275 
00276         faux_self = FauxProtected( { 'Group A' : ( 'Manager', ) } )
00277         faux_method = FauxMethod( faux_self
00278                                 , { 'Group C' : ( 'Manager', 'Owner' ) } )
00279 
00280         self.failUnless( user.allowed( faux_method, ( 'Manager', ) ) )
00281 

Definition at line 50 of file test_PropertiedUser.py.

00050 
00051     def test_empty( self ):
00052 
00053         user = self._makeOne( 'empty' )
00054 
00055         # BaseUser interface
00056         self.assertEqual( user.getId(), 'empty' )
00057         self.assertEqual( user.getUserName(), 'empty' )
00058         self.assertRaises( NotImplementedError, user._getPassword )
00059         self.assertEqual( len( user.getRoles() ), 0 )
00060         self.assertEqual(len(user.getGroups()), 0)
00061         self.assertEqual( len( user.getDomains() ), 0 )
00062 
00063         # plus propertysheets
00064         self.assertEqual( len( user.listPropertysheets() ), 0 )
00065         self.assertRaises( KeyError, user.getPropertysheet, 'nonesuch'  )

Definition at line 164 of file test_PropertiedUser.py.

00164 
00165     def test_getRolesInContext_acquisition( self ):
00166 
00167         groups = ( 'Group A', 'Group B' )
00168         user = self._makeOne()
00169         user._addGroups( groups )
00170 
00171         faux_container = FauxProtected( { 'Group A' : ( 'Manager', ) } )
00172         faux_contained = FauxProtected( { 'Group C' : ( 'Manager', 'Owner' ) }
00173                                       ).__of__( faux_container )
00174 
00175         local_roles = user.getRolesInContext( faux_contained )
00176         self.assertEqual( len( local_roles ), 1 )
00177         self.failUnless( 'Manager' in local_roles )

Definition at line 126 of file test_PropertiedUser.py.

00126 
00127     def test_getRolesInContext_group_match( self ):
00128 
00129         groups = ( 'Group A', 'Group B' )
00130         user = self._makeOne()
00131         user._addGroups( groups )
00132 
00133         faux = FauxProtected( { 'Group A' : ( 'Manager', ) } )
00134 
00135         local_roles = user.getRolesInContext( faux )
00136         self.assertEqual( len( local_roles ), 1 )
00137         self.failUnless( 'Manager' in local_roles )

Definition at line 153 of file test_PropertiedUser.py.

00153 
00154     def test_getRolesInContext_group_nomatch( self ):
00155 
00156         groups = ( 'Group A', 'Group B' )
00157         user = self._makeOne()
00158         user._addGroups( groups )
00159 
00160         faux = FauxProtected( { 'Group C' : ( 'Manager', ) } )
00161 
00162         local_roles = user.getRolesInContext( faux )
00163         self.assertEqual( len( local_roles ), 0 )

Definition at line 138 of file test_PropertiedUser.py.

00138 
00139     def test_getRolesInContext_group_overlap( self ):
00140 
00141         groups = ( 'Group A', 'Group B' )
00142         user = self._makeOne()
00143         user._addGroups( groups )
00144 
00145         faux = FauxProtected( { 'Group A' : ( 'Manager', )
00146                               , 'Group B' : ( 'Manager', 'Owner' )
00147                               } )
00148 
00149         local_roles = user.getRolesInContext( faux )
00150         self.assertEqual( len( local_roles ), 2 )
00151         self.failUnless( 'Manager' in local_roles )
00152         self.failUnless( 'Owner' in local_roles )

Definition at line 112 of file test_PropertiedUser.py.

00112 
00113     def test_getRolesInContext_no_local( self ):
00114 
00115         groups = ( 'Group A', 'Group B' )
00116         user = self._makeOne()
00117         user._addGroups( groups )
00118 
00119         self.assertEqual( len( user.getRoles() ), 0 )
00120         self.assertEqual( len( user.getGroups() ), len( groups ) )
00121 
00122         faux = FauxProtected()
00123 
00124         local_roles = user.getRolesInContext( faux )
00125         self.assertEqual( len( local_roles ), 0 )

Definition at line 178 of file test_PropertiedUser.py.

00178 
00179     def test_getRolesInContext_weslayan( self ):
00180 
00181         # Test "methodish" checks.
00182 
00183         groups = ( 'Group A', 'Group B' )
00184         user = self._makeOne()
00185         user._addGroups( groups )
00186 
00187         faux_self = FauxProtected( { 'Group A' : ( 'Manager', ) } )
00188         faux_method = FauxMethod( faux_self
00189                                 , { 'Group C' : ( 'Manager', 'Owner' ) } )
00190 
00191         local_roles = user.getRolesInContext( faux_method )
00192         self.assertEqual( len( local_roles ), 1 )
00193         self.failUnless( 'Manager' in local_roles )

Definition at line 66 of file test_PropertiedUser.py.

00066 
00067     def test_groups(self):
00068         groups = ('Group A', 'Group B')
00069         user = self._makeOne('groups')
00070         user._addGroups(groups)
00071         self.assertEqual(len(user.getGroups()), len(groups))
00072         for g in user.getGroups():
00073             self.assert_(g in groups)

Definition at line 78 of file test_PropertiedUser.py.

00078 
00079     def test_roles(self):
00080         roles = ['Manager', 'Members']
00081         user = self._makeOne('user')
00082         user._addRoles(roles)
00083         self.assertEqual(len(user.getRoles()), 2)
00084         for r in user.getRoles():
00085             self.assert_(r in roles)

Definition at line 74 of file test_PropertiedUser.py.

00074 
00075     def test_username(self):
00076         user = self._makeOne('username', 'User with Username')
00077         self.assertEqual(user.getUserName(), 'User with Username')


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