Esempio n. 1
0
    def test_POSTDowngradeWithMissingInvitee(self):

        yield self.resource.upgradeToShare()

        yield self._doPOST("""<?xml version="1.0" encoding="utf-8" ?>
            <CS:share xmlns:D="DAV:" xmlns:CS="http://calendarserver.org/ns/">
                <CS:set>
                    <D:href>mailto:[email protected]</D:href>
                    <CS:summary>My Shared Calendar</CS:summary>
                    <CS:read-write/>
                </CS:set>
            </CS:share>
            """)

        propInvite = (yield self.resource.readProperty(customxml.Invite, None))
        self.assertEquals(
            self._clearUIDElementValue(propInvite),
            customxml.Invite(
                customxml.InviteUser(
                    customxml.UID.fromString(""),
                    davxml.HRef.fromString("urn:x-uid:user02"),
                    customxml.CommonName.fromString("User 02"),
                    customxml.InviteAccess(customxml.ReadWriteAccess()),
                    customxml.InviteStatusNoResponse(),
                ), ))

        yield self.directory.removeRecords(
            ((yield self.userUIDFromShortName("user02")), ))
        self.assertTrue((yield self.userUIDFromShortName("user02")) is None)

        yield self.resource.downgradeFromShare(norequest())
Esempio n. 2
0
    def test_POSTDowngradeWithMissingInvitee(self):

        yield self.resource.upgradeToShare()

        yield self._doPOST("""<?xml version="1.0" encoding="utf-8" ?>
            <CS:share xmlns:D="DAV:" xmlns:CS="http://calendarserver.org/ns/">
                <CS:set>
                    <D:href>mailto:[email protected]</D:href>
                    <CS:summary>My Shared Calendar</CS:summary>
                    <CS:read-write/>
                </CS:set>
            </CS:share>
            """)

        propInvite = (yield self.resource.readProperty(customxml.Invite, None))
        self.assertEquals(self._clearUIDElementValue(propInvite), customxml.Invite(
            customxml.InviteUser(
                customxml.UID.fromString(""),
                davxml.HRef.fromString("urn:x-uid:user02"),
                customxml.CommonName.fromString("User 02"),
                customxml.InviteAccess(customxml.ReadWriteAccess()),
                customxml.InviteStatusNoResponse(),
            ),
        ))

        yield self.directory.removeRecords(((yield self.userUIDFromShortName("user02")),))
        self.assertTrue((yield self.userUIDFromShortName("user02")) is None)

        yield self.resource.downgradeFromShare(norequest())
Esempio n. 3
0
    def test_POSTDowngradeWithDisabledInvitee(self):

        yield self.resource.upgradeToShare()

        yield self._doPOST("""<?xml version="1.0" encoding="utf-8" ?>
            <CS:share xmlns:D="DAV:" xmlns:CS="http://calendarserver.org/ns/">
                <CS:set>
                    <D:href>mailto:[email protected]</D:href>
                    <CS:summary>My Shared Calendar</CS:summary>
                    <CS:read-write/>
                </CS:set>
            </CS:share>
            """)

        propInvite = (yield self.resource.readProperty(customxml.Invite, None))
        self.assertEquals(self._clearUIDElementValue(propInvite), customxml.Invite(
            customxml.InviteUser(
                customxml.UID.fromString(""),
                davxml.HRef.fromString("urn:uuid:user02"),
                customxml.CommonName.fromString("USER02"),
                customxml.InviteAccess(customxml.ReadWriteAccess()),
                customxml.InviteStatusNoResponse(),
            ),
        ))

        self.patch(FakePrincipal, "invalid_names", set(("user02",)))
        yield self.resource.downgradeFromShare(norequest())
 def _refreshRoot(self, request=None):
     if request is None:
         request = norequest()
     result = yield super(SharingTests, self)._refreshRoot(request)
     self.resource = (
         yield self.site.resource.locateChild(request, ["calendar"])
     )[0]
     returnValue(result)
 def _refreshRoot(self, request=None):
     if request is None:
         request = norequest()
     result = yield super(SharingTests, self)._refreshRoot(request)
     self.resource = (
         yield self.site.resource.locateChild(request, ["calendar"])
     )[0]
     self.site.resource.responseCache = StubResponseCacheResource()
     self.site.resource.putChild("calendars", self.homeProvisioner)
     returnValue(result)
Esempio n. 6
0
 def _refreshRoot(self, request=None):
     if request is None:
         request = norequest()
     result = yield super(SharingTests, self)._refreshRoot(request)
     self.resource = (yield
                      self.site.resource.locateChild(request,
                                                     ["calendar"]))[0]
     self.site.resource.responseCache = StubResponseCacheResource()
     self.site.resource.putChild("calendars", self.homeProvisioner)
     returnValue(result)
    def setUp(self):
        yield super(SharingTests, self).setUp()

        self.patch(config.Sharing, "Enabled", True)
        self.patch(config.Sharing.Calendars, "Enabled", True)

        self.resource = (
            yield self.site.resource.locateChild(norequest(), ["calendar"])
        )[0]
        self.site.resource.putChild("calendar", self.resource)

        CalDAVResource.validUserIDForShare = self._fakeValidUserID
        CalDAVResource.validUserIDWithCommonNameForShare = self._fakeValidUserID
        CalDAVResource.sendInvite = lambda self, record, request: succeed(True)
        CalDAVResource.removeInvite = lambda self, record, request: succeed(True)

        CalDAVResource.principalForCalendarUserAddress = lambda self, cuaddr: SharingTests.FakePrincipal(cuaddr)