def _invalidDefaultCalendarUpgrade_setup(self):

        # Set dead property on inbox
        for user in ("user01", "user02"):
            inbox = (yield self.calendarUnderTest(name="inbox", home=user))
            inbox.properties()[PropertyName.fromElement(ScheduleDefaultCalendarURL)] = ScheduleDefaultCalendarURL(
                HRef.fromString("/calendars/__uids__/%s/tasks_1" % (user,))
            )

            # Force current default to null
            home = (yield self.homeUnderTest(name=user))
            chm = home._homeMetaDataSchema
            yield Update({chm.DEFAULT_EVENTS: None}, Where=chm.RESOURCE_ID == home._resourceID).on(
                self.transactionUnderTest()
            )

            # Create tasks only calendar
            tasks = (yield home.createCalendarWithName("tasks_1"))
            yield tasks.setSupportedComponents("VTODO")

            # Force data version to previous
            ch = home._homeSchema
            yield Update({ch.DATAVERSION: 3}, Where=ch.RESOURCE_ID == home._resourceID).on(self.transactionUnderTest())

        yield self.commit()
Пример #2
0
    def _defaultCalendarUpgrade_setup(self):

        # Set dead property on inbox
        for user in (
                "user01",
                "user02",
        ):
            inbox = (yield self.calendarUnderTest(name="inbox", home=user))
            inbox.properties()[PropertyName.fromElement(
                ScheduleDefaultCalendarURL)] = ScheduleDefaultCalendarURL(
                    HRef.fromString("/calendars/__uids__/%s/calendar_1" %
                                    (user, )))

            # Force current default to null
            home = (yield self.homeUnderTest(name=user))
            chm = home._homeMetaDataSchema
            yield Update(
                {
                    chm.DEFAULT_EVENTS: None
                },
                Where=chm.RESOURCE_ID == home._resourceID,
            ).on(self.transactionUnderTest())

            # Force data version to previous
            ch = home._homeSchema
            yield Update(
                {
                    ch.DATAVERSION: 3
                },
                Where=ch.RESOURCE_ID == home._resourceID,
            ).on(self.transactionUnderTest())

        yield self.commit()
Пример #3
0
class CurrentUserPrincipalTests(WebDAVElementTestsMixin, TestCase):
    """
    Tests for L{CurrentUserPrincipal}.
    """
    serialized = ("""<?xml version="1.0" encoding="utf-8" ?>"""
                  """<D:current-user-principal xmlns:D="DAV:">"""
                  """  <D:href>foo</D:href>"""
                  """</D:current-user-principal>""")

    element = CurrentUserPrincipal(HRef("foo"))
Пример #4
0
 def test_isOwnerUnauthenticated(self):
     """
     L{CalDAVResource.isOwner} returns C{False} for unauthenticated requests.
     """
     site = None
     request = SimpleRequest(site, "GET", "/not/a/real/url/")
     request.authzUser = request.authnUser = None
     rsrc = CalDAVResource()
     rsrc.owner = lambda igreq: HRef("/somebody/")
     self.assertEquals((yield rsrc.isOwner(request)), False)
Пример #5
0
 def test_isOwnerYes(self):
     """
     L{CalDAVResource.isOwner} returns C{True} for authenticated requests
     with a principal that matches the resource's owner.
     """
     site = None
     request = SimpleRequest(site, "GET", "/not/a/real/url/")
     request.authzUser = request.authnUser = StubPrincipal("/yes-i-am-the-owner/")
     rsrc = CalDAVResource()
     rsrc.owner = lambda igreq: HRef("/yes-i-am-the-owner/")
     self.assertEquals((yield rsrc.isOwner(request)), True)
Пример #6
0
 def test_isOwnerReadPrincipal(self):
     """
     L{CalDAVResource.isOwner} returns C{True} for authenticated requests
     with a principal that matches any principal configured in the
     L{AdminPrincipals} list.
     """
     theAdmin = "/read-only-admin/"
     self.patch(config, "ReadPrincipals", [theAdmin])
     site = None
     request = SimpleRequest(site, "GET", "/not/a/real/url/")
     request.authzUser = request.authnUser = StubPrincipal(theAdmin)
     rsrc = CalDAVResource()
     rsrc.owner = lambda igreq: HRef("/some-other-user/")
     self.assertEquals((yield rsrc.isOwner(request)), True)
Пример #7
0
class MultiStatusTests(WebDAVElementTestsMixin, TestCase):
    """
    Tests for L{MultiStatus}
    """
    serialized = (
        """<?xml version="1.0" encoding="utf-8" ?>"""
        """<D:multistatus xmlns:D="DAV:">"""
        """  <D:response>"""
        """    <D:href>http://webdav.sb.aol.com/webdav/secret</D:href>"""
        """    <D:status>HTTP/1.1 403 Forbidden</D:status>"""
        """  </D:response>"""
        """</D:multistatus>""")

    element = MultiStatus(
        Response(HRef("http://webdav.sb.aol.com/webdav/secret"),
                 Status("HTTP/1.1 403 Forbidden")), )
    def _calendarTranspUpgrade_setup(self):

        # Set dead property on inbox
        for user in ("user01", "user02"):
            inbox = (yield self.calendarUnderTest(name="inbox", home=user))
            inbox.properties()[PropertyName.fromElement(CalendarFreeBusySet)] = CalendarFreeBusySet(
                HRef.fromString("/calendars/__uids__/%s/calendar_1" % (user,))
            )

            # Force current to transparent
            calendar = (yield self.calendarUnderTest(name="calendar_1", home=user))
            yield calendar.setUsedForFreeBusy(False)
            calendar.properties()[PropertyName.fromElement(ScheduleCalendarTransp)] = ScheduleCalendarTransp(
                Opaque() if user == "user01" else Transparent()
            )

            # Force data version to previous
            home = (yield self.homeUnderTest(name=user))
            ch = home._homeSchema
            yield Update({ch.DATAVERSION: 3}, Where=ch.RESOURCE_ID == home._resourceID).on(self.transactionUnderTest())

        yield self.commit()

        for user in ("user01", "user02"):
            calendar = (yield self.calendarUnderTest(name="calendar_1", home=user))
            self.assertFalse(calendar.isUsedForFreeBusy())
            self.assertTrue(PropertyName.fromElement(ScheduleCalendarTransp) in calendar.properties())
            inbox = (yield self.calendarUnderTest(name="inbox", home=user))
            self.assertTrue(PropertyName.fromElement(CalendarFreeBusySet) in inbox.properties())
        yield self.commit()

        # Create "fake" entry for non-existent share
        txn = self.transactionUnderTest()
        calendar = (yield self.calendarUnderTest(name="calendar_1", home="user01"))
        rp = schema.RESOURCE_PROPERTY
        yield Insert(
            {
                rp.RESOURCE_ID: calendar._resourceID,
                rp.NAME: PropertyName.fromElement(ScheduleCalendarTransp).toString(),
                rp.VALUE: ScheduleCalendarTransp(Opaque()).toxml(),
                rp.VIEWER_UID: "user03",
            }
        ).on(txn)
        yield self.commit()
Пример #9
0
    def _calendarTranspUpgrade_setup(self):

        # Set dead property on inbox
        for user in (
                "user01",
                "user02",
        ):
            inbox = (yield self.calendarUnderTest(name="inbox", home=user))
            inbox.properties()[PropertyName.fromElement(
                CalendarFreeBusySet)] = CalendarFreeBusySet(
                    HRef.fromString("/calendars/__uids__/%s/calendar_1" %
                                    (user, )))

            # Force current to transparent
            calendar = (yield self.calendarUnderTest(name="calendar_1",
                                                     home=user))
            yield calendar.setUsedForFreeBusy(False)
            calendar.properties()[PropertyName.fromElement(
                ScheduleCalendarTransp)] = ScheduleCalendarTransp(
                    Opaque() if user == "user01" else Transparent())

            # Force data version to previous
            home = (yield self.homeUnderTest(name=user))
            ch = home._homeSchema
            yield Update(
                {
                    ch.DATAVERSION: 3
                },
                Where=ch.RESOURCE_ID == home._resourceID,
            ).on(self.transactionUnderTest())

        yield self.commit()

        for user in (
                "user01",
                "user02",
        ):
            calendar = (yield self.calendarUnderTest(name="calendar_1",
                                                     home=user))
            self.assertFalse(calendar.isUsedForFreeBusy())
            self.assertTrue(
                PropertyName.fromElement(ScheduleCalendarTransp) in
                calendar.properties())
            inbox = (yield self.calendarUnderTest(name="inbox", home=user))
            self.assertTrue(
                PropertyName.fromElement(CalendarFreeBusySet) in
                inbox.properties())
        yield self.commit()

        # Create "fake" entry for non-existent share
        txn = self.transactionUnderTest()
        calendar = (yield self.calendarUnderTest(name="calendar_1",
                                                 home="user01"))
        rp = schema.RESOURCE_PROPERTY
        yield Insert({
            rp.RESOURCE_ID:
            calendar._resourceID,
            rp.NAME:
            PropertyName.fromElement(ScheduleCalendarTransp).toString(),
            rp.VALUE:
            ScheduleCalendarTransp(Opaque()).toxml(),
            rp.VIEWER_UID:
            "user03",
        }).on(txn)
        yield self.commit()
    def _defaultCalendarUpgrade_setup(self):

        # Set dead property on inbox
        for user in ("user01", "user02",):
            inbox = (yield self.calendarUnderTest(name="inbox", home=user))
            inbox.properties()[PropertyName.fromElement(ScheduleDefaultCalendarURL)] = ScheduleDefaultCalendarURL(HRef.fromString("/calendars/__uids__/%s/calendar_1" % (user,)))

            # Force current default to null
            home = (yield self.homeUnderTest(name=user))
            chm = home._homeMetaDataSchema
            yield Update(
                {chm.DEFAULT_EVENTS: None},
                Where=chm.RESOURCE_ID == home._resourceID,
            ).on(self.transactionUnderTest())

            # Force data version to previous
            ch = home._homeSchema
            yield Update(
                {ch.DATAVERSION: 3},
                Where=ch.RESOURCE_ID == home._resourceID,
            ).on(self.transactionUnderTest())

        yield self.commit()