/**
  * @expectedException \OCA\Gallery\Environment\NotFoundEnvException
  */
 public function testGetDisplayName()
 {
     $userId = null;
     $userFolder = null;
     $this->mockSetEnvironment($userId, $userFolder);
     $this->environment->getDisplayName();
 }
Example #2
0
 /**
  * Returns the node matching the given ID
  *
  * @param int $nodeId ID of the resource to locate
  *
  * @return Node
  * @throws NotFoundServiceException
  */
 private function getNode($nodeId)
 {
     try {
         $node = $this->environment->getResourceFromId($nodeId);
         return $node;
     } catch (\Exception $exception) {
         throw new NotFoundServiceException($exception->getMessage());
     }
 }
Example #3
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());
     }
 }
 /**
  * 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];
 }
 /**
  * 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 {
         $share = $this->getShare($token);
         $password = $this->request->getParam('password');
         // Let's see if the user needs to provide a password
         $this->checkAuthorisation($share, $password);
         $this->environment->setTokenBasedEnv($share);
     }
 }
 private function mockGetSharePassword($password)
 {
     $this->environment->expects($this->once())->method('getSharePassword')->willReturn($password);
 }
 protected function mockGetPathFromVirtualRoot($node, $path)
 {
     $this->environment->expects($this->any())->method('getPathFromVirtualRoot')->with($node)->willReturn($path);
 }