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)
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)
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)