[CalendarServer-changes] [11827] CalendarServer/branches/users/gaya/sharedgroupfixes/txdav
source_changes at macosforge.org
source_changes at macosforge.org
Wed Mar 12 11:18:43 PDT 2014
Revision: 11827
http://trac.calendarserver.org//changeset/11827
Author: gaya at apple.com
Date: 2013-10-18 13:54:58 -0700 (Fri, 18 Oct 2013)
Log Message:
-----------
raise SyncTokenValidException when nonzero revision is < bind revision; fix tests
Modified Paths:
--------------
CalDAVTester/branches/users/gaya/sharedgroupfixestester/scripts/tests/CalDAV/sharing-notification-sync.xml
CalDAVTester/branches/users/gaya/sharedgroupfixestester/scripts/tests/CalDAV/sharing-sync.xml
CalendarServer/branches/users/gaya/sharedgroupfixes/txdav/caldav/datastore/test/test_sql.py
CalendarServer/branches/users/gaya/sharedgroupfixes/txdav/carddav/datastore/sql.py
CalendarServer/branches/users/gaya/sharedgroupfixes/txdav/common/datastore/sql.py
Modified: CalDAVTester/branches/users/gaya/sharedgroupfixestester/scripts/tests/CalDAV/sharing-notification-sync.xml
===================================================================
--- CalDAVTester/branches/users/gaya/sharedgroupfixestester/scripts/tests/CalDAV/sharing-notification-sync.xml 2013-10-18 19:38:34 UTC (rev 11826)
+++ CalDAVTester/branches/users/gaya/sharedgroupfixestester/scripts/tests/CalDAV/sharing-notification-sync.xml 2013-10-18 20:54:58 UTC (rev 11827)
@@ -466,8 +466,34 @@
<name>{DAV:}href</name>
<variable>$sharedcalendar:</variable>
</grabelement>
+ <grabelement>
+ <name>{DAV:}href</name>
+ <variable>basename($sharedcalendarbasename:)</variable>
+ </grabelement>
</request>
</test>
+ <test name='6-' ignore='no'>
+ <description>bad sync token</description>
+ <request user="$userid2:" pswd="$pswd2:" print-response='no'>
+ <method>REPORT</method>
+ <ruri>$calendarhome2:/</ruri>
+ <header>
+ <name>Depth</name>
+ <value>infinity</value>
+ </header>
+ <data substitutions='yes'>
+ <content-type>text/xml; charset=utf-8</content-type>
+ <filepath>Resource/CalDAV/sharing/notification-sync/4.xml</filepath>
+ </data>
+ <verify>
+ <callback>statusCode</callback>
+ <arg>
+ <name>status</name>
+ <value>403</value>
+ </arg>
+ </verify>
+ </request>
+ </test>
<test name='6' ignore='no'>
<description>new calendar</description>
<request user="$userid2:" pswd="$pswd2:" print-response='no'>
@@ -479,18 +505,46 @@
</header>
<data substitutions='yes'>
<content-type>text/xml; charset=utf-8</content-type>
- <filepath>Resource/CalDAV/sharing/notification-sync/4.xml</filepath>
+ <filepath>Resource/CalDAV/sharing/notification-sync/2.xml</filepath>
</data>
<verify>
+ <exclude-feature>
+ <feature>split-calendars</feature>
+ </exclude-feature>
<callback>multistatusItems</callback>
<arg>
- <name>prefix</name>
- <value/>
+ <name>okhrefs</name>
+ <value>$sharedcalendarbasename:/</value>
+ <value>$calendar:/</value>
+ <value>$inbox:/</value>
+ <value>$outbox:/</value>
+ <value>$freebusy:</value>
+ <value>$notification:/</value>
</arg>
<arg>
+ <name>badhrefs</name>
+ <value>$dropbox:/</value>
+ </arg>
+ </verify>
+ <verify>
+ <require-feature>
+ <feature>split-calendars</feature>
+ </require-feature>
+ <callback>multistatusItems</callback>
+ <arg>
<name>okhrefs</name>
- <value>$sharedcalendar:/</value>
+ <value>$sharedcalendarbasename:/</value>
+ <value>$calendar:/</value>
+ <value>$tasks:/</value>
+ <value>$inbox:/</value>
+ <value>$outbox:/</value>
+ <value>$freebusy:</value>
+ <value>$notification:/</value>
</arg>
+ <arg>
+ <name>badhrefs</name>
+ <value>$dropbox:/</value>
+ </arg>
</verify>
<grabelement>
<name>/{DAV:}multistatus/{DAV:}sync-token</name>
@@ -662,8 +716,34 @@
<name>{DAV:}href</name>
<variable>$sharedcalendar:</variable>
</grabelement>
+ <grabelement>
+ <name>{DAV:}href</name>
+ <variable>basename($sharedcalendarbasename:)</variable>
+ </grabelement>
</request>
</test>
+ <test name='6-' ignore='no'>
+ <description>bad sync token</description>
+ <request user="$userid2:" pswd="$pswd2:" print-response='no'>
+ <method>REPORT</method>
+ <ruri>$calendarhome2:/</ruri>
+ <header>
+ <name>Depth</name>
+ <value>infinity</value>
+ </header>
+ <data substitutions='yes'>
+ <content-type>text/xml; charset=utf-8</content-type>
+ <filepath>Resource/CalDAV/sharing/notification-sync/4.xml</filepath>
+ </data>
+ <verify>
+ <callback>statusCode</callback>
+ <arg>
+ <name>status</name>
+ <value>403</value>
+ </arg>
+ </verify>
+ </request>
+ </test>
<test name='6' ignore='no'>
<description>new calendar</description>
<request user="$userid2:" pswd="$pswd2:" print-response='no'>
@@ -675,18 +755,46 @@
</header>
<data substitutions='yes'>
<content-type>text/xml; charset=utf-8</content-type>
- <filepath>Resource/CalDAV/sharing/notification-sync/4.xml</filepath>
+ <filepath>Resource/CalDAV/sharing/notification-sync/2.xml</filepath>
</data>
<verify>
+ <exclude-feature>
+ <feature>split-calendars</feature>
+ </exclude-feature>
<callback>multistatusItems</callback>
<arg>
- <name>prefix</name>
- <value/>
+ <name>okhrefs</name>
+ <value>$sharedcalendarbasename:/</value>
+ <value>$calendar:/</value>
+ <value>$inbox:/</value>
+ <value>$outbox:/</value>
+ <value>$freebusy:</value>
+ <value>$notification:/</value>
</arg>
<arg>
+ <name>badhrefs</name>
+ <value>$dropbox:/</value>
+ </arg>
+ </verify>
+ <verify>
+ <require-feature>
+ <feature>split-calendars</feature>
+ </require-feature>
+ <callback>multistatusItems</callback>
+ <arg>
<name>okhrefs</name>
- <value>$sharedcalendar:/</value>
+ <value>$sharedcalendarbasename:/</value>
+ <value>$calendar:/</value>
+ <value>$tasks:/</value>
+ <value>$inbox:/</value>
+ <value>$outbox:/</value>
+ <value>$freebusy:</value>
+ <value>$notification:/</value>
</arg>
+ <arg>
+ <name>badhrefs</name>
+ <value>$dropbox:/</value>
+ </arg>
</verify>
<grabelement>
<name>/{DAV:}multistatus/{DAV:}sync-token</name>
@@ -896,8 +1004,34 @@
<name>{DAV:}href</name>
<variable>$sharedcalendar:</variable>
</grabelement>
+ <grabelement>
+ <name>{DAV:}href</name>
+ <variable>basename($sharedcalendarbasename:)</variable>
+ </grabelement>
</request>
</test>
+ <test name='6-' ignore='no'>
+ <description>bad sync token</description>
+ <request user="$userid2:" pswd="$pswd2:" print-response='no'>
+ <method>REPORT</method>
+ <ruri>$calendarhome2:/</ruri>
+ <header>
+ <name>Depth</name>
+ <value>infinity</value>
+ </header>
+ <data substitutions='yes'>
+ <content-type>text/xml; charset=utf-8</content-type>
+ <filepath>Resource/CalDAV/sharing/notification-sync/4.xml</filepath>
+ </data>
+ <verify>
+ <callback>statusCode</callback>
+ <arg>
+ <name>status</name>
+ <value>403</value>
+ </arg>
+ </verify>
+ </request>
+ </test>
<test name='6' ignore='no'>
<description>new calendar</description>
<request user="$userid2:" pswd="$pswd2:" print-response='no'>
@@ -909,19 +1043,48 @@
</header>
<data substitutions='yes'>
<content-type>text/xml; charset=utf-8</content-type>
- <filepath>Resource/CalDAV/sharing/notification-sync/4.xml</filepath>
+ <filepath>Resource/CalDAV/sharing/notification-sync/2.xml</filepath>
</data>
<verify>
+ <exclude-feature>
+ <feature>split-calendars</feature>
+ </exclude-feature>
<callback>multistatusItems</callback>
<arg>
- <name>prefix</name>
- <value/>
+ <name>okhrefs</name>
+ <value>$sharedcalendarbasename:/</value>
+ <value>$sharedcalendarbasename:/1.ics</value>
+ <value>$calendar:/</value>
+ <value>$inbox:/</value>
+ <value>$outbox:/</value>
+ <value>$freebusy:</value>
+ <value>$notification:/</value>
</arg>
<arg>
+ <name>badhrefs</name>
+ <value>$dropbox:/</value>
+ </arg>
+ </verify>
+ <verify>
+ <require-feature>
+ <feature>split-calendars</feature>
+ </require-feature>
+ <callback>multistatusItems</callback>
+ <arg>
<name>okhrefs</name>
- <value>$sharedcalendar:/</value>
- <value>$sharedcalendar:/1.ics</value>
+ <value>$sharedcalendarbasename:/</value>
+ <value>$sharedcalendarbasename:/1.ics</value>
+ <value>$calendar:/</value>
+ <value>$tasks:/</value>
+ <value>$inbox:/</value>
+ <value>$outbox:/</value>
+ <value>$freebusy:</value>
+ <value>$notification:/</value>
</arg>
+ <arg>
+ <name>badhrefs</name>
+ <value>$dropbox:/</value>
+ </arg>
</verify>
<grabelement>
<name>/{DAV:}multistatus/{DAV:}sync-token</name>
Modified: CalDAVTester/branches/users/gaya/sharedgroupfixestester/scripts/tests/CalDAV/sharing-sync.xml
===================================================================
--- CalDAVTester/branches/users/gaya/sharedgroupfixestester/scripts/tests/CalDAV/sharing-sync.xml 2013-10-18 19:38:34 UTC (rev 11826)
+++ CalDAVTester/branches/users/gaya/sharedgroupfixestester/scripts/tests/CalDAV/sharing-sync.xml 2013-10-18 20:54:58 UTC (rev 11827)
@@ -292,6 +292,21 @@
<filepath>Resource/Common/REPORT/sync-token5-level-infinite.xml</filepath>
</data>
<verify>
+ <callback>statusCode</callback>
+ <arg>
+ <name>status</name>
+ <value>403</value>
+ </arg>
+ </verify>
+ </request>
+ <request user="$userid2:" pswd="$pswd2:" print-response='no'>
+ <method>REPORT</method>
+ <ruri>$calendarhome2:/</ruri>
+ <data substitutions='yes'>
+ <content-type>text/xml; charset=utf-8</content-type>
+ <filepath>Resource/Common/REPORT/sync-init-level-infinite.xml</filepath>
+ </data>
+ <verify>
<callback>multistatusItems</callback>
<arg>
<name>ignoremissing</name>
Modified: CalendarServer/branches/users/gaya/sharedgroupfixes/txdav/caldav/datastore/test/test_sql.py
===================================================================
--- CalendarServer/branches/users/gaya/sharedgroupfixes/txdav/caldav/datastore/test/test_sql.py 2013-10-18 19:38:34 UTC (rev 11826)
+++ CalendarServer/branches/users/gaya/sharedgroupfixes/txdav/caldav/datastore/test/test_sql.py 2013-10-18 20:54:58 UTC (rev 11827)
@@ -1773,7 +1773,7 @@
otherCal = yield otherHome.childWithName(newCalName)
self.assertNotEqual(otherCal._bindRevision, 0)
- changed, deleted = yield otherCal.resourceNamesSinceRevision(otherCal._bindRevision - 1)
+ changed, deleted = yield otherCal.resourceNamesSinceRevision(0)
self.assertNotEqual(len(changed), 0)
self.assertEqual(len(deleted), 0)
@@ -1782,7 +1782,7 @@
self.assertEqual(len(deleted), 0)
for depth in ("1", "infinity",):
- changed, deleted = yield otherHome.resourceNamesSinceRevision(otherCal._bindRevision - 1, depth)
+ changed, deleted = yield otherHome.resourceNamesSinceRevision(0, depth)
self.assertNotEqual(len(changed), 0)
self.assertEqual(len(deleted), 0)
Modified: CalendarServer/branches/users/gaya/sharedgroupfixes/txdav/carddav/datastore/sql.py
===================================================================
--- CalendarServer/branches/users/gaya/sharedgroupfixes/txdav/carddav/datastore/sql.py 2013-10-18 19:38:34 UTC (rev 11826)
+++ CalendarServer/branches/users/gaya/sharedgroupfixes/txdav/carddav/datastore/sql.py 2013-10-18 20:54:58 UTC (rev 11827)
@@ -595,10 +595,10 @@
bindRevisions += [groupBindRow[5] for groupBindRow in groupBindRows]
if revision != 0 and revision < max(bindRevisions):
- if depth == '1':
+ if depth != '1':
+ raise SyncTokenValidException
+ else:
revision = 0
- else:
- raise SyncTokenValidException
path = self.name()
Modified: CalendarServer/branches/users/gaya/sharedgroupfixes/txdav/common/datastore/sql.py
===================================================================
--- CalendarServer/branches/users/gaya/sharedgroupfixes/txdav/common/datastore/sql.py 2013-10-18 19:38:34 UTC (rev 11826)
+++ CalendarServer/branches/users/gaya/sharedgroupfixes/txdav/common/datastore/sql.py 2013-10-18 20:54:58 UTC (rev 11827)
@@ -67,7 +67,8 @@
HomeChildNameAlreadyExistsError, NoSuchHomeChildError, \
ObjectResourceNameNotAllowedError, ObjectResourceNameAlreadyExistsError, \
NoSuchObjectResourceError, AllRetriesFailed, InvalidSubscriptionValues, \
- InvalidIMIPTokenValues, TooManyObjectResourcesError
+ InvalidIMIPTokenValues, TooManyObjectResourcesError, \
+ SyncTokenValidException
from txdav.common.idirectoryservice import IStoreDirectoryService
from txdav.common.inotifications import INotificationCollection, \
INotificationObject
@@ -1945,8 +1946,7 @@
# Now deal with shared collections
# TODO: think about whether this can be done in one query rather than looping over each share
- shares = yield self.children()
- for share in shares:
+ for share in (yield self.children()):
if not share.owned():
sharedChanged, sharedDeleted = yield share.sharedChildResourceNamesSinceRevision(revision, depth)
changed |= sharedChanged
@@ -4118,8 +4118,9 @@
@type revision: C{int}
"""
- if revision < self._bindRevision:
- revision = 0
+ if revision != 0 and revision < self._bindRevision:
+ raise SyncTokenValidException
+
return super(CommonHomeChild, self).resourceNamesSinceRevision(revision)
@@ -4146,10 +4147,15 @@
"""
assert not self.owned()
+ if revision != 0 and revision < self._bindRevision:
+ if depth != '1':
+ raise SyncTokenValidException
+ else:
+ revision = 0
+
changed = set()
deleted = set()
rev = self._revisionsSchema
- sharerevision = 0 if revision < self._bindRevision else revision
results = [
(
self.name(),
@@ -4159,14 +4165,14 @@
for name, wasdeleted in
(yield Select([rev.RESOURCE_NAME, rev.DELETED],
From=rev,
- Where=(rev.REVISION > sharerevision).And(
+ Where=(rev.REVISION > revision).And(
rev.RESOURCE_ID == self._resourceID)).on(self._txn))
if name
]
for path, name, wasdeleted in results:
if wasdeleted:
- if sharerevision:
+ if revision:
if depth == "1":
changed.add("%s/" % (path,))
else:
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20140312/d102df37/attachment.html>
More information about the calendarserver-changes
mailing list