示例#1
0
    def setupRights(self, username, rights=None):
        if rights is not None:
            rights_str = "".join(
                ["<%s/>" % x for x in self.rightsToSOGoRights(rights)])
            aclQuery = ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
                        "<acl-query" +
                        " xmlns=\"urn:inverse:params:xml:ns:inverse-dav\">" +
                        "<set-roles user=\"%s\">%s</set-roles>" %
                        (xml.sax.saxutils.escape(username), rights_str) +
                        "</acl-query>")
        else:
            aclQuery = ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
                        "<acl-query" +
                        " xmlns=\"urn:inverse:params:xml:ns:inverse-dav\">" +
                        "<remove-user user=\"%s\"/>" %
                        xml.sax.saxutils.escape(username) + "</acl-query>")

        post = webdavlib.HTTPPOST(self.resource, aclQuery)
        post.content_type = "application/xml; charset=\"utf-8\""
        self.client.execute(post)

        if rights is None:
            err_msg = (
                "rights modification: failure to remove entry (status: %d)" %
                post.response["status"])
        else:
            err_msg = (
                "rights modification: failure to set '%s' (status: %d)" %
                (rights_str, post.response["status"]))
        self.test.assertEquals(post.response["status"], 204, err_msg)
示例#2
0
    def _urlPostData(self, client, url, data, exp_status=200):
        post = webdavlib.HTTPPOST(url, data)
        post.content_type = "application/x-www-form-urlencoded"
        post.cookie = self.cookie

        client.execute(post)
        if (exp_status is not None):
            self.assertEquals(post.response["status"], exp_status)
        return post.response
示例#3
0
    def _urlPostData(self, client, url, data, exp_status=200):
        post = webdavlib.HTTPPOST(url, simplejson.dumps(data))
        post.content_type = "application/json"
        post.cookie = self.cookie

        client.execute(post)
        if (exp_status is not None):
            self.assertEquals(post.response["status"], exp_status)
        return post.response
示例#4
0
 def _subscriptionOperation(self, subscribers, operation):
     subscribeQuery = ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
                       "<%s" % operation +
                       " xmlns=\"urn:inverse:params:xml:ns:inverse-dav\"")
     if (subscribers is not None):
         subscribeQuery = (subscribeQuery +
                           " users=\"%s\"" % ",".join(subscribers))
     subscribeQuery = subscribeQuery + "/>"
     post = webdavlib.HTTPPOST(self.resource, subscribeQuery)
     post.content_type = "application/xml; charset=\"utf-8\""
     self.client.execute(post)
     self.test.assertEquals(
         post.response["status"], 204,
         "subscribtion failure to '%s' for '%s' (status: %d)" %
         (self.resource, "', '".join(subscribers), post.response["status"]))