'If the SSH public key presented by the SSH server does not match the
previously remembered key, as reported by the L{KnownHostsFile}
instance use to construct the endpoint, for that server, the
L{Deferred} returned by L{SSHCommandClientEndpoint.connect} fires with
a L{Failure} wrapping L{HostKeyChanged}.'

def test_mismatchedHostKey(self):

    firstKey = Key.fromString(privateRSA_openssh).public()
    knownHosts = KnownHostsFile(FilePath(self.mktemp()))
    knownHosts.addHostKey(networkString(self.serverAddress.host), firstKey)
    differentKey = Key.fromString(privateRSA_openssh_encrypted_aes, passphrase='testxp').public()
    knownHosts.addHostKey(self.hostname, differentKey)
    ui = FixedResponseUI(True)
    endpoint = SSHCommandClientEndpoint.newConnection(self.reactor, '/bin/ls    -l', 'dummy    user', self.hostname, self.port, password='dummy    password', knownHosts=knownHosts, ui=ui)
    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(HostKeyChanged)
