'L{UNIXPasswordDatabase} with no arguments has checks the C{pwd} database
and then the C{spwd} database.'

def test_defaultCheckers(self):

    checker = checkers.UNIXPasswordDatabase()
    def crypted(username, password):
        salt = crypt.crypt(password, username)
        crypted = crypt.crypt(password, ('$1$' + salt))
        return crypted
    pwd = UserDatabase()
    pwd.addUser('alice', crypted('alice', 'password'), 1, 2, 'foo', '/foo', '/bin/sh')
    pwd.addUser('bob', 'x', 1, 2, 'bar', '/bar', '/bin/sh')
    spwd = ShadowDatabase()
    spwd.addUser('alice', 'wrong', 1, 2, 3, 4, 5, 6, 7)
    spwd.addUser('bob', crypted('bob', 'password'), 8, 9, 10, 11, 12, 13, 14)
    self.patch(checkers, 'pwd', pwd)
    self.patch(checkers, 'spwd', spwd)
    mockos = MockOS()
    self.patch(util, 'os', mockos)
    mockos.euid = 2345
    mockos.egid = 1234
    cred = UsernamePassword('alice', 'password')
    self.assertLoggedIn(checker.requestAvatarId(cred), 'alice')
    self.assertEqual(mockos.seteuidCalls, [])
    self.assertEqual(mockos.setegidCalls, [])
    cred.username = 'bob'
    self.assertLoggedIn(checker.requestAvatarId(cred), 'bob')
    self.assertEqual(mockos.seteuidCalls, [0, 2345])
    self.assertEqual(mockos.setegidCalls, [0, 1234])
