[CalendarServer-changes] [9846] CalendarServer/branches/users/gaya/inviteclean/twistedcaldav

source_changes at macosforge.org source_changes at macosforge.org
Mon Sep 24 13:47:09 PDT 2012


Revision: 9846
          http://trac.calendarserver.org//changeset/9846
Author:   gaya at apple.com
Date:     2012-09-24 13:47:09 -0700 (Mon, 24 Sep 2012)
Log Message:
-----------
fix up update to changeset/9821

Modified Paths:
--------------
    CalendarServer/branches/users/gaya/inviteclean/twistedcaldav/sharing.py
    CalendarServer/branches/users/gaya/inviteclean/twistedcaldav/test/test_sharing.py

Modified: CalendarServer/branches/users/gaya/inviteclean/twistedcaldav/sharing.py
===================================================================
--- CalendarServer/branches/users/gaya/inviteclean/twistedcaldav/sharing.py	2012-09-24 18:10:58 UTC (rev 9845)
+++ CalendarServer/branches/users/gaya/inviteclean/twistedcaldav/sharing.py	2012-09-24 20:47:09 UTC (rev 9846)
@@ -436,7 +436,9 @@
                 if not (yield self.validUserIDForShare("urn:uuid:" + invitation.shareeUID(), request)):
                     yield self._updateInvitation(invitation, state="INVALID")
 
+        returnValue(len(invitations))
 
+
     def inviteUserToShare(self, userid, cn, ace, summary, request):
         """ Send out in invite first, and then add this user to the share list
             @param userid:

Modified: CalendarServer/branches/users/gaya/inviteclean/twistedcaldav/test/test_sharing.py
===================================================================
--- CalendarServer/branches/users/gaya/inviteclean/twistedcaldav/test/test_sharing.py	2012-09-24 18:10:58 UTC (rev 9845)
+++ CalendarServer/branches/users/gaya/inviteclean/twistedcaldav/test/test_sharing.py	2012-09-24 20:47:09 UTC (rev 9846)
@@ -62,7 +62,8 @@
 
         def calendarHome(self, request):
             class FakeHome(object):
-                def removeShareByUID(self, request, uid):pass
+                def removeShareByUID(self, request, uid):
+                    pass
             return FakeHome()
 
         def principalURL(self):
@@ -87,6 +88,7 @@
         CalDAVResource.sendInviteNotification = lambda self, record, request: succeed(True)
         CalDAVResource.removeInviteNotification = lambda self, record, request: succeed(True)
 
+        self.patch(CalDAVResource, "validUserIDForShare", lambda self, userid, request: None if "bogus" in userid else SharingTests.FakePrincipal(userid).principalURL())
         self.patch(CalDAVResource, "principalForCalendarUserAddress", lambda self, cuaddr: None if "bogus" in cuaddr else SharingTests.FakePrincipal(cuaddr))
         self.patch(CalDAVResource, "principalForUID", lambda self, principalUID: SharingTests.FakePrincipal("urn:uuid:" + principalUID))
 
@@ -114,6 +116,7 @@
         self.assertEqual(response.code, resultcode)
         returnValue(response)
 
+
     def _clearUIDElementValue(self, xml):
 
         for user in xml.children:
@@ -122,69 +125,49 @@
                     element.children[0].data = ""
         return xml
 
+
     @inlineCallbacks
-    def test_upgradeToShareOnCreate(self):
-        request = SimpleRequest(self.site, "MKCOL", "/calendar/")
+    def test_upgradeToShare(self):
 
         rtype = self.resource.resourceType()
         self.assertEquals(rtype, regularCalendarType)
-        propInvite = (yield self.resource.readProperty(customxml.Invite, request))
-        self.assertEquals(propInvite, None)
+        isShared = (yield self.resource.isShared(None))
+        self.assertFalse(isShared)
+        isShareeCollection = self.resource.isShareeCollection()
+        self.assertFalse(isShareeCollection)
 
         self.resource.upgradeToShare()
 
         rtype = self.resource.resourceType()
         self.assertEquals(rtype, sharedOwnerType)
-        propInvite = (yield self.resource.readProperty(customxml.Invite, request))
-        self.assertEquals(propInvite, customxml.Invite())
-
-        isShared = (yield self.resource.isShared(request))
+        isShared = (yield self.resource.isShared(None))
         self.assertTrue(isShared)
-        isVShared = self.resource.isShareeCollection()
-        self.assertFalse(isVShared)
+        isShareeCollection = self.resource.isShareeCollection()
+        self.assertFalse(isShareeCollection)
 
+
     @inlineCallbacks
-    def test_upgradeToShareAfterCreate(self):
-        request = SimpleRequest(self.site, "PROPPATCH", "/calendar/")
+    def test_downgradeFromShare(self):
 
-        rtype = self.resource.resourceType()
-        self.assertEquals(rtype, regularCalendarType)
-        propInvite = (yield self.resource.readProperty(customxml.Invite, request))
-        self.assertEquals(propInvite, None)
-
         self.resource.upgradeToShare()
 
         rtype = self.resource.resourceType()
         self.assertEquals(rtype, sharedOwnerType)
-        propInvite = (yield self.resource.readProperty(customxml.Invite, request))
-        self.assertEquals(propInvite, customxml.Invite())
-
-        isShared = (yield self.resource.isShared(request))
+        isShared = (yield self.resource.isShared(None))
         self.assertTrue(isShared)
-        isVShared = self.resource.isShareeCollection()
-        self.assertFalse(isVShared)
+        isShareeCollection = self.resource.isShareeCollection()
+        self.assertFalse(isShareeCollection)
 
-    @inlineCallbacks
-    def test_downgradeFromShare(self):
-        self.resource.writeDeadProperty(sharedOwnerType)
-        self.resource.writeDeadProperty(customxml.Invite())
-        rtype = self.resource.resourceType()
-        self.assertEquals(rtype, sharedOwnerType)
-        propInvite = (yield self.resource.readProperty(customxml.Invite, None))
-        self.assertEquals(propInvite, customxml.Invite())
-
         yield self.resource.downgradeFromShare(None)
 
         rtype = self.resource.resourceType()
         self.assertEquals(rtype, regularCalendarType)
-        propInvite = (yield self.resource.readProperty(customxml.Invite, None))
-        self.assertEquals(propInvite, None)
-
         isShared = (yield self.resource.isShared(None))
         self.assertFalse(isShared)
-        isVShared = self.resource.isShareeCollection()
-        self.assertFalse(isVShared)
+        isShareeCollection = self.resource.isShareeCollection()
+        self.assertFalse(isShareeCollection)
 
+
     @inlineCallbacks
     def test_POSTaddInviteeAlreadyShared(self):
 
@@ -213,9 +196,10 @@
 
         isShared = (yield self.resource.isShared(None))
         self.assertTrue(isShared)
-        isVShared = self.resource.isShareeCollection()
-        self.assertFalse(isVShared)
+        isShareeCollection = self.resource.isShareeCollection()
+        self.assertFalse(isShareeCollection)
 
+
     @inlineCallbacks
     def test_POSTaddInviteeNotAlreadyShared(self):
 
@@ -243,13 +227,15 @@
 
         isShared = (yield self.resource.isShared(None))
         self.assertTrue(isShared)
-        isVShared = (yield self.resource.isShareeCollection())
-        self.assertFalse(isVShared)
+        isShareeCollection = (yield self.resource.isShareeCollection())
+        self.assertFalse(isShareeCollection)
 
+
     @inlineCallbacks
     def test_POSTupdateInvitee(self):
 
-        self.resource.upgradeToShare()
+        isShared = (yield self.resource.isShared(None))
+        self.assertFalse(isShared)
 
         yield self._doPOST("""<?xml version="1.0" encoding="utf-8" ?>
 <CS:share xmlns:D="DAV:" xmlns:CS="http://calendarserver.org/ns/">
@@ -261,6 +247,9 @@
 </CS:share>
 """)
 
+        isShared = (yield self.resource.isShared(None))
+        self.assertTrue(isShared)
+
         yield self._doPOST("""<?xml version="1.0" encoding="utf-8" ?>
 <CS:share xmlns:D="DAV:" xmlns:CS="http://calendarserver.org/ns/">
     <CS:set>
@@ -271,6 +260,9 @@
 </CS:share>
 """)
 
+        isShared = (yield self.resource.isShared(None))
+        self.assertTrue(isShared)
+
         propInvite = (yield self.resource.readProperty(customxml.Invite, None))
         self.assertEquals(self._clearUIDElementValue(propInvite), customxml.Invite(
             customxml.InviteUser(
@@ -282,10 +274,12 @@
             )
         ))
 
+
     @inlineCallbacks
     def test_POSTremoveInvitee(self):
 
-        self.resource.upgradeToShare()
+        isShared = (yield self.resource.isShared(None))
+        self.assertFalse(isShared)
 
         yield self._doPOST("""<?xml version="1.0" encoding="utf-8" ?>
 <CS:share xmlns:D="DAV:" xmlns:CS="http://calendarserver.org/ns/">
@@ -297,6 +291,9 @@
 </CS:share>
 """)
 
+        isShared = (yield self.resource.isShared(None))
+        self.assertTrue(isShared)
+
         yield self._doPOST("""<?xml version="1.0" encoding="utf-8" ?>
 <CS:share xmlns:D="DAV:" xmlns:CS="http://calendarserver.org/ns/">
     <CS:remove>
@@ -305,9 +302,13 @@
 </CS:share>
 """)
 
+        isShared = (yield self.resource.isShared(None))
+        self.assertFalse(isShared)
+
         propInvite = (yield self.resource.readProperty(customxml.Invite, None))
-        self.assertEquals(self._clearUIDElementValue(propInvite), customxml.Invite())
+        self.assertEquals(propInvite, None)
 
+
     @inlineCallbacks
     def test_POSTaddMoreInvitees(self):
 
@@ -362,6 +363,7 @@
             ),
         ))
 
+
     @inlineCallbacks
     def test_POSTaddRemoveInvitees(self):
 
@@ -462,6 +464,7 @@
             ),
         ))
 
+
     @inlineCallbacks
     def test_POSTremoveNonInvitee(self):
         """
@@ -505,7 +508,7 @@
 """)
 
         propInvite = (yield self.resource.readProperty(customxml.Invite, None))
-        self.assertEquals(self._clearUIDElementValue(propInvite), customxml.Invite())
+        self.assertEquals(propInvite, None)
 
 
     @inlineCallbacks
@@ -535,9 +538,7 @@
         )
         propInvite = (yield self.resource.readProperty(customxml.Invite, None))
 
-        self.assertEquals(
-            self._clearUIDElementValue(propInvite), customxml.Invite()
-        )
+        self.assertEquals(propInvite, None)
 
 
     @inlineCallbacks
@@ -566,6 +567,7 @@
             )
         ))
 
+        self.resource.validUserIDForShare = lambda userid, request: None
         self.resource.principalForCalendarUserAddress = lambda cuaddr: None
         self.resource.principalForUID = lambda principalUID: None
 
@@ -589,7 +591,7 @@
 """)
 
         propInvite = (yield self.resource.readProperty(customxml.Invite, None))
-        self.assertEquals(self._clearUIDElementValue(propInvite), customxml.Invite())
+        self.assertEquals(propInvite, None)
 
 
     @inlineCallbacks
@@ -600,6 +602,8 @@
         access.
         """
 
+        access = "read"
+
         def stubWikiAccessMethod(userID, wikiID):
             return access
 
@@ -657,19 +661,21 @@
 
             def locateChild(self, req, segments):
                 pass
-            def renderHTTP(req):
+
+
+            def renderHTTP(self, req):
                 pass
+
+
             def ownerPrincipal(self, req):
                 return succeed(StubWikiPrincipal())
 
-
         collection = TestCollection()
         collection._share = StubShare()
         self.site.resource.putChild("wikifoo", StubWikiResource())
         request = SimpleRequest(self.site, "GET", "/wikifoo")
 
         # Simulate the wiki server granting Read access
-        access = "read"
         acl = (yield collection.shareeAccessControlList(request,
             wikiAccessMethod=stubWikiAccessMethod))
         self.assertFalse("<write/>" in acl.toxml())
@@ -681,7 +687,7 @@
         self.assertTrue("<write/>" in acl.toxml())
 
 
-"""
+'''
 class DatabaseSharingTests(SharingTests):
 
     @inlineCallbacks
@@ -693,4 +699,4 @@
     def createDataStore(self):
         return self.calendarStore
 
-"""
+'''
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20120924/e9c3c420/attachment-0001.html>


More information about the calendarserver-changes mailing list