def _setClassification(self, user, component, classification=""): resource = '/SOGo/dav/%s/Calendar/' % user props = { "{urn:inverse:params:xml:ns:inverse-dav}%s-default-classification" % component: classification } proppatch = webdavlib.WebDAVPROPPATCH(resource, props) client = webdavlib.WebDAVClient(hostname, port, username, password) client.execute(proppatch) return (proppatch.response["status"] == 207)
def UploadSignature(client, user, signature): collection = '/SOGo/dav/%s/' % user proppatch \ = webdavlib.WebDAVPROPPATCH(collection, { "{%s}signature" % xmlns_inversedav: \ signature.encode("utf-8") }) client.execute(proppatch) if (proppatch.response["status"] < 200 or proppatch.response["status"] > 399): print "Failure uploading signature for user '%s': %d" \ % (user, proppatch.response["status"])
def _setMemberSet(self, owner, members, perm): resource = '/SOGo/dav/%s/calendar-proxy-%s/' % (owner, perm) membersHref = [{"{DAV:}href": '/SOGo/dav/%s/' % x} for x in members] props = {"{DAV:}group-member-set": membersHref} proppatch = webdavlib.WebDAVPROPPATCH(resource, props) client = webdavlib.WebDAVClient(hostname, port, superuser, superuser_password) client.user_agent = "DAVKit/4.0.1 (730); CalendarStore/4.0.1 (973); iCal/4.0.1 (1374); Mac OS X/10.6.2 (10C540)" client.execute(proppatch) self.assertEquals( proppatch.response["status"], 207, "failure (%s) setting '%s' permission for '%s' on %s's calendars" % (proppatch.response["status"], perm, "', '".join(members), owner))
def _setCategories(self, user, categories=None): resource = '/SOGo/dav/%s/Contacts/' % user if categories is None: categories = [] elements = [{ "{urn:inverse:params:xml:ns:inverse-dav}category": x } for x in categories] props = { "{urn:inverse:params:xml:ns:inverse-dav}contacts-categories": elements } proppatch = webdavlib.WebDAVPROPPATCH(resource, props) client = webdavlib.WebDAVClient(hostname, port, username, password) client.execute(proppatch) self.assertEquals( proppatch.response["status"], 207, "failure (%s) setting '%s' categories on %s's contacts" % (proppatch.response["status"], "', '".join(categories), user))
def testDavScheduleCalendarTransparency(self): """{urn:ietf:params:xml:ns:caldav}schedule-calendar-transp""" ## PROPFIND propfind = webdavlib.WebDAVPROPFIND( self.test_calendar, ["{urn:ietf:params:xml:ns:caldav}schedule-calendar-transp"], 0) self.client.execute(propfind) response = propfind.response["document"].find('{DAV:}response') propstat = response.find('{DAV:}propstat') status = propstat.find('{DAV:}status').text[9:12] self.assertEquals( status, "200", "schedule-calendar-transp marked as 'Not Found' in response") transp = propstat.find( '{DAV:}prop/{urn:ietf:params:xml:ns:caldav}schedule-calendar-transp' ) values = transp.getchildren() self.assertEquals(len(values), 1, "one and only one element expected") value = values[0] self.assertTrue(xml.etree.ElementTree.iselement(value)) ns = value.tag[0:31] tag = value.tag[31:] self.assertTrue(ns == "{urn:ietf:params:xml:ns:caldav}", "schedule-calendar-transp must have a value in"\ " namespace '%s', not '%s'" % ("urn:ietf:params:xml:ns:caldav", ns)) self.assertTrue(tag == "opaque", "schedule-calendar-transp must be 'opaque' on new" \ " collections, not '%s'" % tag) ## PROPPATCH newValueNode = "{urn:ietf:params:xml:ns:caldav}thisvaluedoesnotexist" proppatch = webdavlib.WebDAVPROPPATCH(self.test_calendar, {"{urn:ietf:params:xml:ns:caldav}schedule-calendar-transp": \ { newValueNode: True }}) self.client.execute(proppatch) self.assertEquals(proppatch.response["status"], 400, "expecting failure when setting transparency to" \ " an invalid value") newValueNode = "{urn:ietf:params:xml:ns:caldav}transparent" proppatch = webdavlib.WebDAVPROPPATCH(self.test_calendar, {"{urn:ietf:params:xml:ns:caldav}schedule-calendar-transp": \ { newValueNode: True }}) self.client.execute(proppatch) self.assertEquals(proppatch.response["status"], 207, "failure (%s) setting transparency to" \ " 'transparent': '%s'" % (proppatch.response["status"], proppatch.response["body"])) newValueNode = "{urn:ietf:params:xml:ns:caldav}opaque" proppatch = webdavlib.WebDAVPROPPATCH(self.test_calendar, {"{urn:ietf:params:xml:ns:caldav}schedule-calendar-transp": \ { newValueNode: True }}) self.client.execute(proppatch) self.assertEquals(proppatch.response["status"], 207, "failure (%s) setting transparency to" \ " 'transparent': '%s'" % (proppatch.response["status"], proppatch.response["body"]))