<!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>[14157] CalendarServer/branches/release/CalendarServer-5.3-dev/twistedcaldav</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/14157">14157</a></dd>
<dt>Author</dt> <dd>cdaboo@apple.com</dd>
<dt>Date</dt> <dd>2014-11-12 12:56:24 -0800 (Wed, 12 Nov 2014)</dd>
</dl>
<h3>Log Message</h3>
<pre>Fix for clients that fail when resources/locations do not have an email address.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#CalendarServerbranchesreleaseCalendarServer53devtwistedcaldavdirectorycachingdirectorypy">CalendarServer/branches/release/CalendarServer-5.3-dev/twistedcaldav/directory/cachingdirectory.py</a></li>
<li><a href="#CalendarServerbranchesreleaseCalendarServer53devtwistedcaldavdirectorydirectorypy">CalendarServer/branches/release/CalendarServer-5.3-dev/twistedcaldav/directory/directory.py</a></li>
<li><a href="#CalendarServerbranchesreleaseCalendarServer53devtwistedcaldavdirectorytesttest_cachedirectorypy">CalendarServer/branches/release/CalendarServer-5.3-dev/twistedcaldav/directory/test/test_cachedirectory.py</a></li>
<li><a href="#CalendarServerbranchesreleaseCalendarServer53devtwistedcaldavdirectorytesttest_directorypy">CalendarServer/branches/release/CalendarServer-5.3-dev/twistedcaldav/directory/test/test_directory.py</a></li>
<li><a href="#CalendarServerbranchesreleaseCalendarServer53devtwistedcaldavicalpy">CalendarServer/branches/release/CalendarServer-5.3-dev/twistedcaldav/ical.py</a></li>
<li><a href="#CalendarServerbranchesreleaseCalendarServer53devtwistedcaldavstdconfigpy">CalendarServer/branches/release/CalendarServer-5.3-dev/twistedcaldav/stdconfig.py</a></li>
<li><a href="#CalendarServerbranchesreleaseCalendarServer53devtwistedcaldavtesttest_icalendarpy">CalendarServer/branches/release/CalendarServer-5.3-dev/twistedcaldav/test/test_icalendar.py</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="CalendarServerbranchesreleaseCalendarServer53devtwistedcaldavdirectorycachingdirectorypy"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/release/CalendarServer-5.3-dev/twistedcaldav/directory/cachingdirectory.py (14156 => 14157)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/release/CalendarServer-5.3-dev/twistedcaldav/directory/cachingdirectory.py        2014-11-12 18:09:15 UTC (rev 14156)
+++ CalendarServer/branches/release/CalendarServer-5.3-dev/twistedcaldav/directory/cachingdirectory.py        2014-11-12 20:56:24 UTC (rev 14157)
</span><span class="lines">@@ -300,6 +300,11 @@
</span><span class="cx"> def recordWithCalendarUserAddress(self, address):
</span><span class="cx"> address = normalizeCUAddr(address)
</span><span class="cx"> record = None
</span><ins>+
+ if config.Scheduling.Options.FakeResourceLocationEmail:
+ if address.startswith("mailto:") and address.endswith("@do_not_reply"):
+ address = "urn:uuid:{}".format(address[7:-13])
+
</ins><span class="cx"> if address.startswith("mailto:"):
</span><span class="cx"> record = self._lookupRecord(None, CachingDirectoryService.INDEX_TYPE_CUA, address)
</span><span class="cx"> return record if record and record.enabledForCalendaring else None
</span></span></pre></div>
<a id="CalendarServerbranchesreleaseCalendarServer53devtwistedcaldavdirectorydirectorypy"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/release/CalendarServer-5.3-dev/twistedcaldav/directory/directory.py (14156 => 14157)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/release/CalendarServer-5.3-dev/twistedcaldav/directory/directory.py        2014-11-12 18:09:15 UTC (rev 14156)
+++ CalendarServer/branches/release/CalendarServer-5.3-dev/twistedcaldav/directory/directory.py        2014-11-12 20:56:24 UTC (rev 14157)
</span><span class="lines">@@ -225,6 +225,11 @@
</span><span class="cx"> def recordWithCalendarUserAddress(self, address):
</span><span class="cx"> address = normalizeCUAddr(address)
</span><span class="cx"> record = None
</span><ins>+
+ if config.Scheduling.Options.FakeResourceLocationEmail:
+ if address.startswith("mailto:") and address.endswith("@do_not_reply"):
+ address = "urn:uuid:{}".format(address[7:-13])
+
</ins><span class="cx"> if address.startswith("urn:uuid:"):
</span><span class="cx"> guid = address[9:]
</span><span class="cx"> record = self.recordWithGUID(guid)
</span><span class="lines">@@ -1171,6 +1176,10 @@
</span><span class="cx"> if fullName is None:
</span><span class="cx"> fullName = ""
</span><span class="cx">
</span><ins>+ if config.Scheduling.Options.FakeResourceLocationEmail:
+ if recordType in (service.recordType_locations, service.recordType_resources) and not emailAddresses:
+ emailAddresses = set(("%s@do_not_reply" % uid,))
+
</ins><span class="cx"> self.service = service
</span><span class="cx"> self.recordType = recordType
</span><span class="cx"> self.guid = guid
</span></span></pre></div>
<a id="CalendarServerbranchesreleaseCalendarServer53devtwistedcaldavdirectorytesttest_cachedirectorypy"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/release/CalendarServer-5.3-dev/twistedcaldav/directory/test/test_cachedirectory.py (14156 => 14157)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/release/CalendarServer-5.3-dev/twistedcaldav/directory/test/test_cachedirectory.py        2014-11-12 18:09:15 UTC (rev 14156)
+++ CalendarServer/branches/release/CalendarServer-5.3-dev/twistedcaldav/directory/test/test_cachedirectory.py        2014-11-12 20:56:24 UTC (rev 14157)
</span><span class="lines">@@ -383,3 +383,20 @@
</span><span class="cx"> self.service.generateMemcacheKey(self.service.INDEX_TYPE_SHORTNAME, "foo", "users"),
</span><span class="cx"> "dir|v2|20CB1593-DE3F-4422-A7D7-BA9C2099B317|users|shortname|foo",
</span><span class="cx"> )
</span><ins>+
+
+ def test_fakeemail(self):
+
+ self.patch(config.Scheduling.Options, "FakeResourceLocationEmail", True)
+ self.dummyRecords()
+
+ self.assertTrue(self.service.recordWithCalendarUserAddress(
+ "mailto:{}@do_not_reply".format(self.guidForShortName("resource02", recordType=DirectoryService.recordType_resources))
+ ) is not None)
+ self.assertTrue(self.service.recordWithCalendarUserAddress(
+ "mailto:{}@do_not_reply".format(self.guidForShortName("location02", recordType=DirectoryService.recordType_locations))
+ ) is not None)
+ self.assertTrue(self.service.recordWithCalendarUserAddress(
+ "mailto:bogus@do_not_reply"
+ ) is None)
+ self.assertTrue(self.service.queried)
</ins></span></pre></div>
<a id="CalendarServerbranchesreleaseCalendarServer53devtwistedcaldavdirectorytesttest_directorypy"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/release/CalendarServer-5.3-dev/twistedcaldav/directory/test/test_directory.py (14156 => 14157)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/release/CalendarServer-5.3-dev/twistedcaldav/directory/test/test_directory.py        2014-11-12 18:09:15 UTC (rev 14156)
+++ CalendarServer/branches/release/CalendarServer-5.3-dev/twistedcaldav/directory/test/test_directory.py        2014-11-12 20:56:24 UTC (rev 14157)
</span><span class="lines">@@ -1164,7 +1164,38 @@
</span><span class="cx"> self.assertTrue(record is None)
</span><span class="cx">
</span><span class="cx">
</span><ins>+ def test_recordWithCalendarUserAddress_fake_email(self):
+ """
+ Make sure that recordWithCalendarUserAddress handles fake emails for
+ resources and locations.
+ """
</ins><span class="cx">
</span><ins>+ self.patch(config.Scheduling.Options, "FakeResourceLocationEmail", True)
+
+ self.service.createRecord(
+ DirectoryService.recordType_resources,
+ guid="resource01",
+ shortNames=("resource 01", "Resource 01"),
+ fullName="Resource 01",
+ enabledForCalendaring=True,
+ )
+ self.service.createRecord(
+ DirectoryService.recordType_locations,
+ guid="location02",
+ shortNames=("location02", "Location 02"),
+ fullName="Location 02",
+ enabledForCalendaring=True,
+ )
+
+ record = self.service.recordWithCalendarUserAddress("mailto:resource01@do_not_reply")
+ self.assertTrue(record is not None)
+ record = self.service.recordWithCalendarUserAddress("mailto:location02@do_not_reply")
+ self.assertTrue(record is not None)
+ record = self.service.recordWithCalendarUserAddress("mailto:location01@do_not_reply")
+ self.assertTrue(record is None)
+
+
+
</ins><span class="cx"> class DirectoryRecordTests(TestCase):
</span><span class="cx"> """
</span><span class="cx"> Test L{DirectoryRecord} apis.
</span></span></pre></div>
<a id="CalendarServerbranchesreleaseCalendarServer53devtwistedcaldavicalpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/release/CalendarServer-5.3-dev/twistedcaldav/ical.py (14156 => 14157)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/release/CalendarServer-5.3-dev/twistedcaldav/ical.py        2014-11-12 18:09:15 UTC (rev 14156)
+++ CalendarServer/branches/release/CalendarServer-5.3-dev/twistedcaldav/ical.py        2014-11-12 20:56:24 UTC (rev 14157)
</span><span class="lines">@@ -3248,6 +3248,10 @@
</span><span class="cx"> if oldemail:
</span><span class="cx"> oldemail = "mailto:%s" % (oldemail,)
</span><span class="cx">
</span><ins>+ if config.Scheduling.Options.FakeResourceLocationEmail:
+ if oldemail.endswith("@do_not_reply"):
+ oldemail = None
+
</ins><span class="cx"> # Get any CN parameter
</span><span class="cx"> oldCN = prop.parameterValue("CN")
</span><span class="cx">
</span><span class="lines">@@ -3326,6 +3330,10 @@
</span><span class="cx"> else:
</span><span class="cx"> email = None
</span><span class="cx">
</span><ins>+ if config.Scheduling.Options.FakeResourceLocationEmail:
+ if email.endswith("@do_not_reply"):
+ email = ""
+
</ins><span class="cx"> if email:
</span><span class="cx"> prop.setParameter("EMAIL", email)
</span><span class="cx"> else:
</span></span></pre></div>
<a id="CalendarServerbranchesreleaseCalendarServer53devtwistedcaldavstdconfigpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/release/CalendarServer-5.3-dev/twistedcaldav/stdconfig.py (14156 => 14157)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/release/CalendarServer-5.3-dev/twistedcaldav/stdconfig.py        2014-11-12 18:09:15 UTC (rev 14156)
+++ CalendarServer/branches/release/CalendarServer-5.3-dev/twistedcaldav/stdconfig.py        2014-11-12 20:56:24 UTC (rev 14157)
</span><span class="lines">@@ -733,6 +733,7 @@
</span><span class="cx"> "AllowResourceWithoutOrganizer" : True, # Allow resources to have events without an Organizer
</span><span class="cx"> "TrackUnscheduledLocationData" : True, # Track who the last modifier of an unscheduled location event is
</span><span class="cx"> "TrackUnscheduledResourceData" : True, # Track who the last modifier of an unscheduled resource event is
</span><ins>+ "FakeResourceLocationEmail" : False, # Add fake email addresses to work around client bug
</ins><span class="cx"> "LimitFreeBusyAttendees" : 30, # Maximum number of attendees to request freebusy for
</span><span class="cx"> "AttendeeRefreshBatch" : 5, # Number of attendees to do batched refreshes: 0 - no batching
</span><span class="cx"> "AttendeeRefreshBatchDelaySeconds" : 5, # Time after an iTIP REPLY for first batched attendee refresh
</span></span></pre></div>
<a id="CalendarServerbranchesreleaseCalendarServer53devtwistedcaldavtesttest_icalendarpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/release/CalendarServer-5.3-dev/twistedcaldav/test/test_icalendar.py (14156 => 14157)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/release/CalendarServer-5.3-dev/twistedcaldav/test/test_icalendar.py        2014-11-12 18:09:15 UTC (rev 14156)
+++ CalendarServer/branches/release/CalendarServer-5.3-dev/twistedcaldav/test/test_icalendar.py        2014-11-12 20:56:24 UTC (rev 14157)
</span><span class="lines">@@ -31,6 +31,7 @@
</span><span class="cx"> from pycalendar.duration import PyCalendarDuration
</span><span class="cx"> from twistedcaldav.dateops import normalizeForExpand
</span><span class="cx"> from pycalendar.value import PyCalendarValue
</span><ins>+from twistedcaldav.config import config
</ins><span class="cx">
</span><span class="cx"> class iCalendar (twistedcaldav.test.util.TestCase):
</span><span class="cx"> """
</span><span class="lines">@@ -8177,6 +8178,70 @@
</span><span class="cx"> self.assertEquals(prop.parameterValue("CN"), "{Restricted} Buzz")
</span><span class="cx">
</span><span class="cx">
</span><ins>+ def test_normalizeCalendarUserAddressesWithFakeEmail(self):
+ """
+ Ensure fake email addresses are not inserted as EMAIL parameters.
+ """
+
+ self.patch(config.Scheduling.Options, "FakeResourceLocationEmail", True)
+
+ data = """BEGIN:VCALENDAR
+VERSION:2.0
+DTSTART:20071114T000000Z
+BEGIN:VEVENT
+UID:12345-67890
+DTSTART:20071114T000000Z
+ATTENDEE:/principals/users/foo
+ATTENDEE;CN=Fake 1;CUTYPE=ROOM:mailto:fake1@do_not_reply
+ATTENDEE;CN=Fake 2;EMAIL=fake2@do_not_reply;CUTYPE=ROOM:mailto:fake2@do_not_reply
+LOCATION:Buzz
+DTSTAMP:20071114T000000Z
+END:VEVENT
+END:VCALENDAR
+"""
+
+ result = """BEGIN:VCALENDAR
+VERSION:2.0
+DTSTART:20071114T000000Z
+BEGIN:VEVENT
+UID:12345-67890
+DTSTART:20071114T000000Z
+ATTENDEE;CN=Foo;EMAIL=foo@example.com:urn:uuid:foo
+ATTENDEE;CN=Fake 1;CUTYPE=ROOM:urn:uuid:fake1
+ATTENDEE;CN=Fake 2;CUTYPE=ROOM:urn:uuid:fake2
+LOCATION:Buzz
+DTSTAMP:20071114T000000Z
+END:VEVENT
+END:VCALENDAR
+"""
+
+ component = Component.fromString(data)
+
+
+ def lookupFunction(cuaddr, ignored1, ignored2):
+ return {
+ "/principals/users/foo" : (
+ "Foo",
+ "foo",
+ ("urn:uuid:foo", "mailto:foo@example.com")
+ ),
+ "mailto:fake1@do_not_reply" : (
+ "Fake 1",
+ "fake1",
+ ("urn:uuid:fake1", "mailto:fake1@do_not_reply")
+ ),
+ "mailto:fake2@do_not_reply" : (
+ "Fake 2",
+ "fake2",
+ ("urn:uuid:fake2", "mailto:fake2@do_not_reply")
+ ),
+ }[cuaddr]
+
+ component.normalizeCalendarUserAddresses(lookupFunction, None, toUUID=True)
+
+ self.assertEqual(normalize_iCalStr(component), normalize_iCalStr(result))
+
+
</ins><span class="cx"> def test_serializationCaching(self):
</span><span class="cx">
</span><span class="cx"> data = """BEGIN:VCALENDAR
</span></span></pre>
</div>
</div>
</body>
</html>