diff --git a/apps/dav/lib/CalDAV/PublicCalendarRoot.php b/apps/dav/lib/CalDAV/PublicCalendarRoot.php index 6d74b97f96..94fb7e5e4d 100644 --- a/apps/dav/lib/CalDAV/PublicCalendarRoot.php +++ b/apps/dav/lib/CalDAV/PublicCalendarRoot.php @@ -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 []; } } diff --git a/apps/dav/tests/unit/CalDAV/PublicCalendarRootTest.php b/apps/dav/tests/unit/CalDAV/PublicCalendarRootTest.php index 59fa4747a9..ccef0cf678 100644 --- a/apps/dav/tests/unit/CalDAV/PublicCalendarRootTest.php +++ b/apps/dav/tests/unit/CalDAV/PublicCalendarRootTest.php @@ -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); } /** diff --git a/build/integration/features/bootstrap/CalDavContext.php b/build/integration/features/bootstrap/CalDavContext.php index 4843dde135..8c0348f37a 100644 --- a/build/integration/features/bootstrap/CalDavContext.php +++ b/build/integration/features/bootstrap/CalDavContext.php @@ -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' => '', + '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 + ) + ); + } + } } diff --git a/build/integration/features/caldav.feature b/build/integration/features/caldav.feature index 5c3983fc40..2bddbc3e9e 100644 --- a/build/integration/features/caldav.feature +++ b/build/integration/features/caldav.feature @@ -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