Ejemplo n.º 1
0
    def setUp(self):
        yield super(MultiStoreConduitTest, self).setUp()

        # Store 1
        serversDB1 = ServersDB()
        server1a = Server("A", "http://127.0.0.1:8008", "A", True)
        serversDB1.addServer(server1a)
        server1b = Server("B", "http://127.0.0.1:8108", "B", False)
        serversDB1.addServer(server1b)
        yield self.buildStoreAndDirectory(serversDB=serversDB1)
        self.store.queryCacher = None     # Cannot use query caching
        self.store.conduit = self.makeConduit(self.store)

        # Store 2
        serversDB2 = ServersDB()
        server2a = Server("A", "http://127.0.0.1:8008", "A", False)
        serversDB2.addServer(server2a)
        server2b = Server("B", "http://127.0.0.1:8108", "B", True)
        serversDB2.addServer(server2b)

        self.store2 = yield self.buildStore(self.theStoreBuilder2)
        directory2 = buildTestDirectory(
            self.store2, self.mktemp(), serversDB=serversDB2
        )

        self.store2.setDirectoryService(directory2)
        self.store2.queryCacher = None     # Cannot use query caching
        self.store2.conduit = self.makeConduit(self.store2)

        FakeConduitRequest.addServerStore(server1a, self.store)
        FakeConduitRequest.addServerStore(server2b, self.store2)
Ejemplo n.º 2
0
    def setUp(self):
        yield super(MultiStoreConduitTest, self).setUp()

        # Stores
        for i in range(self.numberOfStores):
            serversDB = ServersDB()
            for j in range(self.numberOfStores):
                letter = chr(ord("A") + j)
                port = 8008 + 100 * j
                server = Server(letter, "http://127.0.0.1:{}".format(port),
                                letter, j == i)
                serversDB.addServer(server)

            if i == 0:
                yield self.buildStoreAndDirectory(
                    serversDB=serversDB, storeBuilder=self.theStoreBuilders[i])
                self.theStores[i] = self.store
            else:
                self.theStores[i] = yield self.buildStore(
                    self.theStoreBuilders[i])
                directory = buildTestDirectory(self.theStores[i],
                                               self.mktemp(),
                                               serversDB=serversDB)
                self.theStores[i].setDirectoryService(directory)

            self.theStores[i].queryCacher = None  # Cannot use query caching
            self.theStores[i].conduit = self.makeConduit(self.theStores[i])

            FakeConduitRequest.addServerStore(
                serversDB.getServerById(chr(ord("A") + i)), self.theStores[i])
Ejemplo n.º 3
0
    def _setupServers(self, data=data1):
        self.patch(config, "ServerHostName", "caldav1.example.com")
        self.patch(config, "HTTPPort", 8008)

        xmlFile = StringIO.StringIO(data)
        servers = ServersDB()
        servers.load(xmlFile, ignoreIPLookupFailures=True)

        return servers
Ejemplo n.º 4
0
    def _setupServers(self, data=data1):
        self.patch(config, "ServerHostName", "caldav1.example.com")
        self.patch(config, "HTTPPort", 8008)

        xmlFile = StringIO.StringIO(data)
        servers = ServersDB()
        servers.load(xmlFile, ignoreIPLookupFailures=True)

        return servers
Ejemplo n.º 5
0
    def setUp(self):
        yield super(ConduitPOST, self).setUp()

        serversDB = ServersDB()
        self.thisServer = Server("A", "http://127.0.0.1", "A", True)
        serversDB.addServer(self.thisServer)
        yield self.buildStoreAndDirectory(serversDB=serversDB)

        self.site.resource.putChild("conduit", ConduitResource(self.site.resource, self.storeUnderTest()))

        yield self.populate()
Ejemplo n.º 6
0
    def setUp(self):
        yield super(ConduitPOST, self).setUp()

        serversDB = ServersDB()
        self.thisServer = Server("A", "http://127.0.0.1", "A", True)
        serversDB.addServer(self.thisServer)
        yield self.buildStoreAndDirectory(serversDB=serversDB)

        self.site.resource.putChild("conduit", ConduitResource(self.site.resource, self.storeUnderTest()))

        yield self.populate()
Ejemplo n.º 7
0
    def test_this_server(self):

        servers = self._setupServers()

        self.assertTrue(servers.getServerById("00001").thisServer)
        self.assertFalse(servers.getServerById("00002").thisServer)

        self.patch(config, "ServerHostName", "caldav2.example.com")
        self.patch(config, "SSLPort", 8443)
        self.patch(config, "BindSSLPorts", [8843])

        xmlFile = StringIO.StringIO(ServerTests.data1)
        servers = ServersDB()
        servers.load(xmlFile, ignoreIPLookupFailures=True)

        self.assertFalse(servers.getServerById("00001").thisServer)
        self.assertTrue(servers.getServerById("00002").thisServer)
Ejemplo n.º 8
0
    def setUp(self):
        yield super(MultiStoreConduitTest, self).setUp()

        # Stores
        for i in range(self.numberOfStores):
            serversDB = ServersDB()
            for j in range(self.numberOfStores):
                letter = chr(ord("A") + j)
                port = 8008 + 100 * j
                server = Server(
                    letter, "http://127.0.0.1:{}".format(port), letter, j == i
                )
                serversDB.addServer(server)

            if i == 0:
                yield self.buildStoreAndDirectory(
                    serversDB=serversDB,
                    storeBuilder=self.theStoreBuilders[i],
                    accounts=self.accounts,
                    augments=self.augments,
                )
                self.theStores[i] = self.store
            else:
                self.theStores[i] = yield self.buildStore(
                    self.theStoreBuilders[i]
                )
                directory = buildTestDirectory(
                    self.theStores[i],
                    self.mktemp(),
                    serversDB=serversDB,
                    accounts=self.accounts,
                    augments=self.augments,
                )
                self.theStores[i].setDirectoryService(directory)

            self.theStores[i].queryCacher = None     # Cannot use query caching
            self.theStores[i].conduit = self.makeConduit(self.theStores[i])

            FakeConduitRequest.addServerStore(
                serversDB.getServerById(chr(ord("A") + i)), self.theStores[i]
            )
Ejemplo n.º 9
0
    def setUp(self):
        yield super(iSchedulePOST, self).setUp()

        serversDB = ServersDB()
        a_server = Server("A", "http://localhost:8008", thisServer=True)
        serversDB.addServer(a_server)
        b_server = Server("B", "http://localhost:8108", thisServer=False)
        serversDB.addServer(b_server)
        yield self.buildStoreAndDirectory(serversDB=serversDB)

        self.site.resource.putChild("ischedule", IScheduleInboxResource(self.site.resource, self.storeUnderTest()))
        self.site.resource.putChild("podding", IScheduleInboxResource(self.site.resource, self.storeUnderTest(), podding=True))

        yield self.populate()

        # iSchedule server
        IScheduleServers()
        server = IScheduleServerRecord("http://127.0.0.1")
        server.allow_from = True
        IScheduleServers._domainMap["example.org"] = server
        self.addCleanup(lambda : IScheduleServers._domainMap.pop("example.org")) #@UndefinedVariable
Ejemplo n.º 10
0
    def setUp(self):
        yield super(iSchedulePOST, self).setUp()

        serversDB = ServersDB()
        a_server = Server("A", "http://localhost:8008", thisServer=True)
        serversDB.addServer(a_server)
        b_server = Server("B", "http://localhost:8108", thisServer=False)
        serversDB.addServer(b_server)
        yield self.buildStoreAndDirectory(serversDB=serversDB)

        self.site.resource.putChild(
            "ischedule",
            IScheduleInboxResource(self.site.resource, self.storeUnderTest()))
        self.site.resource.putChild(
            "podding",
            IScheduleInboxResource(self.site.resource,
                                   self.storeUnderTest(),
                                   podding=True))

        yield self.populate()

        # iSchedule server
        IScheduleServers()
        server = IScheduleServerRecord("http://127.0.0.1")
        server.allow_from = True
        IScheduleServers._domainMap["example.org"] = server
        self.addCleanup(lambda: IScheduleServers._domainMap.pop("example.org")
                        )  #@UndefinedVariable
Ejemplo n.º 11
0
    def setUp(self):
        yield super(ExternalHome, self).setUp()

        serversDB = ServersDB()
        serversDB.addServer(Server("A", "http://127.0.0.1", "A", True))
        serversDB.addServer(Server("B", "http://127.0.0.2", "B", False))

        yield self.buildStoreAndDirectory(serversDB=serversDB)

        self.site.resource.putChild("conduit", ConduitResource(self.site.resource, self.storeUnderTest()))
Ejemplo n.º 12
0
    def test_all_except_this_server(self):

        servers = self._setupServers()

        self.assertTrue(servers.getServerById("00001").thisServer)
        self.assertFalse(servers.getServerById("00002").thisServer)
        self.assertEqual(servers.allServersExceptThis(), [servers.getServerById("00002"), ])

        self.patch(config, "ServerHostName", "caldav2.example.com")
        self.patch(config, "SSLPort", 8443)
        self.patch(config, "BindSSLPorts", [8843])

        xmlFile = StringIO.StringIO(ServerTests.data1)
        servers = ServersDB()
        servers.load(xmlFile, ignoreIPLookupFailures=True)

        self.assertFalse(servers.getServerById("00001").thisServer)
        self.assertTrue(servers.getServerById("00002").thisServer)
        self.assertEqual(servers.allServersExceptThis(), [servers.getServerById("00001"), ])
Ejemplo n.º 13
0
    def setUp(self):
        yield super(MultiStoreConduitTest, self).setUp()

        # Store 1
        serversDB1 = ServersDB()
        server1a = Server("A", "http://127.0.0.1:8008", "A", True)
        serversDB1.addServer(server1a)
        server1b = Server("B", "http://127.0.0.1:8108", "B", False)
        serversDB1.addServer(server1b)
        yield self.buildStoreAndDirectory(serversDB=serversDB1)
        self.store.queryCacher = None  # Cannot use query caching
        self.store.conduit = self.makeConduit(self.store)

        # Store 2
        serversDB2 = ServersDB()
        server2a = Server("A", "http://127.0.0.1:8008", "A", False)
        serversDB2.addServer(server2a)
        server2b = Server("B", "http://127.0.0.1:8108", "B", True)
        serversDB2.addServer(server2b)

        self.store2 = yield self.buildStore(self.theStoreBuilder2)
        directory2 = buildTestDirectory(self.store2,
                                        self.mktemp(),
                                        serversDB=serversDB2)

        self.store2.setDirectoryService(directory2)
        self.store2.queryCacher = None  # Cannot use query caching
        self.store2.conduit = self.makeConduit(self.store2)

        FakeConduitRequest.addServerStore(server1a, self.store)
        FakeConduitRequest.addServerStore(server2b, self.store2)