'If the SSH server rejects the key pair presented during authentication,
the L{Deferred} returned by L{SSHCommandClientEndpoint.connect} fires
with a L{Failure} wrapping L{AuthenticationFailed}.'

def test_publicKeyAuthenticationFailure(self):

    badKey = Key.fromString(privateRSA_openssh)
    self.setupKeyChecker(self.portal, {self.user: privateDSA_openssh})
    endpoint = SSHCommandClientEndpoint.newConnection(self.reactor, '/bin/ls    -l', self.user, self.hostname, self.port, keys=[badKey], knownHosts=self.knownHosts, ui=FixedResponseUI(False))
    factory = Factory()
    factory.protocol = Protocol
    connected = endpoint.connect(factory)
    (server, client, pump) = self.connectedServerAndClient(self.factory, self.reactor.tcpClients[0][2])
    f = self.failureResultOf(connected)
    f.trap(AuthenticationFailed)
    self.assertTrue(client.transport.disconnecting)
