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_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 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_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))