[CalendarServer-changes] [6376] CalendarServer/trunk/twistedcaldav

source_changes at macosforge.org source_changes at macosforge.org
Mon Sep 27 13:27:33 PDT 2010


Revision: 6376
          http://trac.macosforge.org/projects/calendarserver/changeset/6376
Author:   sagen at apple.com
Date:     2010-09-27 13:27:32 -0700 (Mon, 27 Sep 2010)
Log Message:
-----------
Implicitly allow our own JID in roster

Modified Paths:
--------------
    CalendarServer/trunk/twistedcaldav/notify.py
    CalendarServer/trunk/twistedcaldav/test/test_notify.py

Modified: CalendarServer/trunk/twistedcaldav/notify.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/notify.py	2010-09-24 18:11:13 UTC (rev 6375)
+++ CalendarServer/trunk/twistedcaldav/notify.py	2010-09-27 20:27:32 UTC (rev 6376)
@@ -955,6 +955,15 @@
             d.addCallback(self.handleRoster)
 
     def allowedInRoster(self, jid):
+        """ Returns True if jid matches any of the patterns in AllowedJIDs,
+            or is our own JID.  False otherwise. """
+
+        # Always allow our own JID (in case multiple servers are sharing it)
+        settings = self.settings
+        if settings is not None:
+            if settings["JID"] == jid:
+                return True
+
         for pattern in self.settings.get("AllowedJIDs", []):
             if fnmatch(jid, pattern):
                 return True

Modified: CalendarServer/trunk/twistedcaldav/test/test_notify.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/test/test_notify.py	2010-09-24 18:11:13 UTC (rev 6375)
+++ CalendarServer/trunk/twistedcaldav/test/test_notify.py	2010-09-27 20:27:32 UTC (rev 6376)
@@ -533,6 +533,7 @@
 
 
 
+
 class XMPPNotificationFactoryTests(TestCase):
 
     def test_sendPresence(self):
@@ -605,3 +606,16 @@
         self.assertEquals(conf, None)
         conf = getPubSubAPSConfiguration("UnknownPrefix|foo", enabledConfig)
         self.assertEquals(conf, None)
+
+    def test_allowedInRoster(self):
+        """
+        Our own JID is implicitly included in AllowedJIDs
+        """
+        settings = {
+            "JID" : "test1 at example.com",
+            "AllowedJIDs" : ["test2 at example.com"]
+        }
+        notifier = XMPPNotifier(settings, heartbeat=False)
+        self.assertTrue(notifier.allowedInRoster("test1 at example.com"))
+        self.assertTrue(notifier.allowedInRoster("test2 at example.com"))
+        self.assertFalse(notifier.allowedInRoster("test3 at example.com"))
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20100927/0bc040a2/attachment.html>


More information about the calendarserver-changes mailing list