[CalendarServer-changes] [13380] CalendarServer/branches/release/CalendarServer-5.3-dev

source_changes at macosforge.org source_changes at macosforge.org
Mon Apr 28 18:23:50 PDT 2014


Revision: 13380
          http://trac.calendarserver.org//changeset/13380
Author:   cdaboo at apple.com
Date:     2014-04-28 18:23:50 -0700 (Mon, 28 Apr 2014)
Log Message:
-----------
Make sure purging of missing users correctly does implicit scheduling.

Modified Paths:
--------------
    CalendarServer/branches/release/CalendarServer-5.3-dev/calendarserver/tools/test/purge/accounts.xml
    CalendarServer/branches/release/CalendarServer-5.3-dev/calendarserver/tools/test/test_purge.py
    CalendarServer/branches/release/CalendarServer-5.3-dev/twistedcaldav/directory/aggregate.py

Modified: CalendarServer/branches/release/CalendarServer-5.3-dev/calendarserver/tools/test/purge/accounts.xml
===================================================================
--- CalendarServer/branches/release/CalendarServer-5.3-dev/calendarserver/tools/test/purge/accounts.xml	2014-04-29 01:08:01 UTC (rev 13379)
+++ CalendarServer/branches/release/CalendarServer-5.3-dev/calendarserver/tools/test/purge/accounts.xml	2014-04-29 01:23:50 UTC (rev 13380)
@@ -26,4 +26,11 @@
     <name>Example User</name>
     <email-address>example at example.com</email-address>
   </user>
+  <user>
+    <uid>example2</uid>
+    <guid>37DB0C90-4DB1-4932-BC69-3DAB66F374F5</guid>
+    <password>example</password>
+    <name>Example User2</name>
+    <email-address>example2 at example.com</email-address>
+  </user>
 </accounts>

Modified: CalendarServer/branches/release/CalendarServer-5.3-dev/calendarserver/tools/test/test_purge.py
===================================================================
--- CalendarServer/branches/release/CalendarServer-5.3-dev/calendarserver/tools/test/test_purge.py	2014-04-29 01:08:01 UTC (rev 13379)
+++ CalendarServer/branches/release/CalendarServer-5.3-dev/calendarserver/tools/test/test_purge.py	2014-04-29 01:23:50 UTC (rev 13380)
@@ -796,13 +796,33 @@
 """.replace("\n", "\r\n") % (past,)
 
 
+# Purging non-existent organizer; has existing attendee
+EVENT_MISSING_ORGANIZER_ICS = """BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//Apple Inc.//iCal 4.0.1//EN
+X-CALENDARSERVER-ACCESS:PRIVATE
+BEGIN:VEVENT
+UID:8ED97931-9A19-4596-9D4D-52B36D6AB803
+SUMMARY:Repeating Organizer
+DTSTART:%s
+DURATION:PT1H
+ORGANIZER:urn:uuid:89D79D4C-DDF3-48EA-8C6A-71BD01FDC60D
+ATTENDEE;CUTYPE=INDIVIDUAL;PARTSTAT=ACCEPTED:urn:uuid:89D79D4C-DDF3-48EA-8C6A-71BD01FDC60D
+ATTENDEE;CUTYPE=INDIVIDUAL;PARTSTAT=ACCEPTED:urn:uuid:37DB0C90-4DB1-4932-BC69-3DAB66F374F5
+DTSTAMP:20100303T195203Z
+END:VEVENT
+END:VCALENDAR
+""".replace("\n", "\r\n") % (past,)
 
+
+
 class PurgePrincipalTests(StoreTestCase):
     """
     Tests for purging the data belonging to a given principal
     """
     uid = "6423F94A-6B76-4A3A-815B-D52CFD77935D"
     uid2 = "37DB0C90-4DB1-4932-BC69-3DAB66F374F5"
+    uid3 = "89D79D4C-DDF3-48EA-8C6A-71BD01FDC60D"
 
     metadata = {
         "accessMode": "PUBLIC",
@@ -817,26 +837,25 @@
             "calendar1" : {
                 "attachment.ics" : (ATTACHMENT_ICS, metadata,),
                 "organizer.ics" : (REPEATING_PUBLIC_EVENT_ORGANIZER_ICS, metadata,),
-            }
+            },
+            "inbox" : {},
         },
         uid2 : {
             "calendar2" : {
-            }
+                "missing.ics" : (EVENT_MISSING_ORGANIZER_ICS, metadata,),
+            },
+            "inbox" : {},
         },
+        uid3 : {
+            "calendar3" : {
+                "missing.ics" : (EVENT_MISSING_ORGANIZER_ICS, metadata,),
+            },
+            "inbox" : {},
+        },
     }
 
     @inlineCallbacks
     def setUp(self):
-        self.patch(config.DirectoryService.params, "xmlFile",
-            os.path.join(
-                os.path.dirname(__file__), "purge", "accounts.xml"
-            )
-        )
-        self.patch(config.ResourceService.params, "xmlFile",
-            os.path.join(
-                os.path.dirname(__file__), "purge", "resources.xml"
-            )
-        )
         yield super(PurgePrincipalTests, self).setUp()
 
         txn = self._sqlCalendarStore.newTransaction()
@@ -871,6 +890,20 @@
         (yield txn.commit())
 
 
+    def configure(self):
+        super(PurgePrincipalTests, self).configure()
+        self.patch(config.DirectoryService.params, "xmlFile",
+            os.path.join(
+                os.path.dirname(__file__), "purge", "accounts.xml"
+            )
+        )
+        self.patch(config.ResourceService.params, "xmlFile",
+            os.path.join(
+                os.path.dirname(__file__), "purge", "resources.xml"
+            )
+        )
+
+
     @inlineCallbacks
     def populate(self):
         yield populateCalendarsFrom(self.requirements, self.storeUnderTest())
@@ -949,3 +982,30 @@
         home = (yield txn.calendarHomeWithUID(self.uid))
         self.assertNotEquals(home, None)
         (yield txn.commit())
+
+
+    @inlineCallbacks
+    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))

Modified: CalendarServer/branches/release/CalendarServer-5.3-dev/twistedcaldav/directory/aggregate.py
===================================================================
--- CalendarServer/branches/release/CalendarServer-5.3-dev/twistedcaldav/directory/aggregate.py	2014-04-29 01:08:01 UTC (rev 13379)
+++ CalendarServer/branches/release/CalendarServer-5.3-dev/twistedcaldav/directory/aggregate.py	2014-04-29 01:23:50 UTC (rev 13380)
@@ -192,6 +192,15 @@
 
 
     def recordWithCalendarUserAddress(self, address):
+        # FIXME: These temporary records shouldn't be needed when we move
+        # to the new data store API.  They're currently needed when purging
+        # deprovisioned users' data.
+        if address.startswith("urn:uuid:"):
+            uid = address[9:]
+            record = self._tmpRecords["uids"].get(uid, None)
+            if record:
+                return record
+
         return self._queryAll("recordWithCalendarUserAddress", address)
 
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20140428/803589e1/attachment-0001.html>


More information about the calendarserver-changes mailing list