[CalendarServer-changes] [5412] CalendarServer/branches/users/sagen/deprovision/calendarserver/tools
source_changes at macosforge.org
source_changes at macosforge.org
Tue Mar 30 08:55:19 PDT 2010
Revision: 5412
http://trac.macosforge.org/projects/calendarserver/changeset/5412
Author: sagen at apple.com
Date: 2010-03-30 08:55:15 -0700 (Tue, 30 Mar 2010)
Log Message:
-----------
Clear out proxy assignments when purging deprovisioned users
Modified Paths:
--------------
CalendarServer/branches/users/sagen/deprovision/calendarserver/tools/purge.py
CalendarServer/branches/users/sagen/deprovision/calendarserver/tools/test/test_purge.py
Modified: CalendarServer/branches/users/sagen/deprovision/calendarserver/tools/purge.py
===================================================================
--- CalendarServer/branches/users/sagen/deprovision/calendarserver/tools/purge.py 2010-03-29 20:58:35 UTC (rev 5411)
+++ CalendarServer/branches/users/sagen/deprovision/calendarserver/tools/purge.py 2010-03-30 15:55:15 UTC (rev 5412)
@@ -18,6 +18,7 @@
from calendarserver.tap.util import FakeRequest
from calendarserver.tap.util import getRootResource
+from calendarserver.tools.principals import removeProxy
from calendarserver.tools.util import loadConfig, setupMemcached, setupNotifications
from datetime import date, timedelta, datetime
from getopt import getopt, GetoptError
@@ -317,4 +318,15 @@
uri, guid, implicit=(name in ongoingEvents)))
count += 1
+ # Remove proxy assignments
+ for proxyType in ("read", "write"):
+
+ proxyFor = (yield principal.proxyFor(proxyType))
+ for other in proxyFor:
+ (yield removeProxy(other, principal))
+
+ subPrincipal = principal.getChild("calendar-proxy-" + proxyType)
+ (yield subPrincipal.writeProperty(davxml.GroupMemberSet(), None))
+
returnValue(count)
+
Modified: CalendarServer/branches/users/sagen/deprovision/calendarserver/tools/test/test_purge.py
===================================================================
--- CalendarServer/branches/users/sagen/deprovision/calendarserver/tools/test/test_purge.py 2010-03-29 20:58:35 UTC (rev 5411)
+++ CalendarServer/branches/users/sagen/deprovision/calendarserver/tools/test/test_purge.py 2010-03-30 15:55:15 UTC (rev 5412)
@@ -15,13 +15,16 @@
##
from calendarserver.tap.util import getRootResource
+from calendarserver.tools.principals import addProxy, removeProxy
from calendarserver.tools.purge import purgeOldEvents, purgeGUID
from datetime import datetime, timedelta
from twext.python.filepath import CachingFilePath as FilePath
from twext.python.plistlib import readPlistFromString
+from twext.web2.dav import davxml
from twisted.internet import reactor
from twisted.internet.defer import inlineCallbacks, Deferred, returnValue
from twistedcaldav.config import config
+from twistedcaldav.directory.directory import DirectoryRecord
from twistedcaldav.test.util import TestCase, CapturingProcessProtocol
import os
import xml
@@ -411,7 +414,55 @@
returnValue(plist)
+
@inlineCallbacks
+ def test_purgeProxies(self):
+
+ # Set up fake user
+ purging = "5D6ABA3C-3446-4340-8083-7E37C5BC0B26"
+ record = DirectoryRecord(self.directory, "users", purging,
+ shortNames=(purging,), enabledForCalendaring=True)
+ record.enabled = True # Enabling might not be required here
+ self.directory._tmpRecords["shortNames"][purging] = record
+ self.directory._tmpRecords["guids"][purging] = record
+ pc = self.directory.principalCollection
+ purgingPrincipal = pc.principalForRecord(record)
+
+ keeping = "291C2C29-B663-4342-8EA1-A055E6A04D65"
+ keepingPrincipal = pc.principalForUID(keeping)
+
+ # Add purgingPrincipal as a proxy for keepingPrincipal
+ (yield addProxy(keepingPrincipal, "write", purgingPrincipal))
+
+ # Add keepingPrincipal as a proxy for purgingPrincipal
+ (yield addProxy(purgingPrincipal, "write", keepingPrincipal))
+
+ def getProxies(principal, proxyType):
+ subPrincipal = principal.getChild("calendar-proxy-" + proxyType)
+ return subPrincipal.readProperty(davxml.GroupMemberSet, None)
+
+ # Verify the proxy assignments
+ membersProperty = (yield getProxies(keepingPrincipal, "write"))
+ self.assertEquals(len(membersProperty.children), 1)
+ self.assertEquals(membersProperty.children[0],
+ "/principals/__uids__/5D6ABA3C-3446-4340-8083-7E37C5BC0B26/")
+
+ membersProperty = (yield getProxies(purgingPrincipal, "write"))
+ self.assertEquals(len(membersProperty.children), 1)
+ self.assertEquals(membersProperty.children[0],
+ "/principals/__uids__/291C2C29-B663-4342-8EA1-A055E6A04D65/")
+
+
+ # Purging the guid should clear out proxy assignments
+
+ (yield purgeGUID(purging, self.directory, self.rootResource))
+
+ membersProperty = (yield getProxies(keepingPrincipal, "write"))
+ self.assertEquals(len(membersProperty.children), 0)
+ membersProperty = (yield getProxies(purgingPrincipal, "write"))
+ self.assertEquals(len(membersProperty.children), 0)
+
+ @inlineCallbacks
def test_purgeExistingGUID(self):
# Deprovisioned user is E9E78C86-4829-4520-A35D-70DDADAB2092
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20100330/cd8f5e06/attachment.html>
More information about the calendarserver-changes
mailing list