diff options
-rw-r--r-- | apps/dav/lib/Connector/Sabre/FilesReportPlugin.php | 12 | ||||
-rw-r--r-- | apps/dav/lib/Files/RootCollection.php | 1 | ||||
-rw-r--r-- | apps/dav/lib/Server.php | 40 | ||||
-rw-r--r-- | apps/federation/lib/DAV/FedAuth.php | 8 | ||||
-rw-r--r-- | build/integration/features/bootstrap/WebDav.php | 24 | ||||
-rw-r--r-- | build/integration/features/webdav-related.feature | 16 |
6 files changed, 76 insertions, 25 deletions
diff --git a/apps/dav/lib/Connector/Sabre/FilesReportPlugin.php b/apps/dav/lib/Connector/Sabre/FilesReportPlugin.php index bc0c1c2f603..81c082b9105 100644 --- a/apps/dav/lib/Connector/Sabre/FilesReportPlugin.php +++ b/apps/dav/lib/Connector/Sabre/FilesReportPlugin.php @@ -24,9 +24,7 @@ namespace OCA\DAV\Connector\Sabre; use OC\Files\View; -use Sabre\DAV\Exception\NotFound; use Sabre\DAV\Exception\PreconditionFailed; -use Sabre\DAV\Exception\ReportNotSupported; use Sabre\DAV\Exception\BadRequest; use Sabre\DAV\ServerPlugin; use Sabre\DAV\Tree; @@ -105,7 +103,7 @@ class FilesReportPlugin extends ServerPlugin { * @param ITagManager $fileTagger manager for private tags * @param IUserSession $userSession * @param IGroupManager $groupManager - * @param Folder $userfolder + * @param Folder $userFolder */ public function __construct(Tree $tree, View $view, @@ -161,11 +159,12 @@ class FilesReportPlugin extends ServerPlugin { * REPORT operations to look for files * * @param string $reportName - * @param [] $report + * @param $report * @param string $uri * @return bool - * @throws NotFound - * @throws ReportNotSupported + * @throws BadRequest + * @throws PreconditionFailed + * @internal param $ [] $report */ public function onReport($reportName, $report, $uri) { $reportTargetNode = $this->server->tree->getNodeForPath($uri); @@ -232,7 +231,6 @@ class FilesReportPlugin extends ServerPlugin { private function getFilesBaseUri($uri, $subPath) { $uri = trim($uri, '/'); $subPath = trim($subPath, '/'); - $filesUri = ''; if (empty($subPath)) { $filesUri = $uri; } else { diff --git a/apps/dav/lib/Files/RootCollection.php b/apps/dav/lib/Files/RootCollection.php index 345015530e2..c73d7c175ce 100644 --- a/apps/dav/lib/Files/RootCollection.php +++ b/apps/dav/lib/Files/RootCollection.php @@ -21,6 +21,7 @@ */ namespace OCA\DAV\Files; +use Sabre\DAV\INode; use Sabre\DAVACL\AbstractPrincipalCollection; use Sabre\HTTP\URLUtil; use Sabre\DAV\SimpleCollection; diff --git a/apps/dav/lib/Server.php b/apps/dav/lib/Server.php index 1205d018241..79c4301a8d8 100644 --- a/apps/dav/lib/Server.php +++ b/apps/dav/lib/Server.php @@ -33,11 +33,14 @@ use OCA\DAV\CardDAV\ImageExportPlugin; use OCA\DAV\Comments\CommentsPlugin; use OCA\DAV\Connector\Sabre\Auth; use OCA\DAV\Connector\Sabre\BlockLegacyClientPlugin; +use OCA\DAV\Connector\Sabre\CommentPropertiesPlugin; use OCA\DAV\Connector\Sabre\CopyEtagHeaderPlugin; use OCA\DAV\Connector\Sabre\DavAclPlugin; use OCA\DAV\Connector\Sabre\DummyGetResponsePlugin; use OCA\DAV\Connector\Sabre\FakeLockerPlugin; use OCA\DAV\Connector\Sabre\FilesPlugin; +use OCA\DAV\Connector\Sabre\FilesReportPlugin; +use OCA\DAV\Connector\Sabre\SharesPlugin; use OCA\DAV\DAV\PublicAuth; use OCA\DAV\Connector\Sabre\QuotaPlugin; use OCA\DAV\Files\BrowserErrorPagePlugin; @@ -85,7 +88,6 @@ class Server { $this->server->addPlugin(new BlockLegacyClientPlugin(\OC::$server->getConfig())); $authPlugin = new Plugin(); - $authPlugin->addBackend($authBackend); $authPlugin->addBackend(new PublicAuth()); $this->server->addPlugin($authPlugin); @@ -166,7 +168,7 @@ class Server { // custom properties plugin must be the last one $userSession = \OC::$server->getUserSession(); $user = $userSession->getUser(); - if (!is_null($user)) { + if ($user !== null) { $view = \OC\Files\Filesystem::getView(); $this->server->addPlugin( new FilesPlugin( @@ -188,9 +190,10 @@ class Server { ) ) ); - $this->server->addPlugin( - new QuotaPlugin($view) - ); + if ($view !== null) { + $this->server->addPlugin( + new QuotaPlugin($view)); + } $this->server->addPlugin( new TagsPlugin( $this->server->tree, \OC::$server->getTagManager() @@ -198,28 +201,29 @@ class Server { ); // TODO: switch to LazyUserFolder $userFolder = \OC::$server->getUserFolder(); - $this->server->addPlugin(new \OCA\DAV\Connector\Sabre\SharesPlugin( + $this->server->addPlugin(new SharesPlugin( $this->server->tree, $userSession, $userFolder, \OC::$server->getShareManager() )); - $this->server->addPlugin(new \OCA\DAV\Connector\Sabre\CommentPropertiesPlugin( + $this->server->addPlugin(new CommentPropertiesPlugin( \OC::$server->getCommentsManager(), $userSession )); - $this->server->addPlugin(new \OCA\DAV\Connector\Sabre\FilesReportPlugin( - $this->server->tree, - $view, - \OC::$server->getSystemTagManager(), - \OC::$server->getSystemTagObjectMapper(), - \OC::$server->getTagManager(), - $userSession, - \OC::$server->getGroupManager(), - $userFolder - )); + if ($view !== null) { + $this->server->addPlugin(new FilesReportPlugin( + $this->server->tree, + $view, + \OC::$server->getSystemTagManager(), + \OC::$server->getSystemTagObjectMapper(), + \OC::$server->getTagManager(), + $userSession, + \OC::$server->getGroupManager(), + $userFolder + )); + } } - $this->server->addPlugin(new \OCA\DAV\Connector\Sabre\CopyEtagHeaderPlugin()); }); } diff --git a/apps/federation/lib/DAV/FedAuth.php b/apps/federation/lib/DAV/FedAuth.php index 705ccbdd3bb..ae78ffeded9 100644 --- a/apps/federation/lib/DAV/FedAuth.php +++ b/apps/federation/lib/DAV/FedAuth.php @@ -24,6 +24,8 @@ namespace OCA\Federation\DAV; use OCA\Federation\DbHandler; use Sabre\DAV\Auth\Backend\AbstractBasic; +use Sabre\HTTP\RequestInterface; +use Sabre\HTTP\ResponseInterface; class FedAuth extends AbstractBasic { @@ -57,4 +59,10 @@ class FedAuth extends AbstractBasic { protected function validateUserPass($username, $password) { return $this->db->auth($username, $password); } + + /** + * @inheritdoc + */ + function challenge(RequestInterface $request, ResponseInterface $response) { + } } diff --git a/build/integration/features/bootstrap/WebDav.php b/build/integration/features/bootstrap/WebDav.php index c44a6175579..6438a871fb1 100644 --- a/build/integration/features/bootstrap/WebDav.php +++ b/build/integration/features/bootstrap/WebDav.php @@ -657,4 +657,28 @@ trait WebDav { $this->asGetsPropertiesOfFolderWith($user, 'entry', $path, $propertiesTable); PHPUnit_Framework_Assert::assertNotEquals($this->response['{DAV:}getetag'], $this->storedETAG[$user][$path]); } + + /** + * @When Connecting to dav endpoint + */ + public function connectingToDavEndpoint() { + try { + $this->response = $this->makeDavRequest(null, 'PROPFIND', '', []); + } catch (\GuzzleHttp\Exception\ClientException $e) { + $this->response = $e->getResponse(); + } + } + + /** + * @Then there are no duplicate headers + */ + public function thereAreNoDuplicateHeaders() { + $headers = $this->response->getHeaders(); + foreach ($headers as $headerName => $headerValues) { + // if a header has multiple values, they must be different + if (count($headerValues) > 1 && count(array_unique($headerValues)) < count($headerValues)) { + throw new \Exception('Duplicate header found: ' . $headerName); + } + } + } } diff --git a/build/integration/features/webdav-related.feature b/build/integration/features/webdav-related.feature index b75fdd35618..c3aa6145527 100644 --- a/build/integration/features/webdav-related.feature +++ b/build/integration/features/webdav-related.feature @@ -2,6 +2,22 @@ Feature: webdav-related Background: Given using api version "1" + Scenario: Unauthenticated call old dav path + Given using old dav path + When connecting to dav endpoint + Then the HTTP status code should be "401" + And there are no duplicate headers + And The following headers should be set + |WWW-Authenticate|Basic realm="Nextcloud"| + + Scenario: Unauthenticated call new dav path + Given using new dav path + When connecting to dav endpoint + Then the HTTP status code should be "401" + And there are no duplicate headers + And The following headers should be set + |WWW-Authenticate|Basic realm="Nextcloud"| + Scenario: Moving a file Given using old dav path And As an "admin" |