diff options
author | Roeland Jago Douma <roeland@famdouma.nl> | 2018-06-14 10:20:10 +0200 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2018-06-20 08:53:37 +0200 |
commit | 9f658febcafb0a51c20ef114a2a8e76bc9d05445 (patch) | |
tree | 2657f88ec740d0a234c5dbd263558bf95f6a5103 /apps/files_sharing/lib | |
parent | ff3f63fd4746441c08bdb79d771b5c3e3da259c8 (diff) | |
download | nextcloud-server-9f658febcafb0a51c20ef114a2a8e76bc9d05445.tar.gz nextcloud-server-9f658febcafb0a51c20ef114a2a8e76bc9d05445.zip |
Fix ShareControllerTest
* Removed tests that are now handled by the middleware
* Updated tests
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'apps/files_sharing/lib')
-rw-r--r-- | apps/files_sharing/lib/Controller/ShareController.php | 39 |
1 files changed, 7 insertions, 32 deletions
diff --git a/apps/files_sharing/lib/Controller/ShareController.php b/apps/files_sharing/lib/Controller/ShareController.php index cb54c0b28f1..0b30a599c7f 100644 --- a/apps/files_sharing/lib/Controller/ShareController.php +++ b/apps/files_sharing/lib/Controller/ShareController.php @@ -49,7 +49,6 @@ use OCP\Template; use OCP\Share; use OCP\IRequest; use OCP\AppFramework\Http\TemplateResponse; -use OCP\AppFramework\Http\RedirectResponse; use OCP\AppFramework\Http\NotFoundResponse; use OCP\IURLGenerator; use OCP\IConfig; @@ -114,7 +113,7 @@ class ShareController extends AuthPublicShareController { * @param IL10N $l10n * @param Defaults $defaults */ - public function __construct($appName, + public function __construct(string $appName, IRequest $request, IConfig $config, IURLGenerator $urlGenerator, @@ -171,34 +170,8 @@ class ShareController extends AuthPublicShareController { $this->session->set('public_link_authenticated', (string)$this->share->getId()); } - /** - * Authenticate a link item with the given password. - * Or use the session if no password is provided. - * - * This is a modified version of Helper::authenticate - * TODO: Try to merge back eventually with Helper::authenticate - * - * @param \OCP\Share\IShare $share - * @param string|null $password - * @return bool - */ - private function linkShareAuth(\OCP\Share\IShare $share, $password = null) { - if ($password !== null) { - if ($this->shareManager->checkPassword($share, $password)) { - $this->session->regenerateId(true, true); - $this->session->set('public_link_authenticated', (string)$share->getId()); - } else { - $this->emitAccessShareHook($share, 403, 'Wrong password'); - return false; - } - } else { - // not authenticated ? - if ( ! $this->session->exists('public_link_authenticated') - || $this->session->get('public_link_authenticated') !== (string)$share->getId()) { - return false; - } - } - return true; + protected function authFailed() { + $this->emitAccessShareHook($this->share, 403, 'Wrong password'); } /** @@ -463,13 +436,15 @@ class ShareController extends AuthPublicShareController { } } - $userFolder = $this->rootFolder->getUserFolder($share->getShareOwner()); - $originalSharePath = $userFolder->getRelativePath($share->getNode()->getPath()); if (!$this->validateShare($share)) { throw new NotFoundException(); } + $userFolder = $this->rootFolder->getUserFolder($share->getShareOwner()); + $originalSharePath = $userFolder->getRelativePath($share->getNode()->getPath()); + + // Single file share if ($share->getNode() instanceof \OCP\Files\File) { // Single file download |