[CalendarServer-changes] [5410] CalendarServer/branches/users/sagen/deprovision
source_changes at macosforge.org
source_changes at macosforge.org
Sat Mar 27 11:01:00 PDT 2010
Revision: 5410
http://trac.macosforge.org/projects/calendarserver/changeset/5410
Author: sagen at apple.com
Date: 2010-03-27 11:00:58 -0700 (Sat, 27 Mar 2010)
Log Message:
-----------
Testing out how to fake a directory record for a deprovisioned user
Modified Paths:
--------------
CalendarServer/branches/users/sagen/deprovision/calendarserver/tools/purge.py
CalendarServer/branches/users/sagen/deprovision/calendarserver/tools/test/test_purge.py
CalendarServer/branches/users/sagen/deprovision/twistedcaldav/directory/aggregate.py
Modified: CalendarServer/branches/users/sagen/deprovision/calendarserver/tools/purge.py
===================================================================
--- CalendarServer/branches/users/sagen/deprovision/calendarserver/tools/purge.py 2010-03-27 17:53:42 UTC (rev 5409)
+++ CalendarServer/branches/users/sagen/deprovision/calendarserver/tools/purge.py 2010-03-27 18:00:58 UTC (rev 5410)
@@ -31,7 +31,7 @@
from twistedcaldav import caldavxml
from twistedcaldav.caldavxml import TimeRange
from twistedcaldav.config import config, ConfigurationError
-from twistedcaldav.directory.directory import DirectoryError
+from twistedcaldav.directory.directory import DirectoryError, DirectoryRecord
from twistedcaldav.method.delete_common import DeleteResource
import os
import sys
@@ -266,7 +266,10 @@
# The user has already been removed from the directory service. We
# need to fashion a temporary, fake record
# FIXME: implement the fake record
- pass
+ record = DirectoryRecord(directory, "users", guid, shortNames=(guid,),
+ enabledForCalendaring=True)
+ record.enabled = True
+ directory._tmpRecords[guid] = record
principalCollection = directory.principalCollection
principal = principalCollection.principalForRecord(record)
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-27 17:53:42 UTC (rev 5409)
+++ CalendarServer/branches/users/sagen/deprovision/calendarserver/tools/test/test_purge.py 2010-03-27 18:00:58 UTC (rev 5410)
@@ -412,8 +412,7 @@
returnValue(plist)
@inlineCallbacks
- def test_purgeGUID(self):
- # deprovision, add an event
+ def test_purgeExistingGUID(self):
# Deprovisioned user is E9E78C86-4829-4520-A35D-70DDADAB2092
# Keeper user is 291C2C29-B663-4342-8EA1-A055E6A04D65
@@ -467,8 +466,6 @@
count = (yield purgeGUID("E9E78C86-4829-4520-A35D-70DDADAB2092",
self.directory, self.rootResource))
- # print config.DocumentRoot
- # import pdb; pdb.set_trace()
self.assertEquals(count, 3)
after = {
@@ -529,9 +526,123 @@
)
+ @inlineCallbacks
+ def test_purgeNonExistentGUID(self):
+
+ before = {
+ "calendars" : {
+ "__uids__" : {
+ "1C" : {
+ "B4" : {
+ "1CB4378B-DD76-462D-B4D4-BD131FE89243" : {
+ "calendar": {
+ "@xattrs" :
+ {
+ resourceAttr : collectionType,
+ },
+ "noninvite.ics": {
+ "@contents" : NON_INVITE_ICS_2,
+ },
+ "organizer.ics": {
+ "@contents" : ORGANIZER_ICS_2,
+ },
+ "attendee.ics": {
+ "@contents" : ATTENDEE_ICS_2,
+ },
+ },
+ },
+ },
+ },
+ "29" : {
+ "1C" : {
+ "291C2C29-B663-4342-8EA1-A055E6A04D65" : {
+ "calendar": {
+ "@xattrs" :
+ {
+ resourceAttr : collectionType,
+ },
+ "organizer.ics": {
+ "@contents" : ORGANIZER_ICS_2,
+ },
+ "attendee.ics": {
+ "@contents" : ATTENDEE_ICS_2,
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ }
+ self.createHierarchy(before, config.DocumentRoot)
+ count = (yield purgeGUID("1CB4378B-DD76-462D-B4D4-BD131FE89243",
+ self.directory, self.rootResource))
+
+ self.assertEquals(count, 3)
+
+ after = {
+ "__uids__" : {
+ "1C" : {
+ "B4" : {
+ "1CB4378B-DD76-462D-B4D4-BD131FE89243" : {
+ "calendar": {
+ ".db.sqlite": {
+ "@contents" : None, # ignore contents
+ },
+ },
+ },
+ },
+ },
+ "29" : {
+ "1C" : {
+ "291C2C29-B663-4342-8EA1-A055E6A04D65" : {
+ "inbox": {
+ ".db.sqlite": {
+ "@contents" : None, # ignore contents
+ },
+ "*.ics/UID:7ED97931-9A19-4596-9D4D-52B36D6AB803": {
+ "@contents" : (
+ "METHOD:CANCEL",
+ ),
+ },
+ "*.ics/UID:1974603C-B2C0-4623-92A0-2436DEAB07EF": {
+ "@contents" : (
+ "METHOD:REPLY",
+ "ATTENDEE;CUTYPE=INDIVIDUAL;PARTSTAT=DECLINED:urn:uuid:1CB4378B-DD76-462D-B\r\n 4D4-BD131FE89243",
+ ),
+ },
+ },
+ "calendar": {
+ ".db.sqlite": {
+ "@contents" : None, # ignore contents
+ },
+ "organizer.ics": {
+ "@contents" : (
+ "STATUS:CANCELLED",
+ ),
+ },
+ "attendee.ics": {
+ "@contents" : (
+ "ATTENDEE;CUTYPE=INDIVIDUAL;PARTSTAT=DECLINED;SCHEDULE-STATUS=2.0:urn:uuid:\r\n 1CB4378B-DD76-462D-B4D4-BD131FE89243",
+ ),
+ },
+ },
+ },
+ },
+ },
+ },
+ }
+ self.assertTrue(self.verifyHierarchy(
+ os.path.join(config.DocumentRoot, "calendars"),
+ after)
+ )
+
+
future = (datetime.utcnow() + timedelta(days=1)).strftime("%Y%m%dT%H%M%SZ")
past = (datetime.utcnow() - timedelta(days=1)).strftime("%Y%m%dT%H%M%SZ")
+# For test_purgeExistingGUID
+
NON_INVITE_ICS = """BEGIN:VCALENDAR
VERSION:2.0
BEGIN:VEVENT
@@ -571,3 +682,45 @@
END:VCALENDAR
""".replace("\n", "\r\n") % (future,)
+
+# For test_purgeNonExistentGUID
+
+NON_INVITE_ICS_2 = """BEGIN:VCALENDAR
+VERSION:2.0
+BEGIN:VEVENT
+UID:151AFC76-6036-40EF-952B-97D1840760BF
+SUMMARY:Non Invitation
+DTSTART:%s
+DURATION:PT1H
+END:VEVENT
+END:VCALENDAR
+""".replace("\n", "\r\n") % (past,)
+
+ORGANIZER_ICS_2 = """BEGIN:VCALENDAR
+VERSION:2.0
+BEGIN:VEVENT
+UID:7ED97931-9A19-4596-9D4D-52B36D6AB803
+SUMMARY:Organizer
+DTSTART:%s
+DURATION:PT1H
+ORGANIZER:urn:uuid:1CB4378B-DD76-462D-B4D4-BD131FE89243
+ATTENDEE;CUTYPE=INDIVIDUAL;PARTSTAT=ACCEPTED:urn:uuid:1CB4378B-DD76-462D-B4D4-BD131FE89243
+ATTENDEE;CUTYPE=INDIVIDUAL;PARTSTAT=ACCEPTED:urn:uuid:291C2C29-B663-4342-8EA1-A055E6A04D65
+END:VEVENT
+END:VCALENDAR
+""".replace("\n", "\r\n") % (future,)
+
+ATTENDEE_ICS_2 = """BEGIN:VCALENDAR
+VERSION:2.0
+BEGIN:VEVENT
+UID:1974603C-B2C0-4623-92A0-2436DEAB07EF
+SUMMARY:Attendee
+DTSTART:%s
+DURATION:PT1H
+ORGANIZER:urn:uuid:291C2C29-B663-4342-8EA1-A055E6A04D65
+ATTENDEE;CUTYPE=INDIVIDUAL;PARTSTAT=ACCEPTED:urn:uuid:1CB4378B-DD76-462D-B4D4-BD131FE89243
+ATTENDEE;CUTYPE=INDIVIDUAL;PARTSTAT=ACCEPTED:urn:uuid:291C2C29-B663-4342-8EA1-A055E6A04D65
+END:VEVENT
+END:VCALENDAR
+""".replace("\n", "\r\n") % (future,)
+
Modified: CalendarServer/branches/users/sagen/deprovision/twistedcaldav/directory/aggregate.py
===================================================================
--- CalendarServer/branches/users/sagen/deprovision/twistedcaldav/directory/aggregate.py 2010-03-27 17:53:42 UTC (rev 5409)
+++ CalendarServer/branches/users/sagen/deprovision/twistedcaldav/directory/aggregate.py 2010-03-27 18:00:58 UTC (rev 5410)
@@ -69,6 +69,8 @@
self.realmName = realmName
self._recordTypes = recordTypes
+ self._tmpRecords = { }
+
def __repr__(self):
return "<%s (%s): %r>" % (self.__class__.__name__, self.realmName, self._recordTypes)
@@ -114,6 +116,9 @@
return self._query("recordWithShortName", recordType, shortName)
def recordWithUID(self, uid):
+ record = self._tmpRecords.get(uid, None)
+ if record:
+ return record
return self._queryAll("recordWithUID", uid)
def recordWithAuthID(self, authID):
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20100327/0e57589b/attachment-0001.html>
More information about the calendarserver-changes
mailing list