Пример #1
0
 /**
  * @dataProvider deleteStorageDataProvider
  */
 public function testDeleteStorage($backendOptions, $rustyStorageId, $expectedCountAfterDeletion)
 {
     $backend = $this->backendService->getBackend('identifier:\\OCA\\Files_External\\Lib\\Backend\\SMB');
     $authMechanism = $this->backendService->getAuthMechanism('identifier:\\Auth\\Mechanism');
     $storage = new StorageConfig(255);
     $storage->setMountPoint('mountpoint');
     $storage->setBackend($backend);
     $storage->setAuthMechanism($authMechanism);
     $storage->setBackendOptions($backendOptions);
     $newStorage = $this->service->addStorage($storage);
     $this->assertEquals(1, $newStorage->getId());
     // manually trigger storage entry because normally it happens on first
     // access, which isn't possible within this test
     $storageCache = new \OC\Files\Cache\Storage($rustyStorageId);
     // get numeric id for later check
     $numericId = $storageCache->getNumericId();
     $newStorage = $this->service->removeStorage(1);
     $caught = false;
     try {
         $this->service->getStorage(1);
     } catch (NotFoundException $e) {
         $caught = true;
     }
     $this->assertTrue($caught);
     // storage id was removed from oc_storages
     $qb = \OC::$server->getDatabaseConnection()->getQueryBuilder();
     $storageCheckQuery = $qb->select('*')->from('storages')->where($qb->expr()->eq('numeric_id', $qb->expr()->literal($numericId)));
     $this->assertCount($expectedCountAfterDeletion, $storageCheckQuery->execute()->fetchAll());
 }
Пример #2
0
 private static function setAttributes($user_id, $saml_display_name, $saml_email, $saml_groups, $saml_quota)
 {
     /*$secure_cookie = \OC_Config::getValue("forcessl", false);
     		$expires = time() + \OC_Config::getValue('remember_login_cookie_lifetime', 60 * 60 * 24 * 15);
     		setcookie("oc_display_name", $saml_display_name, $expires, \OC::$WEBROOT, '', $secure_cookie);
     		setcookie("oc_mail", $saml_email, $expires, \OC::$WEBROOT, '', $secure_cookie);
     		setcookie("oc_quota", $saml_quota, $expires, \OC::$WEBROOT, '', $secure_cookie);
     		setcookie("oc_groups", json_encode($saml_groups), $expires, \OC::$WEBROOT, '', $secure_cookie);*/
     self::setRedirectCookie();
     $_SESSION["oc_display_name"] = $saml_display_name;
     $_SESSION["oc_mail"] = $saml_email;
     $_SESSION["oc_groups"] = $saml_groups;
     $_SESSION["oc_quota"] = $saml_quota;
     if (OCP\App::isEnabled('files_sharding') && OCA\FilesSharding\Lib::isMaster()) {
         //\OC_Util::setupFS();
         // Let slaves know which folders are data folders
         $dataFolders = OCA\FilesSharding\Lib::dbGetDataFoldersList($user_id);
         $_SESSION["oc_data_folders"] = $dataFolders;
         // Have slaves use the same numeric ID for "storages".
         $view = \OC\Files\Filesystem::getView();
         $rootInfo = $view->getFileInfo('');
         $storageId = $rootInfo->getStorage()->getId();
         $numericStorageId = OC\Files\Cache\Storage::getNumericStorageId($storageId);
         $_SESSION["oc_storage_id"] = $storageId;
         $_SESSION["oc_numeric_storage_id"] = $numericStorageId;
     }
 }