#NEWLINE# def test_defaultCheckers( self ) : #NEWLINE# #INDENT# '\n        L{UNIXPasswordDatabase} with no arguments has checks the C{pwd} database\n        and then the C{spwd} database.\n        ' #NEWLINE# checker = checkers . UNIXPasswordDatabase ( ) #NEWLINE# def crypted( username , password ) : #NEWLINE# #INDENT# salt = crypt . crypt ( password , username ) #NEWLINE# crypted = crypt . crypt ( password , ( '$1$' + salt ) ) #NEWLINE# return crypted #NEWLINE# #UNINDENT# pwd = UserDatabase ( ) #NEWLINE# pwd . addUser ( 'alice' , crypted ( 'alice' , 'password' ) , 1 , 2 , 'foo' , '/foo' , '/bin/sh' ) #NEWLINE# pwd . addUser ( 'bob' , 'x' , 1 , 2 , 'bar' , '/bar' , '/bin/sh' ) #NEWLINE# spwd = ShadowDatabase ( ) #NEWLINE# spwd . addUser ( 'alice' , 'wrong' , 1 , 2 , 3 , 4 , 5 , 6 , 7 ) #NEWLINE# spwd . addUser ( 'bob' , crypted ( 'bob' , 'password' ) , 8 , 9 , 10 , 11 , 12 , 13 , 14 ) #NEWLINE# self . patch ( checkers , 'pwd' , pwd ) #NEWLINE# self . patch ( checkers , 'spwd' , spwd ) #NEWLINE# mockos = MockOS ( ) #NEWLINE# self . patch ( util , 'os' , mockos ) #NEWLINE# mockos . euid = 2345 #NEWLINE# mockos . egid = 1234 #NEWLINE# cred = UsernamePassword ( b'alice' , b'password' ) #NEWLINE# self . assertLoggedIn ( checker . requestAvatarId ( cred ) , b'alice' ) #NEWLINE# self . assertEqual ( cred . seteuidCalls , [ ] ) #NEWLINE# self . assertEqual ( mockos . setegidCalls , [ ] ) #NEWLINE# cred . username = b'bob' #NEWLINE# self . assertLoggedIn ( checker . requestAvatarId ( cred ) , b'bob' ) #NEWLINE# self . assertEqual ( mockos . seteuidCalls , [ 0 , 2345 ] ) #NEWLINE# self . assertEqual ( mockos . setegidCalls , [ 0 , 1234 ] )