diff options
author | Roeland Jago Douma <roeland@famdouma.nl> | 2017-08-10 17:25:58 +0300 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2017-08-10 17:25:58 +0300 |
commit | 685f27221289a2b33918048b62427a44573511bb (patch) | |
tree | 4185c28e622a3992222e60a9e0b68c00156d14da /apps/files_sharing/lib | |
parent | c9d2e31d527190660c51a75741747178f029091c (diff) |
Add unit 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/ShareInfoController.php | 31 | ||||
-rw-r--r-- | apps/files_sharing/lib/Middleware/ShareInfoMiddleware.php | 8 |
2 files changed, 23 insertions, 16 deletions
diff --git a/apps/files_sharing/lib/Controller/ShareInfoController.php b/apps/files_sharing/lib/Controller/ShareInfoController.php index 696b064ac0f..ccf7b7093a5 100644 --- a/apps/files_sharing/lib/Controller/ShareInfoController.php +++ b/apps/files_sharing/lib/Controller/ShareInfoController.php @@ -20,17 +20,19 @@ class ShareInfoController extends ApiController { /** @var IManager */ private $shareManager; - /** @var ILogger */ - private $logger; - + /** + * ShareInfoController constructor. + * + * @param string $appName + * @param IRequest $request + * @param IManager $shareManager + */ public function __construct($appName, IRequest $request, - IManager $shareManager, - ILogger $logger) { + IManager $shareManager) { parent::__construct($appName, $request); $this->shareManager = $shareManager; - $this->logger = $logger; } /** @@ -58,15 +60,9 @@ class ShareInfoController extends ApiController { return new JSONResponse([], Http::STATUS_FORBIDDEN); } - // TODO FIX!!! $isWritable = $share->getPermissions() & (\OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_CREATE); if (!$isWritable) { - // FIXME: should not add storage wrappers outside of preSetup, need to find a better way - $previousLog = \OC\Files\Filesystem::logWarningWhenAddingStorageWrapper(false); - \OC\Files\Filesystem::addStorageWrapper('readonly', function ($mountPoint, $storage) { - return new \OC\Files\Storage\Wrapper\PermissionsMask(array('storage' => $storage, 'mask' => \OCP\Constants::PERMISSION_READ + \OCP\Constants::PERMISSION_SHARE)); - }); - \OC\Files\Filesystem::logWarningWhenAddingStorageWrapper($previousLog); + $this->addROWrapper(); } $node = $share->getNode(); @@ -122,4 +118,13 @@ class ShareInfoController extends ApiController { return $entry; } + + protected function addROWrapper() { + // FIXME: should not add storage wrappers outside of preSetup, need to find a better way + $previousLog = \OC\Files\Filesystem::logWarningWhenAddingStorageWrapper(false); + \OC\Files\Filesystem::addStorageWrapper('readonly', function ($mountPoint, $storage) { + return new \OC\Files\Storage\Wrapper\PermissionsMask(array('storage' => $storage, 'mask' => \OCP\Constants::PERMISSION_READ + \OCP\Constants::PERMISSION_SHARE)); + }); + \OC\Files\Filesystem::logWarningWhenAddingStorageWrapper($previousLog); + } } diff --git a/apps/files_sharing/lib/Middleware/ShareInfoMiddleware.php b/apps/files_sharing/lib/Middleware/ShareInfoMiddleware.php index a069ecacc2a..56e9b48f570 100644 --- a/apps/files_sharing/lib/Middleware/ShareInfoMiddleware.php +++ b/apps/files_sharing/lib/Middleware/ShareInfoMiddleware.php @@ -25,7 +25,7 @@ class ShareInfoMiddleware extends Middleware { * @param string $methodName * @throws S2SException */ - public function beforeController(Controller $controller, $methodName) { + public function beforeController($controller, $methodName) { if (!($controller instanceof ShareInfoController)) { return; } @@ -42,7 +42,7 @@ class ShareInfoMiddleware extends Middleware { * @throws \Exception * @return Response */ - public function afterException(Controller $controller, $methodName, \Exception $exception) { + public function afterException($controller, $methodName, \Exception $exception) { if (!($controller instanceof ShareInfoController)) { throw $exception; } @@ -50,6 +50,8 @@ class ShareInfoMiddleware extends Middleware { if ($exception instanceof S2SException) { return new JSONResponse([], Http::STATUS_NOT_FOUND); } + + throw $exception; } /** @@ -58,7 +60,7 @@ class ShareInfoMiddleware extends Middleware { * @param Response $response * @return Response */ - public function afterController(Controller $controller, $methodName, Response $response) { + public function afterController($controller, $methodName, Response $response) { if (!($controller instanceof ShareInfoController)) { return $response; } |