Exemple #1
0
class IPV4FTPTimeoutTestCase(TestCase):
    def setUp(self):
        self.hostname = '127.0.0.1'
        self.user = getpass.getuser()
        self.password = '******'
        self.server = SlowSSHServer()
        self.server.protocol = ServerProtocol

        self.port = reactor.listenTCP(0, self.server, interface=self.hostname)
        self.portnum = self.port.getHost().port

        options = {
            'hostname': self.hostname,
            'port': self.portnum,
            'user': self.user,
            'password': self.password,
            'buffersize': 32768
        }

        self.client = SSHClient(options)
        self.client.protocol = ClientProtocol
        self.client.connect()

    def tearDown(self):
        # Shut down the server and client
        log.debug('tearing down')
        port, self.port = self.port, None
        client, self.client = self.client, None
        server, self.server = self.server, None

        # A Deferred for the server listening port
        d = port.stopListening()

        # Tell the client to disconnect and not retry.
        client.disconnect()

        return defer.gatherResults(
            [d, client.onConnectionLost, server.onConnectionLost])

    def test_lsdir_timeout_fail(self):
        d = self.client.ls('/tmp', timeout=1)
        return self.assertFailure(d, TimeoutError)

    @defer.inlineCallbacks
    def test_lsdir_timeout_pass(self):
        try:
            test_file = 'test_ls_dir'
            sandbox = tempfile.mkdtemp()
            testfile = '/'.join([sandbox, test_file])
            touch(testfile)
            d = yield self.client.ls(sandbox, timeout=60)

            self.assertEquals(d[0][0], test_file)
            defer.returnValue(d)
        finally:
            shutil.rmtree(sandbox)
class IPV4FTPTimeoutTestCase(TestCase):
    def setUp(self):
        self.hostname = '127.0.0.1'
        self.user = getpass.getuser()
        self.password = '******'
        self.server = SlowSSHServer()
        self.server.protocol = ServerProtocol

        self.port = reactor.listenTCP(0, self.server, interface=self.hostname)
        self.portnum = self.port.getHost().port

        options = {'hostname': self.hostname,
                   'port': self.portnum,
                   'user': self.user,
                   'password': self.password,
                   'buffersize': 32768}

        self.client = SSHClient(options)
        self.client.protocol = ClientProtocol
        self.client.connect()

    def tearDown(self):
        # Shut down the server and client
        log.debug('tearing down')
        port, self.port = self.port, None
        client, self.client = self.client, None
        server, self.server = self.server, None

        # A Deferred for the server listening port
        d = port.stopListening()

        # Tell the client to disconnect and not retry.
        client.disconnect()

        return defer.gatherResults([d,
                                    client.onConnectionLost,
                                    server.onConnectionLost])

    def test_lsdir_timeout_fail(self):
        d = self.client.ls('/tmp', timeout=1)
        return self.assertFailure(d, TimeoutError)

    @defer.inlineCallbacks
    def test_lsdir_timeout_pass(self):
        try:
            test_file = 'test_ls_dir'
            sandbox = tempfile.mkdtemp()
            testfile = '/'.join([sandbox, test_file])
            touch(testfile)
            d = yield self.client.ls(sandbox, timeout=60)

            self.assertEquals(d[0][0], test_file)
            defer.returnValue(d)
        finally:
            shutil.rmtree(sandbox)
class IPV4FunctionalNoServerTestCase(TestCase):
    def setUp(self):
        self.hostname = "127.0.0.1"
        self.user = getpass.getuser()
        self.password = "******"
        self.server = SSHServer()
        self.server.protocol = ServerProtocol

        self.port = reactor.listenTCP(0, self.server, interface=self.hostname)
        self.portnum = self.port.getHost().port

        options = {
            "hostname": self.hostname,
            "port": self.portnum + 1,
            "user": self.user,
            "password": self.password,
            "buffersize": 32768,
        }

        self.client = SSHClient(options)
        self.client.protocol = ClientProtocol
        self.client.connect()

    def tearDown(self):
        # Shut down the server and client
        port, self.port = self.port, None
        client, self.client = self.client, None
        server, self.server = self.server, None

        # A Deferred for the server listening port
        d = port.stopListening()

        # Tell the client to disconnect and not retry.
        client.disconnect()

        # Wait for the deferred that tell us we disconnected.
        return defer.gatherResults([d])

    def test_run_command_connect_failure(self):
        "test what happens if the server isnt running"
        d = self.client.run("echo hi")
        return self.assertFailure(d, ConnectError)

    def test_ls_connect_failure(self):
        "test what happens if the server isnt running"

        sandbox = tempfile.mkdtemp()
        d = self.client.ls(sandbox)

        def sandbox_cleanup(data):
            shutil.rmtree(sandbox)
            return data

        d.addBoth(sandbox_cleanup)
        return self.assertFailure(d, ConnectError)
Exemple #4
0
class IPV4FunctionalNoServerTestCase(TestCase):
    def setUp(self):
        self.hostname = '127.0.0.1'
        self.user = getpass.getuser()
        self.password = '******'
        self.server = SSHServer()
        self.server.protocol = ServerProtocol

        self.port = reactor.listenTCP(0, self.server, interface=self.hostname)
        self.portnum = self.port.getHost().port

        options = {
            'hostname': self.hostname,
            'port': self.portnum + 1,
            'user': self.user,
            'password': self.password,
            'buffersize': 32768
        }

        self.client = SSHClient(options)
        self.client.protocol = ClientProtocol
        self.client.connect()

    def tearDown(self):
        # Shut down the server and client
        port, self.port = self.port, None
        client, self.client = self.client, None
        server, self.server = self.server, None

        # A Deferred for the server listening port
        d = port.stopListening()

        # Tell the client to disconnect and not retry.
        client.disconnect()

        # Wait for the deferred that tell us we disconnected.
        return defer.gatherResults([d])

    def test_run_command_connect_failure(self):
        'test what happens if the server isnt running'
        d = self.client.run('echo hi')
        return self.assertFailure(d, ConnectError)

    def test_ls_connect_failure(self):
        'test what happens if the server isnt running'

        sandbox = tempfile.mkdtemp()
        d = self.client.ls(sandbox)

        def sandbox_cleanup(data):
            shutil.rmtree(sandbox)
            return data

        d.addBoth(sandbox_cleanup)
        return self.assertFailure(d, ConnectError)
class IPV4FunctionalNoReconnectionTestCase(TestCase):
    def setUp(self):
        self.timeout = 10
        self.hostname = "127.0.0.1"
        self.user = getpass.getuser()
        self.password = "******"
        self.server = SSHServer()
        self.server.protocol = ServerProtocol

        self.port = reactor.listenTCP(0, self.server, interface=self.hostname)
        self.portnum = self.port.getHost().port

        options = {
            "hostname": self.hostname,
            "port": self.portnum,
            "user": self.user,
            "password": self.password,
            "buffersize": 32768,
        }

        self.client = SSHClient(options)
        self.client.maxRetries = 0
        # self.client.maxDelay = 0
        self.client.protocol = ClientProtocol
        self.client.connect()

    def tearDown(self):
        # Shut down the server and client
        log.debug("tearing down")
        port, self.port = self.port, None
        client, self.client = self.client, None
        server, self.server = self.server, None

        # A Deferred for the server listening port
        d = port.stopListening()

        # Tell the client to disconnect and not retry.
        client.disconnect()

        # Wait for the server to stop.
        return defer.gatherResults([d])

    def test_run_command(self):
        def server_stop_listening(data):
            sld = self.port.stopListening()
            return sld

        def server_drop_connections(data):
            port, self.port = self.port, None
            server, self.server = self.server, None
            server.protocol.transport.loseConnection()
            log.debug("Dropping server connection")
            return self.client.onConnectionLost

        def run_command(data):

            log.debug("running command hi2")
            results = self.client.run("echo hi2")
            return results

        def test_failure_done(deferred):
            log.debug("Failure %s " % deferred)
            return self.assertEqual(deferred.type, ConnectionDone)

        def test_success(data):
            log.debug("Success %s" % (data,))
            self.assertEqual(data.exitCode, 0)
            self.assertEqual(data.output, "hi\n")

        def bring_up_server(data):
            self.server = SSHServer()
            self.server.protocol = ServerProtocol
            self.port = reactor.listenTCP(self.portnum, self.server, interface=self.hostname)
            log.debug("server started")
            return data.factory.dConnected

        d = self.client.run("echo hi")
        d.addBoth(test_success)
        d.addCallback(server_stop_listening)
        d.addCallback(server_drop_connections)
        d.addCallback(bring_up_server)
        d.addCallback(run_command)
        d.addErrback(test_failure_done)

        return d

    def test_lsdir(self):
        test_file = "test_ls_dir"
        sandbox = tempfile.mkdtemp()
        testfile = "/".join([sandbox, test_file])
        touch(testfile)
        d = self.client.ls(sandbox)

        def cleanup_sandbox(data):
            log.debug("Cleaning up sandbox")
            shutil.rmtree(sandbox)

        def test_success(data):
            return self.assertEqual(data[0][0], test_file)

        def server_stop_listening(data):
            sld = self.port.stopListening()
            return sld

        def server_drop_connections(data):
            port, self.port = self.port, None
            server, self.server = self.server, None
            server.protocol.transport.loseConnection()
            log.debug("Dropping server connection")
            return self.client.onConnectionLost

        def bring_up_server(data):
            self.server = SSHServer()
            self.server.protocol = ServerProtocol
            self.port = reactor.listenTCP(self.portnum, self.server, interface=self.hostname)
            log.debug("server started")
            return data.factory.dConnected

        def run_lsdir(data):

            log.debug("running command ls again")
            results = self.client.ls(sandbox)
            return results

        def test_failure_done(deferred):
            log.debug("Failure %s " % deferred)
            return self.assertEqual(deferred.type, ConnectionDone)

        d.addCallback(test_success)
        d.addCallback(server_stop_listening)
        d.addCallback(server_drop_connections)
        d.addCallback(bring_up_server)
        d.addCallback(run_lsdir)
        d.addErrback(test_failure_done)
        d.addBoth(cleanup_sandbox)

        return d
Exemple #6
0
class IPV4FunctionalBaseTestCase(TestCase):
    def setUp(self):
        self.hostname = '127.0.0.1'
        self.user = getpass.getuser()
        self.password = '******'
        self.server = SSHServer()
        self.server.protocol = ServerProtocol

        self.port = reactor.listenTCP(0, self.server, interface=self.hostname)
        self.portnum = self.port.getHost().port

        options = {
            'hostname': self.hostname,
            'port': self.portnum,
            'user': self.user,
            'password': self.password,
            'buffersize': 32768
        }

        self.client = SSHClient(options)
        self.client.protocol = ClientProtocol
        self.client.connect()

    def tearDown(self):
        # Shut down the server and client
        log.debug('tearing down')
        port, self.port = self.port, None
        client, self.client = self.client, None
        server, self.server = self.server, None

        # A Deferred for the server listening port
        d = port.stopListening()

        # Tell the client to disconnect and not retry.
        client.disconnect()

        return defer.gatherResults(
            [d, client.onConnectionLost, server.onConnectionLost])

    def test_run_command(self):

        d = self.client.run('echo hi')

        def got_hi(data):
            log.debug('Got Data %s' % (data, ))
            self.assertEqual(data.exitCode, 0)
            self.assertEqual(data.output, 'hi\n')
            return data

        d.addCallback(got_hi)
        return d

    @defer.inlineCallbacks
    def test_lsdir(self):
        try:
            test_file = 'test_ls_dir'
            sandbox = tempfile.mkdtemp()
            testfile = '/'.join([sandbox, test_file])
            touch(testfile)
            d = yield self.client.ls(sandbox)

            self.assertEquals(d[0][0], test_file)
            defer.returnValue(d)
        finally:
            shutil.rmtree(sandbox)

    def test_lsdir_no_dir(self):
        d = self.client.ls('/_not_real')
        return self.assertFailure(d, SFTPError)

    @defer.inlineCallbacks
    def test_mkdir(self):
        try:
            sandbox = tempfile.mkdtemp()
            test_dir = 'tmpMkdir'
            directory = '/'.join([sandbox, test_dir])
            result = yield self.client.mkdir(directory)
            self.assertEquals(result[0], 'mkdir succeeded')
            self.assertTrue(os.path.isdir(directory))
            defer.returnValue(result)
        finally:
            shutil.rmtree(sandbox)

    @defer.inlineCallbacks
    def test_rmdir(self):
        try:
            sandbox = tempfile.mkdtemp()
            test_dir = 'tmpRmdir'
            directory = '/'.join([sandbox, test_dir])
            os.mkdir(directory)
            result = yield self.client.rmdir(directory)
            self.assertEquals(result[0], 'rmdir succeeded')
            self.assertFalse(os.path.exists(directory))
            defer.returnValue(result)
        finally:
            shutil.rmtree(sandbox)

    @defer.inlineCallbacks
    def test_rename(self):
        try:
            original_filename = 'test_rename'
            destination_filename = 'test_rename_changed'
            sandbox = tempfile.mkdtemp()
            original_path = '/'.join([sandbox, original_filename])
            destination_path = '/'.join([sandbox, destination_filename])
            touch(original_path)

            result = yield self.client.rename(original_path, destination_path)
            self.assertEquals(result[0], 'rename succeeded')
            self.assertFalse(os.path.exists(original_path))
            self.assertTrue(os.path.exists(destination_path))
            defer.returnValue(result)
        finally:
            shutil.rmtree(sandbox)

    @defer.inlineCallbacks
    def test_ln(self):
        try:
            original_filename = 'test_ln'
            destination_filename = 'test_ln_destination'
            sandbox = tempfile.mkdtemp()
            original_path = '/'.join([sandbox, original_filename])
            destination_path = '/'.join([sandbox, destination_filename])
            touch(original_path)
            result = yield self.client.ln(destination_path, original_path)

            self.assertEquals(result[0], 'symlink succeeded')
            self.assertTrue(os.path.isfile(original_path))
            self.assertTrue(os.path.islink(destination_path))
            defer.returnValue(result)
        finally:
            shutil.rmtree(sandbox)

    @defer.inlineCallbacks
    def test_rm(self):
        try:
            original_filename = 'test_rm_file'
            sandbox = tempfile.mkdtemp()
            original_path = '/'.join([sandbox, original_filename])
            touch(original_path)

            result = yield self.client.rm(original_path)

            self.assertEquals(result[0], 'remove succeeded')
            self.assertFalse(os.path.exists(original_path))
            defer.returnValue(result)
        finally:
            shutil.rmtree(sandbox)

    @defer.inlineCallbacks
    def test_put(self):
        try:
            source_data = 'This was my sourcefile...'
            source_filename = 'test_source_file'
            destination_filename = 'test_destination_file'

            source_sandbox = tempfile.mkdtemp()
            destination_sandbox = tempfile.mkdtemp()

            source_path = '/'.join([source_sandbox, source_filename])
            destination_path = '/'.join(
                [destination_sandbox, destination_filename])
            open(source_path, 'w').write(source_data)

            result = yield self.client.put(source_path, destination_path)
            self.assertTrue(os.path.isfile(source_path))
            self.assertTrue(os.path.isfile(destination_path))
            self.assertEqual(source_data, open(destination_path, 'r').read())
            defer.returnValue(result)
        finally:
            shutil.rmtree(source_sandbox)
            shutil.rmtree(destination_sandbox)

    @defer.inlineCallbacks
    def test_get(self):
        try:
            source_data = 'This was my sourcefile...'
            source_filename = 'test_source_file'
            destination_filename = 'test_destination_file'

            source_sandbox = tempfile.mkdtemp()
            destination_sandbox = tempfile.mkdtemp()

            source_path = '/'.join([source_sandbox, source_filename])
            destination_path = '/'.join(
                [destination_sandbox, destination_filename])
            open(source_path, 'w').write(source_data)

            result = yield self.client.get(source_path, destination_path)
            self.assertTrue(os.path.isfile(source_path))
            self.assertTrue(os.path.isfile(destination_path))
            self.assertEqual(source_data, open(destination_path, 'r').read())
            defer.returnValue(result)
        finally:
            shutil.rmtree(source_sandbox)
            shutil.rmtree(destination_sandbox)

    @defer.inlineCallbacks
    def test_chown(self):
        try:
            chown_filename = 'test_chown_file'
            sandbox = tempfile.mkdtemp()
            chown_path = '/'.join([sandbox, chown_filename])
            touch(chown_path)

            import os
            import pwd
            uid = pwd.getpwuid(os.getuid()).pw_uid
            result = yield self.client.chown(chown_path, uid)

            self.assertEquals(result[0], 'setstat succeeded')
            defer.returnValue(result)
        finally:
            shutil.rmtree(sandbox)

    @defer.inlineCallbacks
    def test_chgrp(self):
        try:
            chgrp_filename = 'test_chgrp_file'
            sandbox = tempfile.mkdtemp()
            chgrp_path = '/'.join([sandbox, chgrp_filename])
            touch(chgrp_path)

            import os
            import pwd
            gid = pwd.getpwuid(os.getuid()).pw_gid
            result = yield self.client.chgrp(chgrp_path, gid)

            self.assertEquals(result[0], 'setstat succeeded')
            defer.returnValue(result)
        finally:
            shutil.rmtree(sandbox)

    @defer.inlineCallbacks
    def test_chmod(self):
        try:
            chmod_filename = 'test_chmod_file'
            sandbox = tempfile.mkdtemp()
            chmod_path = '/'.join([sandbox, chmod_filename])
            touch(chmod_path)

            result = yield self.client.chmod(chmod_path, '1000')

            self.assertEquals(result[0], 'setstat succeeded')
            defer.returnValue(result)
        finally:
            shutil.rmtree(sandbox)
Exemple #7
0
class IPV4FunctionalNoReconnectionTestCase(TestCase):
    def setUp(self):
        self.timeout = 10
        self.hostname = '127.0.0.1'
        self.user = getpass.getuser()
        self.password = '******'
        self.server = SSHServer()
        self.server.protocol = ServerProtocol

        self.port = reactor.listenTCP(0, self.server, interface=self.hostname)
        self.portnum = self.port.getHost().port

        options = {
            'hostname': self.hostname,
            'port': self.portnum,
            'user': self.user,
            'password': self.password,
            'buffersize': 32768
        }

        self.client = SSHClient(options)
        self.client.maxRetries = 0
        #self.client.maxDelay = 0
        self.client.protocol = ClientProtocol
        self.client.connect()

    def tearDown(self):
        # Shut down the server and client
        log.debug('tearing down')
        port, self.port = self.port, None
        client, self.client = self.client, None
        server, self.server = self.server, None

        # A Deferred for the server listening port
        d = port.stopListening()

        # Tell the client to disconnect and not retry.
        client.disconnect()

        # Wait for the server to stop.
        return defer.gatherResults([d])

    def test_run_command(self):
        def server_stop_listening(data):
            sld = self.port.stopListening()
            return sld

        def server_drop_connections(data):
            port, self.port = self.port, None
            server, self.server = self.server, None
            server.protocol.transport.loseConnection()
            log.debug('Dropping server connection')
            return self.client.onConnectionLost

        def run_command(data):

            log.debug('running command hi2')
            results = self.client.run('echo hi2')
            return results

        def test_failure_done(deferred):
            log.debug('Failure %s ' % deferred)
            return self.assertEqual(deferred.type, ConnectionDone)

        def test_success(data):
            log.debug('Success %s' % (data, ))
            self.assertEqual(data.exitCode, 0)
            self.assertEqual(data.output, 'hi\n')

        def bring_up_server(data):
            self.server = SSHServer()
            self.server.protocol = ServerProtocol
            self.port = reactor.listenTCP(self.portnum,
                                          self.server,
                                          interface=self.hostname)
            log.debug('server started')
            return data.factory.dConnected

        d = self.client.run('echo hi')
        d.addBoth(test_success)
        d.addCallback(server_stop_listening)
        d.addCallback(server_drop_connections)
        d.addCallback(bring_up_server)
        d.addCallback(run_command)
        d.addErrback(test_failure_done)

        return d

    def test_lsdir(self):
        test_file = 'test_ls_dir'
        sandbox = tempfile.mkdtemp()
        testfile = '/'.join([sandbox, test_file])
        touch(testfile)
        d = self.client.ls(sandbox)

        def cleanup_sandbox(data):
            log.debug('Cleaning up sandbox')
            shutil.rmtree(sandbox)

        def test_success(data):
            return self.assertEqual(data[0][0], test_file)

        def server_stop_listening(data):
            sld = self.port.stopListening()
            return sld

        def server_drop_connections(data):
            port, self.port = self.port, None
            server, self.server = self.server, None
            server.protocol.transport.loseConnection()
            log.debug('Dropping server connection')
            return self.client.onConnectionLost

        def bring_up_server(data):
            self.server = SSHServer()
            self.server.protocol = ServerProtocol
            self.port = reactor.listenTCP(self.portnum,
                                          self.server,
                                          interface=self.hostname)
            log.debug('server started')
            return data.factory.dConnected

        def run_lsdir(data):

            log.debug('running command ls again')
            results = self.client.ls(sandbox)
            return results

        def test_failure_done(deferred):
            log.debug('Failure %s ' % deferred)
            return self.assertEqual(deferred.type, ConnectionDone)

        d.addCallback(test_success)
        d.addCallback(server_stop_listening)
        d.addCallback(server_drop_connections)
        d.addCallback(bring_up_server)
        d.addCallback(run_lsdir)
        d.addErrback(test_failure_done)
        d.addBoth(cleanup_sandbox)

        return d
class IPV4FunctionalBaseTestCase(TestCase):
    def setUp(self):
        self.hostname = '127.0.0.1'
        self.user = getpass.getuser()
        self.password = '******'
        self.server = SSHServer()
        self.server.protocol = ServerProtocol

        self.port = reactor.listenTCP(0, self.server, interface=self.hostname)
        self.portnum = self.port.getHost().port

        options = {'hostname': self.hostname,
                   'port': self.portnum,
                   'user': self.user,
                   'password': self.password,
                   'buffersize': 32768}

        self.client = SSHClient(options)
        self.client.protocol = ClientProtocol
        self.client.connect()

    def tearDown(self):
        # Shut down the server and client
        log.debug('tearing down')
        port, self.port = self.port, None
        client, self.client = self.client, None
        server, self.server = self.server, None

        # A Deferred for the server listening port
        d = port.stopListening()

        # Tell the client to disconnect and not retry.
        client.disconnect()

        return defer.gatherResults([d,
                                    client.onConnectionLost,
                                    server.onConnectionLost])

    def test_run_command(self):

        d = self.client.run('echo hi')

        def got_hi(data):
            log.debug('Got Data %s' % (data,))
            self.assertEqual(data.exitCode, 0)
            self.assertEqual(data.output,  'hi\n')
            return data

        d.addCallback(got_hi)
        return d

    @defer.inlineCallbacks
    def test_lsdir(self):
        try:
            test_file = 'test_ls_dir'
            sandbox = tempfile.mkdtemp()
            testfile = '/'.join([sandbox, test_file])
            touch(testfile)
            d = yield self.client.ls(sandbox)

            self.assertEquals(d[0][0], test_file)
            defer.returnValue(d)
        finally:
            shutil.rmtree(sandbox)

    def test_lsdir_no_dir(self):
        d = self.client.ls('/_not_real')
        return self.assertFailure(d, SFTPError)

    @defer.inlineCallbacks
    def test_mkdir(self):
        try:
            sandbox = tempfile.mkdtemp()
            test_dir = 'tmpMkdir'
            directory = '/'.join([sandbox, test_dir])
            result = yield self.client.mkdir(directory)
            self.assertEquals(result[0], 'mkdir succeeded')
            self.assertTrue(os.path.isdir(directory))
            defer.returnValue(result)
        finally:
            shutil.rmtree(sandbox)

    @defer.inlineCallbacks
    def test_rmdir(self):
        try:
            sandbox = tempfile.mkdtemp()
            test_dir = 'tmpRmdir'
            directory = '/'.join([sandbox, test_dir])
            os.mkdir(directory)
            result = yield self.client.rmdir(directory)
            self.assertEquals(result[0], 'rmdir succeeded')
            self.assertFalse(os.path.exists(directory))
            defer.returnValue(result)
        finally:
            shutil.rmtree(sandbox)

    @defer.inlineCallbacks
    def test_rename(self):
        try:
            original_filename = 'test_rename'
            destination_filename = 'test_rename_changed'
            sandbox = tempfile.mkdtemp()
            original_path = '/'.join([sandbox, original_filename])
            destination_path = '/'.join([sandbox, destination_filename])
            touch(original_path)

            result = yield self.client.rename(original_path,
                                              destination_path)
            self.assertEquals(result[0], 'rename succeeded')
            self.assertFalse(os.path.exists(original_path))
            self.assertTrue(os.path.exists(destination_path))
            defer.returnValue(result)
        finally:
            shutil.rmtree(sandbox)

    @defer.inlineCallbacks
    def test_ln(self):
        try:
            original_filename = 'test_ln'
            destination_filename = 'test_ln_destination'
            sandbox = tempfile.mkdtemp()
            original_path = '/'.join([sandbox, original_filename])
            destination_path = '/'.join([sandbox, destination_filename])
            touch(original_path)
            result = yield self.client.ln(destination_path, original_path)

            self.assertEquals(result[0], 'symlink succeeded')
            self.assertTrue(os.path.isfile(original_path))
            self.assertTrue(os.path.islink(destination_path))
            defer.returnValue(result)
        finally:
            shutil.rmtree(sandbox)

    @defer.inlineCallbacks
    def test_rm(self):
        try:
            original_filename = 'test_rm_file'
            sandbox = tempfile.mkdtemp()
            original_path = '/'.join([sandbox, original_filename])
            touch(original_path)

            result = yield self.client.rm(original_path)

            self.assertEquals(result[0], 'remove succeeded')
            self.assertFalse(os.path.exists(original_path))
            defer.returnValue(result)
        finally:
            shutil.rmtree(sandbox)

    @defer.inlineCallbacks
    def test_put(self):
        try:
            source_data = 'This was my sourcefile...'
            source_filename = 'test_source_file'
            destination_filename = 'test_destination_file'

            source_sandbox = tempfile.mkdtemp()
            destination_sandbox = tempfile.mkdtemp()

            source_path = '/'.join([source_sandbox, source_filename])
            destination_path = '/'.join([destination_sandbox,
                                         destination_filename])
            open(source_path, 'w').write(source_data)

            result = yield self.client.put(source_path, destination_path)
            self.assertTrue(os.path.isfile(source_path))
            self.assertTrue(os.path.isfile(destination_path))
            self.assertEqual(source_data,
                             open(destination_path, 'r').read())
            defer.returnValue(result)
        finally:
            shutil.rmtree(source_sandbox)
            shutil.rmtree(destination_sandbox)

    @defer.inlineCallbacks
    def test_get(self):
        try:
            source_data = 'This was my sourcefile...'
            source_filename = 'test_source_file'
            destination_filename = 'test_destination_file'

            source_sandbox = tempfile.mkdtemp()
            destination_sandbox = tempfile.mkdtemp()

            source_path = '/'.join([source_sandbox, source_filename])
            destination_path = '/'.join([destination_sandbox,
                                         destination_filename])
            open(source_path, 'w').write(source_data)

            result = yield self.client.get(source_path, destination_path)
            self.assertTrue(os.path.isfile(source_path))
            self.assertTrue(os.path.isfile(destination_path))
            self.assertEqual(source_data,
                             open(destination_path, 'r').read())
            defer.returnValue(result)
        finally:
            shutil.rmtree(source_sandbox)
            shutil.rmtree(destination_sandbox)

    @defer.inlineCallbacks
    def test_chown(self):
        try:
            chown_filename = 'test_chown_file'
            sandbox = tempfile.mkdtemp()
            chown_path = '/'.join([sandbox, chown_filename])
            touch(chown_path)

            import os
            import pwd
            uid = pwd.getpwuid(os.getuid()).pw_uid
            result = yield self.client.chown(chown_path, uid)

            self.assertEquals(result[0], 'setstat succeeded')
            defer.returnValue(result)
        finally:
            shutil.rmtree(sandbox)

    @defer.inlineCallbacks
    def test_chgrp(self):
        try:
            chgrp_filename = 'test_chgrp_file'
            sandbox = tempfile.mkdtemp()
            chgrp_path = '/'.join([sandbox, chgrp_filename])
            touch(chgrp_path)

            import os
            import pwd
            gid = pwd.getpwuid(os.getuid()).pw_gid
            result = yield self.client.chgrp(chgrp_path, gid)

            self.assertEquals(result[0], 'setstat succeeded')
            defer.returnValue(result)
        finally:
            shutil.rmtree(sandbox)

    @defer.inlineCallbacks
    def test_chmod(self):
        try:
            chmod_filename = 'test_chmod_file'
            sandbox = tempfile.mkdtemp()
            chmod_path = '/'.join([sandbox, chmod_filename])
            touch(chmod_path)

            result = yield self.client.chmod(chmod_path, '1000')

            self.assertEquals(result[0], 'setstat succeeded')
            defer.returnValue(result)
        finally:
            shutil.rmtree(sandbox)