diff options
Diffstat (limited to 'apps/dav/tests')
16 files changed, 619 insertions, 91 deletions
diff --git a/apps/dav/tests/travis/caldav/install.sh b/apps/dav/tests/travis/caldav/install.sh index e836e37f86f..9688ec660de 100644 --- a/apps/dav/tests/travis/caldav/install.sh +++ b/apps/dav/tests/travis/caldav/install.sh @@ -15,6 +15,7 @@ fi cd "$SCRIPTPATH/../../../../../" OC_PASS=user01 php occ user:add --password-from-env user01 php occ dav:create-calendar user01 calendar +php occ dav:create-calendar user01 shared OC_PASS=user02 php occ user:add --password-from-env user02 php occ dav:create-calendar user02 calendar cd "$SCRIPTPATH/../../../../../" diff --git a/apps/dav/tests/travis/caldav/script.sh b/apps/dav/tests/travis/caldav/script.sh index fe3391d5a06..aa5fc732922 100644 --- a/apps/dav/tests/travis/caldav/script.sh +++ b/apps/dav/tests/travis/caldav/script.sh @@ -10,9 +10,7 @@ sleep 30 # run the tests cd "$SCRIPTPATH/CalDAVTester" PYTHONPATH="$SCRIPTPATH/pycalendar/src" python testcaldav.py --print-details-onfail --basedir "$SCRIPTPATH/../caldavtest/" -o cdt.txt \ - "CalDAV/current-user-principal.xml" \ - "CalDAV/sync-report.xml" - + "CalDAV/sharing-calendars.xml" RESULT=$? diff --git a/apps/dav/tests/travis/caldavtest/data/Resource/CalDAV/sharing/calendars/read-write/1.xml b/apps/dav/tests/travis/caldavtest/data/Resource/CalDAV/sharing/calendars/read-write/1.xml new file mode 100644 index 00000000000..3bcf9dc47f9 --- /dev/null +++ b/apps/dav/tests/travis/caldavtest/data/Resource/CalDAV/sharing/calendars/read-write/1.xml @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="utf-8" ?> +<CS:share xmlns:D="DAV:" xmlns:CS="http://owncloud.org/ns"> + <CS:set> + <D:href>principal:principals/users/user02</D:href> + <CS:summary>My Shared Calendar</CS:summary> + <CS:read-write/> + </CS:set> +</CS:share> diff --git a/apps/dav/tests/travis/caldavtest/data/Resource/CalDAV/sharing/calendars/read-write/4.xml b/apps/dav/tests/travis/caldavtest/data/Resource/CalDAV/sharing/calendars/read-write/4.xml new file mode 100644 index 00000000000..fd0f248bb31 --- /dev/null +++ b/apps/dav/tests/travis/caldavtest/data/Resource/CalDAV/sharing/calendars/read-write/4.xml @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="utf-8" ?> +<D:propfind xmlns:D="DAV:"> +<D:prop> +<D:resourcetype/> +<D:owner/> +<D:current-user-privilege-set/> +</D:prop> +</D:propfind> diff --git a/apps/dav/tests/travis/caldavtest/data/Resource/CalDAV/sharing/calendars/read-write/5.ics b/apps/dav/tests/travis/caldavtest/data/Resource/CalDAV/sharing/calendars/read-write/5.ics new file mode 100644 index 00000000000..ae21adac8b2 --- /dev/null +++ b/apps/dav/tests/travis/caldavtest/data/Resource/CalDAV/sharing/calendars/read-write/5.ics @@ -0,0 +1,29 @@ +BEGIN:VCALENDAR +VERSION:2.0 +PRODID:-//PYVOBJECT//NONSGML Version 1//EN +BEGIN:VTIMEZONE +TZID:US/Eastern +LAST-MODIFIED:20040110T032845Z +BEGIN:STANDARD +DTSTART:20001026T020000 +RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=10 +TZNAME:EST +TZOFFSETFROM:-0400 +TZOFFSETTO:-0500 +END:STANDARD +BEGIN:DAYLIGHT +DTSTART:20000404T020000 +RRULE:FREQ=YEARLY;BYDAY=1SU;BYMONTH=4 +TZNAME:EDT +TZOFFSETFROM:-0500 +TZOFFSETTO:-0400 +END:DAYLIGHT +END:VTIMEZONE +BEGIN:VEVENT +UID:$uid1: +DTSTART;TZID=US/Eastern:$now.year.1:0101T100000 +DURATION:PT1H +DTSTAMP:20051222T205953Z +SUMMARY:event 1 +END:VEVENT +END:VCALENDAR diff --git a/apps/dav/tests/travis/caldavtest/data/Resource/CalDAV/sharing/calendars/read-write/5.xml b/apps/dav/tests/travis/caldavtest/data/Resource/CalDAV/sharing/calendars/read-write/5.xml new file mode 100644 index 00000000000..4862ed195f8 --- /dev/null +++ b/apps/dav/tests/travis/caldavtest/data/Resource/CalDAV/sharing/calendars/read-write/5.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="utf-8" ?> +<D:propfind xmlns:D="DAV:" xmlns:CS="http://owncloud.org/ns"> +<D:prop> +<CS:invite/> +</D:prop> +</D:propfind> diff --git a/apps/dav/tests/travis/caldavtest/data/Resource/CalDAV/sharing/calendars/read-write/6.ics b/apps/dav/tests/travis/caldavtest/data/Resource/CalDAV/sharing/calendars/read-write/6.ics new file mode 100644 index 00000000000..145f5f14c7b --- /dev/null +++ b/apps/dav/tests/travis/caldavtest/data/Resource/CalDAV/sharing/calendars/read-write/6.ics @@ -0,0 +1,29 @@ +BEGIN:VCALENDAR +VERSION:2.0 +PRODID:-//PYVOBJECT//NONSGML Version 1//EN +BEGIN:VTIMEZONE +TZID:US/Eastern +LAST-MODIFIED:20040110T032845Z +BEGIN:STANDARD +DTSTART:20001026T020000 +RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=10 +TZNAME:EST +TZOFFSETFROM:-0400 +TZOFFSETTO:-0500 +END:STANDARD +BEGIN:DAYLIGHT +DTSTART:20000404T020000 +RRULE:FREQ=YEARLY;BYDAY=1SU;BYMONTH=4 +TZNAME:EDT +TZOFFSETFROM:-0500 +TZOFFSETTO:-0400 +END:DAYLIGHT +END:VTIMEZONE +BEGIN:VEVENT +UID:$uid1: +DTSTART;TZID=US/Eastern:$now.year.1:0101T100000 +DURATION:PT4H +DTSTAMP:20051222T205953Z +SUMMARY:event 4 +END:VEVENT +END:VCALENDAR diff --git a/apps/dav/tests/travis/caldavtest/data/Resource/CalDAV/sharing/calendars/read-write/7.ics b/apps/dav/tests/travis/caldavtest/data/Resource/CalDAV/sharing/calendars/read-write/7.ics new file mode 100644 index 00000000000..c4e816210df --- /dev/null +++ b/apps/dav/tests/travis/caldavtest/data/Resource/CalDAV/sharing/calendars/read-write/7.ics @@ -0,0 +1,29 @@ +BEGIN:VCALENDAR +VERSION:2.0 +PRODID:-//PYVOBJECT//NONSGML Version 1//EN +BEGIN:VTIMEZONE +TZID:US/Eastern +LAST-MODIFIED:20040110T032845Z +BEGIN:STANDARD +DTSTART:20001026T020000 +RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=10 +TZNAME:EST +TZOFFSETFROM:-0400 +TZOFFSETTO:-0500 +END:STANDARD +BEGIN:DAYLIGHT +DTSTART:20000404T020000 +RRULE:FREQ=YEARLY;BYDAY=1SU;BYMONTH=4 +TZNAME:EDT +TZOFFSETFROM:-0500 +TZOFFSETTO:-0400 +END:DAYLIGHT +END:VTIMEZONE +BEGIN:VEVENT +UID:$uid2: +DTSTART;TZID=US/Eastern:$now.year.1:0201T100000 +DURATION:PT1H +DTSTAMP:20051222T205953Z +SUMMARY:event 7 +END:VEVENT +END:VCALENDAR diff --git a/apps/dav/tests/travis/caldavtest/data/Resource/CalDAV/sharing/calendars/read-write/8.ics b/apps/dav/tests/travis/caldavtest/data/Resource/CalDAV/sharing/calendars/read-write/8.ics new file mode 100644 index 00000000000..2da72d2f601 --- /dev/null +++ b/apps/dav/tests/travis/caldavtest/data/Resource/CalDAV/sharing/calendars/read-write/8.ics @@ -0,0 +1,29 @@ +BEGIN:VCALENDAR +VERSION:2.0 +PRODID:-//PYVOBJECT//NONSGML Version 1//EN +BEGIN:VTIMEZONE +TZID:US/Eastern +LAST-MODIFIED:20040110T032845Z +BEGIN:STANDARD +DTSTART:20001026T020000 +RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=10 +TZNAME:EST +TZOFFSETFROM:-0400 +TZOFFSETTO:-0500 +END:STANDARD +BEGIN:DAYLIGHT +DTSTART:20000404T020000 +RRULE:FREQ=YEARLY;BYDAY=1SU;BYMONTH=4 +TZNAME:EDT +TZOFFSETFROM:-0500 +TZOFFSETTO:-0400 +END:DAYLIGHT +END:VTIMEZONE +BEGIN:VEVENT +UID:$uid2: +DTSTART;TZID=US/Eastern:$now.year.1:0201T100000 +DURATION:PT7H +DTSTAMP:20051222T205953Z +SUMMARY:event 7-1 +END:VEVENT +END:VCALENDAR diff --git a/apps/dav/tests/travis/caldavtest/data/Resource/CalDAV/sharing/calendars/read-write/9.ics b/apps/dav/tests/travis/caldavtest/data/Resource/CalDAV/sharing/calendars/read-write/9.ics new file mode 100644 index 00000000000..dfc21bb9c5b --- /dev/null +++ b/apps/dav/tests/travis/caldavtest/data/Resource/CalDAV/sharing/calendars/read-write/9.ics @@ -0,0 +1,29 @@ +BEGIN:VCALENDAR +VERSION:2.0 +PRODID:-//PYVOBJECT//NONSGML Version 1//EN +BEGIN:VTIMEZONE +TZID:US/Eastern +LAST-MODIFIED:20040110T032845Z +BEGIN:STANDARD +DTSTART:20001026T020000 +RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=10 +TZNAME:EST +TZOFFSETFROM:-0400 +TZOFFSETTO:-0500 +END:STANDARD +BEGIN:DAYLIGHT +DTSTART:20000404T020000 +RRULE:FREQ=YEARLY;BYDAY=1SU;BYMONTH=4 +TZNAME:EDT +TZOFFSETFROM:-0500 +TZOFFSETTO:-0400 +END:DAYLIGHT +END:VTIMEZONE +BEGIN:VEVENT +UID:$uid3: +DTSTART;TZID=US/Eastern:$now.year.1:0201T100000 +DURATION:PT7H +DTSTAMP:20051222T205953Z +SUMMARY:event 9.ics +END:VEVENT +END:VCALENDAR diff --git a/apps/dav/tests/travis/caldavtest/tests/CalDAV/sharing-calendars.xml b/apps/dav/tests/travis/caldavtest/tests/CalDAV/sharing-calendars.xml index fa20a6e4862..334fa561aec 100644 --- a/apps/dav/tests/travis/caldavtest/tests/CalDAV/sharing-calendars.xml +++ b/apps/dav/tests/travis/caldavtest/tests/CalDAV/sharing-calendars.xml @@ -27,6 +27,7 @@ </require-feature> <start> + <!-- <request user="$userid1:" pswd="$pswd1:"> <method>DELETEALL</method> <ruri>$notificationpath1:/</ruri> @@ -50,6 +51,7 @@ <filepath>Resource/Common/PROPPATCH/calendar-transp-opaque.xml</filepath> </data> </request> + --> </start> <test-suite name='Read-write calendar'> @@ -67,56 +69,11 @@ </verify> </request> </test> - <test name='2'> - <description>Check Sharee notification collection</description> - <request user="$userid2:" pswd="$pswd2:"> - <method>WAITCOUNT 1</method> - <ruri>$notificationpath2:/</ruri> - </request> - <request user="$userid2:" pswd="$pswd2:"> - <method>GETNEW</method> - <ruri>$notificationpath2:/</ruri> - <verify> - <callback>xmlDataMatch</callback> - <arg> - <name>filepath</name> - <value>Resource/CalDAV/sharing/calendars/read-write/2.xml</value> - </arg> - <arg> - <name>filter</name> - <value>{http://calendarserver.org/ns/}dtstamp</value> - <value>{http://calendarserver.org/ns/}uid</value> - </arg> - </verify> - <grabelement> - <name>{http://calendarserver.org/ns/}invite-notification/{http://calendarserver.org/ns/}uid</name> - <variable>$inviteuid:</variable> - </grabelement> - </request> - </test> - <test name='3'> - <description>Sharee replies ACCEPTED</description> - <request user="$userid2:" pswd="$pswd2:"> - <method>POST</method> - <ruri>$calendarhome2:/</ruri> - <data> - <content-type>application/xml; charset=utf-8</content-type> - <filepath>Resource/CalDAV/sharing/calendars/read-write/3.xml</filepath> - </data> - <verify> - <callback>statusCode</callback> - </verify> - <grabelement> - <name>{DAV:}href</name> - <variable>$sharedcalendar:</variable> - </grabelement> - </request> - </test> <test name='4'> <description>Shared calendar exists</description> <request user="$userid2:" pswd="$pswd2:"> <method>PROPFIND</method> - <ruri>$sharedcalendar:/</ruri> + <ruri>$calendarhome1:/shared/</ruri> <header> <name>Depth</name> <value>0</value> @@ -132,12 +89,12 @@ <value>$verify-property-prefix:/{DAV:}owner/{DAV:}href[=$principaluri1:]</value> <value>$verify-property-prefix:/{DAV:}resourcetype/{DAV:}collection</value> <value>$verify-property-prefix:/{DAV:}resourcetype/{urn:ietf:params:xml:ns:caldav}calendar</value> - <value>$verify-property-prefix:/{DAV:}resourcetype/{http://calendarserver.org/ns/}shared</value> + <!-- value>$verify-property-prefix:/{DAV:}resourcetype/{http://calendarserver.org/ns/}shared</value --> <value>$verify-property-prefix:/{DAV:}current-user-privilege-set/{DAV:}privilege/{DAV:}read</value> <value>$verify-property-prefix:/{DAV:}current-user-privilege-set/{DAV:}privilege/{DAV:}write</value> <value>$verify-property-prefix:/{DAV:}current-user-privilege-set/{DAV:}privilege/{DAV:}bind</value> <value>$verify-property-prefix:/{DAV:}current-user-privilege-set/{DAV:}privilege/{DAV:}unbind</value> - <value>$verify-property-prefix:/{urn:ietf:params:xml:ns:caldav}schedule-calendar-transp/{urn:ietf:params:xml:ns:caldav}transparent</value> + <!-- value>$verify-property-prefix:/{urn:ietf:params:xml:ns:caldav}schedule-calendar-transp/{urn:ietf:params:xml:ns:caldav}transparent</value --> </arg> <arg> <name>notexists</name> @@ -151,7 +108,7 @@ <description>Shared calendar exists Depth:1</description> <request user="$userid2:" pswd="$pswd2:"> <method>PROPFIND</method> - <ruri>$calendarhome2:/</ruri> + <ruri>$calendarhome2:</ruri> <header> <name>Depth</name> <value>1</value> @@ -164,19 +121,19 @@ <callback>xmlElementMatch</callback> <arg> <name>parent</name> - <value>$multistatus-response-prefix:[^{DAV:}href=$sharedcalendar:/]</value> + <value>$multistatus-response-prefix:[^{DAV:}href=$calendarhome2:/shared_shared_by_user01/]</value> </arg> <arg> <name>exists</name> <value>$verify-response-prefix:/{DAV:}owner/{DAV:}href[=$principaluri1:]</value> <value>$verify-response-prefix:/{DAV:}resourcetype/{DAV:}collection</value> <value>$verify-response-prefix:/{DAV:}resourcetype/{urn:ietf:params:xml:ns:caldav}calendar</value> - <value>$verify-response-prefix:/{DAV:}resourcetype/{http://calendarserver.org/ns/}shared</value> + <!-- value>$verify-response-prefix:/{DAV:}resourcetype/{http://calendarserver.org/ns/}shared</value --> <value>$verify-response-prefix:/{DAV:}current-user-privilege-set/{DAV:}privilege/{DAV:}read</value> <value>$verify-response-prefix:/{DAV:}current-user-privilege-set/{DAV:}privilege/{DAV:}write</value> <value>$verify-response-prefix:/{DAV:}current-user-privilege-set/{DAV:}privilege/{DAV:}bind</value> <value>$verify-response-prefix:/{DAV:}current-user-privilege-set/{DAV:}privilege/{DAV:}unbind</value> - <value>$verify-response-prefix:/{urn:ietf:params:xml:ns:caldav}schedule-calendar-transp/{urn:ietf:params:xml:ns:caldav}transparent</value> + <!-- value>$verify-response-prefix:/{urn:ietf:params:xml:ns:caldav}schedule-calendar-transp/{urn:ietf:params:xml:ns:caldav}transparent</value --> </arg> <arg> <name>notexists</name> @@ -186,44 +143,31 @@ </verify> </request> </test> - <test name='4b'> - <description>Shared calendar has invite property</description> - <request user="$userid2:" pswd="$pswd2:"> + <test name='5'> + <description>Original calendar unchanged</description> + <request> <method>PROPFIND</method> - <ruri>$sharedcalendar:/</ruri> + <ruri>$calendarhome1:/shared/</ruri> <header> <name>Depth</name> <value>0</value> </header> <data> <content-type>text/xml; charset=utf-8</content-type> - <filepath>Resource/CalDAV/sharing/calendars/read-write/5.xml</filepath> + <filepath>Resource/CalDAV/sharing/calendars/read-write/4.xml</filepath> </data> <verify> - <callback>propfindItems</callback> - <arg> - <name>okprops</name> - <value>{http://calendarserver.org/ns/}invite</value> - </arg> - </verify> - <verify> <callback>xmlElementMatch</callback> <arg> <name>exists</name> - <value>$verify-property-prefix:/{http://calendarserver.org/ns/}invite</value> - <value>$verify-property-prefix:/{http://calendarserver.org/ns/}invite/{http://calendarserver.org/ns/}organizer</value> - <value>$verify-property-prefix:/{http://calendarserver.org/ns/}invite/{http://calendarserver.org/ns/}organizer/{DAV:}href[=$principaluri1:]</value> - <value>$verify-property-prefix:/{http://calendarserver.org/ns/}invite/{http://calendarserver.org/ns/}organizer/{http://calendarserver.org/ns/}common-name[=$username1:]</value> - <value>$verify-property-prefix:/{http://calendarserver.org/ns/}invite/{http://calendarserver.org/ns/}user</value> - <value>$verify-property-prefix:/{http://calendarserver.org/ns/}invite/{http://calendarserver.org/ns/}user/{DAV:}href[=$cuaddrurn2:]</value> - <value>$verify-property-prefix:/{http://calendarserver.org/ns/}invite/{http://calendarserver.org/ns/}user/{http://calendarserver.org/ns/}access/{http://calendarserver.org/ns/}read-write</value> - <value>$verify-property-prefix:/{http://calendarserver.org/ns/}invite/{http://calendarserver.org/ns/}user/{http://calendarserver.org/ns/}invite-accepted</value> + <value>$verify-property-prefix:/{DAV:}owner/{DAV:}href[=$principaluri1:]</value> + <!--<value>$verify-property-prefix:/{urn:ietf:params:xml:ns:caldav}schedule-calendar-transp/{urn:ietf:params:xml:ns:caldav}opaque</value>--> </arg> </verify> </request> </test> - <test name='5'> - <description>Original calendar unchanged</description> + <test name='5a'> + <description>Invite propfind returns sharees</description> <request> <method>PROPFIND</method> <ruri>$calendarhome1:/shared/</ruri> @@ -233,14 +177,14 @@ </header> <data> <content-type>text/xml; charset=utf-8</content-type> - <filepath>Resource/CalDAV/sharing/calendars/read-write/4.xml</filepath> + <filepath>Resource/CalDAV/sharing/calendars/read-write/5.xml</filepath> </data> <verify> <callback>xmlElementMatch</callback> <arg> <name>exists</name> - <value>$verify-property-prefix:/{DAV:}owner/{DAV:}href[=$principaluri1:]</value> - <value>$verify-property-prefix:/{urn:ietf:params:xml:ns:caldav}schedule-calendar-transp/{urn:ietf:params:xml:ns:caldav}opaque</value> + <value>$verify-property-prefix:/{http://owncloud.org/ns}invite/{http://owncloud.org/ns}user/{DAV:}href</value> + <value>$verify-property-prefix:/{http://owncloud.org/ns}invite/{http://owncloud.org/ns}user/{http://owncloud.org/ns}invite-accepted</value> </arg> </verify> </request> @@ -249,7 +193,7 @@ <description>Sharee creates event</description> <request user="$userid2:" pswd="$pswd2:"> <method>PUT</method> - <ruri>$sharedcalendar:/1.ics</ruri> + <ruri>$calendarhome1:/shared/1.ics</ruri> <data> <content-type>text/calendar; charset=utf-8</content-type> <filepath>Resource/CalDAV/sharing/calendars/read-write/5.ics</filepath> @@ -291,7 +235,7 @@ <description>Sharee sees changed event</description> <request user="$userid2:" pswd="$pswd2:"> <method>GET</method> - <ruri>$sharedcalendar:/1.ics</ruri> + <ruri>$calendarhome1:/shared/1.ics</ruri> <verify> <callback>calendarDataMatch</callback> <arg> @@ -319,7 +263,7 @@ <description>Sharee sees new event</description> <request user="$userid2:" pswd="$pswd2:"> <method>GET</method> - <ruri>$sharedcalendar:/2.ics</ruri> + <ruri>$calendarhome1:/shared/2.ics</ruri> <verify> <callback>calendarDataMatch</callback> <arg> @@ -333,7 +277,7 @@ <description>Sharee changes event</description> <request user="$userid2:" pswd="$pswd2:"> <method>PUT</method> - <ruri>$sharedcalendar:/2.ics</ruri> + <ruri>$calendarhome1:/shared/2.ics</ruri> <data> <content-type>text/calendar; charset=utf-8</content-type> <filepath>Resource/CalDAV/sharing/calendars/read-write/8.ics</filepath> @@ -357,8 +301,76 @@ </verify> </request> </test> + <test name='14'> + <description>Un-share by delete</description> + <request user="$userid2:" pswd="$pswd2:"> + <method>DELETE</method> + <ruri>$calendarhome2:/shared_shared_by_user01/</ruri> + <verify> + <callback>statusCode</callback> + </verify> + </request> + </test> + <test name='15'> + <description>Original calendar still exists</description> + <request> + <method>PROPFIND</method> + <ruri>$calendarhome1:/shared/</ruri> + <header> + <name>Depth</name> + <value>0</value> + </header> + <data> + <content-type>text/xml; charset=utf-8</content-type> + <filepath>Resource/CalDAV/sharing/calendars/read-write/4.xml</filepath> + </data> + <verify> + <callback>xmlElementMatch</callback> + <arg> + <name>exists</name> + <value>$verify-property-prefix:/{DAV:}owner/{DAV:}href[=$principaluri1:]</value> + <value>$verify-property-prefix:/{DAV:}resourcetype/{DAV:}collection</value> + <value>$verify-property-prefix:/{DAV:}resourcetype/{urn:ietf:params:xml:ns:caldav}calendar</value> + <!-- value>$verify-property-prefix:/{DAV:}resourcetype/{http://calendarserver.org/ns/}shared</value --> + <value>$verify-property-prefix:/{DAV:}current-user-privilege-set/{DAV:}privilege/{DAV:}read</value> + <value>$verify-property-prefix:/{DAV:}current-user-privilege-set/{DAV:}privilege/{DAV:}write</value> + <value>$verify-property-prefix:/{DAV:}current-user-privilege-set/{DAV:}privilege/{DAV:}bind</value> + <value>$verify-property-prefix:/{DAV:}current-user-privilege-set/{DAV:}privilege/{DAV:}unbind</value> + <!-- value>$verify-property-prefix:/{urn:ietf:params:xml:ns:caldav}schedule-calendar-transp/{urn:ietf:params:xml:ns:caldav}transparent</value --> + </arg> + <arg> + <name>notexists</name> + <value>$verify-property-prefix:/{DAV:}current-user-privilege-set/{DAV:}privilege/{DAV:}admin</value> + <value>$verify-property-prefix:/{DAV:}current-user-privilege-set/{DAV:}privilege/{DAV:}all</value> + </arg> + </verify> + </request> + </test> + <test name='16'> + <description>Shared calendar no longer exists Depth:1</description> + <request user="$userid2:" pswd="$pswd2:"> + <method>PROPFIND</method> + <ruri>$calendarhome2:</ruri> + <header> + <name>Depth</name> + <value>1</value> + </header> + <data> + <content-type>text/xml; charset=utf-8</content-type> + <filepath>Resource/CalDAV/sharing/calendars/read-write/4.xml</filepath> + </data> + <verify> + <callback>xmlElementMatch</callback> + <arg> + <name>notexists</name> + <value>$multistatus-response-prefix:[^{DAV:}href=$calendarhome2:/shared_shared_by_user01/]</value> + </arg> + </verify> + </request> + </test> </test-suite> - + + <!-- <test-suite name='Default calendar cannot be shared calendar'> <test name='1'> <description>Set property on Inbox</description> @@ -560,7 +572,10 @@ </test> </test-suite> +--> + <end> + <!-- <request user="$useradmin:" pswd="$pswdadmin:"> <method>DELETEALL</method> <ruri>$notificationpath1:/</ruri> @@ -568,6 +583,7 @@ <ruri>$notificationpath3:/</ruri> <ruri>$notificationpath4:/</ruri> </request> + --> </end> </caldavtest> diff --git a/apps/dav/tests/travis/caldavtest/tests/CardDAV/sharing-addressbooks.xml b/apps/dav/tests/travis/caldavtest/tests/CardDAV/sharing-addressbooks.xml index 37b4941b9f1..84ee6265017 100644 --- a/apps/dav/tests/travis/caldavtest/tests/CardDAV/sharing-addressbooks.xml +++ b/apps/dav/tests/travis/caldavtest/tests/CardDAV/sharing-addressbooks.xml @@ -238,7 +238,70 @@ </verify> </request> </test> - </test-suite> + <test name='14'> + <description>Un-share by delete</description> + <request user="$userid2:" pswd="$pswd2:"> + <method>DELETE</method> + <ruri>$addressbookhome2:/addressbook_shared_by_user01/</ruri> + <verify> + <callback>statusCode</callback> + </verify> + </request> + </test> + <test name='15'> + <description>Original address book still exists</description> + <request> + <method>PROPFIND</method> + <ruri>$addressbookhome1:/addressbook/</ruri> + <header> + <name>Depth</name> + <value>0</value> + </header> + <data> + <content-type>text/xml; charset=utf-8</content-type> + <filepath>Resource/CardDAV/sharing/read-write/4.xml</filepath> + </data> + <verify> + <callback>xmlElementMatch</callback> + <arg> + <name>exists</name> + <value>$verify-property-prefix:/{DAV:}owner/{DAV:}href[=$principaluri1:]</value> + <value>$verify-property-prefix:/{DAV:}resourcetype/{DAV:}collection</value> + <value>$verify-property-prefix:/{DAV:}resourcetype/{urn:ietf:params:xml:ns:carddav}addressbook</value> + <value>$verify-property-prefix:/{DAV:}current-user-privilege-set/{DAV:}privilege/{DAV:}read</value> + <value>$verify-property-prefix:/{DAV:}current-user-privilege-set/{DAV:}privilege/{DAV:}write</value> + <value>$verify-property-prefix:/{DAV:}current-user-privilege-set/{DAV:}privilege/{DAV:}bind</value> + <value>$verify-property-prefix:/{DAV:}current-user-privilege-set/{DAV:}privilege/{DAV:}unbind</value> + </arg> + <arg> + <name>notexists</name> + <value>$verify-property-prefix:/{DAV:}current-user-privilege-set/{DAV:}privilege/{DAV:}admin</value> + <value>$verify-property-prefix:/{DAV:}current-user-privilege-set/{DAV:}privilege/{DAV:}all</value> + </arg> + </verify> </request> + </test> + <test name='16'> + <description>Shared calendar no longer exists Depth:1</description> + <request user="$userid2:" pswd="$pswd2:"> + <method>PROPFIND</method> + <ruri>$addressbookhome2:</ruri> + <header> + <name>Depth</name> + <value>1</value> + </header> + <data> + <content-type>text/xml; charset=utf-8</content-type> + <filepath>Resource/CardDAV/sharing/read-write/4.xml</filepath> + </data> + <verify> + <callback>xmlElementMatch</callback> + <arg> + <name>notexists</name> + <value>$multistatus-response-prefix:[^{DAV:}href=$addressbookhome2:/addressbook_shared_by_user01/]</value> + </arg> + </verify> + </request> + </test> </test-suite> <end> </end> diff --git a/apps/dav/tests/unit/caldav/caldavbackendtest.php b/apps/dav/tests/unit/caldav/caldavbackendtest.php index 939fd36fba8..aece738166a 100644 --- a/apps/dav/tests/unit/caldav/caldavbackendtest.php +++ b/apps/dav/tests/unit/caldav/caldavbackendtest.php @@ -23,9 +23,12 @@ namespace Tests\Connector\Sabre; use DateTime; use DateTimeZone; use OCA\DAV\CalDAV\CalDavBackend; +use OCA\DAV\CalDAV\Calendar; +use OCA\DAV\Connector\Sabre\Principal; use Sabre\CalDAV\Xml\Property\SupportedCalendarComponentSet; use Sabre\DAV\PropPatch; use Sabre\DAV\Xml\Property\Href; +use Sabre\DAVACL\IACL; use Test\TestCase; /** @@ -40,14 +43,30 @@ class CalDavBackendTest extends TestCase { /** @var CalDavBackend */ private $backend; - const UNIT_TEST_USER = 'caldav-unit-test'; + /** @var Principal | \PHPUnit_Framework_MockObject_MockObject */ + private $principal; + const UNIT_TEST_USER = 'principals/users/caldav-unit-test'; + const UNIT_TEST_USER1 = 'principals/users/caldav-unit-test1'; + const UNIT_TEST_GROUP = 'principals/groups/caldav-unit-test-group'; public function setUp() { parent::setUp(); + $this->principal = $this->getMockBuilder('OCA\DAV\Connector\Sabre\Principal') + ->disableOriginalConstructor() + ->setMethods(['getPrincipalByPath', 'getGroupMembership']) + ->getMock(); + $this->principal->method('getPrincipalByPath') + ->willReturn([ + 'uri' => 'principals/best-friend' + ]); + $this->principal->method('getGroupMembership') + ->withAnyParameters() + ->willReturn([self::UNIT_TEST_GROUP]); + $db = \OC::$server->getDatabaseConnection(); - $this->backend = new CalDavBackend($db); + $this->backend = new CalDavBackend($db, $this->principal); $this->tearDown(); } @@ -90,6 +109,87 @@ class CalDavBackendTest extends TestCase { $this->assertEquals(0, count($books)); } + public function providesSharingData() { + return [ + [true, true, true, false, [ + [ + 'href' => 'principal:' . self::UNIT_TEST_USER1, + 'readOnly' => false + ], + [ + 'href' => 'principal:' . self::UNIT_TEST_GROUP, + 'readOnly' => true + ] + ]], + [true, false, false, false, [ + [ + 'href' => 'principal:' . self::UNIT_TEST_USER1, + 'readOnly' => true + ], + ]], + + ]; + } + + /** + * @dataProvider providesSharingData + */ + public function testCalendarSharing($userCanRead, $userCanWrite, $groupCanRead, $groupCanWrite, $add) { + + $calendarId = $this->createTestCalendar(); + $books = $this->backend->getCalendarsForUser(self::UNIT_TEST_USER); + $this->assertEquals(1, count($books)); + $calendar = new Calendar($this->backend, $books[0]); + $this->backend->updateShares($calendar, $add, []); + $books = $this->backend->getCalendarsForUser(self::UNIT_TEST_USER1); + $this->assertEquals(1, count($books)); + $calendar = new Calendar($this->backend, $books[0]); + $acl = $calendar->getACL(); + $this->assertAcl(self::UNIT_TEST_USER, '{DAV:}read', $acl); + $this->assertAcl(self::UNIT_TEST_USER, '{DAV:}write', $acl); + $this->assertAccess($userCanRead, self::UNIT_TEST_USER1, '{DAV:}read', $acl); + $this->assertAccess($userCanWrite, self::UNIT_TEST_USER1, '{DAV:}write', $acl); + $this->assertAccess($groupCanRead, self::UNIT_TEST_GROUP, '{DAV:}read', $acl); + $this->assertAccess($groupCanWrite, self::UNIT_TEST_GROUP, '{DAV:}write', $acl); + $this->assertEquals(self::UNIT_TEST_USER, $calendar->getOwner()); + + // test acls on the child + $uri = $this->getUniqueID('calobj'); + $calData = <<<'EOD' +BEGIN:VCALENDAR +VERSION:2.0 +PRODID:ownCloud Calendar +BEGIN:VEVENT +CREATED;VALUE=DATE-TIME:20130910T125139Z +UID:47d15e3ec8 +LAST-MODIFIED;VALUE=DATE-TIME:20130910T125139Z +DTSTAMP;VALUE=DATE-TIME:20130910T125139Z +SUMMARY:Test Event +DTSTART;VALUE=DATE-TIME:20130912T130000Z +DTEND;VALUE=DATE-TIME:20130912T140000Z +CLASS:PUBLIC +END:VEVENT +END:VCALENDAR +EOD; + + $this->backend->createCalendarObject($calendarId, $uri, $calData); + + /** @var IACL $child */ + $child = $calendar->getChild($uri); + $acl = $child->getACL(); + $this->assertAcl(self::UNIT_TEST_USER, '{DAV:}read', $acl); + $this->assertAcl(self::UNIT_TEST_USER, '{DAV:}write', $acl); + $this->assertAccess($userCanRead, self::UNIT_TEST_USER1, '{DAV:}read', $acl); + $this->assertAccess($userCanWrite, self::UNIT_TEST_USER1, '{DAV:}write', $acl); + $this->assertAccess($groupCanRead, self::UNIT_TEST_GROUP, '{DAV:}read', $acl); + $this->assertAccess($groupCanWrite, self::UNIT_TEST_GROUP, '{DAV:}write', $acl); + + // delete the address book + $this->backend->deleteCalendar($books[0]['id']); + $books = $this->backend->getCalendarsForUser(self::UNIT_TEST_USER); + $this->assertEquals(0, count($books)); + } + public function testCalendarObjectsOperations() { $calendarId = $this->createTestCalendar(); @@ -345,4 +445,32 @@ EOD; $sos = $this->backend->getSchedulingObjects(self::UNIT_TEST_USER); $this->assertEquals(0, count($sos)); } + + private function assertAcl($principal, $privilege, $acl) { + foreach($acl as $a) { + if ($a['principal'] === $principal && $a['privilege'] === $privilege) { + $this->assertTrue(true); + return; + } + } + $this->fail("ACL does not contain $principal / $privilege"); + } + + private function assertNotAcl($principal, $privilege, $acl) { + foreach($acl as $a) { + if ($a['principal'] === $principal && $a['privilege'] === $privilege) { + $this->fail("ACL contains $principal / $privilege"); + return; + } + } + $this->assertTrue(true); + } + + private function assertAccess($shouldHaveAcl, $principal, $privilege, $acl) { + if ($shouldHaveAcl) { + $this->assertAcl($principal, $privilege, $acl); + } else { + $this->assertNotAcl($principal, $privilege, $acl); + } + } } diff --git a/apps/dav/tests/unit/caldav/calendartest.php b/apps/dav/tests/unit/caldav/calendartest.php new file mode 100644 index 00000000000..93b3f4bff8c --- /dev/null +++ b/apps/dav/tests/unit/caldav/calendartest.php @@ -0,0 +1,64 @@ +<?php +/** + * @author Thomas Müller <thomas.mueller@tmit.eu> + * + * @copyright Copyright (c) 2016, ownCloud, Inc. + * @license AGPL-3.0 + * + * This code is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License, version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License, version 3, + * along with this program. If not, see <http://www.gnu.org/licenses/> + * + */ + +namespace OCA\DAV\Tests\Unit\CalDAV; + +use OCA\DAV\CalDAV\CalDavBackend; +use OCA\DAV\CalDAV\Calendar; +use Test\TestCase; + +class CalendarTest extends TestCase { + + public function testDelete() { + /** @var \PHPUnit_Framework_MockObject_MockObject | CalDavBackend $backend */ + $backend = $this->getMockBuilder('OCA\DAV\CalDAV\CalDavBackend')->disableOriginalConstructor()->getMock(); + $backend->expects($this->once())->method('updateShares'); + $backend->method('getShares')->willReturn([ + ['href' => 'principal:user2'] + ]); + $calendarInfo = [ + '{http://owncloud.org/ns}owner-principal' => 'user1', + 'principaluri' => 'user2', + 'id' => 666 + ]; + $c = new Calendar($backend, $calendarInfo); + $c->delete(); + } + + /** + * @expectedException \Sabre\DAV\Exception\Forbidden + */ + public function testDeleteFromGroup() { + /** @var \PHPUnit_Framework_MockObject_MockObject | CalDavBackend $backend */ + $backend = $this->getMockBuilder('OCA\DAV\CalDAV\CalDavBackend')->disableOriginalConstructor()->getMock(); + $backend->expects($this->never())->method('updateShares'); + $backend->method('getShares')->willReturn([ + ['href' => 'principal:group2'] + ]); + $calendarInfo = [ + '{http://owncloud.org/ns}owner-principal' => 'user1', + 'principaluri' => 'user2', + 'id' => 666 + ]; + $c = new Calendar($backend, $calendarInfo); + $c->delete(); + } +} diff --git a/apps/dav/tests/unit/carddav/addressbooktest.php b/apps/dav/tests/unit/carddav/addressbooktest.php new file mode 100644 index 00000000000..d714fc71679 --- /dev/null +++ b/apps/dav/tests/unit/carddav/addressbooktest.php @@ -0,0 +1,64 @@ +<?php +/** + * @author Thomas Müller <thomas.mueller@tmit.eu> + * + * @copyright Copyright (c) 2016, ownCloud, Inc. + * @license AGPL-3.0 + * + * This code is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License, version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License, version 3, + * along with this program. If not, see <http://www.gnu.org/licenses/> + * + */ + +namespace OCA\DAV\Tests\Unit\CardDAV; + +use OCA\DAV\CardDAV\AddressBook; +use OCA\DAV\CardDAV\CardDavBackend; +use Test\TestCase; + +class AddressBookTest extends TestCase { + + public function testDelete() { + /** @var \PHPUnit_Framework_MockObject_MockObject | CardDavBackend $backend */ + $backend = $this->getMockBuilder('OCA\DAV\CardDAV\CardDavBackend')->disableOriginalConstructor()->getMock(); + $backend->expects($this->once())->method('updateShares'); + $backend->method('getShares')->willReturn([ + ['href' => 'principal:user2'] + ]); + $calendarInfo = [ + '{http://owncloud.org/ns}owner-principal' => 'user1', + 'principaluri' => 'user2', + 'id' => 666 + ]; + $c = new AddressBook($backend, $calendarInfo); + $c->delete(); + } + + /** + * @expectedException \Sabre\DAV\Exception\Forbidden + */ + public function testDeleteFromGroup() { + /** @var \PHPUnit_Framework_MockObject_MockObject | CardDavBackend $backend */ + $backend = $this->getMockBuilder('OCA\DAV\CardDAV\CardDavBackend')->disableOriginalConstructor()->getMock(); + $backend->expects($this->never())->method('updateShares'); + $backend->method('getShares')->willReturn([ + ['href' => 'principal:group2'] + ]); + $calendarInfo = [ + '{http://owncloud.org/ns}owner-principal' => 'user1', + 'principaluri' => 'user2', + 'id' => 666 + ]; + $c = new AddressBook($backend, $calendarInfo); + $c->delete(); + } +} diff --git a/apps/dav/tests/unit/carddav/carddavbackendtest.php b/apps/dav/tests/unit/carddav/carddavbackendtest.php index 0158330a194..86bc26b4c0d 100644 --- a/apps/dav/tests/unit/carddav/carddavbackendtest.php +++ b/apps/dav/tests/unit/carddav/carddavbackendtest.php @@ -27,7 +27,6 @@ use OCA\DAV\CardDAV\AddressBook; use OCA\DAV\CardDAV\CardDavBackend; use OCA\DAV\Connector\Sabre\Principal; use OCP\IDBConnection; -use OCP\ILogger; use Sabre\DAV\PropPatch; use Sabre\VObject\Component\VCard; use Sabre\VObject\Property\Text; @@ -57,19 +56,24 @@ class CardDavBackendTest extends TestCase { /** @var string */ private $dbCardsPropertiesTable = 'cards_properties'; - const UNIT_TEST_USER = 'carddav-unit-test'; + const UNIT_TEST_USER = 'principals/users/carddav-unit-test'; + const UNIT_TEST_USER1 = 'principals/users/carddav-unit-test1'; + const UNIT_TEST_GROUP = 'principals/groups/carddav-unit-test-group'; public function setUp() { parent::setUp(); $this->principal = $this->getMockBuilder('OCA\DAV\Connector\Sabre\Principal') ->disableOriginalConstructor() - ->setMethods(['getPrincipalByPath']) + ->setMethods(['getPrincipalByPath', 'getGroupMembership']) ->getMock(); $this->principal->method('getPrincipalByPath') ->willReturn([ 'uri' => 'principals/best-friend' ]); + $this->principal->method('getGroupMembership') + ->withAnyParameters() + ->willReturn([self::UNIT_TEST_GROUP]); $this->db = \OC::$server->getDatabaseConnection(); @@ -124,6 +128,29 @@ class CardDavBackendTest extends TestCase { $this->assertEquals(0, count($books)); } + public function testAddressBookSharing() { + + $this->backend->createAddressBook(self::UNIT_TEST_USER, 'Example', []); + $books = $this->backend->getAddressBooksForUser(self::UNIT_TEST_USER); + $this->assertEquals(1, count($books)); + $addressBook = new AddressBook($this->backend, $books[0]); + $this->backend->updateShares($addressBook, [ + [ + 'href' => 'principal:' . self::UNIT_TEST_USER1, + ], + [ + 'href' => 'principal:' . self::UNIT_TEST_GROUP, + ] + ], []); + $books = $this->backend->getAddressBooksForUser(self::UNIT_TEST_USER1); + $this->assertEquals(1, count($books)); + + // delete the address book + $this->backend->deleteAddressBook($books[0]['id']); + $books = $this->backend->getAddressBooksForUser(self::UNIT_TEST_USER); + $this->assertEquals(0, count($books)); + } + public function testCardOperations() { /** @var CardDavBackend | \PHPUnit_Framework_MockObject_MockObject $backend */ |