def test_purgeUIDsNotCompletely(self):
        """
        Verify purgeUIDs removes some events, but leaves others and the home behind
        """

        self.patch(config, "EnablePrivateEvents", True)

        # Now you see it
        txn = self._sqlCalendarStore.newTransaction()
        home = (yield txn.calendarHomeWithUID(self.uid))
        self.assertNotEquals(home, None)
        (yield txn.commit())

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

        # Now you still see it
        txn = self._sqlCalendarStore.newTransaction()
        home = (yield txn.calendarHomeWithUID(self.uid))
        self.assertNotEquals(home, None)
        # Verify calendar1 was unshared to uid2
        home2 = (yield txn.calendarHomeWithUID(self.uid2))
        self.assertEquals((yield home2.childWithName(self.sharedName)), None)
        (yield txn.commit())

        count, ignored = (yield PurgePrincipalService.purgeUIDs(self.storeUnderTest(), self.directory,
            self.rootResource, (self.uid,), verbose=False, proxies=False, completely=False))
        self.assertEquals(count, 1)

        # And you still do
        txn = self._sqlCalendarStore.newTransaction()
        home = (yield txn.calendarHomeWithUID(self.uid))
        self.assertNotEquals(home, None)
        (yield txn.commit())
    def test_purgeUIDs(self):
        """
        Verify purgeUIDs removes homes, and doesn't provision homes that don't exist
        """

        # Now you see it
        txn = self._sqlCalendarStore.newTransaction()
        home = (yield txn.calendarHomeWithUID(self.uid))
        self.assertNotEquals(home, None)
        (yield txn.commit())

        count, ignored = (yield PurgePrincipalService.purgeUIDs(self.storeUnderTest(), self.directory,
            self.rootResource, (self.uid,), verbose=False, proxies=False, completely=True))
        self.assertEquals(count, 1) # 1 event

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

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

        # And you still don't (making sure it's not provisioned)
        txn = self._sqlCalendarStore.newTransaction()
        home = (yield txn.calendarHomeWithUID(self.uid))
        self.assertEquals(home, None)
        (yield txn.commit())
    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()
    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()
    def test_purgeUIDCompletely(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, ignored = (yield PurgePrincipalService.purgeUIDs(self._sqlCalendarStore, self.directory,
            self.rootResource, ("home1",), verbose=False, proxies=False, completely=True))

        # 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
        total, ignored = (yield PurgePrincipalService.purgeUIDs(self._sqlCalendarStore, self.directory,
            self.rootResource, ("home1",), verbose=False, proxies=False,
            when=PyCalendarDateTime(now, 4, 1, 12, 0, 0, 0, PyCalendarTimezone(utc=True))))

        # 4 items deleted: 3 events and 1 vcard
        self.assertEquals(total, 4)

        txn = self._sqlCalendarStore.newTransaction()
        # adressbook home is deleted since it's now empty
        abHome = (yield txn.addressbookHomeWithUID("home1"))
        self.assertEquals(abHome, None)

        calHome = (yield txn.calendarHomeWithUID("home1"))
        calColl = (yield calHome.calendarWithName("calendar1"))
        self.assertEquals(len((yield calColl.calendarObjects())), 5)
 def test_cancelAsAttendeeMultipleOccurrences(self):
     # Multiple meeting occurrences with no master, where purged CUA is
     # an attendee
     event = Component.fromString(INVITED_TO_MULTIPLE_OCCURRENCES_ICS)
     action = PurgePrincipalService._cancelEvent(event, PyCalendarDateTime(2010, 12, 6, 12, 0, 0, PyCalendarTimezone(utc=True)),
         "urn:uuid:9DC04A71-E6DD-11DF-9492-0800200C9A66")
     self.assertEquals(action, PurgePrincipalService.CANCELEVENT_SHOULD_DELETE)
 def test_cancelAllDayRepeating(self):
     # A repeating All Day event where purged CUA is organizer
     event = Component.fromString(REPEATING_2_ICS_BEFORE)
     action = PurgePrincipalService._cancelEvent(event, PyCalendarDateTime(2010, 12, 6, 12, 0, 0, PyCalendarTimezone(utc=True)),
         "urn:uuid:0F168477-CF3D-45D3-AE60-9875EA02C4D1")
     self.assertEquals(action, PurgePrincipalService.CANCELEVENT_MODIFIED)
     self.assertEquals(str(event), REPEATING_2_ICS_AFTER)
    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)
    def test_purgeWithMissingOrganizer(self):
        """
        Verify purgeUID sends cancels even when organizer is not in the directory
        """

        # Now you see it
        home2 = yield self.homeUnderTest(name=self.uid2)
        self.assertNotEquals(home2, None)
        home3 = yield self.homeUnderTest(name=self.uid3)
        self.assertNotEquals(home3, None)

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

        yield self.commit()

        count, ignored = (yield PurgePrincipalService.purgeUIDs(self.storeUnderTest(), self.directory,
            self.rootResource, (self.uid3,), verbose=False, proxies=False, completely=True))
        self.assertEquals(count, 1) # 1 events

        calobj2 = yield self.calendarObjectUnderTest(name="missing.ics", calendar_name="calendar2", home=self.uid2)
        comp = yield calobj2.componentForUser()
        self.assertTrue("STATUS:CANCELLED" in str(comp))
Exemple #12
0
 def test_cancelAsAttendee(self):
     # A repeating meeting event where purged CUA is an attendee
     event = Component.fromString(REPEATING_ATTENDEE_MEETING_ICS)
     action = PurgePrincipalService._cancelEvent(event, PyCalendarDateTime(2010, 12, 6, 12, 0, 0, PyCalendarTimezone(utc=True)),
         "urn:uuid:0F168477-CF3D-45D3-AE60-9875EA02C4D1")
     self.assertEquals(action, PurgePrincipalService.CANCELEVENT_SHOULD_DELETE)
Exemple #13
0
 def test_cancelFutureEvent(self):
     # A future event
     event = Component.fromString(FUTURE_EVENT_ICS)
     action = PurgePrincipalService._cancelEvent(event, PyCalendarDateTime(2010, 12, 6, 12, 0, 0, PyCalendarTimezone(utc=True)),
         "urn:uuid:0F168477-CF3D-45D3-AE60-9875EA02C4D1")
     self.assertEquals(action, PurgePrincipalService.CANCELEVENT_SHOULD_DELETE)
 def test_cancelNonMeeting(self):
     # A repeating non-meeting event
     event = Component.fromString(REPEATING_NON_MEETING_ICS)
     action = PurgePrincipalService._cancelEvent(event, DateTime(2010, 12, 6, 12, 0, 0, Timezone(utc=True)),
         "urn:uuid:0F168477-CF3D-45D3-AE60-9875EA02C4D1")
     self.assertEquals(action, PurgePrincipalService.CANCELEVENT_SHOULD_DELETE)