Esempio n. 1
0
    def test_purgeUIDs(self):
        """
        Verify purgeUIDs removes homes, and doesn't provision homes that don't exist
        """

        # Now you see it
        home = yield self.homeUnderTest(name=self.uid)
        self.assertNotEquals(home, None)

        calobj2 = yield self.calendarObjectUnderTest(name="attendee.ics", calendar_name="calendar2", home=self.uid2)
        comp = yield calobj2.componentForUser()
        self.assertTrue("STATUS:CANCELLED" not in str(comp))
        self.assertTrue(";UNTIL=" not in str(comp))
        yield self.commit()

        count = (yield PurgePrincipalService.purgeUIDs(
            self.storeUnderTest(), self.directory,
            (self.uid,), verbose=False, proxies=False))
        self.assertEquals(count, 2) # 2 events

        # Wait for queue to process
        while(True):
            txn = self.transactionUnderTest()
            work = yield PrincipalPurgeHomeWork.all(txn)
            yield self.commit()
            if len(work) == 0:
                break
            d = Deferred()
            reactor.callLater(1, lambda : d.callback(None))
            yield d

        # Now you don't
        home = yield self.homeUnderTest(name=self.uid)
        self.assertEquals(home, None)
        # Verify calendar1 was unshared to uid2
        home2 = yield self.homeUnderTest(name=self.uid2)
        self.assertEquals((yield home2.childWithName(self.sharedName)), None)
        yield self.commit()

        count = yield PurgePrincipalService.purgeUIDs(
            self.storeUnderTest(),
            self.directory,
            (self.uid,),
            verbose=False,
            proxies=False,
        )
        self.assertEquals(count, 0)

        # And you still don't (making sure it's not provisioned)
        home = yield self.homeUnderTest(name=self.uid)
        self.assertEquals(home, None)
        yield self.commit()

        calobj2 = yield self.calendarObjectUnderTest(name="attendee.ics", calendar_name="calendar2", home=self.uid2)
        comp = yield calobj2.componentForUser()
        self.assertTrue("STATUS:CANCELLED" in str(comp))
        self.assertTrue(";UNTIL=" not in str(comp))
        yield self.commit()
Esempio n. 2
0
    def test_purgeUIDs(self):
        """
        Verify purgeUIDs removes homes, and doesn't provision homes that don't exist
        """

        # Now you see it
        home = yield self.homeUnderTest(name=self.uid)
        self.assertNotEquals(home, None)

        calobj2 = yield self.calendarObjectUnderTest(name="attendee.ics", calendar_name="calendar2", home=self.uid2)
        comp = yield calobj2.componentForUser()
        self.assertTrue("STATUS:CANCELLED" not in str(comp))
        self.assertTrue(";UNTIL=" not in str(comp))
        yield self.commit()

        count = (yield PurgePrincipalService.purgeUIDs(self.storeUnderTest(), self.directory,
            (self.uid,), verbose=False, proxies=False))
        self.assertEquals(count, 2) # 2 events

        # Wait for queue to process
        while(True):
            txn = self.transactionUnderTest()
            work = yield PrincipalPurgeHomeWork.all(txn)
            yield self.commit()
            if len(work) == 0:
                break
            d = Deferred()
            reactor.callLater(1, lambda : d.callback(None))
            yield d

        # Now you don't
        home = yield self.homeUnderTest(name=self.uid)
        self.assertEquals(home, None)
        # Verify calendar1 was unshared to uid2
        home2 = yield self.homeUnderTest(name=self.uid2)
        self.assertEquals((yield home2.childWithName(self.sharedName)), None)
        yield self.commit()

        count = yield PurgePrincipalService.purgeUIDs(
            self.storeUnderTest(),
            self.directory,
            (self.uid,),
            verbose=False,
            proxies=False,
        )
        self.assertEquals(count, 0)

        # And you still don't (making sure it's not provisioned)
        home = yield self.homeUnderTest(name=self.uid)
        self.assertEquals(home, None)
        yield self.commit()

        calobj2 = yield self.calendarObjectUnderTest(name="attendee.ics", calendar_name="calendar2", home=self.uid2)
        comp = yield calobj2.componentForUser()
        self.assertTrue("STATUS:CANCELLED" in str(comp))
        self.assertTrue(";UNTIL=" not in str(comp))
        yield self.commit()
Esempio n. 3
0
    def test_purgeUIDService(self):
        """
        Test that the full sequence of work items are processed via automatic polling.
        """

        # Now you see it
        home = yield self.homeUnderTest(name=self.uid)
        self.assertNotEquals(home, None)

        calobj2 = yield self.calendarObjectUnderTest(name="attendee.ics",
                                                     calendar_name="calendar2",
                                                     home=self.uid2)
        comp = yield calobj2.componentForUser()
        self.assertTrue("STATUS:CANCELLED" not in str(comp))
        self.assertTrue(";UNTIL=" not in str(comp))
        yield self.commit()

        txn = self.transactionUnderTest()
        notBefore = (datetime.datetime.utcnow() +
                     datetime.timedelta(seconds=3))
        yield txn.enqueue(PrincipalPurgePollingWork, notBefore=notBefore)
        yield self.commit()

        while True:
            txn = self.transactionUnderTest()
            work1 = yield PrincipalPurgePollingWork.all(txn)
            work2 = yield PrincipalPurgeCheckWork.all(txn)
            work3 = yield PrincipalPurgeWork.all(txn)
            work4 = yield PrincipalPurgeHomeWork.all(txn)

            if len(work4) != 0:
                home = yield txn.calendarHomeWithUID(self.uid)
                self.assertTrue(home.purging())

            yield self.commit()
            # print len(work1), len(work2), len(work3), len(work4)
            if len(work1) + len(work2) + len(work3) + len(work4) == 0:
                break
            d = Deferred()
            reactor.callLater(1, lambda: d.callback(None))
            yield d

        # Now you don't
        home = yield self.homeUnderTest(name=self.uid)
        self.assertEquals(home, None)
        # Verify calendar1 was unshared to uid2
        home2 = yield self.homeUnderTest(name=self.uid2)
        self.assertEquals((yield home2.childWithName(self.sharedName)), None)

        calobj2 = yield self.calendarObjectUnderTest(name="attendee.ics",
                                                     calendar_name="calendar2",
                                                     home=self.uid2)
        comp = yield calobj2.componentForUser()
        self.assertTrue("STATUS:CANCELLED" in str(comp))
        self.assertTrue(";UNTIL=" not in str(comp))
        yield self.commit()
Esempio n. 4
0
    def test_purgeUIDService(self):
        """
        Test that the full sequence of work items are processed via automatic polling.
        """

        # Now you see it
        home = yield self.homeUnderTest(name=self.uid)
        self.assertNotEquals(home, None)

        calobj2 = yield self.calendarObjectUnderTest(name="attendee.ics", calendar_name="calendar2", home=self.uid2)
        comp = yield calobj2.componentForUser()
        self.assertTrue("STATUS:CANCELLED" not in str(comp))
        self.assertTrue(";UNTIL=" not in str(comp))
        yield self.commit()

        txn = self.transactionUnderTest()
        notBefore = (
            datetime.datetime.utcnow() +
            datetime.timedelta(seconds=3)
        )
        yield txn.enqueue(PrincipalPurgePollingWork, notBefore=notBefore)
        yield self.commit()

        while True:
            txn = self.transactionUnderTest()
            work1 = yield PrincipalPurgePollingWork.all(txn)
            work2 = yield PrincipalPurgeCheckWork.all(txn)
            work3 = yield PrincipalPurgeWork.all(txn)
            work4 = yield PrincipalPurgeHomeWork.all(txn)

            if len(work4) != 0:
                home = yield txn.calendarHomeWithUID(self.uid)
                self.assertTrue(home.purging())

            yield self.commit()
            #print len(work1), len(work2), len(work3), len(work4)
            if len(work1) + len(work2) + len(work3) + len(work4) == 0:
                break
            d = Deferred()
            reactor.callLater(1, lambda : d.callback(None))
            yield d

        # Now you don't
        home = yield self.homeUnderTest(name=self.uid)
        self.assertEquals(home, None)
        # Verify calendar1 was unshared to uid2
        home2 = yield self.homeUnderTest(name=self.uid2)
        self.assertEquals((yield home2.childWithName(self.sharedName)), None)

        calobj2 = yield self.calendarObjectUnderTest(name="attendee.ics", calendar_name="calendar2", home=self.uid2)
        comp = yield calobj2.componentForUser()
        self.assertTrue("STATUS:CANCELLED" in str(comp))
        self.assertTrue(";UNTIL=" not in str(comp))
        yield self.commit()
    def test_purgeUID(self):
        txn = self._sqlCalendarStore.newTransaction()

        # Create an addressbook and one CardDAV resource
        abHome = (yield txn.addressbookHomeWithUID("home1", create=True))
        abColl = (yield abHome.addressbookWithName("addressbook"))
        (yield abColl.createAddressBookObjectWithName(
            "card1",
            VCardComponent.fromString(VCARD_1)))
        self.assertEquals(len((yield abColl.addressbookObjects())), 1)

        # Verify there are 8 events in calendar1
        calHome = (yield txn.calendarHomeWithUID("home1"))
        calColl = (yield calHome.calendarWithName("calendar1"))
        self.assertEquals(len((yield calColl.calendarObjects())), 8)

        # Make the newly created objects available to the purgeUID transaction
        (yield txn.commit())

        # Purge home1 completely
        total = yield PurgePrincipalService.purgeUIDs(
            self._sqlCalendarStore, self.directory,
            ("home1",), verbose=False, proxies=False)

        # Wait for queue to process
        while(True):
            txn = self.transactionUnderTest()
            work = yield PrincipalPurgeHomeWork.all(txn)
            yield self.commit()
            if len(work) == 0:
                break
            d = Deferred()
            reactor.callLater(1, lambda: d.callback(None))
            yield d

        # 9 items deleted: 8 events and 1 vcard
        self.assertEquals(total, 9)

        # Homes have been deleted as well
        txn = self._sqlCalendarStore.newTransaction()
        abHome = (yield txn.addressbookHomeWithUID("home1"))
        self.assertEquals(abHome, None)
        calHome = (yield txn.calendarHomeWithUID("home1"))
        self.assertEquals(calHome, None)
    def test_purgeUID(self):
        txn = self._sqlCalendarStore.newTransaction()

        # Create an addressbook and one CardDAV resource
        abHome = (yield txn.addressbookHomeWithUID("home1", create=True))
        abColl = (yield abHome.addressbookWithName("addressbook"))
        (yield abColl.createAddressBookObjectWithName(
            "card1",
            VCardComponent.fromString(VCARD_1)))
        self.assertEquals(len((yield abColl.addressbookObjects())), 1)

        # Verify there are 8 events in calendar1
        calHome = (yield txn.calendarHomeWithUID("home1"))
        calColl = (yield calHome.calendarWithName("calendar1"))
        self.assertEquals(len((yield calColl.calendarObjects())), 8)

        # Make the newly created objects available to the purgeUID transaction
        (yield txn.commit())

        # Purge home1 completely
        total = yield PurgePrincipalService.purgeUIDs(
            self._sqlCalendarStore, self.directory,
            ("home1",), verbose=False, proxies=False)

        # Wait for queue to process
        while(True):
            txn = self.transactionUnderTest()
            work = yield PrincipalPurgeHomeWork.all(txn)
            yield self.commit()
            if len(work) == 0:
                break
            d = Deferred()
            reactor.callLater(1, lambda : d.callback(None))
            yield d

        # 9 items deleted: 8 events and 1 vcard
        self.assertEquals(total, 9)

        # Homes have been deleted as well
        txn = self._sqlCalendarStore.newTransaction()
        abHome = (yield txn.addressbookHomeWithUID("home1"))
        self.assertEquals(abHome, None)
        calHome = (yield txn.calendarHomeWithUID("home1"))
        self.assertEquals(calHome, None)