コード例 #1
0
    def setUp(self):
        self.superuser_client = webdavlib.WebDAVClient(hostname, port,
                                             superuser, superuser_password)
        self.client = webdavlib.WebDAVClient(hostname, port,
                                             username, password)
        self.attendee1_client = webdavlib.WebDAVClient(hostname, port,
                                             attendee1_username, attendee1_password)
        self.attendee1_delegate_client = webdavlib.WebDAVClient(hostname, port,
                                                                attendee1_delegate_username, attendee1_delegate_password)

        utility = utilities.TestUtility(self.test, self.client)
        (self.user_name, self.user_email) = utility.fetchUserInfo(username)
        (self.attendee1_name, self.attendee1_email) = utility.fetchUserInfo(attendee1)
        (self.attendee1_delegate_name, self.attendee1_delegate_email) = utility.fetchUserInfo(attendee1_delegate)

        self.user_calendar = "/SOGo/dav/%s/Calendar/personal/" % username
        self.attendee1_calendar = "/SOGo/dav/%s/Calendar/personal/" % attendee1
        self.attendee1_delegate_calendar = "/SOGo/dav/%s/Calendar/personal/" % attendee1_delegate

        # fetch non existing event to let sogo create the calendars in the db
        self._getEvent(self.client, "%snonexistent" % self.user_calendar, exp_status=404)
        self._getEvent(self.attendee1_client, "%snonexistent" % self.attendee1_calendar, exp_status=404)
        self._getEvent(self.attendee1_delegate_client, "%snonexistent" %
                        self.attendee1_delegate_calendar, exp_status=404)

        # list of ics used by the test.
        # tearDown will loop over this and wipe them in all users' calendar
        self.ics_list = []
コード例 #2
0
 def setUp(self):
     self.createdRsrc = None
     self.superuser_client = webdavlib.WebDAVClient(hostname, port,
                                                    superuser,
                                                    superuser_password)
     self.client = webdavlib.WebDAVClient(hostname, port, username,
                                          password)
     self.subscriber_client = webdavlib.WebDAVClient(
         hostname, port, subscriber_username, subscriber_password)
     self.anon_client = webdavlib.WebDAVClient(hostname, port)
コード例 #3
0
    def __init__(self, otherLogin=None, otherPassword=None):
        if otherLogin and otherPassword:
            self.login = otherLogin
            self.passw = otherPassword

        self.client = webdavlib.WebDAVClient(hostname, port)

        authCookie = sogoLogin.getAuthCookie(hostname, port, username,
                                             password)
        self.cookie = authCookie

        # map between preferences/jsonDefaults and the webUI names
        # should probably be unified...
        self.preferencesMap = {
            "SOGoLanguage": "language",
            "SOGoTimeZone": "timezone",
            "SOGoSieveFilters": "sieveFilters",

            # Vacation stuff
            "Vacation": "enableVacation",  # to disable, don't specify it
            "autoReplyText": "autoReplyText",  # string
            "autoReplyEmailAddresses": "autoReplyEmailAddresses",  # LIST
            "daysBetweenResponse": "daysBetweenResponsesList",
            "ignoreLists": "ignoreLists",  #bool

            # forward stuff
            "Forward": "enableForward",  # to disable, don't specify it
            "forwardAddress": "forwardAddress",
            "keepCopy": "forwardKeepCopy",
        }
コード例 #4
0
 def setUp(self):
     self.client = webdavlib.WebDAVClient(hostname, port, username,
                                          password)
     self.test_calendar \
         = "/SOGo/dav/%s/Calendar/test-dav-properties/" % username
     mkcol = webdavlib.WebDAVMKCOL(self.test_calendar)
     self.client.execute(mkcol)
コード例 #5
0
    def __init__(self, arg):
        self.client = webdavlib.WebDAVClient(hostname, port, superuser,
                                             superuser_password)
        self.resource = "/SOGo/dav/%s/Calendar/test-dav-superuser-acl/" % subscriber_username
        self.filename = "suevent.ics"
        self.url = "%s%s" % (self.resource, self.filename)

        unittest.TestCase.__init__(self, arg)
コード例 #6
0
ファイル: test-carddav.py プロジェクト: zoosky/sogo
 def _get_dav_data(self, filename, user=username, passwd=password):
     w = webdavlib.WebDAVClient(hostname, port, user, passwd)
     query = webdavlib.HTTPGET(
         "http://localhost/SOGo/dav/%s/Calendar/personal/%s" %
         (username, filename))
     w.execute(query)
     self.assertEquals(query.response['status'], 200)
     return query.response['body'].split("\r\n")
コード例 #7
0
    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)
コード例 #8
0
 def setUp(self):
     delete = webdavlib.WebDAVDELETE(self.resource)
     self.client.execute(delete)
     mkcol = webdavlib.WebDAVMKCOL(self.resource)
     self.client.execute(mkcol)
     self.assertEquals(
         mkcol.response["status"], 201,
         "preparation: failure creating collection"
         "(code = %d)" % mkcol.response["status"])
     self.subscriber_client = webdavlib.WebDAVClient(
         hostname, port, subscriber_username, subscriber_password)
コード例 #9
0
    def __init__(self, otherLogin = None, otherPassword = None):
        if otherLogin and otherPassword:
            self.login = otherLogin
            self.passw = otherPassword

        self.client = webdavlib.WebDAVClient(hostname, port)

        authCookie = sogoLogin.getAuthCookie(hostname, port, self.login, self.passw)
        self.cookie = authCookie

        #- If this is not set, we CAN'T save preferences
        self.preferences = None
コード例 #10
0
ファイル: test-maildav.py プロジェクト: zoosky/sogo
  def setUp(self):
    self.client = webdavlib.WebDAVClient(hostname, port,
                                         username, password)
    if self.user_email is None:
      self.user_email = fetchUserEmail(username)
      if self.user_email.startswith("mailto:"):
        self.user_email = self.user_email[7:]

    self.resource = '/SOGo/dav/%s/Mail/%s_A_%s/' \
        % (username,
           username.replace("@", "_A_").replace(".", "_D_"),
           mailserver.replace(".", "_D_"))
コード例 #11
0
ファイル: test-maildav.py プロジェクト: zoosky/sogo
def fetchUserEmail(login):
  client = webdavlib.WebDAVClient(hostname, port,
                                  username, password)
  resource = '/SOGo/dav/%s/' % login
  propfind = webdavlib.WebDAVPROPFIND(resource,
                                      ["{urn:ietf:params:xml:ns:caldav}calendar-user-address-set"],
                                      0)
  client.execute(propfind)
  nodes = propfind.xpath_evaluate('{DAV:}response/{DAV:}propstat/{DAV:}prop/C:calendar-user-address-set/{DAV:}href',
                                  None)

  return nodes[0].childNodes[0].nodeValue
コード例 #12
0
ファイル: test-ical.py プロジェクト: zoosky/sogo
 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))
コード例 #13
0
ファイル: test-sieve.py プロジェクト: sarkartanzil/sogo
    def setUp(self):
        ret = ""

        self.client = webdavlib.WebDAVClient(hostname, port, username,
                                             password)
        utility = utilities.TestUtility(self, self.client)
        (self.user_name, self.user_email) = utility.fetchUserInfo(username)
        self.user_email = self.user_email.replace("mailto:", "")

        self.ms = managesieve.MANAGESIEVE(sieve_server, sieve_port)
        self.assertEqual(self.ms.login("", username, password), "OK",
                         "Couldn't login")

        self._killFilters()
コード例 #14
0
ファイル: webdavsync-tool.py プロジェクト: zoosky/sogo
def main():
  depth = 1
  synctoken = "1"
  url = None

  try:
   opts, args = getopt.getopt (sys.argv[1:], "hs:u:", \
                               ("sync-token=", "url="));
  except getopt.GetoptError:
    usage()
    exit(1)

  for o, v in opts :
    if o == "-h" :
      usage()
      exit(1)
    elif o == "-s" or o == "--sync-token" :
      synctoken = v
    elif o == "-u" or o == "--url" :
      url = v

  if url is None:
    usage()
    exit(1)

  o = urlparse.urlparse(url)
  hostname = o.hostname
  port = o.port
  username = o.username
  password = o.password
  uri = o.path

  client = webdavlib.WebDAVClient(hostname, port, username, password)

  collections = getAllCollections(client, uri)
  if len(collections) == 0:
    print "No collections found!"
    sys.exit(1)

  for collection in collections:
    changedItems = changedItemsFromCollection(client, collection) 
    # fetch the href data
    if len(changedItems) > 0:
      multiget = webdavlib.CalDAVCalendarMultiget(collection,
                                                  ["getetag", "{%s}calendar-data" % webdavlib.xmlns_caldav],
                                                  changedItems, depth)
      client.execute(multiget)
      client.conn.close()
      if (multiget.response["status"] != 207):
        raise Exception("Bad http response code: %d" % multiget.response["status"])
コード例 #15
0
ファイル: test-ical.py プロジェクト: zoosky/sogo
    def _getMembership(self, user):
        resource = '/SOGo/dav/%s/' % user
        propfind = webdavlib.WebDAVPROPFIND(resource,
                                            ["{DAV:}group-membership"], 0)
        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(propfind)

        hrefs = propfind.response["document"].findall(
            "{DAV:}response/{DAV:}propstat/{DAV:}prop/{DAV:}group-membership/{DAV:}href"
        )
        members = [x.text for x in hrefs]

        return members
コード例 #16
0
ファイル: test-ical.py プロジェクト: zoosky/sogo
    def _getProxyFor(self, user, perm):
        resource = '/SOGo/dav/%s/' % user
        prop = "{http://calendarserver.org/ns/}calendar-proxy-%s-for" % perm
        propfind = webdavlib.WebDAVPROPFIND(resource, [prop], 0)
        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(propfind)

        hrefs = propfind.response["document"].findall(
            "{DAV:}response/{DAV:}propstat/{DAV:}prop/{http://calendarserver.org/ns/}calendar-proxy-%s-for/{DAV:}href"
            % perm)
        members = [x.text[len("/SOGo/dav/"):-1] for x in hrefs]

        return members
コード例 #17
0
 def run(self):
     client = webdavlib.WebDAVClient(hostname, port, self.username,
                                     password)
     resource = "/SOGo/dav/%s/Calendar/personal/" % self.username
     startTime = time.time()
     query = webdavlib.WebDAVSyncQuery(resource, None,
                                       ["getetag", "calendar-data"])
     client.execute(query)
     if query.response["status"] != 207:
         print "*** received unexpected code: %d (%s)" \
               % (query.response["status"], resource)
     endTime = time.time()
     headers = query.response["headers"]
     if headers.has_key(durationHeader):
         self.sogoTime = float(headers[durationHeader])
     self.time = endTime - startTime
コード例 #18
0
    def _getClassification(self, user, component):
        resource = '/SOGo/dav/%s/Calendar/' % user
        property_name = "{urn:inverse:params:xml:ns:inverse-dav}%s-default-classification" % component
        propfind = webdavlib.WebDAVPROPFIND(resource, [property_name], "0")
        client = webdavlib.WebDAVClient(hostname, port, username, password)
        client.execute(propfind)
        classification = None
        propstat_nodes = propfind.response["document"].findall(
            "{DAV:}response/{DAV:}propstat")
        for propstat_node in propstat_nodes:
            status_nodes = propstat_node.findall("{DAV:}status")
            if status_nodes[0].text.lower() == "http/1.1 200 ok":
                property_nodes = propstat_node.findall("{DAV:}prop/%s" %
                                                       property_name)
                if len(property_nodes) > 0:
                    classification = property_nodes[0].text

        return classification
コード例 #19
0
 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))
コード例 #20
0
    def uploadEntries(self, entries, extension, mimeType):
        isatty = sys.stdout.isatty()  # enable progressive display of summary
        success = 0
        failure = 0
        client = webdavlib.WebDAVClient(self.webdavConfig["hostname"],
                                        self.webdavConfig["port"],
                                        self.webdavConfig["username"],
                                        self.webdavConfig["password"])
        collection = '/SOGo/dav/%s/Contacts/personal' % self.currentUser

        mkcol = webdavlib.WebDAVMKCOL(collection)
        client.execute(mkcol)

        for entryName in entries.keys():
            entry = entries[entryName]
            if entry.has_key("data"):
                fullFilename = "%s.%s" % (entry["filename"], extension)
                url = "%s/%s" % (collection, fullFilename)
                put = webdavlib.HTTPPUT(url, entry["data"])
                put.content_type = mimeType
                client.execute(put)
                if (put.response["status"] < 200
                        or put.response["status"] > 399):
                    failure = failure + 1
                    print "  error uploading '%s': %d" \
                        % (fullFilename, put.response["status"])
                else:
                    success = success + 1
                if isatty:
                    print "\r  successes: %d; failures: %d" % (success,
                                                               failure),
                    if (success + failure) % 5 == 0:
                        sys.stdout.flush()
        if isatty:
            print ""
        else:
            if (success + failure) > 0:
                print "  successes: %d; failures: %d\n" % (success, failure)
                sys.stdout.flush()
コード例 #21
0
    def _getCategories(self, user):
        resource = '/SOGo/dav/%s/Contacts/' % user
        props = ["{urn:inverse:params:xml:ns:inverse-dav}contacts-categories"]
        propfind = webdavlib.WebDAVPROPFIND(resource, props, "0")
        client = webdavlib.WebDAVClient(hostname, port, username, password)
        client.execute(propfind)
        self.assertEquals(
            propfind.response["status"], 207,
            "failure (%s) getting categories on %s's contacts" %
            (propfind.response["status"], user))

        categories = []
        prop_nodes = propfind.response["document"].findall(
            "{DAV:}response/{DAV:}propstat/{DAV:}prop/{urn:inverse:params:xml:ns:inverse-dav}contacts-categories"
        )
        for prop_node in prop_nodes:
            cat_nodes = prop_node.findall(
                "{urn:inverse:params:xml:ns:inverse-dav}category")
            if cat_nodes is not None:
                for cat_node in cat_nodes:
                    categories.append(cat_node.text)

        return categories
コード例 #22
0
ファイル: test-ical.py プロジェクト: zoosky/sogo
    def testPrincipalCollectionSet(self):
        """principal-collection-set: 'DAV' header must be returned with iCal 4"""
        client = webdavlib.WebDAVClient(hostname, port, username, password)
        resource = '/SOGo/dav/%s/' % username

        # NOT iCal4
        propfind = webdavlib.WebDAVPROPFIND(resource,
                                            ["{DAV:}principal-collection-set"],
                                            0)
        client.execute(propfind)
        self.assertEquals(propfind.response["status"], 207)
        headers = propfind.response["headers"]
        self.assertFalse(
            headers.has_key("dav"),
            "DAV header must not be returned when user-agent is NOT iCal 4")

        # iCal4
        propfind = webdavlib.WebDAVPROPFIND(resource,
                                            ["{DAV:}principal-collection-set"],
                                            0)
        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(propfind)
        self.assertEquals(propfind.response["status"], 207)
        headers = propfind.response["headers"]
        self.assertTrue(
            headers.has_key("dav"),
            "DAV header must be returned when user-agent is iCal 4")

        expectedDAVClasses = [
            "1", "2", "access-control", "calendar-access", "calendar-schedule",
            "calendar-auto-schedule", "calendar-proxy"
        ]
        davClasses = [x.strip() for x in headers["dav"].split(",")]
        for davClass in expectedDAVClasses:
            self.assertTrue(davClass in davClasses,
                            "DAV class '%s' not found" % davClass)
コード例 #23
0
 def setUp(self):
     self.client = webdavlib.WebDAVClient(hostname, port)
     self.gcClient = webdavlib.WebDAVClient(hostname, port)
     self.cookie = sogoLogin.getAuthCookie(hostname, port, username,
                                           password)
コード例 #24
0
ファイル: test-webdavsync.py プロジェクト: exekias/sogo
 def setUp(self):
     self.client = webdavlib.WebDAVClient(hostname, port, username,
                                          password)
コード例 #25
0
ファイル: propfind.py プロジェクト: zoosky/sogo
    if (pair[0] == "-d" or pair[0] == "--depth"):
        depth = pair[1]
    elif (pair[0] == "-q" or pair[0] == "--quiet"):
        quiet = True

# print "depth: " + depth

nargs = len(args)
if (nargs > 0):
    resource = args[0]
    if (nargs > 1):
        properties = args[1:]
    else:
        properties = ["allprop"]
else:
    print "resource required"
    sys.exit(-1)

client = webdavlib.WebDAVClient(hostname, port, username, password)
propfind = webdavlib.WebDAVPROPFIND(resource, properties, depth)
client.execute(propfind)

sys.stderr.write("response:\n\n")
print propfind.response["body"]

if propfind.response.has_key("document"):
    sys.stderr.write("document tree:\n")
    elem = propfind.response["document"]
    dom = xml.dom.minidom.parseString(xml.etree.ElementTree.tostring(elem))
    print dom.toprettyxml()
コード例 #26
0
    if (proppatch.response["status"] < 200
            or proppatch.response["status"] > 399):
        print "Failure uploading signature for user '%s': %d" \
            % (user, proppatch.response["status"])


if __name__ == "__main__":
    if len(sys.argv) > 1:
        user = sys.argv[1]
    else:
        raise Exception, "<user> argument must be specified" \
            " (use 'ALL' for everyone)"

    conn = MySQLdb.connect(host=dbConfig["hostname"],
                           user=dbConfig["username"],
                           passwd=dbConfig["password"],
                           db=dbConfig["database"],
                           use_unicode=True)

    cnv = HordeSignatureConverter.HordeSignatureConverter(user, "DOMAIN.COM")
    signatures = cnv.fetchSignatures(conn)
    conn.close()

    client = webdavlib.WebDAVClient(webdavConfig["hostname"],
                                    webdavConfig["port"],
                                    webdavConfig["username"],
                                    webdavConfig["password"])
    for user in signatures:
        signature = signatures[user]
        UploadSignature(client, user, signature)
コード例 #27
0
ファイル: test-webdav.py プロジェクト: zoosky/sogo
 def __init__(self, arg):
     unittest.TestCase.__init__(self, arg)
     self.client = webdavlib.WebDAVClient(hostname, port,
                                          username, password)
     self.dav_utility = utilities.TestUtility(self, self.client)
コード例 #28
0
 def setUp(self):
     self.client = webdavlib.WebDAVClient(hostname, port)
     self.anon_client = webdavlib.WebDAVClient(hostname, port)
     self.dav_utility = utilities.TestUtility(self, self.client)
コード例 #29
0
ファイル: test-ical.py プロジェクト: zoosky/sogo
    def testCalendarProxy2(self):
        """calendar-proxy as used from SOGo"""
        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)"
        personal_resource = "/SOGo/dav/%s/Calendar/personal/" % username
        dav_utility = utilities.TestCalendarACLUtility(self, client,
                                                       personal_resource)
        dav_utility.setupRights(subscriber_username, {})
        dav_utility.subscribe([subscriber_username])

        other_resource = ("/SOGo/dav/%s/Calendar/test-calendar-proxy2/" %
                          username)
        delete = webdavlib.WebDAVDELETE(other_resource)
        client.execute(delete)
        mkcol = webdavlib.WebDAVMKCOL(other_resource)
        client.execute(mkcol)
        dav_utility = utilities.TestCalendarACLUtility(self, client,
                                                       other_resource)
        dav_utility.setupRights(subscriber_username, {})
        dav_utility.subscribe([subscriber_username])

        ## we test the rights mapping
        # write: write on 'personal', none on 'test-calendar-proxy2'
        self._testMapping(client, "write", personal_resource, {
            "c": True,
            "d": False,
            "pu": "v"
        })
        self._testMapping(client, "write", personal_resource, {
            "c": False,
            "d": True,
            "pu": "v"
        })
        self._testMapping(client, "write", personal_resource, {
            "c": False,
            "d": False,
            "pu": "m"
        })
        self._testMapping(client, "write", personal_resource, {
            "c": False,
            "d": False,
            "pu": "r"
        })

        # read: read on 'personal', none on 'test-calendar-proxy2'
        self._testMapping(client, "read", personal_resource, {
            "c": False,
            "d": False,
            "pu": "d"
        })
        self._testMapping(client, "read", personal_resource, {
            "c": False,
            "d": False,
            "pu": "v"
        })

        # write: read on 'personal', write on 'test-calendar-proxy2'
        self._testMapping(client, "write", other_resource, {
            "c": False,
            "d": False,
            "pu": "r"
        })

        ## we test the unsubscription
        # unsubscribed from personal, subscribed to 'test-calendar-proxy2'
        dav_utility = utilities.TestCalendarACLUtility(self, client,
                                                       personal_resource)
        dav_utility.unsubscribe([subscriber_username])
        membership = self._getMembership(subscriber_username)
        self.assertEquals(['/SOGo/dav/%s/calendar-proxy-write/' % username],
                          membership,
                          "'%s' must have write access to %s's calendars" %
                          (subscriber_username, username))
        # unsubscribed from personal, unsubscribed from 'test-calendar-proxy2'
        dav_utility = utilities.TestCalendarACLUtility(self, client,
                                                       other_resource)
        dav_utility.unsubscribe([subscriber_username])
        membership = self._getMembership(subscriber_username)
        self.assertEquals([], membership,
                          "'%s' must have no access to %s's calendars" %
                          (subscriber_username, username))

        delete = webdavlib.WebDAVDELETE(other_resource)
        client.execute(delete)
コード例 #30
0
 def __init__(self, arg):
     self.client = webdavlib.WebDAVClient(hostname, port, username,
                                          password)
     unittest.TestCase.__init__(self, arg)