Exemplo n.º 1
0
 def test_memcacheINET(self):
     """
     Spawn a memcached process listening on a network socket that becomes
     connectable in no more than one second. Interact with it.
     """
     self.patch(config.Memcached.Pools.Default, "MemcacheSocket", "")
     ba = config.Memcached.Pools.Default.BindAddress
     bp = config.Memcached.Pools.Default.Port
     CalDAVServiceMaker()._spawnMemcached(monitor=self.monitor)
     sleep(1)
     mc = memcacheclient.Client(["{}:{}".format(ba, bp)], debug=1)
     rando = random.random()
     mc.set("the_password", rando)
     self.assertEquals(rando, mc.get("the_password"))
     mc.disconnect_all()
Exemplo n.º 2
0
 def test_memcacheUnix(self):
     """
     Spawn a memcached process listening on a unix socket that becomes
     connectable in no more than one second. Connect and interact.
     Verify secure file permissions on the socket file.
     """
     self.patch(config.Memcached.Pools.Default, "MemcacheSocket", self.socket)
     CalDAVServiceMaker()._spawnMemcached(monitor=self.monitor)
     sleep(1)
     mc = memcacheclient.Client(["unix:{}".format(self.socket)], debug=1)
     rando = random.random()
     mc.set("the_answer", rando)
     self.assertEquals(rando, mc.get("the_answer"))
     # The socket file should not be usable to other users
     st = os.stat(self.socket)
     self.assertTrue(str(oct(st.st_mode)).endswith("00"))
     mc.disconnect_all()