There is no need to allow listing here.
Signed-off-by: Lukas Reschke <lukas@statuscode.ch>
namespace OCA\DAV\CalDAV;
use Sabre\DAV\Collection;
-use Sabre\DAV\Exception\NotFound;
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);
}
* @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 [];
}
}
*/
class PublicCalendarRootTest extends TestCase {
- const UNIT_TEST_USER = 'principals/users/caldav-unit-test';
+ const UNIT_TEST_USER = '';
/** @var CalDavBackend */
private $backend;
/** @var PublicCalendarRoot */
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);
}
/**
'auth' => [
$user,
$password,
- ]
+ ],
]
);
$this->response = $this->client->send($request);
$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
+ )
+ );
+ }
+ }
}
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