[CalendarServer-changes] [8005] CalendarServer/branches/release/CalendarServer-3.1-dev/twistedcaldav

source_changes at macosforge.org source_changes at macosforge.org
Mon Aug 22 14:41:44 PDT 2011


Revision: 8005
          http://trac.macosforge.org/projects/calendarserver/changeset/8005
Author:   sagen at apple.com
Date:     2011-08-22 14:41:44 -0700 (Mon, 22 Aug 2011)
Log Message:
-----------
Copying the old-style mailgateway tokens fix from trunk

Modified Paths:
--------------
    CalendarServer/branches/release/CalendarServer-3.1-dev/twistedcaldav/mail.py
    CalendarServer/branches/release/CalendarServer-3.1-dev/twistedcaldav/test/test_mail.py

Modified: CalendarServer/branches/release/CalendarServer-3.1-dev/twistedcaldav/mail.py
===================================================================
--- CalendarServer/branches/release/CalendarServer-3.1-dev/twistedcaldav/mail.py	2011-08-22 21:01:02 UTC (rev 8004)
+++ CalendarServer/branches/release/CalendarServer-3.1-dev/twistedcaldav/mail.py	2011-08-22 21:41:44 UTC (rev 8005)
@@ -903,11 +903,25 @@
             # event uid
             token = self.db.getToken(originator, toAddr, icaluid)
             if token is None:
+
+                # Because in the past the originator was sometimes in mailto:
+                # form, lookup an existing token by mailto: as well
+                organizerProperty = calendar.getOrganizerProperty()
+                organizerEmailAddress = organizerProperty.parameterValue("EMAIL", None)
+                if organizerEmailAddress is not None:
+                    token = self.db.getToken("mailto:%s" % (organizerEmailAddress,), toAddr, icaluid)
+
+            if token is None:
                 token = self.db.createToken(originator, toAddr, icaluid)
-                self.log_debug("Mail gateway created token %s for %s (originator), %s (recipient) and %s (icaluid)" % (token, originator, toAddr, icaluid))
+                self.log_debug("Mail gateway created token %s for %s "
+                               "(originator), %s (recipient) and %s (icaluid)"
+                               % (token, originator, toAddr, icaluid))
                 inviteState = "new"
+
             else:
-                self.log_debug("Mail gateway reusing token %s for %s (originator), %s (recipient) and %s (icaluid)" % (token, originator, toAddr, icaluid))
+                self.log_debug("Mail gateway reusing token %s for %s "
+                               "(originator), %s (recipient) and %s (icaluid)"
+                               % (token, originator, toAddr, icaluid))
                 inviteState = "update"
 
             fullServerAddress = settings['Address']

Modified: CalendarServer/branches/release/CalendarServer-3.1-dev/twistedcaldav/test/test_mail.py
===================================================================
--- CalendarServer/branches/release/CalendarServer-3.1-dev/twistedcaldav/test/test_mail.py	2011-08-22 21:01:02 UTC (rev 8004)
+++ CalendarServer/branches/release/CalendarServer-3.1-dev/twistedcaldav/test/test_mail.py	2011-08-22 21:41:44 UTC (rev 8005)
@@ -32,6 +32,28 @@
 def echo(*args):
     return args
 
+initialInviteText = u"""BEGIN:VCALENDAR
+VERSION:2.0
+METHOD:REQUEST
+BEGIN:VEVENT
+UID:CFDD5E46-4F74-478A-9311-B3FF905449C3
+DTSTART:20100325T154500Z
+DTEND:20100325T164500Z
+ATTENDEE;CN=Th\xe9 Attendee;CUTYPE=INDIVIDUAL;PARTSTAT=NEEDS-ACTION;RSVP=TRU
+ E:mailto:attendee at example.com
+ATTENDEE;CN=Th\xe9 Organizer;CUTYPE=INDIVIDUAL;EMAIL=organizer at example.com;P
+ ARTSTAT=ACCEPTED:urn:uuid:C3B38B00-4166-11DD-B22C-A07C87E02F6A
+ATTENDEE;CN=An Attendee without CUTYPE;EMAIL=nocutype at example.com;PARTSTAT=A
+ CCEPTED:urn:uuid:4DB528DC-3E60-44FA-9546-2A00FCDCFFAB
+ATTENDEE;EMAIL=nocn at example.com;PARTSTAT=ACCEPTED:urn:uuid:A592CF8B-4FC8-4E4
+ F-B543-B2F29A7EEB0B
+ORGANIZER;CN=Th\xe9 Organizer;EMAIL=organizer at example.com:urn:uuid:C3B38B00-
+ 4166-11DD-B22C-A07C87E02F6A
+SUMMARY:t\xe9sting outbound( )
+DESCRIPTION:awesome description with "<" and "&"
+END:VEVENT
+END:VCALENDAR
+"""
 
 class MailHandlerTests(TestCase):
 
@@ -399,6 +421,47 @@
                 self.assertEquals(actualReplyTo, actualFrom)
 
 
+    @inlineCallbacks
+    def test_mailtoTokens(self):
+        """
+        Make sure old mailto tokens are still honored
+        """
+
+        organizerEmail = "mailto:organizer at example.com"
+
+        config.Scheduling.iMIP.Sending.Address = "server at example.com"
+
+        # Explictly store a token with mailto: CUA for organizer
+        # (something that doesn't happen any more, but did in the past)
+        origToken = self.handler.db.createToken(organizerEmail,
+            "mailto:attendee at example.com",
+            "CFDD5E46-4F74-478A-9311-B3FF905449C3")
+
+        inputCalendar = initialInviteText
+        UID = "CFDD5E46-4F74-478A-9311-B3FF905449C3"
+        inputOriginator = "urn:uuid:C3B38B00-4166-11DD-B22C-A07C87E02F6A"
+        inputRecipient = "mailto:attendee at example.com"
+
+        (actualInviteState, actualCalendar, actualOrganizerEmail,
+            actualOrganizerName, actualAttendeeList, actualFrom,
+            actualRecipient, actualReplyTo) = (yield self.handler.outbound(
+                inputOriginator,
+                inputRecipient,
+                Component.fromString(inputCalendar.replace("\n", "\r\n")),
+                send=False)
+            )
+
+        # Verify we didn't create a new token...
+        token = self.handler.db.getToken(inputOriginator,
+            inputRecipient, UID)
+        self.assertEquals(token, None)
+
+        # But instead kept the old one...
+        token = self.handler.db.getToken(organizerEmail,
+            inputRecipient, UID)
+        self.assertEquals(token, origToken)
+
+
 class MailGatewayTokensDatabaseTests(TestCase):
 
     def setUp(self):
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20110822/0ad2e8e5/attachment-0001.html>


More information about the calendarserver-changes mailing list