'If L{SSHCommandClientEndpoint} is initialized with an
L{SSHAgentClient}, the agent is used to authenticate with the SSH
server. Once the connection with the SSH server has concluded, the
connection to the agent is disconnected.'

def test_agentAuthentication(self):

    key = Key.fromString(privateRSA_openssh)
    agentServer = SSHAgentServer()
    agentServer.factory = Factory()
    agentServer.factory.keys = {key.blob(): (key, '')}
    self.setupKeyChecker(self.portal, {self.user: privateRSA_openssh})
    agentEndpoint = SingleUseMemoryEndpoint(agentServer)
    endpoint = SSHCommandClientEndpoint.newConnection(self.reactor, '/bin/ls    -l', self.user, self.hostname, self.port, knownHosts=self.knownHosts, ui=FixedResponseUI(False), agentEndpoint=agentEndpoint)
    self.realm.channelLookup['session'] = WorkingExecSession
    factory = Factory()
    factory.protocol = Protocol
    connected = endpoint.connect(factory)
    (server, client, pump) = self.connectedServerAndClient(self.factory, self.reactor.tcpClients[0][2])
    for i in range(14):
        agentEndpoint.pump.pump()
        pump.pump()
    protocol = self.successResultOf(connected)
    self.assertIsNotNone(protocol.transport)
    self.loseConnectionToServer(server, client, protocol, pump)
    self.assertTrue(client.transport.disconnecting)
    self.assertTrue(agentEndpoint.pump.clientIO.disconnecting)
