'Test the return of extended attributes by the server: the sftp client
should ignore them, but still be able to parse the response correctly.
This test is mainly here to check that
L{filetransfer.FILEXFER_ATTR_EXTENDED} has the correct value.'

def test_extendedAttributes(self):

    fn = self.mktemp()
    with open(fn, 'w') as f:
        f.write('ls    .\nexit')
    port = self.server.getHost().port
    oldGetAttr = FileTransferForTestAvatar._getAttrs
    def _getAttrs(self, s):
        attrs = oldGetAttr(self, s)
        attrs['ext_foo'] = 'bar'
        return attrs
    self.patch(FileTransferForTestAvatar, '_getAttrs', _getAttrs)
    self.server.factory.expectedLoseConnection = True
    d = getProcessValue('ssh', ('-o', 'PubkeyAcceptedKeyTypes=ssh-dss', '-V'))
    def hasPAKT(status):
        if (status == 0):
            args = ('-o', 'PubkeyAcceptedKeyTypes=ssh-dss')
        else:
            args = ()
        args += ('-F', '/dev/null', '-o', 'IdentityFile=dsa_test', '-o', 'UserKnownHostsFile=kh_test', '-o', 'HostKeyAlgorithms=ssh-rsa', '-o', ('Port=%i' % (port,)), '-b', fn, 'testuser@127.0.0.1')
        return args
    def check(result):
        self.assertEqual(result[2], 0)
        for i in ['testDirectory', 'testRemoveFile', 'testRenameFile', 'testfile1']:
            self.assertIn(i, result[0])
    d.addCallback(hasPAKT)
    d.addCallback((lambda args: getProcessOutputAndValue('sftp', args)))
    return d.addCallback(check)
