adds another caldav frontend test
authorPhilipp Schüle <p.schuele@metaways.de>
Thu, 22 Jun 2017 13:47:27 +0000 (15:47 +0200)
committerPhilipp Schüle <p.schuele@metaways.de>
Thu, 22 Jun 2017 15:11:08 +0000 (17:11 +0200)
... and clarifies getChildren for paths like
/calendars/CONTACT_ID
with non-delegation clients

see also 0010198: Latest GIT breaks some Cal/CardDAV stuff

https://forge.tine20.org/view.php?id=10198

Change-Id: I119378fb787706ac99c775060e51f2df4861e80a
Reviewed-on: http://gerrit.tine20.com/customers/4931
Tested-by: Jenkins CI (http://ci.tine20.com/)
Reviewed-by: Philipp Schüle <p.schuele@metaways.de>
tests/tine20/Calendar/Frontend/CalDAVTest.php
tine20/Tinebase/WebDav/Collection/AbstractContainerTree.php

index 09c288e..56c2bbe 100644 (file)
@@ -38,9 +38,32 @@ class Calendar_Frontend_CalDAVTest extends TestCase
         $this->assertTrue(array_reduce($children, function($result, $container){
             return $result || $container instanceof Tasks_Frontend_WebDAV_Container;
         }, FALSE), 'tasks container is missing');
-        
+
         return $children;
     }
+
+    public function testGetUserDirectory()
+    {
+        $grants = Tinebase_Model_Grants::getPersonalGrants($this->_personas['sclever']->getId());
+        $grants->merge(new Tinebase_Record_RecordSet('Tinebase_Model_Grants', array(array(
+            'account_id' => Tinebase_Core::getUser()->getId(),
+            'account_type' => Tinebase_Acl_Rights::ACCOUNT_TYPE_USER,
+            Tinebase_Model_Grants::GRANT_READ => true,
+            Tinebase_Model_Grants::GRANT_EXPORT => true,
+            Tinebase_Model_Grants::GRANT_SYNC => true,
+        ))));
+        $scleverTestCal = $this->_getCalendarTestContainer(Tinebase_Model_Container::TYPE_PERSONAL, $grants);
+
+        $_SERVER['HTTP_USER_AGENT'] = 'xxx';
+        $collection = new Calendar_Frontend_WebDAV(\Sabre\CalDAV\Plugin::CALENDAR_ROOT . '/' . $this->_personas['sclever']->contact_id, true);
+        $children = $collection->getChildren();
+
+        $containerIds = [];
+        foreach ($children as $child) {
+            $containerIds[] = $child->getName();
+        }
+        self::assertTrue(in_array($scleverTestCal->getId(), $containerIds));
+    }
     
     /**
      * test getChild
@@ -366,7 +389,7 @@ END:VCALENDAR&#13;
      *
      * @return Tinebase_Model_Container
      */
-    protected function _getCalendarTestContainer($type = Tinebase_Model_Container::TYPE_PERSONAL)
+    protected function _getCalendarTestContainer($type = Tinebase_Model_Container::TYPE_PERSONAL, $grants = null)
     {
         $container = Tinebase_Container::getInstance()->addContainer(new Tinebase_Model_Container(array(
             'name'              => Tinebase_Record_Abstract::generateUID(),
@@ -374,7 +397,7 @@ END:VCALENDAR&#13;
             'type'              => $type,
             'backend'           => 'Sql',
             'application_id'    => Tinebase_Application::getInstance()->getApplicationByName('Calendar')->getId(),
-        )));
+        )), $grants);
         
         return $container;
     }
index 4ce15d0..5463274 100644 (file)
@@ -548,6 +548,7 @@ abstract class Tinebase_WebDav_Collection_AbstractContainerTree
                         )
                     );
                 } else {
+                    // NOTE: seems to be the expected behavior for non-delegation clients
                     $containers = $this->_containerController->getContainerByACL(Tinebase_Core::getUser(), $this->_getApplicationName(),  array(
                         Tinebase_Model_Grants::GRANT_READ,
                         Tinebase_Model_Grants::GRANT_SYNC