Monotone-Parent: ebe6d4bf201db3d567631a28731d5d2345f7ab9e

Monotone-Revision: 859bf2013653e0366336126b6d00368fe0dbc147

Monotone-Author: wsourdeau@inverse.ca
Monotone-Date: 2012-02-21T16:19:46
Monotone-Branch: ca.inverse.sogo
maint-2.0.2
Wolfgang Sourdeau 2012-02-21 16:19:46 +00:00
parent 6ae5556d8c
commit 1655d27dbe
3 changed files with 127 additions and 0 deletions

View File

@ -1,3 +1,15 @@
2012-02-21 Wolfgang Sourdeau <wsourdeau@inverse.ca>
* SoObjects/Appointments/SOGoAppointmentFolders.m
(-davEventsDefaultClassification,)
(setDavEventsDefaultClassification:)
(-davTasksDefaultClassification)
(-setDavTasksDefaultClassification:): new DAV accessors for the
default classification preferences.
* Tests/Integration/test-default-classification.py: new test
module for setting/getting defaults classification preferences.
2012-02-20 Wolfgang Sourdeau <wsourdeau@inverse.ca>
* UI/Scheduler/UIxComponentEditor.m (-setComponent:): fetch

View File

@ -398,6 +398,69 @@ static SoSecurityManager *sm = nil;
return componentSet;
}
- (NSString *) _davDefaultClassWithSelector: (SEL) selector
{
SOGoUser *ownerUser;
SOGoUserDefaults *defaults;
NSString *classification;
ownerUser = [SOGoUser userWithLogin: [self ownerInContext: context]];
defaults = [ownerUser userDefaults];
classification = [defaults performSelector: selector];
return classification;
}
- (NSException *) _davSetDefaultClass: (NSString *) newClass
withSelector: (SEL) selector
{
NSException *error;
static NSArray *validClassifications = nil;
SOGoUser *ownerUser;
SOGoUserDefaults *defaults;
if (!validClassifications)
validClassifications = [[NSArray alloc] initWithObjects: @"PUBLIC",
@"CONFIDENTIAL", @"PRIVATE", nil];
if (newClass && [validClassifications containsObject: newClass])
{
error = nil;
ownerUser = [SOGoUser userWithLogin: [self ownerInContext: context]];
defaults = [ownerUser userDefaults];
[defaults performSelector: selector withObject: newClass];
[defaults synchronize];
}
else
error = [NSException exceptionWithHTTPStatus: 403
reason: @"invalid"
@" classification value"];
return error;
}
- (NSString *) davEventsDefaultClassification
{
return [self _davDefaultClassWithSelector: @selector (calendarEventsDefaultClassification)];
}
- (NSException *) setDavEventsDefaultClassification: (NSString *) newClass
{
return [self _davSetDefaultClass: newClass
withSelector: @selector (setCalendarEventsDefaultClassification:)];
}
- (NSString *) davTasksDefaultClassification
{
return [self _davDefaultClassWithSelector: @selector (calendarTasksDefaultClassification)];
}
- (NSException *) setDavTasksDefaultClassification: (NSString *) newClass
{
return [self _davSetDefaultClass: newClass
withSelector: @selector (setCalendarTasksDefaultClassification:)];
}
/* This method fixes an issue that occurred previously in
_migrateWebCalendarsSettings, where the active user, rather than the
owner's login would be taken to compose the expected key prefix, leading to

View File

@ -0,0 +1,52 @@
#!/usr/bin/python
import sogotests
import unittest
import webdavlib
from config import *
class HTTPDefaultClassificationTest(unittest.TestCase):
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 _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
def test(self):
self.assertFalse(self._setClassification(username, "123456", "PUBLIC"),
"expected failure when setting a classification with an invalid property")
self.assertFalse(self._setClassification(username, "events", ""),
"expected failure when setting an empty classification")
self.assertFalse(self._setClassification(username, "events", "pouet"),
"expected failure when setting an invalid classification")
for component in [ "events", "tasks" ]:
for classification in [ "PUBLIC", "PRIVATE", "CONFIDENTIAL" ]:
self.assertTrue(self._setClassification(username, component, classification),
"error when setting classification to '%s'" % classification)
fetched_class = self._getClassification(username, component)
self.assertTrue(classification == fetched_class,
"set and fetched classifications do not match (%s != %s)" % (classification, fetched_class))
if __name__ == "__main__":
sogotests.runTests()