Exemplo n.º 1
0
 /**
  * @expectedException \OCA\GalleryPlus\Environment\NotFoundEnvException
  */
 public function testGetDisplayName()
 {
     $userId = null;
     $userFolder = null;
     $this->mockSetEnvironment($userId, $userFolder);
     $this->environment->getDisplayName();
 }
Exemplo n.º 2
0
 /**
  * Returns the node matching the given ID
  *
  * @param int $nodeId ID of the resource to locate
  *
  * @return Node
  * @throws NotFoundServiceException
  */
 public function getResourceFromId($nodeId)
 {
     try {
         $node = $this->environment->getResourceFromId($nodeId);
         // Making extra sure that we can actually do something with the file
         if (!$node->getMimetype() || !$node->isReadable()) {
             throw new NotFoundServiceException("Can't access the file");
         }
         return $node;
     } catch (\Exception $exception) {
         throw new NotFoundServiceException($exception->getMessage());
     }
 }
Exemplo n.º 3
0
 /**
  * Returns the node matching the given ID
  *
  * @param int $nodeId ID of the resource to locate
  *
  * @return Node|null
  *
  * @throws NotFoundServiceException
  */
 public function getResourceFromId($nodeId)
 {
     try {
         $node = $this->environment->getResourceFromId($nodeId);
         // Making extra sure that we can actually do something with the file
         if ($node->getMimetype() && $node->isReadable()) {
             return $node;
         } else {
             $this->logAndThrowNotFound("Can't access the file");
         }
     } catch (\Exception $exception) {
         $this->logAndThrowNotFound($exception->getMessage());
     }
 }
Exemplo n.º 4
0
 /**
  * Determines if we can add external shared to this instance
  *
  * @return array<bool,string>
  */
 private function getServer2ServerProperties()
 {
     $server2ServerSharing = $this->appConfig->getAppValue('files_sharing', 'outgoing_server2server_share_enabled', 'yes');
     $server2ServerSharing = $server2ServerSharing === 'yes' ? true : false;
     $password = $this->environment->getSharePassword();
     $passwordProtected = $password ? 'true' : 'false';
     return [$server2ServerSharing, $passwordProtected];
 }
Exemplo n.º 5
0
 /**
  * Shows the albums and pictures the token gives access to
  *
  * @param $token
  *
  * @return TemplateResponse
  */
 private function showPublicPage($token)
 {
     $albumName = $this->environment->getSharedFolderName();
     $server2ServerSharing = $this->appConfig->getAppValue('files_sharing', 'outgoing_server2server_share_enabled', 'yes');
     $server2ServerSharing = $server2ServerSharing === 'yes' ? true : false;
     $protected = $this->environment->isShareProtected();
     $protected = $protected ? 'true' : 'false';
     // Parameters sent to the template
     $params = ['appName' => $this->appName, 'token' => $token, 'displayName' => $this->environment->getDisplayName(), 'albumName' => $albumName, 'server2ServerSharing' => $server2ServerSharing, 'protected' => $protected, 'filename' => $albumName];
     // Will render the page using the template found in templates/public.php
     return new TemplateResponse($this->appName, 'public', $params, 'public');
 }
Exemplo n.º 6
0
 /**
  * Checks that we have a token and an optional password giving access to a
  * valid resource. Sets the token based environment after that
  *
  * @throws CheckException
  */
 private function validateAndSetTokenBasedEnv()
 {
     $token = $this->request->getParam('token');
     if (!$token) {
         throw new CheckException("Can't access a public resource without a token", Http::STATUS_NOT_FOUND);
     } else {
         $linkItem = $this->getLinkItem($token);
         $password = $this->request->getParam('password');
         // Let's see if the user needs to provide a password
         $this->checkAuthorisation($linkItem, $password);
         $this->environment->setTokenBasedEnv($linkItem);
     }
 }
Exemplo n.º 7
0
 /**
  * Checks that we have a token and an optional password giving access to a
  * valid resource. Sets the token based environment after that
  */
 private function validateAndSetTokenBasedEnv()
 {
     $token = $this->request->getParam('token');
     if (!$token) {
         $this->noTokenFound();
     } else {
         // We have a token
         // Let's see if it's linked to a valid resource
         $linkItem = $this->getLinkItem($token);
         $password = $this->request->getParam('password');
         // Let's see if the user needs to provide a password
         $this->checkAuthorisation($linkItem, $password);
         $this->environment->setTokenBasedEnv($linkItem);
     }
 }
Exemplo n.º 8
0
 protected function mockGetPathFromVirtualRoot($node, $path)
 {
     $this->environment->expects($this->any())->method('getPathFromVirtualRoot')->with($node)->willReturn($path);
 }
Exemplo n.º 9
0
 private function mockGetSharePassword($password)
 {
     $this->environment->expects($this->once())->method('getSharePassword')->willReturn($password);
 }