Back to index

plone3  3.1.7
Public Member Functions | Private Member Functions | Private Attributes
PluggableAuthService.plugins.tests.test_ZODBUserManager.ZODBUserManagerTests Class Reference
Inheritance diagram for PluggableAuthService.plugins.tests.test_ZODBUserManager.ZODBUserManagerTests:
Inheritance graph
[legend]
Collaboration diagram for PluggableAuthService.plugins.tests.test_ZODBUserManager.ZODBUserManagerTests:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def test_empty
def test_addUser
def test_addUser_duplicate_check
def test_removeUser_nonesuch
def test_removeUser_valid_id
def test_authenticateCredentials_bad_creds
def test_authenticateCredentials_valid_creds
def test_enumerateUsers_no_criteria
def test_enumerateUsers_exact
def test_enumerateUsers_partial
def test_enumerateUsers_other_criteria
def test_enumerateUsers_unicode
def test_enumerateUsers_exact_nonesuch
def test_enumerateUsers_multiple_ids
def test_enumerateUsers_multiple_logins
def test_authenticateWithOldPasswords
def test_updateUserPassword
def test_updateUser
def test_enumerateUsersWithOptionalMangling
def test_getUserByIdWithOptionalMangling
def test_addUser_with_not_yet_encrypted_password
def test_addUser_with_preencrypted_password
def test_updateUserPassword_with_not_yet_encrypted_password
def test_updateUserPassword_with_preencrypted_password
def test_manage_updatePassword
def testPOSTProtections

Private Member Functions

def _getTargetClass
def _makeOne

Private Attributes

 _id

Detailed Description

Definition at line 39 of file test_ZODBUserManager.py.


Member Function Documentation

Definition at line 41 of file test_ZODBUserManager.py.

00041 
00042     def _getTargetClass( self ):
00043 
00044         from Products.PluggableAuthService.plugins.ZODBUserManager \
00045             import ZODBUserManager
00046 
00047         return ZODBUserManager

def PluggableAuthService.plugins.tests.test_ZODBUserManager.ZODBUserManagerTests._makeOne (   self,
  id = 'test',
  args,
  kw 
) [private]

Definition at line 48 of file test_ZODBUserManager.py.

00048 
00049     def _makeOne( self, id='test', *args, **kw ):
00050 
00051         return self._getTargetClass()( id=id, *args, **kw )

Definition at line 63 of file test_ZODBUserManager.py.

00063 
00064     def test_addUser( self ):
00065 
00066         zum = self._makeOne()
00067 
00068         zum.addUser( 'userid', 'userid@example.com', 'password' )
00069 
00070         user_ids = zum.listUserIds()
00071         self.assertEqual( len( user_ids ), 1 )
00072         self.assertEqual( user_ids[0], 'userid' )
00073         self.assertEqual( zum.getUserIdForLogin( 'userid@example.com' )
00074                         , 'userid' )
00075         self.assertEqual( zum.getLoginForUserId( 'userid' )
00076                         , 'userid@example.com' )
00077 
00078         info_list = zum.enumerateUsers()
00079         self.assertEqual( len( info_list ), 1 )
00080         info = info_list[ 0 ]
00081         self.assertEqual( info[ 'id' ], 'userid' )
00082         self.assertEqual( info[ 'login' ], 'userid@example.com' )

Definition at line 83 of file test_ZODBUserManager.py.

00083 
00084     def test_addUser_duplicate_check( self ):
00085 
00086         zum = self._makeOne()
00087 
00088         zum.addUser( 'userid', 'userid@example.com', 'password' )
00089 
00090         self.assertRaises( KeyError, zum.addUser
00091                          , 'userid', 'luser@other.com', 'wordpass' )
00092 
00093         self.assertRaises( KeyError, zum.addUser
00094                          , 'new_user', 'userid@example.com', '3733t' )

Definition at line 468 of file test_ZODBUserManager.py.

00468 
00469     def test_addUser_with_not_yet_encrypted_password(self):
00470         # See collector #1869 && #1926
00471         from AccessControl.AuthEncoding import is_encrypted
00472 
00473         USER_ID = 'not_yet_encrypted'
00474         PASSWORD = 'password'
00475 
00476         self.failIf(is_encrypted(PASSWORD))
00477 
00478         zum = self._makeOne()
00479         zum.addUser(USER_ID, USER_ID, PASSWORD)
00480 
00481         uid_and_info = zum.authenticateCredentials(
00482                                 { 'login': USER_ID
00483                                 , 'password': PASSWORD
00484                                 })
00485 
00486         self.assertEqual(uid_and_info, (USER_ID, USER_ID))

Definition at line 487 of file test_ZODBUserManager.py.

00487 
00488     def test_addUser_with_preencrypted_password(self):
00489         # See collector #1869 && #1926
00490         from AccessControl.AuthEncoding import pw_encrypt
00491 
00492         USER_ID = 'already_encrypted'
00493         PASSWORD = 'password'
00494 
00495         ENCRYPTED = pw_encrypt(PASSWORD)
00496 
00497         zum = self._makeOne()
00498         zum.addUser(USER_ID, USER_ID, ENCRYPTED)
00499 
00500         uid_and_info = zum.authenticateCredentials(
00501                                 { 'login': USER_ID
00502                                 , 'password': PASSWORD
00503                                 })
00504 
00505         self.assertEqual(uid_and_info, (USER_ID, USER_ID))

Definition at line 125 of file test_ZODBUserManager.py.

00125 
00126     def test_authenticateCredentials_bad_creds( self ):
00127 
00128         zum = self._makeOne()
00129 
00130         zum.addUser( 'userid', 'userid@example.com', 'password' )
00131 
00132         self.assertEqual( zum.authenticateCredentials( {} ), None )

Definition at line 133 of file test_ZODBUserManager.py.

00133 
00134     def test_authenticateCredentials_valid_creds( self ):
00135 
00136         zum = self._makeOne()
00137 
00138         zum.addUser( 'userid', 'userid@example.com', 'password' )
00139 
00140         user_id, login = zum.authenticateCredentials(
00141                                 { 'login' : 'userid@example.com'
00142                                 , 'password' : 'password'
00143                                 } )
00144 
00145         self.assertEqual( user_id, 'userid' )
00146         self.assertEqual( login, 'userid@example.com' )

Definition at line 366 of file test_ZODBUserManager.py.

00366 
00367     def test_authenticateWithOldPasswords( self ):
00368 
00369         import sha
00370 
00371         zum = self._makeOne()
00372 
00373         # synthesize an older account
00374 
00375         old_password = sha.sha( 'old_password' ).hexdigest()
00376         zum._user_passwords[ 'old_user' ] = old_password
00377         zum._login_to_userid[ 'old_user@example.com' ] = 'old_user'
00378         zum._userid_to_login[ 'old_user' ] = 'old_user@example.com'
00379 
00380         # create a new user
00381 
00382         zum.addUser( 'new_user', 'new_user@example.com', 'new_password' )
00383 
00384         user_id, login = zum.authenticateCredentials(
00385                                 { 'login' : 'old_user@example.com'
00386                                 , 'password' : 'old_password'
00387                                 } )
00388 
00389         self.assertEqual( user_id, 'old_user' )
00390         self.assertEqual( login, 'old_user@example.com' )
00391 
00392         user_id, login = zum.authenticateCredentials(
00393                                 { 'login' : 'new_user@example.com'
00394                                 , 'password' : 'new_password'
00395                                 } )
00396 
00397         self.assertEqual( user_id, 'new_user' )
00398         self.assertEqual( login, 'new_user@example.com' )

Definition at line 52 of file test_ZODBUserManager.py.

00052 
00053     def test_empty( self ):
00054 
00055         zum = self._makeOne()
00056 
00057         self.assertEqual( len( zum.listUserIds() ), 0 )
00058         self.assertEqual( len( zum.enumerateUsers() ), 0 )
00059         self.assertRaises( KeyError
00060                          , zum.getUserIdForLogin, 'userid@example.com' )
00061         self.assertRaises( KeyError
00062                          , zum.getLoginForUserId, 'userid' )

Definition at line 177 of file test_ZODBUserManager.py.

00177 
00178     def test_enumerateUsers_exact( self ):
00179 
00180         from Products.PluggableAuthService.tests.test_PluggableAuthService \
00181             import FauxRoot
00182 
00183         root = FauxRoot()
00184         zum = self._makeOne( id='exact' ).__of__( root )
00185 
00186         ID_LIST = ( 'foo', 'bar', 'baz', 'bam' )
00187 
00188         for id in ID_LIST:
00189 
00190             zum.addUser( id, '%s@example.com' % id, 'password' )
00191 
00192         info_list = zum.enumerateUsers( id='bar', exact_match=True )
00193 
00194         self.assertEqual( len( info_list ), 1 )
00195         info = info_list[ 0 ]
00196 
00197         self.assertEqual( info[ 'id' ], 'bar' )
00198         self.assertEqual( info[ 'login' ], 'bar@example.com' )
00199         self.assertEqual( info[ 'pluginid' ], 'exact' )
00200         self.assertEqual( info[ 'editurl' ]
00201                         , 'exact/manage_users?user_id=bar' )
00202 

Definition at line 285 of file test_ZODBUserManager.py.

00285 
00286     def test_enumerateUsers_exact_nonesuch( self ):
00287 
00288         from Products.PluggableAuthService.tests.test_PluggableAuthService \
00289             import FauxRoot
00290 
00291         root = FauxRoot()
00292         zum = self._makeOne( id='exact_nonesuch' ).__of__( root )
00293 
00294         ID_LIST = ( 'foo', 'bar', 'baz', 'bam' )
00295 
00296         for id in ID_LIST:
00297 
00298             zum.addUser( id, '%s@example.com' % id, 'password' )
00299 
00300         self.assertEquals( zum.enumerateUsers( id='qux', exact_match=True )
00301                          , () )

Definition at line 302 of file test_ZODBUserManager.py.

00302 
00303     def test_enumerateUsers_multiple_ids( self ):
00304 
00305         from Products.PluggableAuthService.tests.test_PluggableAuthService \
00306             import FauxRoot
00307 
00308         root = FauxRoot()
00309         zum = self._makeOne( id='partial' ).__of__( root )
00310 
00311         ID_LIST = ( 'foo', 'bar', 'baz', 'bam' )
00312 
00313         for id in ID_LIST:
00314 
00315             zum.addUser( id, '%s@example.com' % id, 'password' )
00316 
00317         info_list = zum.enumerateUsers( id=ID_LIST )
00318 
00319         self.assertEqual( len( info_list ), len( ID_LIST ) )
00320 
00321         for info in info_list:
00322             self.failUnless( info[ 'id' ] in ID_LIST )
00323 
00324         SUBSET = ID_LIST[:3]
00325 
00326         info_list = zum.enumerateUsers( id=SUBSET )
00327 
00328         self.assertEqual( len( info_list ), len( SUBSET ) )
00329 
00330         for info in info_list:
00331             self.failUnless( info[ 'id' ] in SUBSET )

Definition at line 332 of file test_ZODBUserManager.py.

00332 
00333     def test_enumerateUsers_multiple_logins( self ):
00334 
00335         from Products.PluggableAuthService.tests.test_PluggableAuthService \
00336             import FauxRoot
00337 
00338         root = FauxRoot()
00339         zum = self._makeOne( id='partial' ).__of__( root )
00340 
00341         ID_LIST = ( 'foo', 'bar', 'baz', 'bam' )
00342         LOGIN_LIST = [ '%s@example.com' % x for x in ID_LIST ]
00343 
00344         for i in range( len( ID_LIST ) ):
00345 
00346             zum.addUser( ID_LIST[i], LOGIN_LIST[i], 'password' )
00347 
00348         info_list = zum.enumerateUsers( login=LOGIN_LIST )
00349 
00350         self.assertEqual( len( info_list ), len( LOGIN_LIST ) )
00351 
00352         for info in info_list:
00353             self.failUnless( info[ 'id' ] in ID_LIST )
00354             self.failUnless( info[ 'login' ] in LOGIN_LIST )
00355 
00356         SUBSET_LOGINS = LOGIN_LIST[:3]
00357         SUBSET_IDS = ID_LIST[:3]
00358 
00359         info_list = zum.enumerateUsers( login=SUBSET_LOGINS )
00360 
00361         self.assertEqual( len( info_list ), len( SUBSET_LOGINS ) )
00362 
00363         for info in info_list:
00364             self.failUnless( info[ 'id' ] in SUBSET_IDS )
00365             self.failUnless( info[ 'login' ] in SUBSET_LOGINS )

Definition at line 147 of file test_ZODBUserManager.py.

00147 
00148     def test_enumerateUsers_no_criteria( self ):
00149 
00150         from Products.PluggableAuthService.tests.test_PluggableAuthService \
00151             import FauxRoot
00152 
00153         root = FauxRoot()
00154         zum = self._makeOne( id='no_crit' ).__of__( root )
00155 
00156         ID_LIST = ( 'foo', 'bar', 'baz', 'bam' )
00157 
00158         for id in ID_LIST:
00159 
00160             zum.addUser( id, '%s@example.com' % id, 'password' )
00161 
00162         info_list = zum.enumerateUsers()
00163 
00164         self.assertEqual( len( info_list ), len( ID_LIST ) )
00165 
00166         sorted = list( ID_LIST )
00167         sorted.sort()
00168 
00169         for i in range( len( sorted ) ):
00170 
00171             self.assertEqual( info_list[ i ][ 'id' ], sorted[ i ] )
00172             self.assertEqual( info_list[ i ][ 'login' ]
00173                             , '%s@example.com' % sorted[ i ] )
00174             self.assertEqual( info_list[ i ][ 'pluginid' ], 'no_crit' )
00175             self.assertEqual( info_list[ i ][ 'editurl' ]
00176                             , 'no_crit/manage_users?user_id=%s' % sorted[ i ])

Definition at line 249 of file test_ZODBUserManager.py.

00249 
00250     def test_enumerateUsers_other_criteria( self ):
00251 
00252         from Products.PluggableAuthService.tests.test_PluggableAuthService \
00253             import FauxRoot
00254 
00255         root = FauxRoot()
00256         zum = self._makeOne( id='partial' ).__of__( root )
00257 
00258         ID_LIST = ( 'foo', 'bar', 'baz', 'bam' )
00259 
00260         for id in ID_LIST:
00261 
00262             zum.addUser( id, '%s@example.com' % id, 'password' )
00263 
00264         info_list = zum.enumerateUsers( email='bar@example.com',
00265                                         exact_match=False )
00266         self.assertEqual( len( info_list ), 0 )

Definition at line 203 of file test_ZODBUserManager.py.

00203 
00204     def test_enumerateUsers_partial( self ):
00205 
00206         from Products.PluggableAuthService.tests.test_PluggableAuthService \
00207             import FauxRoot
00208 
00209         root = FauxRoot()
00210         zum = self._makeOne( id='partial' ).__of__( root )
00211 
00212         ID_LIST = ( 'foo', 'bar', 'baz', 'bam' )
00213 
00214         for id in ID_LIST:
00215 
00216             zum.addUser( id, '%s@example.com' % id, 'password' )
00217 
00218         info_list = zum.enumerateUsers( login='example.com', exact_match=False )
00219 
00220         self.assertEqual( len( info_list ), len( ID_LIST ) ) # all match
00221 
00222         sorted = list( ID_LIST )
00223         sorted.sort()
00224 
00225         for i in range( len( sorted ) ):
00226 
00227             self.assertEqual( info_list[ i ][ 'id' ], sorted[ i ] )
00228             self.assertEqual( info_list[ i ][ 'login' ]
00229                             , '%s@example.com' % sorted[ i ] )
00230             self.assertEqual( info_list[ i ][ 'pluginid' ], 'partial' )
00231             self.assertEqual( info_list[ i ][ 'editurl' ]
00232                             , 'partial/manage_users?user_id=%s' % sorted[ i ])
00233 
00234         info_list = zum.enumerateUsers( id='ba', exact_match=False )
00235 
00236         self.assertEqual( len( info_list ), len( ID_LIST ) - 1 ) # no 'foo'
00237 
00238         sorted = list( ID_LIST )
00239         sorted.sort()
00240 
00241         for i in range( len( sorted ) - 1 ):
00242 
00243             self.assertEqual( info_list[ i ][ 'id' ], sorted[ i ] )
00244             self.assertEqual( info_list[ i ][ 'login' ]
00245                             , '%s@example.com' % sorted[ i ] )
00246             self.assertEqual( info_list[ i ][ 'pluginid' ], 'partial' )
00247             self.assertEqual( info_list[ i ][ 'editurl' ]
00248                             , 'partial/manage_users?user_id=%s' % sorted[ i ])

Definition at line 267 of file test_ZODBUserManager.py.

00267 
00268     def test_enumerateUsers_unicode( self ):
00269 
00270         from Products.PluggableAuthService.tests.test_PluggableAuthService \
00271             import FauxRoot
00272 
00273         root = FauxRoot()
00274         zum = self._makeOne( id='partial' ).__of__( root )
00275 
00276         ID_LIST = ( 'foo', 'bar', 'baz', 'bam' )
00277 
00278         for id in ID_LIST:
00279 
00280             zum.addUser( id, '%s@example.com' % id, 'password' )
00281 
00282         info_list = zum.enumerateUsers( id = u'abc',
00283                                         exact_match=False )
00284         self.assertEqual( len( info_list ), 0 )

Definition at line 443 of file test_ZODBUserManager.py.

00443 
00444     def test_enumerateUsersWithOptionalMangling(self):
00445 
00446         zum = self._makeOne()
00447         zum.prefix = 'special__'
00448 
00449         zum.addUser('user', 'login', 'password')
00450         info = zum.enumerateUsers(login='login')
00451         self.assertEqual(info[0]['id'], 'special__user')

Definition at line 452 of file test_ZODBUserManager.py.

00452 
00453     def test_getUserByIdWithOptionalMangling(self):
00454 
00455         zum = self._makeOne()
00456         zum.prefix = 'special__'
00457 
00458         zum.addUser('user', 'login', 'password')
00459 
00460         info = zum.enumerateUsers(id='user', exact_match=True)
00461         self.assertEqual(len(info), 0)
00462 
00463         info = zum.enumerateUsers(id='special__user', exact_match=True)
00464         self.assertEqual(info[0]['id'], 'special__user')
00465 
00466         info = zum.enumerateUsers(id='special__luser', exact_match=True)
00467         self.assertEqual(len(info), 0)

Definition at line 544 of file test_ZODBUserManager.py.

00544 
00545     def test_manage_updatePassword(self):
00546         from AccessControl.SecurityManagement import newSecurityManager
00547         from AccessControl.SecurityManagement import noSecurityManager
00548         from Acquisition import Implicit
00549         # Test that a user can update her own password using the
00550         # ZMI-provided form handler: http://www.zope.org/Collectors/PAS/56
00551         zum = self._makeOne()
00552 
00553         # Create a user and make sure we can authenticate with it
00554         zum.addUser( 'user1', 'user1@example.com', 'password' )
00555         info1 = { 'login' : 'user1@example.com', 'password' : 'password' }
00556         self.failUnless(zum.authenticateCredentials(info1))
00557 
00558         # Give the user a new password; attempting to authenticate with the
00559         # old password must fail
00560         class FauxUser(Implicit):
00561 
00562             def __init__(self, id):
00563                 self._id = id
00564 
00565             def getId( self ):
00566                 return self._id
00567 
00568         newSecurityManager(None, FauxUser('user1'))
00569         try:
00570             zum.manage_updatePassword('user2@example.com',
00571                                       'new_password',
00572                                       'new_password',
00573                                      )
00574         finally:
00575             noSecurityManager()
00576 
00577         self.failIf(zum.authenticateCredentials(info1))
00578 
00579         # Try to authenticate with the new password, this must succeed.
00580         info2 = { 'login' : 'user2@example.com', 'password' : 'new_password' }
00581         user_id, login = zum.authenticateCredentials(info2)
00582         self.assertEqual(user_id, 'user1')
00583         self.assertEqual(login, 'user2@example.com')

Definition at line 95 of file test_ZODBUserManager.py.

00095 
00096     def test_removeUser_nonesuch( self ):
00097 
00098         zum = self._makeOne()
00099 
00100         self.assertRaises( KeyError, zum.removeUser, 'nonesuch' )

Definition at line 101 of file test_ZODBUserManager.py.

00101 
00102     def test_removeUser_valid_id( self ):
00103 
00104         zum = self._makeOne()
00105 
00106         zum.addUser( 'userid', 'userid@example.com', 'password' )
00107         zum.addUser( 'doomed', 'doomed@example.com', 'password' )
00108 
00109         zum.removeUser( 'doomed' )
00110 
00111         user_ids = zum.listUserIds()
00112         self.assertEqual( len( user_ids ), 1 )
00113         self.assertEqual( len( zum.enumerateUsers() ), 1 )
00114         self.assertEqual( user_ids[0], 'userid' )
00115 
00116         self.assertEqual( zum.getUserIdForLogin( 'userid@example.com' )
00117                         , 'userid' )
00118         self.assertEqual( zum.getLoginForUserId( 'userid' )
00119                         , 'userid@example.com' )
00120 
00121         self.assertRaises( KeyError
00122                          , zum.getUserIdForLogin, 'doomed@example.com' )
00123         self.assertRaises( KeyError
00124                          , zum.getLoginForUserId, 'doomed' )

Definition at line 421 of file test_ZODBUserManager.py.

00421 
00422     def test_updateUser(self):
00423 
00424         zum = self._makeOne()
00425 
00426         # Create a user and make sure we can authenticate with it
00427         zum.addUser( 'user1', 'user1@example.com', 'password' )
00428         info1 = { 'login' : 'user1@example.com', 'password' : 'password' }
00429         user_id, login = zum.authenticateCredentials(info1)
00430         self.assertEqual(user_id, 'user1')
00431         self.assertEqual(login, 'user1@example.com')
00432 
00433         # Give the user a new login; attempts to authenticate with the
00434         # old login must fail.
00435         zum.updateUser('user1', 'user1@foobar.com')
00436         self.failIf(zum.authenticateCredentials(info1))
00437 
00438         # Try to authenticate with the new login, this must succeed.
00439         info2 = { 'login' : 'user1@foobar.com', 'password' : 'password' }
00440         user_id, login = zum.authenticateCredentials(info2)
00441         self.assertEqual(user_id, 'user1')
00442         self.assertEqual(login, 'user1@foobar.com')

Definition at line 399 of file test_ZODBUserManager.py.

00399 
00400     def test_updateUserPassword(self):
00401 
00402         zum = self._makeOne()
00403 
00404         # Create a user and make sure we can authenticate with it
00405         zum.addUser( 'user1', 'user1@example.com', 'password' )
00406         info1 = { 'login' : 'user1@example.com', 'password' : 'password' }
00407         user_id, login = zum.authenticateCredentials(info1)
00408         self.assertEqual(user_id, 'user1')
00409         self.assertEqual(login, 'user1@example.com')
00410 
00411         # Give the user a new password; attempting to authenticate with the
00412         # old password must fail
00413         zum.updateUserPassword('user1', 'new_password')
00414         self.failIf(zum.authenticateCredentials(info1))
00415 
00416         # Try to authenticate with the new password, this must succeed.
00417         info2 = { 'login' : 'user1@example.com', 'password' : 'new_password' }
00418         user_id, login = zum.authenticateCredentials(info2)
00419         self.assertEqual(user_id, 'user1')
00420         self.assertEqual(login, 'user1@example.com')

Definition at line 506 of file test_ZODBUserManager.py.

00506 
00507     def test_updateUserPassword_with_not_yet_encrypted_password(self):
00508         from AccessControl.AuthEncoding import is_encrypted
00509 
00510         USER_ID = 'not_yet_encrypted'
00511         PASSWORD = 'password'
00512 
00513         self.failIf(is_encrypted(PASSWORD))
00514 
00515         zum = self._makeOne()
00516         zum.addUser(USER_ID, USER_ID, '')
00517         zum.updateUserPassword(USER_ID, PASSWORD)
00518 
00519         uid_and_info = zum.authenticateCredentials(
00520                                 { 'login': USER_ID
00521                                 , 'password': PASSWORD
00522                                 })
00523 
00524         self.assertEqual(uid_and_info, (USER_ID, USER_ID))

Definition at line 525 of file test_ZODBUserManager.py.

00525 
00526     def test_updateUserPassword_with_preencrypted_password(self):
00527         from AccessControl.AuthEncoding import pw_encrypt
00528 
00529         USER_ID = 'already_encrypted'
00530         PASSWORD = 'password'
00531 
00532         ENCRYPTED = pw_encrypt(PASSWORD)
00533 
00534         zum = self._makeOne()
00535         zum.addUser(USER_ID, USER_ID, '')
00536         zum.updateUserPassword(USER_ID, ENCRYPTED)
00537 
00538         uid_and_info = zum.authenticateCredentials(
00539                                 { 'login': USER_ID
00540                                 , 'password': PASSWORD
00541                                 })
00542 
00543         self.assertEqual(uid_and_info, (USER_ID, USER_ID))

Definition at line 584 of file test_ZODBUserManager.py.

00584 
00585     def testPOSTProtections(self):
00586         from AccessControl.AuthEncoding import pw_encrypt
00587         from zExceptions import Forbidden
00588         USER_ID = 'testuser'
00589         PASSWORD = 'password'
00590 
00591         ENCRYPTED = pw_encrypt(PASSWORD)
00592 
00593         zum = self._makeOne()
00594         zum.addUser(USER_ID, USER_ID, '')
00595 
00596         req, res = makeRequestAndResponse()
00597         # test manage_updateUserPassword
00598         # Fails with a GET
00599         req.set('REQUEST_METHOD', 'GET')
00600         self.assertRaises(Forbidden, zum.manage_updateUserPassword,
00601                           USER_ID, PASSWORD, PASSWORD, REQUEST=req)
00602         # Works with a POST
00603         req.set('REQUEST_METHOD', 'POST')
00604         zum.manage_updateUserPassword(USER_ID, PASSWORD, PASSWORD, REQUEST=req)
00605 
00606         # test manage_updatePassword
00607         req.set('REQUEST_METHOD', 'GET')
00608         self.assertRaises(Forbidden, zum.manage_updatePassword,
00609                           USER_ID, PASSWORD, PASSWORD, REQUEST=req)
00610         # XXX: This method is broken
00611 
00612         # test manage_removeUsers
00613         req.set('REQUEST_METHOD', 'GET')
00614         self.assertRaises(Forbidden, zum.manage_removeUsers,
00615                           [USER_ID], REQUEST=req)
00616         req.set('REQUEST_METHOD', 'POST')
00617         zum.manage_removeUsers([USER_ID], REQUEST=req)
00618 


Member Data Documentation

Definition at line 562 of file test_ZODBUserManager.py.


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