<!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" /><style type="text/css"><!--
#msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer { 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, #msg p { overflow: auto; background: #ffc; border: 1px #fc0 solid; padding: 6px; }
#msg ul { overflow: auto; }
#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>
<title>[2218] CalendarServer/branches/users/wsanchez/guid-calendars/twistedcaldav/
 directory/test/test_guidchange.py</title>
</head>
<body>

<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.macosforge.org/projects/calendarserver/changeset/2218">2218</a></dd>
<dt>Author</dt> <dd>wsanchez@apple.com</dd>
<dt>Date</dt> <dd>2008-03-10 13:49:10 -0700 (Mon, 10 Mar 2008)</dd>
</dl>

<h3>Log Message</h3>
<pre>Cosmetic.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#CalendarServerbranchesuserswsanchezguidcalendarstwistedcaldavdirectorytesttest_guidchangepy">CalendarServer/branches/users/wsanchez/guid-calendars/twistedcaldav/directory/test/test_guidchange.py</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="CalendarServerbranchesuserswsanchezguidcalendarstwistedcaldavdirectorytesttest_guidchangepy"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/users/wsanchez/guid-calendars/twistedcaldav/directory/test/test_guidchange.py (2217 => 2218)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/wsanchez/guid-calendars/twistedcaldav/directory/test/test_guidchange.py        2008-03-07 22:37:56 UTC (rev 2217)
+++ CalendarServer/branches/users/wsanchez/guid-calendars/twistedcaldav/directory/test/test_guidchange.py        2008-03-10 20:49:10 UTC (rev 2218)
</span><span class="lines">@@ -45,7 +45,7 @@
</span><span class="cx">         self.directoryService = XMLDirectoryService(self.xmlfile)
</span><span class="cx">         
</span><span class="cx">         # Set up a principals hierarchy for each service we're testing with
</span><del>-        name = 'principals'
</del><ins>+        name = &quot;principals&quot;
</ins><span class="cx">         url = &quot;/&quot; + name + &quot;/&quot;
</span><span class="cx">         path = os.path.join(self.docroot, url[1:])
</span><span class="cx"> 
</span><span class="lines">@@ -55,7 +55,7 @@
</span><span class="cx"> 
</span><span class="cx">         provisioningResource = DirectoryPrincipalProvisioningResource(path, url, self.directoryService)
</span><span class="cx"> 
</span><del>-        self.site.resource.putChild('principals', provisioningResource)
</del><ins>+        self.site.resource.putChild(&quot;principals&quot;, provisioningResource)
</ins><span class="cx"> 
</span><span class="cx">         self.setupCalendars()
</span><span class="cx"> 
</span><span class="lines">@@ -63,25 +63,29 @@
</span><span class="cx"> 
</span><span class="cx">     def setupCalendars(self):
</span><span class="cx">         calendarCollection = CalendarHomeProvisioningFile(
</span><del>-            os.path.join(self.docroot, 'calendars'),
</del><ins>+            os.path.join(self.docroot, &quot;calendars&quot;),
</ins><span class="cx">             self.directoryService,
</span><del>-            '/calendars/'
</del><ins>+            &quot;/calendars/&quot;
</ins><span class="cx">         )
</span><del>-        self.site.resource.putChild('calendars', calendarCollection)
</del><ins>+        self.site.resource.putChild(&quot;calendars&quot;, calendarCollection)
</ins><span class="cx"> 
</span><span class="cx">     def resetCalendars(self):
</span><del>-        del self.site.resource.putChildren['calendars']
</del><ins>+        del self.site.resource.putChildren[&quot;calendars&quot;]
</ins><span class="cx">         self.setupCalendars()
</span><span class="cx"> 
</span><span class="cx">     def test_guidchange(self):
</span><span class="cx">         &quot;&quot;&quot;
</span><span class="cx">         DirectoryPrincipalResource.proxies()
</span><span class="cx">         &quot;&quot;&quot;
</span><ins>+        oldUID = &quot;5A985493-EE2C-4665-94CF-4DFEA3A89500&quot;
+        newUID = &quot;38D8AC00-5490-4425-BE3A-05FFB9862444&quot;
+
+        homeResource = &quot;/calendars/users/cdaboo/&quot;
</ins><span class="cx">         
</span><span class="cx">         def privs1(result):
</span><span class="cx">             # Change GUID in record
</span><span class="cx">             fd = open(self.xmlfile, &quot;w&quot;)
</span><del>-            fd.write(open(xmlFile.path, &quot;r&quot;).read().replace(&quot;5A985493-EE2C-4665-94CF-4DFEA3A89500&quot;, &quot;38D8AC00-5490-4425-BE3A-05FFB9862444&quot;))
</del><ins>+            fd.write(open(xmlFile.path, &quot;r&quot;).read().replace(oldUID, newUID))
</ins><span class="cx">             fd.close()
</span><span class="cx">             fd = None
</span><span class="cx"> 
</span><span class="lines">@@ -93,31 +97,31 @@
</span><span class="cx">             self.resetCalendars()
</span><span class="cx">             
</span><span class="cx">             # Make sure new user cannot access old user's calendar home
</span><del>-            return self._checkPrivileges(None, &quot;/calendars/users/cdaboo/&quot;, davxml.HRef(&quot;/principals/__uids__/38D8AC00-5490-4425-BE3A-05FFB9862444/&quot;), davxml.Write, False)
</del><ins>+            return self._checkPrivileges(None, homeResource, davxml.HRef(&quot;/principals/__uids__/&quot; + newUID + &quot;/&quot;), davxml.Write, False)
</ins><span class="cx">             
</span><span class="cx">         # Make sure current user has access to their calendar home
</span><del>-        d = self._checkPrivileges(None, &quot;/calendars/users/cdaboo/&quot;, davxml.HRef(&quot;/principals/__uids__/5A985493-EE2C-4665-94CF-4DFEA3A89500/&quot;), davxml.Write, True)
</del><ins>+        d = self._checkPrivileges(None, homeResource, davxml.HRef(&quot;/principals/__uids__/&quot; + oldUID + &quot;/&quot;), davxml.Write, True)
</ins><span class="cx">         d.addCallback(privs1)
</span><span class="cx">         return d
</span><span class="cx">         
</span><span class="cx"> 
</span><span class="cx">     def _checkPrivileges(self, resource, url, principal, privilege, allowed):
</span><del>-        request = SimpleRequest(self.site, &quot;GET&quot;, &quot;/calendars/users/cdaboo/&quot;)
</del><ins>+        request = SimpleRequest(self.site, &quot;GET&quot;, &quot;/&quot;)
</ins><span class="cx"> 
</span><span class="cx">         def gotResource(resource):
</span><span class="cx">             d = resource.checkPrivileges(request, (privilege,), principal=davxml.Principal(principal))
</span><span class="cx">             if allowed:
</span><span class="cx">                 def onError(f):
</span><span class="cx">                     f.trap(AccessDeniedError)
</span><del>-                    #print resource.readDeadProperty(davxml.ACL)
-                    self.fail(&quot;%s should have %s privilege on %r&quot; % (principal.sname(), privilege.sname(), resource))
</del><ins>+                    #print resource.readDeadProperty(davxml.ACL).toxml()
+                    self.fail(&quot;%s should have %s privilege on %r&quot; % (principal, privilege.sname(), resource))
</ins><span class="cx">                 d.addErrback(onError)
</span><span class="cx">             else:
</span><span class="cx">                 def onError(f):
</span><span class="cx">                     f.trap(AccessDeniedError)
</span><span class="cx">                 def onSuccess(_):
</span><del>-                    #print resource.readDeadProperty(davxml.ACL)
-                    self.fail(&quot;%s should not have %s privilege on %r&quot; % (principal.sname(), privilege.sname(), resource))
</del><ins>+                    #print resource.readDeadProperty(davxml.ACL).toxml()
+                    self.fail(&quot;%s should not have %s privilege on %r&quot; % (principal, privilege.sname(), resource))
</ins><span class="cx">                 d.addCallback(onSuccess)
</span><span class="cx">                 d.addErrback(onError)
</span><span class="cx">             return d
</span></span></pre>
</div>
</div>

</body>
</html>