From e361b6615fd9e00a8866ac3a98635487cd6f9a2b Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Tue, 8 Dec 2009 21:15:56 +0000 Subject: [PATCH] Monotone-Parent: 22a2d4f70700185e46dc44f47891c774fa83e592 Monotone-Revision: 5f1640d17dbc95901d131c16f8d4499aa044594c Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2009-12-08T21:15:56 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 6 +++++ Main/SOGo.m | 10 +++++++- Tests/test-webdav.py | 54 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 69 insertions(+), 1 deletion(-) create mode 100755 Tests/test-webdav.py diff --git a/ChangeLog b/ChangeLog index 033180bb9..9c897fd6a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2009-12-08 Wolfgang Sourdeau + + * Main/SOGo.m (-davURLAsString): we ensure that the url ends with + "/" since the /SOGo object is a collection and the caller may rely + on this. + 2009-12-07 Wolfgang Sourdeau * UI/PreferencesUI/UIxPreferences.m (-defaultAction): diff --git a/Main/SOGo.m b/Main/SOGo.m index 15aa057a4..8e06119b2 100644 --- a/Main/SOGo.m +++ b/Main/SOGo.m @@ -581,10 +581,18 @@ static BOOL debugLeaks; - (NSString *) davURLAsString { NSURL *davURL; + NSString *davURLAsString; davURL = [self davURL]; - return (useRelativeURLs ? [davURL path] : [davURL absoluteString]); + /* we know that GNUstep returns a "/" suffix for the absoluteString but not + for the path method. Therefore we add one. */ + if (useRelativeURLs) + davURLAsString = [NSString stringWithFormat: @"%@/", [davURL path]]; + else + davURLAsString = [davURL absoluteString]; + + return davURLAsString; } - (NSURL *) soURL diff --git a/Tests/test-webdav.py b/Tests/test-webdav.py new file mode 100755 index 000000000..d8cb79663 --- /dev/null +++ b/Tests/test-webdav.py @@ -0,0 +1,54 @@ +#!/usr/bin/python + +from config import hostname, port, username, password + +import unittest +import webdavlib + +class WebDAVTest(unittest.TestCase): + def testPrincipalCollectionSet(self): + """property: principal-collection-set""" + client = webdavlib.WebDAVClient(hostname, port, username, password) + resource = '/SOGo/dav/%s/' % username + propfind = webdavlib.WebDAVPROPFIND(resource, + ["{DAV:}principal-collection-set"], + 0) + propfind.xpath_namespace = { "D": "DAV:" } + client.execute(propfind) + assert(propfind.response["status"] == 207) + nodes = propfind.xpath_evaluate('/D:multistatus/D:response/D:propstat/D:prop/D:principal-collection-set/D:href', + None) + responseHref = nodes[0].childNodes[0].nodeValue + if responseHref[0:4] == "http": + self.assertEquals("http://%s%s" % (hostname, resource), responseHref, + "{DAV:}principal-collection-set returned %s instead of '%s'" + % ( responseHref, resource )) + else: + self.assertEquals(resource, responseHref, + "{DAV:}principal-collection-set returned %s instead of '%s'" + % ( responseHref, resource )) + + def testPrincipalCollectionSet2(self): + """property: principal-collection-set""" + client = webdavlib.WebDAVClient(hostname, port, username, password) + resource = '/SOGo/dav/%s/freebusy.ifb' % username + propfind = webdavlib.WebDAVPROPFIND(resource, + ["{DAV:}principal-collection-set"], + 0) + propfind.xpath_namespace = { "D": "DAV:" } + client.execute(propfind) + assert(propfind.response["status"] == 207) + nodes = propfind.xpath_evaluate('/D:multistatus/D:response/D:propstat/D:prop/D:principal-collection-set/D:href', + None) + responseHref = nodes[0].childNodes[0].nodeValue + if responseHref[0:4] == "http": + self.assertEquals("http://%s%s" % (hostname, resource), responseHref, + "{DAV:}principal-collection-set returned %s instead of '%s'" + % ( responseHref, resource )) + else: + self.assertEquals(resource, responseHref, + "{DAV:}principal-collection-set returned %s instead of '%s'" + % ( responseHref, resource )) + +if __name__ == "__main__": + unittest.main()