'L{OpenSSHFactory.getPrivateKeys} should switch to root if the keys
aren\'t readable by the current user.'

def test_getPrivateKeysAsRoot(self):

    keyFile = self.keysDir.child('ssh_host_two_key')
    keyFile.chmod(0)
    self.addCleanup(keyFile.chmod, 511)
    savedSeteuid = os.seteuid
    def seteuid(euid):
        keyFile.chmod(511)
        return savedSeteuid(euid)
    self.patch(os, 'seteuid', seteuid)
    keys = self.factory.getPrivateKeys()
    self.assertEqual(len(keys), 2)
    keyTypes = keys.keys()
    self.assertEqual(set(keyTypes), set(['ssh-rsa', 'ssh-dss']))
    self.assertEqual(self.mockos.seteuidCalls, [0, os.geteuid()])
    self.assertEqual(self.mockos.setegidCalls, [0, os.getegid()])
