[CalendarServer-changes] [10561] CalendarServer/trunk/twext/who
source_changes at macosforge.org
source_changes at macosforge.org
Mon Jan 28 17:22:06 PST 2013
Revision: 10561
http://trac.calendarserver.org//changeset/10561
Author: wsanchez at apple.com
Date: 2013-01-28 17:22:06 -0800 (Mon, 28 Jan 2013)
Log Message:
-----------
Check for bogus record type
Modified Paths:
--------------
CalendarServer/trunk/twext/who/directory.py
CalendarServer/trunk/twext/who/test/test_directory.py
Modified: CalendarServer/trunk/twext/who/directory.py
===================================================================
--- CalendarServer/trunk/twext/who/directory.py 2013-01-29 01:10:08 UTC (rev 10560)
+++ CalendarServer/trunk/twext/who/directory.py 2013-01-29 01:22:06 UTC (rev 10561)
@@ -77,6 +77,12 @@
if not value:
raise ValueError("%s field must not be empty." % (fieldName,))
+ if fields[FieldName.recordType] not in service.RecordTypeClass.iterconstants():
+ raise ValueError("Record type must be one of %r, not %r." % (
+ tuple(service.RecordTypeClass.iterconstants()),
+ fields[FieldName.recordType]
+ ))
+
self.service = service
self.fields = fields
Modified: CalendarServer/trunk/twext/who/test/test_directory.py
===================================================================
--- CalendarServer/trunk/twext/who/test/test_directory.py 2013-01-29 01:10:08 UTC (rev 10560)
+++ CalendarServer/trunk/twext/who/test/test_directory.py 2013-01-29 01:22:06 UTC (rev 10561)
@@ -137,6 +137,11 @@
fields[FieldName.shortNames] = ("wsanchez", "")
self.assertRaises(ValueError, self._testRecord, fields)
+ def test_initWithBogusRecordType(self):
+ fields = self.fields_wsanchez.copy()
+ fields[FieldName.recordType] = object()
+ self.assertRaises(ValueError, self._testRecord, fields)
+
def test_compare(self):
fields_glyphmod = self.fields_glyph.copy()
del fields_glyphmod[FieldName.emailAddresses]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20130128/61649ce7/attachment.html>
More information about the calendarserver-changes
mailing list