[CalendarServer-changes] [15476] CalendarServer/trunk

source_changes at macosforge.org source_changes at macosforge.org
Wed Mar 16 15:56:28 PDT 2016


Revision: 15476
          http://trac.calendarserver.org//changeset/15476
Author:   sagen at apple.com
Date:     2016-03-16 15:56:28 -0700 (Wed, 16 Mar 2016)
Log Message:
-----------
Ensure fake email addresses are unicode; since shortNames/emails are optional, make admin page ignore missing values

Modified Paths:
--------------
    CalendarServer/trunk/calendarserver/webadmin/principals.py
    CalendarServer/trunk/txdav/who/directory.py
    CalendarServer/trunk/txdav/who/test/test_directory.py

Modified: CalendarServer/trunk/calendarserver/webadmin/principals.py
===================================================================
--- CalendarServer/trunk/calendarserver/webadmin/principals.py	2016-03-16 21:42:01 UTC (rev 15475)
+++ CalendarServer/trunk/calendarserver/webadmin/principals.py	2016-03-16 22:56:28 UTC (rev 15476)
@@ -352,9 +352,9 @@
         u"uid": joinWithBR((record.uid,)),
         u"guid": joinWithBR((record.guid,)),
         u"recordType": joinWithBR((record.recordType,)),
-        u"shortNames": joinWithBR(record.shortNames),
+        u"shortNames":  joinWithBR(record.shortNames) if hasattr(record, "shortNames") else "",
         u"fullNames": joinWithBR(record.fullNames),
-        u"emailAddresses": joinWithBR(record.emailAddresses),
+        u"emailAddresses": joinWithBR(record.emailAddresses) if hasattr(record, "emailAddresses") else "",
         u"calendarUserAddresses": joinWithBR(record.calendarUserAddresses),
         u"serverURI": joinWithBR((record.serverURI(),)),
     }

Modified: CalendarServer/trunk/txdav/who/directory.py
===================================================================
--- CalendarServer/trunk/txdav/who/directory.py	2016-03-16 21:42:01 UTC (rev 15475)
+++ CalendarServer/trunk/txdav/who/directory.py	2016-03-16 22:56:28 UTC (rev 15476)
@@ -348,7 +348,7 @@
     def __init__(self):
         if config.Scheduling.Options.FakeResourceLocationEmail:
             if self.recordType in (DAVRecordType.location, DAVRecordType.resource) and not getattr(self, "emailAddresses", None):
-                self.fields[BaseFieldName.emailAddresses] = ("{}@do_not_reply".format(self.uid.encode("hex"),),)
+                self.fields[BaseFieldName.emailAddresses] = (u"{}@do_not_reply".format(self.uid.encode("hex"),),)
 
 
     @inlineCallbacks

Modified: CalendarServer/trunk/txdav/who/test/test_directory.py
===================================================================
--- CalendarServer/trunk/txdav/who/test/test_directory.py	2016-03-16 21:42:01 UTC (rev 15475)
+++ CalendarServer/trunk/txdav/who/test/test_directory.py	2016-03-16 22:56:28 UTC (rev 15476)
@@ -389,10 +389,15 @@
     @inlineCallbacks
     def test_calendarUserAddress_fake_email(self):
         """
-        Make sure that recordWs have fake email addresses.
+        Make sure that records have fake email addresses.
         """
 
         record = yield self.directory.recordWithUID(u"resource01")
         self.assertTrue(record is not None)
+
+        # Verify the fake email address is in fact unicode
+        for address in record.emailAddresses:
+            self.assertTrue(isinstance(address, unicode))
+
         self.assertIn(u"{}@do_not_reply".format("resource01".encode("hex")), record.emailAddresses)
         self.assertIn(u"mailto:{}@do_not_reply".format("resource01".encode("hex")), record.calendarUserAddresses)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20160316/4ec43186/attachment.html>


More information about the calendarserver-changes mailing list