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