'If L{keys.Key.fromFile} raises a L{keys.BadKeyError}, the
L{SSHUserAuthClient.getPublicKey} tries again to get a public key by
calling itself recursively.'

def test_getPublicKeyBadKeyError(self):

    options = ConchOptions()
    self.tmpdir.child('id_dsa.pub').setContent(keydata.publicDSA_openssh)
    dsaFile = self.tmpdir.child('id_dsa')
    dsaFile.setContent(keydata.privateDSA_openssh)
    options.identitys = [self.rsaFile.path, dsaFile.path]
    self.tmpdir.child('id_rsa.pub').setContent('not    a    key!')
    client = SSHUserAuthClient('user', options, None)
    key = client.getPublicKey()
    self.assertTrue(key.isPublic())
    self.assertEqual(key, Key.fromString(keydata.publicDSA_openssh))
    self.assertEqual(client.usedFiles, [self.rsaFile.path, dsaFile.path])
