Example #1
0
 /**
  * @NoAdminRequired
  * @NoCSRFRequired
  */
 public function index()
 {
     \OCP\Util::addscript('core', 'tags');
     \OCP\Util::addStyle($this->appName, 'style');
     \OCP\Util::addStyle($this->appName, 'jquery.Jcrop');
     \OCP\Util::addStyle($this->appName, '3rdparty/fontello/css/animation');
     \OCP\Util::addStyle($this->appName, '3rdparty/fontello/css/fontello');
     \OCP\Util::addStyle($this->appName, '3rdparty/jquery.webui-popover');
     \OCP\Util::addscript($this->appName, 'app');
     \OCP\Util::addscript($this->appName, '3rdparty/jquery.webui-popover');
     \OCP\Util::addscript($this->appName, 'settings');
     \OCP\Util::addscript($this->appName, 'loader');
     \OCP\Util::addscript($this->appName, 'jquery.scrollTo.min');
     \OCP\Util::addscript($this->appName, 'jquery.nicescroll.min');
     \OCP\Util::addscript('files', 'jquery.fileupload');
     \OCP\Util::addscript($this->appName, 'jquery.Jcrop');
     $iosSupport = $this->configInfo->getUserValue($this->userId, $this->appName, 'iossupport');
     $maxUploadFilesize = \OCP\Util::maxUploadFilesize('/');
     $addressbooks = Addressbook::all($this->userId);
     if (count($addressbooks) == 0) {
         Addressbook::addDefault($this->userId);
         $addressbooks = Addressbook::all($this->userId);
     }
     //ContactsApp::addingDummyContacts(50);
     $params = ['uploadMaxFilesize' => $maxUploadFilesize, 'uploadMaxHumanFilesize' => \OCP\Util::humanFileSize($maxUploadFilesize), 'iossupport' => $iosSupport, 'addressbooks' => $addressbooks];
     $csp = new \OCP\AppFramework\Http\ContentSecurityPolicy();
     $csp->addAllowedImageDomain('*');
     $csp->addAllowedFrameDomain('*');
     $response = new TemplateResponse($this->appName, 'index');
     $response->setContentSecurityPolicy($csp);
     $response->setParams($params);
     return $response;
 }
Example #2
0
    /**
     * @NoAdminRequired
     * @NoCSRFRequired
     */
    public function index() {
        $status = $this->statusService->getStatus();
        $response = new TemplateResponse($this->appName, 'index', [
            'cronWarning' => $status['warnings']['improperlyConfiguredCron']
        ]);

        // set csp rules for ownCloud 8.1
        if (class_exists('OCP\AppFramework\Http\ContentSecurityPolicy')) {
            $csp = new \OCP\AppFramework\Http\ContentSecurityPolicy();
            $csp->addAllowedImageDomain('*');
            $csp->addAllowedMediaDomain('*');
            $csp->addAllowedFrameDomain('https://youtube.com');
            $csp->addAllowedFrameDomain('https://www.youtube.com');
            $csp->addAllowedFrameDomain('https://player.vimeo.com');
            $csp->addAllowedFrameDomain('https://www.player.vimeo.com');
            $response->setContentSecurityPolicy($csp);
        }

        return $response;
    }
Example #3
0
 /**
  * @NoAdminRequired
  * @NoCSRFRequired
  *
  * @return TemplateResponse renders the index page
  */
 public function index()
 {
     $response = new TemplateResponse($this->appName, 'index', []);
     // set csp rules for ownCloud 8.1
     if (class_exists('OCP\\AppFramework\\Http\\ContentSecurityPolicy')) {
         $csp = new \OCP\AppFramework\Http\ContentSecurityPolicy();
         $csp->addAllowedFrameDomain('\'self\'');
         $response->setContentSecurityPolicy($csp);
     }
     return $response;
 }
Example #4
0
 public function testIndex()
 {
     $expected = new TemplateResponse($this->appName, 'index', []);
     // set csp rules for ownCloud 8.1
     if (class_exists('OCP\\AppFramework\\Http\\ContentSecurityPolicy')) {
         $csp = new \OCP\AppFramework\Http\ContentSecurityPolicy();
         $csp->addAllowedFrameDomain('\'self\'');
         $expected->setContentSecurityPolicy($csp);
     }
     $response = $this->controller->index();
     $this->assertEquals($expected, $response);
 }
Example #5
0
 /**
  * @NoAdminRequired
  * @NoCSRFRequired
  */
 public function index()
 {
     $iosSupport = $this->configInfo->getUserValue($this->userId, $this->appName, 'iossupport');
     $activeView = $this->configInfo->getUserValue($this->userId, $this->appName, 'view', 'listview');
     $lastSelectedBook = $this->configInfo->getUserValue($this->userId, $this->appName, 'currentbook', 0);
     $maxUploadFilesize = \OCP\Util::maxUploadFilesize('/');
     $addressbooks = Addressbook::all($this->userId);
     if (count($addressbooks) == 0) {
         Addressbook::addDefault($this->userId);
         $addressbooks = Addressbook::all($this->userId);
     }
     //ContactsApp::addingDummyContacts(1000);
     $params = ['uploadMaxFilesize' => $maxUploadFilesize, 'uploadMaxHumanFilesize' => \OCP\Util::humanFileSize($maxUploadFilesize), 'iossupport' => $iosSupport, 'addressbooks' => $addressbooks, 'activeView' => $activeView, 'lastSelectedBook' => $lastSelectedBook];
     $csp = new \OCP\AppFramework\Http\ContentSecurityPolicy();
     $csp->addAllowedImageDomain('*');
     $csp->addAllowedFrameDomain('*');
     $response = new TemplateResponse($this->appName, 'index');
     $response->setContentSecurityPolicy($csp);
     $response->setParams($params);
     return $response;
 }
Example #6
0
 public function testShowShare()
 {
     $owner = $this->getMock('OCP\\IUser');
     $owner->method('getDisplayName')->willReturn('ownerDisplay');
     $owner->method('getUID')->willReturn('ownerUID');
     $file = $this->getMock('OCP\\Files\\File');
     $file->method('getName')->willReturn('file1.txt');
     $file->method('getMimetype')->willReturn('text/plain');
     $file->method('getSize')->willReturn(33);
     $file->method('isReadable')->willReturn(true);
     $file->method('isShareable')->willReturn(true);
     $share = \OC::$server->getShareManager()->newShare();
     $share->setId(42);
     $share->setPassword('password')->setShareOwner('ownerUID')->setNode($file)->setTarget('/file1.txt');
     $this->session->method('exists')->with('public_link_authenticated')->willReturn(true);
     $this->session->method('get')->with('public_link_authenticated')->willReturn('42');
     $this->previewManager->method('isMimeSupported')->with('text/plain')->willReturn(true);
     $this->config->method('getSystemValue')->willReturnMap([['max_filesize_animated_gifs_public_sharing', 10, 10], ['enable_previews', true, true]]);
     $shareTmpl['maxSizeAnimateGif'] = $this->config->getSystemValue('max_filesize_animated_gifs_public_sharing', 10);
     $shareTmpl['previewEnabled'] = $this->config->getSystemValue('enable_previews', true);
     $this->shareManager->expects($this->once())->method('getShareByToken')->with('token')->willReturn($share);
     $this->userManager->method('get')->with('ownerUID')->willReturn($owner);
     $response = $this->shareController->showShare('token');
     $sharedTmplParams = array('displayName' => 'ownerDisplay', 'owner' => 'ownerUID', 'filename' => 'file1.txt', 'directory_path' => '/file1.txt', 'mimetype' => 'text/plain', 'dirToken' => 'token', 'sharingToken' => 'token', 'server2serversharing' => true, 'protected' => 'true', 'dir' => '', 'downloadURL' => null, 'fileSize' => '33 B', 'nonHumanFileSize' => 33, 'maxSizeAnimateGif' => 10, 'previewSupported' => true, 'previewEnabled' => true);
     $csp = new \OCP\AppFramework\Http\ContentSecurityPolicy();
     $csp->addAllowedFrameDomain('\'self\'');
     $expectedResponse = new TemplateResponse($this->appName, 'public', $sharedTmplParams, 'base');
     $expectedResponse->setContentSecurityPolicy($csp);
     $this->assertEquals($expectedResponse, $response);
 }
 public function testShowShare()
 {
     $this->container['UserManager']->expects($this->exactly(2))->method('userExists')->with($this->user)->will($this->returnValue(true));
     // Test without a not existing token
     $response = $this->shareController->showShare('ThisTokenShouldHopefullyNeverExistSoThatTheUnitTestWillAlwaysPass :)');
     $expectedResponse = new NotFoundResponse();
     $this->assertEquals($expectedResponse, $response);
     // Test with a password protected share and no authentication
     $response = $this->shareController->showShare($this->token);
     $expectedResponse = new RedirectResponse($this->urlGenerator->linkToRoute('files_sharing.sharecontroller.authenticate', array('token' => $this->token)));
     $this->assertEquals($expectedResponse, $response);
     // Test with password protected share and authentication
     $linkItem = Share::getShareByToken($this->token, false);
     \OC::$server->getSession()->set('public_link_authenticated', $linkItem['id']);
     $response = $this->shareController->showShare($this->token);
     $sharedTmplParams = array('displayName' => $this->user, 'filename' => 'file1.txt', 'directory_path' => '/file1.txt', 'mimetype' => 'text/plain', 'dirToken' => $this->token, 'sharingToken' => $this->token, 'server2serversharing' => true, 'protected' => 'true', 'dir' => '', 'downloadURL' => null, 'fileSize' => '33 B', 'nonHumanFileSize' => 33, 'maxSizeAnimateGif' => 10, 'previewSupported' => true, 'previewEnabled' => true);
     $csp = new \OCP\AppFramework\Http\ContentSecurityPolicy();
     $csp->addAllowedFrameDomain('\'self\'');
     $expectedResponse = new TemplateResponse($this->container['AppName'], 'public', $sharedTmplParams, 'base');
     $expectedResponse->setContentSecurityPolicy($csp);
     $this->assertEquals($expectedResponse, $response);
 }