<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[13380] CalendarServer/branches/release/CalendarServer-5.3-dev</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.calendarserver.org//changeset/13380">13380</a></dd>
<dt>Author</dt> <dd>cdaboo@apple.com</dd>
<dt>Date</dt> <dd>2014-04-28 18:23:50 -0700 (Mon, 28 Apr 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>Make sure purging of missing users correctly does implicit scheduling.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#CalendarServerbranchesreleaseCalendarServer53devcalendarservertoolstestpurgeaccountsxml">CalendarServer/branches/release/CalendarServer-5.3-dev/calendarserver/tools/test/purge/accounts.xml</a></li>
<li><a href="#CalendarServerbranchesreleaseCalendarServer53devcalendarservertoolstesttest_purgepy">CalendarServer/branches/release/CalendarServer-5.3-dev/calendarserver/tools/test/test_purge.py</a></li>
<li><a href="#CalendarServerbranchesreleaseCalendarServer53devtwistedcaldavdirectoryaggregatepy">CalendarServer/branches/release/CalendarServer-5.3-dev/twistedcaldav/directory/aggregate.py</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="CalendarServerbranchesreleaseCalendarServer53devcalendarservertoolstestpurgeaccountsxml"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/release/CalendarServer-5.3-dev/calendarserver/tools/test/purge/accounts.xml (13379 => 13380)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -26,4 +26,11 @@
</span><span class="cx">     &lt;name&gt;Example User&lt;/name&gt;
</span><span class="cx">     &lt;email-address&gt;example@example.com&lt;/email-address&gt;
</span><span class="cx">   &lt;/user&gt;
</span><ins>+  &lt;user&gt;
+    &lt;uid&gt;example2&lt;/uid&gt;
+    &lt;guid&gt;37DB0C90-4DB1-4932-BC69-3DAB66F374F5&lt;/guid&gt;
+    &lt;password&gt;example&lt;/password&gt;
+    &lt;name&gt;Example User2&lt;/name&gt;
+    &lt;email-address&gt;example2@example.com&lt;/email-address&gt;
+  &lt;/user&gt;
</ins><span class="cx"> &lt;/accounts&gt;
</span></span></pre></div>
<a id="CalendarServerbranchesreleaseCalendarServer53devcalendarservertoolstesttest_purgepy"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/release/CalendarServer-5.3-dev/calendarserver/tools/test/test_purge.py (13379 => 13380)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -796,13 +796,33 @@
</span><span class="cx"> &quot;&quot;&quot;.replace(&quot;\n&quot;, &quot;\r\n&quot;) % (past,)
</span><span class="cx"> 
</span><span class="cx"> 
</span><ins>+# Purging non-existent organizer; has existing attendee
+EVENT_MISSING_ORGANIZER_ICS = &quot;&quot;&quot;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
+&quot;&quot;&quot;.replace(&quot;\n&quot;, &quot;\r\n&quot;) % (past,)
</ins><span class="cx"> 
</span><ins>+
+
</ins><span class="cx"> class PurgePrincipalTests(StoreTestCase):
</span><span class="cx">     &quot;&quot;&quot;
</span><span class="cx">     Tests for purging the data belonging to a given principal
</span><span class="cx">     &quot;&quot;&quot;
</span><span class="cx">     uid = &quot;6423F94A-6B76-4A3A-815B-D52CFD77935D&quot;
</span><span class="cx">     uid2 = &quot;37DB0C90-4DB1-4932-BC69-3DAB66F374F5&quot;
</span><ins>+    uid3 = &quot;89D79D4C-DDF3-48EA-8C6A-71BD01FDC60D&quot;
</ins><span class="cx"> 
</span><span class="cx">     metadata = {
</span><span class="cx">         &quot;accessMode&quot;: &quot;PUBLIC&quot;,
</span><span class="lines">@@ -817,26 +837,25 @@
</span><span class="cx">             &quot;calendar1&quot; : {
</span><span class="cx">                 &quot;attachment.ics&quot; : (ATTACHMENT_ICS, metadata,),
</span><span class="cx">                 &quot;organizer.ics&quot; : (REPEATING_PUBLIC_EVENT_ORGANIZER_ICS, metadata,),
</span><del>-            }
</del><ins>+            },
+            &quot;inbox&quot; : {},
</ins><span class="cx">         },
</span><span class="cx">         uid2 : {
</span><span class="cx">             &quot;calendar2&quot; : {
</span><del>-            }
</del><ins>+                &quot;missing.ics&quot; : (EVENT_MISSING_ORGANIZER_ICS, metadata,),
+            },
+            &quot;inbox&quot; : {},
</ins><span class="cx">         },
</span><ins>+        uid3 : {
+            &quot;calendar3&quot; : {
+                &quot;missing.ics&quot; : (EVENT_MISSING_ORGANIZER_ICS, metadata,),
+            },
+            &quot;inbox&quot; : {},
+        },
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     @inlineCallbacks
</span><span class="cx">     def setUp(self):
</span><del>-        self.patch(config.DirectoryService.params, &quot;xmlFile&quot;,
-            os.path.join(
-                os.path.dirname(__file__), &quot;purge&quot;, &quot;accounts.xml&quot;
-            )
-        )
-        self.patch(config.ResourceService.params, &quot;xmlFile&quot;,
-            os.path.join(
-                os.path.dirname(__file__), &quot;purge&quot;, &quot;resources.xml&quot;
-            )
-        )
</del><span class="cx">         yield super(PurgePrincipalTests, self).setUp()
</span><span class="cx"> 
</span><span class="cx">         txn = self._sqlCalendarStore.newTransaction()
</span><span class="lines">@@ -871,6 +890,20 @@
</span><span class="cx">         (yield txn.commit())
</span><span class="cx"> 
</span><span class="cx"> 
</span><ins>+    def configure(self):
+        super(PurgePrincipalTests, self).configure()
+        self.patch(config.DirectoryService.params, &quot;xmlFile&quot;,
+            os.path.join(
+                os.path.dirname(__file__), &quot;purge&quot;, &quot;accounts.xml&quot;
+            )
+        )
+        self.patch(config.ResourceService.params, &quot;xmlFile&quot;,
+            os.path.join(
+                os.path.dirname(__file__), &quot;purge&quot;, &quot;resources.xml&quot;
+            )
+        )
+
+
</ins><span class="cx">     @inlineCallbacks
</span><span class="cx">     def populate(self):
</span><span class="cx">         yield populateCalendarsFrom(self.requirements, self.storeUnderTest())
</span><span class="lines">@@ -949,3 +982,30 @@
</span><span class="cx">         home = (yield txn.calendarHomeWithUID(self.uid))
</span><span class="cx">         self.assertNotEquals(home, None)
</span><span class="cx">         (yield txn.commit())
</span><ins>+
+
+    @inlineCallbacks
+    def test_purgeWithMissingOrganizer(self):
+        &quot;&quot;&quot;
+        Verify purgeUID sends cancels even when organizer is not in the directory
+        &quot;&quot;&quot;
+
+        # 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=&quot;missing.ics&quot;, calendar_name=&quot;calendar2&quot;, home=self.uid2)
+        comp = yield calobj2.componentForUser()
+        self.assertTrue(&quot;STATUS:CANCELLED&quot; 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=&quot;missing.ics&quot;, calendar_name=&quot;calendar2&quot;, home=self.uid2)
+        comp = yield calobj2.componentForUser()
+        self.assertTrue(&quot;STATUS:CANCELLED&quot; in str(comp))
</ins></span></pre></div>
<a id="CalendarServerbranchesreleaseCalendarServer53devtwistedcaldavdirectoryaggregatepy"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/release/CalendarServer-5.3-dev/twistedcaldav/directory/aggregate.py (13379 => 13380)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -192,6 +192,15 @@
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     def recordWithCalendarUserAddress(self, address):
</span><ins>+        # 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(&quot;urn:uuid:&quot;):
+            uid = address[9:]
+            record = self._tmpRecords[&quot;uids&quot;].get(uid, None)
+            if record:
+                return record
+
</ins><span class="cx">         return self._queryAll(&quot;recordWithCalendarUserAddress&quot;, address)
</span><span class="cx"> 
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>