]> source.dussan.org Git - nextcloud-server.git/commitdiff
Don't list on public calendar endpoints 4224/head
authorLukas Reschke <lukas@statuscode.ch>
Wed, 5 Apr 2017 20:43:05 +0000 (22:43 +0200)
committerLukas Reschke <lukas@statuscode.ch>
Wed, 5 Apr 2017 20:43:05 +0000 (22:43 +0200)
There is no need to allow listing here.

Signed-off-by: Lukas Reschke <lukas@statuscode.ch>
apps/dav/lib/CalDAV/PublicCalendarRoot.php
apps/dav/tests/unit/CalDAV/PublicCalendarRootTest.php
build/integration/features/bootstrap/CalDavContext.php
build/integration/features/caldav.feature

index 6d74b97f96ea92581582b306b92356faa6b27d7d..94fb7e5e4d52291376523f14bd408b12d51e58b4 100644 (file)
@@ -21,7 +21,6 @@
 namespace OCA\DAV\CalDAV;
 
 use Sabre\DAV\Collection;
-use Sabre\DAV\Exception\NotFound;
 
 class PublicCalendarRoot extends Collection {
 
@@ -48,6 +47,7 @@ class PublicCalendarRoot extends Collection {
         */
        function getChild($name) {
                $calendar = $this->caldavBackend->getPublicCalendar($name);
+               $calendar['{http://owncloud.org/ns}owner-principal'] = '';
                return new Calendar($this->caldavBackend, $calendar, $this->l10n);
        }
 
@@ -55,13 +55,6 @@ class PublicCalendarRoot extends Collection {
         * @inheritdoc
         */
        function getChildren() {
-               $calendars = $this->caldavBackend->getPublicCalendars();
-               $children = [];
-               foreach ($calendars as $calendar) {
-                       // TODO: maybe implement a new class PublicCalendar ???
-                       $children[] = new Calendar($this->caldavBackend, $calendar, $this->l10n);
-               }
-
-               return $children;
+               return [];
        }
 }
index 59fa4747a93b83184e033bd80ca9a43737860b37..ccef0cf678b74813e37f82beb77563c818a3b423 100644 (file)
@@ -21,7 +21,7 @@ use Test\TestCase;
  */
 class PublicCalendarRootTest extends TestCase {
 
-       const UNIT_TEST_USER = 'principals/users/caldav-unit-test';
+       const UNIT_TEST_USER = '';
        /** @var CalDavBackend */
        private $backend;
        /** @var PublicCalendarRoot */
@@ -92,13 +92,8 @@ class PublicCalendarRootTest extends TestCase {
 
        public function testGetChildren() {
                $this->createPublicCalendar();
-
-               $publicCalendars = $this->backend->getPublicCalendars();
-
                $calendarResults = $this->publicCalendarRoot->getChildren();
-
-               $this->assertEquals(1, count($calendarResults));
-               $this->assertEquals(new Calendar($this->backend, $publicCalendars[0], $this->l10n), $calendarResults[0]);
+               $this->assertSame([], $calendarResults);
        }
 
        /**
index 4843dde135a96fdc8994a0baeb696cf1eb83e827..8c0348f37a85d664eac5358dedac26e2a8b01c52 100644 (file)
@@ -89,7 +89,7 @@ class CalDavContext implements \Behat\Behat\Context\Context {
                                        'auth' => [
                                                $user,
                                                $password,
-                                       ]
+                                       ],
                                ]
                        );
                        $this->response = $this->client->send($request);
@@ -184,4 +184,51 @@ class CalDavContext implements \Behat\Behat\Context\Context {
                $this->response = $this->client->send($request);
        }
 
+       /**
+        * @Then :user publicly shares the calendar named :name
+        *
+        * @param string $user
+        * @param string $name
+        */
+       public function publiclySharesTheCalendarNamed($user, $name) {
+               $davUrl = $this->baseUrl . '/remote.php/dav/calendars/'.$user.'/'.$name;
+               $password = ($user === 'admin') ? 'admin' : '123456';
+
+               $request = $this->client->createRequest(
+                       'POST',
+                       $davUrl,
+                       [
+                               'body' => '<cs:publish-calendar xmlns:cs="http://calendarserver.org/ns/"/>',
+                               'auth' => [
+                                       $user,
+                                       $password,
+                               ],
+                               'headers' => [
+                                       'Content-Type' => 'application/xml; charset=UTF-8',
+                               ],
+                       ]
+               );
+
+               $this->response = $this->client->send($request);
+       }
+
+       /**
+        * @Then There should be :amount calendars in the response body
+        *
+        * @param string $amount
+        */
+       public function t($amount) {
+               $jsonEncoded = json_encode($this->responseXml);
+               $arrayElement = json_decode($jsonEncoded, true);
+               $actual = count($arrayElement['value']) - 1;
+               if($actual !== (int)$amount) {
+                       throw new InvalidArgumentException(
+                               sprintf(
+                                       'Expected %s got %s',
+                                       $amount,
+                                       $actual
+                               )
+                       );
+               }
+       }
 }
index 5c3983fc40b87da303a2f82923903290915a5579..2bddbc3e9e4086ff3ccb907934096a98e5ef650f 100644 (file)
@@ -50,3 +50,12 @@ Feature: caldav
     Then The CalDAV HTTP status code should be "201"
     And "admin" requests calendar "admin/MyCalendar" on the endpoint "/remote.php/dav/calendars/"
     Then The CalDAV HTTP status code should be "207"
+
+  Scenario: Propfind on public calendar endpoint without calendars
+    When "admin" creates a calendar named "MyCalendar"
+    Then The CalDAV HTTP status code should be "201"
+    And "admin" publicly shares the calendar named "MyCalendar"
+    Then The CalDAV HTTP status code should be "202"
+    When "admin" requests calendar "/" on the endpoint "/remote.php/dav/public-calendars"
+    Then The CalDAV HTTP status code should be "207"
+    Then There should be "0" calendars in the response body
\ No newline at end of file