'Test the NLST command.
Like L{test_passiveNLST} but in the configuration where the server
establishes the data connection to the client, rather than the other
way around.'

def test_passiveNLST(self):

    def cbList(res, proto):
        fls = proto.buffer.splitlines()
        expected = ['foo', 'bar', 'baz']
        expected.sort()
        fls.sort()
        self.assertEqual(fls, expected)
    def cbConnect(host, port, factory):
        self.assertEqual(host, '127.0.0.1')
        self.assertEqual(port, 12345)
        proto = factory.buildProtocol((host, port))
        proto.makeConnection(proto_helpers.StringTransport())
        self.client.lineReceived('150    File    status    okay;    about    to    open    data    connection.')
        proto.dataReceived('foo\r\n')
        proto.dataReceived('bar\r\n')
        proto.dataReceived('baz\r\n')
        proto.connectionLost(failure.Failure(error.ConnectionDone('')))
    self.client.connectFactory = cbConnect
    self._testLogin()
    lstproto = _BufferingProtocol()
    d = self.client.nlst('foo/bar', lstproto).addCallback(cbList, lstproto)
    self.assertEqual(self.transport.value(), 'PASV\r\n')
    self.transport.clear()
    self.client.lineReceived(passivemode_msg(self.client))
    self.assertEqual(self.transport.value(), 'NLST    foo/bar\r\n')
    self.client.lineReceived('226    Transfer    Complete.')
    return d
