示例#1
0
    def test_POSTaddMoreInvitees(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>
            """)
        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>Your Shared Calendar</CS:summary>
                    <CS:read-write/>
                </CS:set>
                <CS:set>
                    <D:href>mailto:[email protected]</D:href>
                    <CS:summary>Your 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(),
                ),
                customxml.InviteUser(
                    customxml.UID.fromString(""),
                    davxml.HRef.fromString("urn:x-uid:user03"),
                    customxml.CommonName.fromString("User 03"),
                    customxml.InviteAccess(customxml.ReadWriteAccess()),
                    customxml.InviteStatusNoResponse(),
                ),
                customxml.InviteUser(
                    customxml.UID.fromString(""),
                    davxml.HRef.fromString("urn:x-uid:user04"),
                    customxml.CommonName.fromString("User 04"),
                    customxml.InviteAccess(customxml.ReadWriteAccess()),
                    customxml.InviteStatusNoResponse(),
                ),
            ))
示例#2
0
    def test_POSTremoveInvalidInvitee(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(),
                )))

        record = yield self.userRecordWithShortName("user02")
        yield self.changeRecord(record, self.directory.fieldName.hasCalendars,
                                False)

        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.InviteStatusInvalid(),
                )))

        yield self._doPOST("""<?xml version="1.0" encoding="utf-8" ?>
            <CS:share xmlns:D="DAV:" xmlns:CS="http://calendarserver.org/ns/">
                <CS:remove>
                    <D:href>urn:x-uid:user02</D:href>
                </CS:remove>
            </CS:share>
            """)

        propInvite = (yield self.resource.readProperty(customxml.Invite, None))
        self.assertEquals(propInvite, None)
示例#3
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())
示例#4
0
    def test_POSTShareeRemoveWithMissingSharer(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))
        uid = self._getUIDElementValue(propInvite)
        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(),
                ), ))

        result = (yield self._doPOSTSharerAccept(
            """<?xml version='1.0' encoding='UTF-8'?>
            <invite-reply xmlns='http://calendarserver.org/ns/'>
              <href xmlns='DAV:'>mailto:[email protected]</href>
              <invite-accepted/>
              <hosturl>
                <href xmlns='DAV:'>/calendars/__uids__/user01/calendar/</href>
              </hosturl>
              <in-reply-to>%s</in-reply-to>
              <summary>The Shared Calendar</summary>
              <common-name>User 02</common-name>
              <first-name>user</first-name>
              <last-name>02</last-name>
            </invite-reply>
            """ % (uid, )))
        href = self._getHRefElementValue(result) + "/"

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

        resource = (yield self._getResourceSharer(href))
        yield resource.removeShareeResource(
            SimpleStoreRequest(self, "DELETE", href))

        resource = (yield self._getResourceSharer(href))
        self.assertFalse(resource.exists())
示例#5
0
            def invitePropertyElement(invitation, includeUID=True):

                userid = "urn:x-uid:" + invitation.shareeUID
                principal = yield self.principalForUID(invitation.shareeUID)
                cn = principal.displayName() if principal else invitation.shareeUID
                returnValue(customxml.InviteUser(
                    customxml.UID.fromString(invitation.uid) if includeUID else None,
                    element.HRef.fromString(userid),
                    customxml.CommonName.fromString(cn),
                    customxml.InviteAccess(invitationBindModeToXMLMap[invitation.mode]()),
                    invitationBindStatusToXMLMap[invitation.status](),
                ))
示例#6
0
    def test_shareeInviteWithDisabledSharer(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))
        uid = self._getUIDElementValue(propInvite)
        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(),
                ), ))

        result = (yield self._doPOSTSharerAccept(
            """<?xml version='1.0' encoding='UTF-8'?>
            <invite-reply xmlns='http://calendarserver.org/ns/'>
              <href xmlns='DAV:'>mailto:[email protected]</href>
              <invite-accepted/>
              <hosturl>
                <href xmlns='DAV:'>/calendars/__uids__/user01/calendar/</href>
              </hosturl>
              <in-reply-to>%s</in-reply-to>
              <summary>The Shared Calendar</summary>
              <common-name>User 02</common-name>
              <first-name>user</first-name>
              <last-name>02</last-name>
            </invite-reply>
            """ % (uid, )))
        href = self._getHRefElementValue(result) + "/"

        record = yield self.userRecordWithShortName("user01")
        yield self.changeRecord(record, self.directory.fieldName.hasCalendars,
                                False)

        resource = (yield self._getResourceSharer(href))
        propInvite = yield resource.inviteProperty(None)
        self.assertEquals(
            self._clearUIDElementValue(propInvite),
            customxml.Invite(
                customxml.Organizer(
                    davxml.HRef.fromString("/principals/__uids__/user01/"),
                    customxml.CommonName.fromString("User 01"),
                ),
                customxml.InviteUser(
                    davxml.HRef.fromString("urn:x-uid:user02"),
                    customxml.CommonName.fromString("User 02"),
                    customxml.InviteAccess(customxml.ReadWriteAccess()),
                    customxml.InviteStatusAccepted(),
                ),
            ))