def dummy(client):
     # set the connection lost handler
     client.connectionLostHandler = conn_lost_handler
     # trigger an operation, which should
     client.dummy_authenticate("open sesame")
     yield d
     # check we logged a warning about this.
     handler.assert_warning("Shutting down protocol: user locked")
 def dummy(client):
     # set the connection lost handler
     client.connectionLostHandler = conn_lost_handler
     # trigger an operation, which should
     client.dummy_authenticate("open sesame")
     yield d
     # check we logged a warning about this.
     self.assertTrue(
         hdlr.check_warning("Shutting down protocol: user locked"))
        def auth(client):

            yield client.dummy_authenticate('open sesame')
            d = defer.Deferred()
            client.connectionLostHandler = d.callback
            # add the log handler
            logger = logging.getLogger('storage.server')
            hdlr = MementoHandler()
            hdlr.setLevel(logging.INFO)
            logger.addHandler(hdlr)
            # patch the looping ping values
            server = self.service.factory.protocols[0]
            server.ping_loop.interval = 0.1
            server.ping_loop.idle_timeout = 0.3
            # reschedule the ping loop
            server.ping_loop.reset()
            try:
                yield d
            except ConnectionDone:
                msg = "Disconnecting - idle timeout"
                self.assertTrue(hdlr.check_info(msg))
            else:
                self.fail("Should get disconnected.")
            finally:
                logger.removeHandler(hdlr)
        def auth(client):
            # stop the real looping ping and patch the reset method.
            yield client.dummy_authenticate('open sesame')
            server = self.service.factory.protocols[0]
            server.ping_loop.shutdown.cancel()

            # Wait for loop to finish
            d = defer.Deferred()
            real_reschedule = server.ping_loop.reschedule

            def reschedule():
                """Callback d the first time we hit this."""
                if not d.called:
                    d.callback(None)
                real_reschedule()

            self.patch(server.ping_loop, 'reschedule', reschedule)
            yield d

            self.patch(server.ping_loop, 'reset', d.callback)

            called = []

            self.patch(server.ping_loop, 'reset', lambda: called.append(1))
            yield client.ping()
            self.assertEqual(0, len(called))
            yield client.list_shares()
            self.assertEqual(1, len(called))
            yield client.list_shares()
            self.assertEqual(2, len(called))
        def auth(client):
            # stop the real looping ping and patch the reset method.
            yield client.dummy_authenticate('open sesame')
            server = self.service.factory.protocols[0]
            server.ping_loop.shutdown.cancel()

            # Wait for loop to finish
            d = defer.Deferred()
            real_reschedule = server.ping_loop.reschedule

            def reschedule():
                """Callback d the first time we hit this."""
                if not d.called:
                    d.callback(None)
                real_reschedule()
            self.patch(server.ping_loop, 'reschedule', reschedule)
            yield d

            self.patch(server.ping_loop, 'reset', d.callback)

            called = []

            self.patch(server.ping_loop, 'reset', lambda: called.append(1))
            yield client.ping()
            self.assertEqual(0, len(called))
            yield client.list_shares()
            self.assertEqual(1, len(called))
            yield client.list_shares()
            self.assertEqual(2, len(called))
        def auth(client):

            yield client.dummy_authenticate('open sesame')
            d = defer.Deferred()
            client.connectionLostHandler = d.callback
            # add the log handler
            logger = logging.getLogger('storage.server')
            hdlr = MementoHandler()
            hdlr.setLevel(logging.INFO)
            logger.addHandler(hdlr)
            # patch the looping ping values
            server = self.service.factory.protocols[0]
            server.ping_loop.interval = 0.1
            server.ping_loop.idle_timeout = 0.3
            # reschedule the ping loop
            server.ping_loop.reset()
            try:
                yield d
            except ConnectionDone:
                msg = "Disconnecting - idle timeout"
                self.assertTrue(hdlr.check_info(msg))
            else:
                self.fail("Should get disconnected.")
            finally:
                logger.removeHandler(hdlr)
 def dummy(client):
     # set the connection lost handler
     client.connectionLostHandler = conn_lost_handler
     # trigger an operation, which should
     yield client.dummy_authenticate("open sesame")
     root_id = yield client.get_root()
     # lock the user:
     StorageUser.objects.filter(id=self.usr0.id).update(locked=True)
     client.make_dir(request.ROOT, root_id, u"open sesame")
     yield d
     # check we logged a warning about this.
     handler.assert_warning("Shutting down protocol: user locked")
        def auth(client):

            yield client.dummy_authenticate('open sesame')
            d = defer.Deferred()
            client.connectionLostHandler = d.callback
            # patch the looping ping values
            server = self.service.factory.protocols[0]
            server.ping_loop.interval = 0.1
            server.ping_loop.idle_timeout = 0.3
            # reschedule the ping loop
            server.ping_loop.reset()
            yield self.assertFailure(d, ConnectionDone)
            handler.assert_info("Disconnecting - idle timeout")
 def dummy(client):
     # set the connection lost handler
     client.connectionLostHandler = conn_lost_handler
     # trigger an operation, which should
     yield client.dummy_authenticate("open sesame")
     root_id = yield client.get_root()
     # lock the user:
     usr = self.user_store.get(model.StorageUser, 0)
     usr.locked = True
     self.user_store.commit()
     client.make_dir(request.ROOT, root_id, u"open sesame")
     yield d
     # check we logged a warning about this.
     self.assertTrue(
         hdlr.check_warning("Shutting down protocol: user locked"))
 def dummy(client):
     # set the connection lost handler
     client.connectionLostHandler = conn_lost_handler
     # trigger an operation, which should
     yield client.dummy_authenticate("open sesame")
     root_id = yield client.get_root()
     # lock the user:
     usr = self.store.get(StorageUser, 0)
     usr.locked = True
     self.store.commit()
     client.make_dir(request.ROOT, root_id, u"open sesame")
     yield d
     # check we logged a warning about this.
     self.assertTrue(hdlr.check_warning(
         "Shutting down protocol: user locked"))