mirror of
https://github.com/nextcloud/server.git
synced 2026-05-14 01:21:32 -04:00
test(integration): write integration tests for calendar delegation
Signed-off-by: Hamza <hamzamahjoubi221@gmail.com>
This commit is contained in:
parent
98203ef17b
commit
ec039f7f22
4 changed files with 90 additions and 74 deletions
26
.drone.yml
26
.drone.yml
|
|
@ -941,6 +941,32 @@ trigger:
|
|||
- pull_request
|
||||
- push
|
||||
|
||||
---
|
||||
kind: pipeline
|
||||
name: integration-caldav-delegation
|
||||
|
||||
steps:
|
||||
- name: submodules
|
||||
image: ghcr.io/nextcloud/continuous-integration-alpine-git:latest
|
||||
commands:
|
||||
- git submodule update --init
|
||||
- name: integration-caldav-delegation
|
||||
image: ghcr.io/nextcloud/continuous-integration-integration-php7.4:latest
|
||||
commands:
|
||||
- curl -O -L https://getcomposer.org/download/2.9.2/composer.phar && chmod +x composer.phar && mv composer.phar /usr/local/bin/composer
|
||||
- bash tests/drone-run-integration-tests.sh || exit 0
|
||||
- ./occ maintenance:install --admin-pass=admin --data-dir=/dev/shm/nc_int
|
||||
- cd build/integration
|
||||
- ./run.sh features/caldav-delegation.feature
|
||||
|
||||
trigger:
|
||||
branch:
|
||||
- master
|
||||
- stable*
|
||||
event:
|
||||
- pull_request
|
||||
- push
|
||||
|
||||
---
|
||||
kind: pipeline
|
||||
name: integration-comments
|
||||
|
|
|
|||
|
|
@ -60,17 +60,21 @@ class CalDavContext implements \Behat\Behat\Context\Context {
|
|||
|
||||
/** @AfterScenario */
|
||||
public function afterScenario() {
|
||||
foreach (['MyCalendar', 'MyCalendar2'] as $calendarName) {
|
||||
try {
|
||||
$this->client->delete(
|
||||
$this->baseUrl . '/remote.php/dav/calendars/admin/' . $calendarName,
|
||||
[
|
||||
'auth' => ['admin', 'admin'],
|
||||
'headers' => ['X-NC-CalDAV-No-Trashbin' => '1'],
|
||||
$davUrl = $this->baseUrl. '/remote.php/dav/calendars/admin/MyCalendar';
|
||||
try {
|
||||
$this->client->delete(
|
||||
$davUrl,
|
||||
[
|
||||
'auth' => [
|
||||
'admin',
|
||||
'admin',
|
||||
],
|
||||
'headers' => [
|
||||
'X-NC-CalDAV-No-Trashbin' => '1',
|
||||
]
|
||||
);
|
||||
} catch (\GuzzleHttp\Exception\ClientException $e) {
|
||||
}
|
||||
]
|
||||
);
|
||||
} catch (\GuzzleHttp\Exception\ClientException $e) {
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -122,39 +126,11 @@ class CalDavContext implements \Behat\Behat\Context\Context {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @When :user requests principal :principal on the endpoint :endpoint
|
||||
*/
|
||||
public function requestsPrincipal(string $user, string $principal, string $endpoint): void {
|
||||
$davUrl = $this->baseUrl . $endpoint . $principal;
|
||||
|
||||
$password = ($user === 'admin') ? 'admin' : '123456';
|
||||
try {
|
||||
$this->response = $this->client->request(
|
||||
'PROPFIND',
|
||||
$davUrl,
|
||||
[
|
||||
'headers' => [
|
||||
'Content-Type' => 'application/xml; charset=UTF-8',
|
||||
'Depth' => 0,
|
||||
],
|
||||
'body' => '<x0:propfind xmlns:x0="DAV:"><x0:prop><x0:displayname/><x1:calendar-user-type xmlns:x1="urn:ietf:params:xml:ns:caldav"/><x1:calendar-user-address-set xmlns:x1="urn:ietf:params:xml:ns:caldav"/><x0:principal-URL/><x0:alternate-URI-set/><x2:email-address xmlns:x2="http://sabredav.org/ns"/><x3:language xmlns:x3="http://nextcloud.com/ns"/><x1:calendar-home-set xmlns:x1="urn:ietf:params:xml:ns:caldav"/><x1:schedule-inbox-URL xmlns:x1="urn:ietf:params:xml:ns:caldav"/><x1:schedule-outbox-URL xmlns:x1="urn:ietf:params:xml:ns:caldav"/><x1:schedule-default-calendar-URL xmlns:x1="urn:ietf:params:xml:ns:caldav"/><x3:resource-type xmlns:x3="http://nextcloud.com/ns"/><x3:resource-vehicle-type xmlns:x3="http://nextcloud.com/ns"/><x3:resource-vehicle-make xmlns:x3="http://nextcloud.com/ns"/><x3:resource-vehicle-model xmlns:x3="http://nextcloud.com/ns"/><x3:resource-vehicle-is-electric xmlns:x3="http://nextcloud.com/ns"/><x3:resource-vehicle-range xmlns:x3="http://nextcloud.com/ns"/><x3:resource-vehicle-seating-capacity xmlns:x3="http://nextcloud.com/ns"/><x3:resource-contact-person xmlns:x3="http://nextcloud.com/ns"/><x3:resource-contact-person-vcard xmlns:x3="http://nextcloud.com/ns"/><x3:room-type xmlns:x3="http://nextcloud.com/ns"/><x3:room-seating-capacity xmlns:x3="http://nextcloud.com/ns"/><x3:room-building-address xmlns:x3="http://nextcloud.com/ns"/><x3:room-building-story xmlns:x3="http://nextcloud.com/ns"/><x3:room-building-room-number xmlns:x3="http://nextcloud.com/ns"/><x3:room-features xmlns:x3="http://nextcloud.com/ns"/><x0:principal-collection-set/><x0:supported-report-set/></x0:prop></x0:propfind>',
|
||||
'auth' => [
|
||||
$user,
|
||||
$password,
|
||||
],
|
||||
]
|
||||
);
|
||||
} catch (\GuzzleHttp\Exception\ClientException $e) {
|
||||
$this->response = $e->getResponse();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @Then The CalDAV response should contain a property :key
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function theCaldavResponseShouldContainAProperty(string $key): void {
|
||||
public function theCaldavResponseShouldContainAProperty(string $key) {
|
||||
/** @var \Sabre\DAV\Xml\Response\MultiStatus $multiStatus */
|
||||
$multiStatus = $this->responseXml['value'];
|
||||
$responses = $multiStatus->getResponses()[0]->getResponseProperties();
|
||||
|
|
@ -179,42 +155,11 @@ class CalDavContext implements \Behat\Behat\Context\Context {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @Then The CalDAV response should contain a property :key with a href value :value
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function theCaldavResponseShouldContainAPropertyWithHrefValue(
|
||||
string $key,
|
||||
string $value,
|
||||
): void {
|
||||
/** @var \Sabre\DAV\Xml\Response\MultiStatus $multiStatus */
|
||||
$multiStatus = $this->responseXml['value'];
|
||||
$responses = $multiStatus->getResponses()[0]->getResponseProperties();
|
||||
if (!isset($responses[200])) {
|
||||
throw new \Exception(
|
||||
sprintf(
|
||||
'Expected code 200 got [%s]',
|
||||
implode(',', array_keys($responses)),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$props = $responses[200];
|
||||
if (!array_key_exists($key, $props)) {
|
||||
throw new \Exception("Cannot find property \"$key\"");
|
||||
}
|
||||
|
||||
$actualValue = $props[$key]->getHref();
|
||||
if ($actualValue !== $value) {
|
||||
throw new \Exception("Property \"$key\" found with value \"$actualValue\", expected \"$value\"");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @Then The CalDAV response should contain an href :href
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function theCaldavResponseShouldContainAnHref(string $href): void {
|
||||
public function theCaldavResponseShouldContainAnHref(string $href) {
|
||||
/** @var \Sabre\DAV\Xml\Response\MultiStatus $multiStatus */
|
||||
$multiStatus = $this->responseXml['value'];
|
||||
foreach ($multiStatus->getResponses() as $response) {
|
||||
|
|
@ -234,7 +179,7 @@ class CalDavContext implements \Behat\Behat\Context\Context {
|
|||
* @Then The CalDAV response should be multi status
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function theCaldavResponseShouldBeMultiStatus(): void {
|
||||
public function theCaldavResponseShouldBeMultiStatus() {
|
||||
if ($this->response->getStatusCode() !== 207) {
|
||||
throw new \Exception(
|
||||
sprintf(
|
||||
|
|
@ -384,4 +329,42 @@ class CalDavContext implements \Behat\Behat\Context\Context {
|
|||
);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @Given :user updates property :key to href :value of principal :principal on the endpoint :endpoint
|
||||
*/
|
||||
public function updatesHrefPropertyOfPrincipal(
|
||||
string $user,
|
||||
string $key,
|
||||
string $value,
|
||||
string $principal,
|
||||
string $endpoint
|
||||
) {
|
||||
$davUrl = $this->baseUrl . $endpoint . $principal;
|
||||
$password = ($user === 'admin') ? 'admin' : '123456';
|
||||
|
||||
$propPatch = new \Sabre\DAV\Xml\Request\PropPatch();
|
||||
$propPatch->properties = [$key => new \Sabre\DAV\Xml\Property\Href($value)];
|
||||
|
||||
$xml = new \Sabre\Xml\Service();
|
||||
$body = $xml->write('{DAV:}propertyupdate', $propPatch, '/');
|
||||
|
||||
try {
|
||||
$this->response = $this->client->request(
|
||||
'PROPPATCH',
|
||||
$davUrl,
|
||||
[
|
||||
'headers' => [
|
||||
'Content-Type' => 'application/xml; charset=UTF-8',
|
||||
],
|
||||
'body' => $body,
|
||||
'auth' => [
|
||||
$user,
|
||||
$password,
|
||||
],
|
||||
]
|
||||
);
|
||||
} catch (\GuzzleHttp\Exception\ClientException $e) {
|
||||
$this->response = $e->getResponse();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,4 +20,11 @@ Feature: calendar delegation
|
|||
When "admin" updates property "{DAV:}group-member-set" to href "/remote.php/dav/principals/users/user0" of principal "users/admin/calendar-proxy-write" on the endpoint "/remote.php/dav/principals/"
|
||||
Then The CalDAV response should be multi status
|
||||
And The CalDAV response should contain an href "/remote.php/dav/principals/users/admin/calendar-proxy-write"
|
||||
And The CalDAV response should contain a property "{DAV:}group-member-set"
|
||||
And The CalDAV response should contain a property "{DAV:}group-member-set"
|
||||
|
||||
Scenario: Admin cannot grant User1 access to User0's calendar account
|
||||
Given user "admin" exists
|
||||
And user "user0" exists
|
||||
And user "user1" exists
|
||||
When "admin" updates property "{DAV:}group-member-set" to href "/remote.php/dav/principals/users/user1" of principal "users/user0/calendar-proxy-write" on the endpoint "/remote.php/dav/principals/"
|
||||
Then The CalDAV HTTP status code should be "404"
|
||||
|
|
@ -26,7 +26,7 @@ else
|
|||
fi
|
||||
NC_DATADIR=$($OCC config:system:get datadirectory)
|
||||
|
||||
composer install
|
||||
composer install --no-audit
|
||||
|
||||
# avoid port collision on jenkins - use $EXECUTOR_NUMBER
|
||||
if [ -z "$EXECUTOR_NUMBER" ]; then
|
||||
|
|
|
|||
Loading…
Reference in a new issue