From 09c6cd77ecb7c4ead4d68226a693e7588df80d09 Mon Sep 17 00:00:00 2001 From: Carl Schwan Date: Tue, 7 Jun 2022 14:14:14 +0200 Subject: Add test Signed-off-by: Carl Schwan --- build/integration/features/bootstrap/WebDav.php | 115 ++++++++++++++++++++++-- build/integration/features/dav-v2.feature | 6 ++ 2 files changed, 116 insertions(+), 5 deletions(-) (limited to 'build') diff --git a/build/integration/features/bootstrap/WebDav.php b/build/integration/features/bootstrap/WebDav.php index ae0659d5dda..680db01a260 100644 --- a/build/integration/features/bootstrap/WebDav.php +++ b/build/integration/features/bootstrap/WebDav.php @@ -32,8 +32,8 @@ * */ use GuzzleHttp\Client as GClient; +use GuzzleHttp\Message\ResponseInterface; use PHPUnit\Framework\Assert; -use Psr\Http\Message\ResponseInterface; use Sabre\DAV\Client as SClient; use Sabre\DAV\Xml\Property\ResourceType; @@ -220,6 +220,14 @@ trait WebDav { Assert::assertEquals($property, $value); } + /** + * @Then /^Image search should work$/ + */ + public function search(): void { + $this->searchFile($this->currentUser); + Assert::assertEquals(207, $this->response->getStatusCode()); + } + /** * @Then /^Downloaded content when downloading file "([^"]*)" with range "([^"]*)" should be "([^"]*)"$/ * @param string $fileSource @@ -393,13 +401,12 @@ trait WebDav { return $response; } - /* Returns the elements of a report command - * @param string $user - * @param string $path + /** + * Returns the elements of a profind command * @param string $properties properties which needs to be included in the report * @param string $filterRules filter-rules to choose what needs to appear in the report */ - public function propfindFile($user, $path, $properties = '') { + public function propfindFile(string $user, string $path, string $properties = '') { $client = $this->getSabreClient($user); $body = ' @@ -417,6 +424,104 @@ trait WebDav { return $parsedResponse; } + /** + * Returns the elements of a searc command + * @param string $properties properties which needs to be included in the report + * @param string $filterRules filter-rules to choose what needs to appear in the report + */ + public function searchFile(string $user, ?string $properties = null, ?string $scope = null, ?string $condition = null) { + $client = $this->getSabreClient($user); + + if ($properties === null) { + $properties = ' '; + } + + if ($condition === null) { + $condition = ' + + + + + + image/png + + + + + + + image/jpeg + + + + + + + image/heic + + + + + + + video/mp4 + + + + + + + video/quicktime + + + + + + + ' . $user . ' + +'; + } + + if ($scope === null) { + $scope = '/files/' . $user . 'infinity'; + } + + $body = ' + + + + ' . $properties . ' + + ' . $scope . ' + ' . $condition . ' + + + + + + + + 35 + 0 + + +'; + + try { + $this->response = $this->makeDavRequest($user, "SEARCH", '', [ + 'Content-Type' => 'text/xml' + ], $body, ''); + var_dump((string)$this->response->getBody()); + } catch (\GuzzleHttp\Exception\ServerException $e) { + // 5xx responses cause a server exception + $this->response = $e->getResponse(); + } catch (\GuzzleHttp\Exception\ClientException $e) { + // 4xx responses cause a client exception + $this->response = $e->getResponse(); + } + } + /* Returns the elements of a report command * @param string $user * @param string $path diff --git a/build/integration/features/dav-v2.feature b/build/integration/features/dav-v2.feature index 9ecce4c6bf9..5b5c835e0dd 100644 --- a/build/integration/features/dav-v2.feature +++ b/build/integration/features/dav-v2.feature @@ -80,3 +80,9 @@ Feature: dav-v2 And As an "user0" When User "user0" uploads file "data/textfile.txt" to "/testquota/asdf.txt" Then the HTTP status code should be "201" + + Scenario: Create a search query + Given using new dav path + And As an "admin" + When User "user0" uploads file "data/green-square-256.png" to "/image.png" + When Image search should work -- cgit v1.2.3