public function setUp() { OC_User::clearBackends(); OC_User::useBackend('dummy'); $this->user1 = uniqid('user1_'); $this->user2 = uniqid('user2_'); $this->user3 = uniqid('user3_'); $this->user4 = uniqid('user4_'); OC_User::createUser($this->user1, 'pass'); OC_User::createUser($this->user2, 'pass'); OC_User::createUser($this->user3, 'pass'); OC_User::createUser($this->user4, 'pass'); OC_User::setUserId($this->user1); OC_Group::clearBackends(); OC_Group::useBackend(new OC_Group_Dummy()); $this->group1 = uniqid('group_'); $this->group2 = uniqid('group_'); OC_Group::createGroup($this->group1); OC_Group::createGroup($this->group2); OC_Group::addToGroup($this->user1, $this->group1); OC_Group::addToGroup($this->user2, $this->group1); OC_Group::addToGroup($this->user3, $this->group1); OC_Group::addToGroup($this->user2, $this->group2); OC_Group::addToGroup($this->user4, $this->group2); OCP\Share::registerBackend('test', 'Test_Share_Backend'); OC_Hook::clear('OCP\\Share'); OC::registerShareHooks(); $this->resharing = OC_Appconfig::getValue('core', 'shareapi_allow_resharing', 'yes'); OC_Appconfig::setValue('core', 'shareapi_allow_resharing', 'yes'); // 20 Minutes in the past, 20 minutes in the future. $now = time(); $dateFormat = 'Y-m-d H:i:s'; $this->dateInPast = date($dateFormat, $now - 20 * 60); $this->dateInFuture = date($dateFormat, $now + 20 * 60); }
public static function setUpBeforeClass() { parent::setUpBeforeClass(); $appManager = \OC::$server->getAppManager(); self::$trashBinStatus = $appManager->isEnabledForUser('files_trashbin'); // reset backend \OC_User::clearBackends(); \OC_User::useBackend('database'); // clear share hooks \OC_Hook::clear('OCP\\Share'); \OC::registerShareHooks(); $application = new \OCA\Files_Sharing\AppInfo\Application(); $application->registerMountProviders(); //disable encryption \OC_App::disable('encryption'); $config = \OC::$server->getConfig(); //configure trashbin self::$rememberRetentionObligation = $config->getSystemValue('trashbin_retention_obligation', Files_Trashbin\Expiration::DEFAULT_RETENTION_OBLIGATION); $config->setSystemValue('trashbin_retention_obligation', 'auto, 2'); // register hooks Files_Trashbin\Trashbin::registerHooks(); // create test user self::loginHelper(self::TEST_TRASHBIN_USER2, true); self::loginHelper(self::TEST_TRASHBIN_USER1, true); }
/** * */ function run() { if ($this->checkGet('app', 'usv2')) { $uid = $this->tokens->getUserId(); if ($uid === false || $uid === null) { if ($this->appConfig->getValue('user_servervars2', 'stop_if_empty', false)) { throw new \Exception('token error'); } // Danger: possibilité de fabriquer une boucle avec janus $ssoURL = $this->appConfig->getValue('user_servervars2', 'sso_url', 'http://localhost/sso'); $this->redirector->redirectTo($ssoURL); } else { $isLoggedIn = $this->uag->isLoggedIn(); if (!$isLoggedIn) { $isLoggedIn = $this->uag->login($uid); } if (!$isLoggedIn) { // if ( !$this->uag->isLoggedIn()) { \OC_Log::write('servervars', 'Error trying to log-in the user' . $uid, \OC_Log::DEBUG); return; } \OC::$REQUESTEDAPP = ''; $this->redirector->redirectToDefaultPage(); } } }
public static function setUpBeforeClass() { parent::setUpBeforeClass(); // note: not using a data provider because these // files all need to coexist to make sure the // share keys are found properly (pattern matching) self::$testFiles = array('t est.txt', 't est_.txt', 't est.doc.txt', 't est(.*).txt', 'multiple.dots.can.happen.too.txt', 't est.' . self::TEST_ENCRYPTION_HOOKS_USER1 . '.txt', 't est_.' . self::TEST_ENCRYPTION_HOOKS_USER1 . '.shareKey.txt', 'who would upload their.shareKey', 'user ones file.txt', 'user ones file.txt.backup', '.t est.txt'); // reset backend \OC_User::clearBackends(); \OC_User::useBackend('database'); \OC_Hook::clear('OC_Filesystem'); \OC_Hook::clear('OC_User'); // clear share hooks \OC_Hook::clear('OCP\\Share'); \OC::registerShareHooks(); \OCP\Util::connectHook('OC_Filesystem', 'setup', '\\OC\\Files\\Storage\\Shared', 'setup'); // Filesystem related hooks \OCA\Encryption\Helper::registerFilesystemHooks(); // Sharing related hooks \OCA\Encryption\Helper::registerShareHooks(); // clear and register proxies \OC_FileProxy::clearProxies(); \OC_FileProxy::register(new OCA\Encryption\Proxy()); // create test user self::loginHelper(\Test_Encryption_Hooks::TEST_ENCRYPTION_HOOKS_USER1, true); self::loginHelper(\Test_Encryption_Hooks::TEST_ENCRYPTION_HOOKS_USER2, true); }
public static function setUpBeforeClass() { // reset backend \OC_User::clearBackends(); \OC_User::useBackend('database'); // enable resharing \OC_Appconfig::setValue('core', 'shareapi_allow_resharing', 'yes'); // clear share hooks \OC_Hook::clear('OCP\\Share'); \OC::registerShareHooks(); \OCP\Util::connectHook('OC_Filesystem', 'setup', '\\OC\\Files\\Storage\\Shared', 'setup'); // Sharing related hooks \OCA\Encryption\Helper::registerShareHooks(); // Filesystem related hooks \OCA\Encryption\Helper::registerFilesystemHooks(); // clear and register hooks \OC_FileProxy::clearProxies(); \OC_FileProxy::register(new OCA\Encryption\Proxy()); // create users \Test_Encryption_Util::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1, true); \Test_Encryption_Util::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2, true); \Test_Encryption_Util::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER3, true); \Test_Encryption_Util::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER4, true); // create group and assign users \OC_Group::createGroup(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_GROUP1); \OC_Group::addToGroup(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER3, \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_GROUP1); \OC_Group::addToGroup(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER4, \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_GROUP1); }
public static function setUpBeforeClass() { parent::setUpBeforeClass(); $application = new Application(); $application->registerMountProviders(); // reset backend \OC_User::clearBackends(); \OC_Group::clearBackends(); // clear share hooks \OC_Hook::clear('OCP\\Share'); \OC::registerShareHooks(); // create users $backend = new \Test\Util\User\Dummy(); \OC_User::useBackend($backend); $backend->createUser(self::TEST_FILES_SHARING_API_USER1, self::TEST_FILES_SHARING_API_USER1); $backend->createUser(self::TEST_FILES_SHARING_API_USER2, self::TEST_FILES_SHARING_API_USER2); $backend->createUser(self::TEST_FILES_SHARING_API_USER3, self::TEST_FILES_SHARING_API_USER3); $backend->createUser(self::TEST_FILES_SHARING_API_USER4, self::TEST_FILES_SHARING_API_USER4); // create group $groupBackend = new \OC_Group_Dummy(); $groupBackend->createGroup(self::TEST_FILES_SHARING_API_GROUP1); $groupBackend->createGroup('group'); $groupBackend->addToGroup(self::TEST_FILES_SHARING_API_USER1, 'group'); $groupBackend->addToGroup(self::TEST_FILES_SHARING_API_USER2, 'group'); $groupBackend->addToGroup(self::TEST_FILES_SHARING_API_USER3, 'group'); $groupBackend->addToGroup(self::TEST_FILES_SHARING_API_USER2, self::TEST_FILES_SHARING_API_GROUP1); \OC_Group::useBackend($groupBackend); }
public static function setUpBeforeClass() { parent::setUpBeforeClass(); // remember files_encryption state self::$stateFilesEncryption = \OC_App::isEnabled('files_encryption'); //we don't want to tests with app files_encryption enabled \OC_App::disable('files_encryption'); // reset backend \OC_User::clearBackends(); \OC_User::useBackend('database'); // clear share hooks \OC_Hook::clear('OCP\\Share'); \OC::registerShareHooks(); \OCP\Util::connectHook('OC_Filesystem', 'setup', '\\OC\\Files\\Storage\\Shared', 'setup'); // create users $backend = new \OC_User_Dummy(); \OC_User::useBackend($backend); $backend->createUser(self::TEST_FILES_SHARING_API_USER1, self::TEST_FILES_SHARING_API_USER1); $backend->createUser(self::TEST_FILES_SHARING_API_USER2, self::TEST_FILES_SHARING_API_USER2); $backend->createUser(self::TEST_FILES_SHARING_API_USER3, self::TEST_FILES_SHARING_API_USER3); // create group $groupBackend = new \OC_Group_Dummy(); $groupBackend->createGroup(self::TEST_FILES_SHARING_API_GROUP1); $groupBackend->createGroup('group'); $groupBackend->addToGroup(self::TEST_FILES_SHARING_API_USER1, 'group'); $groupBackend->addToGroup(self::TEST_FILES_SHARING_API_USER2, 'group'); $groupBackend->addToGroup(self::TEST_FILES_SHARING_API_USER3, 'group'); $groupBackend->addToGroup(self::TEST_FILES_SHARING_API_USER2, self::TEST_FILES_SHARING_API_GROUP1); \OC_Group::useBackend($groupBackend); }
public static function setUpBeforeClass() { parent::setUpBeforeClass(); // reset backend \OC_User::clearBackends(); \OC_User::useBackend('database'); \OC_Hook::clear('OC_Filesystem'); \OC_Hook::clear('OC_User'); \OC_Hook::clear('OCP\\Share'); // trashbin hooks \OCA\Files_Trashbin\Trashbin::registerHooks(); // Filesystem related hooks \OCA\Encryption\Helper::registerFilesystemHooks(); // register share hooks \OC::registerShareHooks(); \OCA\Files_Sharing\Helper::registerHooks(); // Sharing related hooks \OCA\Encryption\Helper::registerShareHooks(); // Filesystem related hooks \OCA\Encryption\Helper::registerFilesystemHooks(); // clear and register hooks \OC_FileProxy::clearProxies(); \OC_FileProxy::register(new OCA\Files\Share\Proxy()); \OC_FileProxy::register(new OCA\Encryption\Proxy()); // create test user self::loginHelper(self::TEST_ENCRYPTION_TRASHBIN_USER2, true); self::loginHelper(self::TEST_ENCRYPTION_TRASHBIN_USER1, true); }
public function setUp() { OC_User::clearBackends(); OC_User::useBackend('dummy'); $this->user1 = uniqid('user1_'); $this->user2 = uniqid('user2_'); $this->user3 = uniqid('user3_'); $this->user4 = uniqid('user4_'); OC_User::createUser($this->user1, 'pass'); OC_User::createUser($this->user2, 'pass'); OC_User::createUser($this->user3, 'pass'); OC_User::createUser($this->user4, 'pass'); OC_User::setUserId($this->user1); OC_Group::clearBackends(); OC_Group::useBackend(new OC_Group_Dummy()); $this->group1 = uniqid('group_'); $this->group2 = uniqid('group_'); OC_Group::createGroup($this->group1); OC_Group::createGroup($this->group2); OC_Group::addToGroup($this->user1, $this->group1); OC_Group::addToGroup($this->user2, $this->group1); OC_Group::addToGroup($this->user3, $this->group1); OC_Group::addToGroup($this->user2, $this->group2); OC_Group::addToGroup($this->user4, $this->group2); OCP\Share::registerBackend('test', 'Test_Share_Backend'); OC_Hook::clear('OCP\\Share'); OC::registerShareHooks(); }
public static function setUpBeforeClass() { parent::setUpBeforeClass(); // reset backend \OC_User::clearBackends(); \OC_User::useBackend('database'); // enable resharing \OC::$server->getAppConfig()->setValue('core', 'shareapi_allow_resharing', 'yes'); // clear share hooks \OC_Hook::clear('OCP\\Share'); // register share hooks \OC::registerShareHooks(); \OCA\Files_Sharing\Helper::registerHooks(); // Sharing related hooks \OCA\Encryption\Helper::registerShareHooks(); // Filesystem related hooks \OCA\Encryption\Helper::registerFilesystemHooks(); // clear and register hooks \OC_FileProxy::clearProxies(); \OC_FileProxy::register(new OCA\Files\Share\Proxy()); \OC_FileProxy::register(new OCA\Encryption\Proxy()); // create users self::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1, true); self::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2, true); self::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER3, true); self::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER4, true); // create group and assign users \OC_Group::createGroup(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_GROUP1); \OC_Group::addToGroup(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER3, \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_GROUP1); \OC_Group::addToGroup(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER4, \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_GROUP1); }
/** * @deprecated 6.0.0 * creates a regular task * @param string $klass class name * @param string $method method name * @return boolean|null * @since 4.5.0 */ public static function addRegularTask($klass, $method) { if (!\OC::needUpgrade()) { self::registerJob('OC\\BackgroundJob\\Legacy\\RegularJob', array($klass, $method)); return true; } }
public static function setUpBeforeClass() { parent::setUpBeforeClass(); // reset backend \OC_User::clearBackends(); \OC_Group::clearBackends(); // clear share hooks \OC_Hook::clear('OCP\\Share'); \OC::registerShareHooks(); \OCP\Util::connectHook('OC_Filesystem', 'setup', '\\OC\\Files\\Storage\\Shared', 'setup'); // create users $backend = new \OC_User_Dummy(); \OC_User::useBackend($backend); $backend->createUser(self::TEST_FILES_SHARING_API_USER1, self::TEST_FILES_SHARING_API_USER1); $backend->createUser(self::TEST_FILES_SHARING_API_USER2, self::TEST_FILES_SHARING_API_USER2); $backend->createUser(self::TEST_FILES_SHARING_API_USER3, self::TEST_FILES_SHARING_API_USER3); // create group $groupBackend = new \OC_Group_Dummy(); $groupBackend->createGroup(self::TEST_FILES_SHARING_API_GROUP1); $groupBackend->createGroup('group'); $groupBackend->addToGroup(self::TEST_FILES_SHARING_API_USER1, 'group'); $groupBackend->addToGroup(self::TEST_FILES_SHARING_API_USER2, 'group'); $groupBackend->addToGroup(self::TEST_FILES_SHARING_API_USER3, 'group'); $groupBackend->addToGroup(self::TEST_FILES_SHARING_API_USER2, self::TEST_FILES_SHARING_API_GROUP1); \OC_Group::useBackend($groupBackend); }
/** * @small * test absolute URL construction * @dataProvider provideSubDirURLs */ function testGetAbsoluteURLSubDir($url, $expectedResult) { \OC::$WEBROOT = '/owncloud'; $urlGenerator = new \OC\URLGenerator(null); $result = $urlGenerator->getAbsoluteURL($url); $this->assertEquals($expectedResult, $result); }
protected function tearDown() { $data = new Data($this->getMock('\\OCP\\Activity\\IManager'), \OC::$server->getDatabaseConnection(), $this->getMock('\\OCP\\IUserSession')); $this->deleteUser($data, 'activity-api-user1'); $this->deleteUser($data, 'activity-api-user2'); $data->deleteActivities(array('app' => 'app1')); \OC::$WEBROOT = $this->originalWEBROOT; parent::tearDown(); }
/** * Execute the upgrade command * * @param InputInterface $input input interface * @param OutputInterface $output output interface */ protected function execute(InputInterface $input, OutputInterface $output) { $simulateStepEnabled = true; $updateStepEnabled = true; if ($input->getOption('skip-migration-test')) { $simulateStepEnabled = false; } if ($input->getOption('dry-run')) { $updateStepEnabled = false; } if (!$simulateStepEnabled && !$updateStepEnabled) { $output->writeln('<error>Only one of "--skip-migration-test" or "--dry-run" ' . 'can be specified at a time.</error>'); return self::ERROR_INVALID_ARGUMENTS; } if (\OC::checkUpgrade(false)) { $self = $this; $updater = new Updater(\OC::$server->getHTTPHelper(), \OC::$server->getAppConfig()); $updater->setSimulateStepEnabled($simulateStepEnabled); $updater->setUpdateStepEnabled($updateStepEnabled); $updater->listen('\\OC\\Updater', 'maintenanceStart', function () use($output) { $output->writeln('<info>Turned on maintenance mode</info>'); }); $updater->listen('\\OC\\Updater', 'maintenanceEnd', function () use($output, $updateStepEnabled, $self) { $output->writeln('<info>Turned off maintenance mode</info>'); $mode = $updateStepEnabled ? 'Update' : 'Update simulation'; $status = $self->upgradeFailed ? 'failed' : 'successful'; $message = "<info>{$mode} {$status}</info>"; $output->writeln($message); }); $updater->listen('\\OC\\Updater', 'dbUpgrade', function () use($output) { $output->writeln('<info>Updated database</info>'); }); $updater->listen('\\OC\\Updater', 'dbSimulateUpgrade', function () use($output) { $output->writeln('<info>Checked database schema update</info>'); }); $updater->listen('\\OC\\Updater', 'disabledApps', function ($appList) use($output) { $output->writeln('<info>Disabled incompatible apps: ' . implode(', ', $appList) . '</info>'); }); $updater->listen('\\OC\\Updater', 'failure', function ($message) use($output, $self) { $output->writeln("<error>{$message}</error>"); $self->upgradeFailed = true; }); $updater->upgrade(); $this->postUpgradeCheck($input, $output); return self::ERROR_SUCCESS; } else { if ($this->config->getSystemValue('maintenance', false)) { //Possible scenario: ownCloud core is updated but an app failed $output->writeln('<warning>ownCloud is in maintenance mode</warning>'); $output->write('<comment>Maybe an upgrade is already in process. Please check the ' . 'logfile (data/owncloud.log). If you want to re-run the ' . 'upgrade procedure, remove the "maintenance mode" from ' . 'config.php and call this script again.</comment>', true); return self::ERROR_MAINTENANCE_MODE; } else { $output->writeln('<info>ownCloud is already latest version</info>'); return self::ERROR_UP_TO_DATE; } } }
/** * @small * test absolute URL construction * @dataProvider provideSubDirURLs */ function testGetAbsoluteURLSubDir($url, $expectedResult) { \OC::$WEBROOT = '/owncloud'; $config = $this->getMock('\\OCP\\IConfig'); $cacheFactory = $this->getMock('\\OCP\\ICacheFactory'); $urlGenerator = new \OC\URLGenerator($config, $cacheFactory); $result = $urlGenerator->getAbsoluteURL($url); $this->assertEquals($expectedResult, $result); }
/** * This method is called before any HTTP method and returns http status code 503 * in case the system is in maintenance mode. * * @throws \Sabre\DAV\Exception\ServiceUnavailable * @internal param string $method * @return bool */ public function checkMaintenanceMode() { if (OC_Config::getValue('maintenance', false)) { throw new \Sabre\DAV\Exception\ServiceUnavailable(); } if (OC::checkUpgrade(false)) { throw new \Sabre\DAV\Exception\ServiceUnavailable('Upgrade needed'); } return true; }
public static function setupFS($user = "", $root = "files") { // configure the initial filesystem based on the configuration if (self::$fsSetup) { //setting up the filesystem twice can only lead to trouble return false; } $CONFIG_DATADIRECTORY_ROOT = OC_Config::getValue("datadirectory", OC::$SERVERROOT . "/data"); $CONFIG_BACKUPDIRECTORY = OC_Config::getValue("backupdirectory", OC::$SERVERROOT . "/backup"); // Check if config folder is writable. if (!is_writable(OC::$SERVERROOT . "/config/")) { $tmpl = new OC_Template('', 'error', 'guest'); $tmpl->assign('errors', array(1 => array('error' => "Can't write into config directory 'config'", 'hint' => "You can usually fix this by giving the webserver user write access to the config directory in owncloud"))); $tmpl->printPage(); exit; } // Check if apps folder is writable. if (!is_writable(OC::$SERVERROOT . "/apps/")) { $tmpl = new OC_Template('', 'error', 'guest'); $tmpl->assign('errors', array(1 => array('error' => "Can't write into apps directory 'apps'", 'hint' => "You can usually fix this by giving the webserver user write access to the config directory in owncloud"))); $tmpl->printPage(); exit; } // Create root dir. if (!is_dir($CONFIG_DATADIRECTORY_ROOT)) { $success = @mkdir($CONFIG_DATADIRECTORY_ROOT); if (!$success) { $tmpl = new OC_Template('', 'error', 'guest'); $tmpl->assign('errors', array(1 => array('error' => "Can't create data directory (" . $CONFIG_DATADIRECTORY_ROOT . ")", 'hint' => "You can usually fix this by giving the webserver write access to the ownCloud directory '" . OC::$SERVERROOT . "' (in a terminal, use the command 'chown -R www-data:www-data /path/to/your/owncloud/install/data' "))); $tmpl->printPage(); exit; } } // If we are not forced to load a specific user we load the one that is logged in if ($user == "" && OC_User::isLoggedIn()) { $user = OC_User::getUser(); } //first set up the local "root" storage if (!self::$rootMounted) { OC_Filesystem::mount('OC_Filestorage_Local', array('datadir' => $CONFIG_DATADIRECTORY_ROOT), '/'); self::$rootMounted = true; } if ($user != "") { //if we aren't logged in, there is no use to set up the filesystem OC::$CONFIG_DATADIRECTORY = $CONFIG_DATADIRECTORY_ROOT . "/{$user}/{$root}"; if (!is_dir(OC::$CONFIG_DATADIRECTORY)) { mkdir(OC::$CONFIG_DATADIRECTORY, 0755, true); } //jail the user into his "home" directory OC_Filesystem::init('/' . $user . '/' . $root); $quotaProxy = new OC_FileProxy_Quota(); OC_FileProxy::register($quotaProxy); self::$fsSetup = true; } }
public static function setUpBeforeClass() { // clear share hooks \OC_Hook::clear('OCP\\Share'); \OC::registerShareHooks(); \OCA\Files_Versions\Hooks::connectHooks(); \OCP\Util::connectHook('OC_Filesystem', 'setup', '\\OC\\Files\\Storage\\Shared', 'setup'); // create test user self::loginHelper(self::TEST_VERSIONS_USER2, true); self::loginHelper(self::TEST_VERSIONS_USER, true); }
protected function tearDown() { $data = new Data($this->getMock('\\OCP\\Activity\\IManager')); $data->deleteActivities(array('affecteduser' => 'activity-api-user1')); \OC_User::deleteUser('activity-api-user1'); $data->deleteActivities(array('affecteduser' => 'activity-api-user2')); \OC_User::deleteUser('activity-api-user2'); $data->deleteActivities(array('type' => 'test')); \OC::$WEBROOT = $this->originalWEBROOT; parent::tearDown(); }
/** * registers an api call * @param string $method the http method * @param string $url the url to match * @param callable $action the function to run * @param string $app the id of the app registering the call * @param int $authLevel the level of authentication required for the call * @param array $defaults * @param array $requirements */ public static function register($method, $url, $action, $app, $authLevel = OC_API::USER_AUTH, $defaults = array(), $requirements = array()) { $name = strtolower($method) . $url; $name = str_replace(array('/', '{', '}'), '_', $name); if (!isset(self::$actions[$name])) { OC::getRouter()->useCollection('ocs'); OC::getRouter()->create($name, $url)->method($method)->action('OC_API', 'call'); self::$actions[$name] = array(); } self::$actions[$name][] = array('app' => $app, 'action' => $action, 'authlevel' => $authLevel); }
protected function setUp() { parent::setUp(); // clear hooks \OC_Hook::clear(); \OC::registerShareHooks(); \OCA\Files_Versions\Hooks::connectHooks(); self::loginHelper(self::TEST_VERSIONS_USER); $this->rootView = new \OC\Files\View(); if (!$this->rootView->file_exists(self::USERS_VERSIONS_ROOT)) { $this->rootView->mkdir(self::USERS_VERSIONS_ROOT); } }
/** * This method is called before any HTTP method and returns http status code 503 * in case the system is in maintenance mode. * * @throws ServiceUnavailable * @return bool */ public function checkMaintenanceMode() { if ($this->config->getSystemValue('singleuser', false)) { throw new ServiceUnavailable('System in single user mode.'); } if ($this->config->getSystemValue('maintenance', false)) { throw new ServiceUnavailable('System in maintenance mode.'); } if (\OC::checkUpgrade(false)) { throw new ServiceUnavailable('Upgrade needed'); } return true; }
/** * Execute the upgrade command * * @param InputInterface $input input interface * @param OutputInterface $output output interface */ protected function execute(InputInterface $input, OutputInterface $output) { global $RUNTIME_NOAPPS; $RUNTIME_NOAPPS = true; //no apps, yet require_once \OC::$SERVERROOT . '/lib/base.php'; // Don't do anything if ownCloud has not been installed if (!\OC_Config::getValue('installed', false)) { $output->writeln('<error>ownCloud has not yet been installed</error>'); return self::ERROR_NOT_INSTALLED; } if (\OC::checkUpgrade(false)) { $updater = new Updater(); $updater->listen('\\OC\\Updater', 'maintenanceStart', function () use($output) { $output->writeln('<info>Turned on maintenance mode</info>'); }); $updater->listen('\\OC\\Updater', 'maintenanceEnd', function () use($output) { $output->writeln('<info>Turned off maintenance mode</info>'); $output->writeln('<info>Update successful</info>'); }); $updater->listen('\\OC\\Updater', 'dbUpgrade', function () use($output) { $output->writeln('<info>Updated database</info>'); }); $updater->listen('\\OC\\Updater', 'filecacheStart', function () use($output) { $output->writeln('<info>Updating filecache, this may take really long...</info>'); }); $updater->listen('\\OC\\Updater', 'filecacheDone', function () use($output) { $output->writeln('<info>Updated filecache</info>'); }); $updater->listen('\\OC\\Updater', 'filecacheProgress', function ($out) use($output) { $output->writeln('... ' . $out . '% done ...'); }); $updater->listen('\\OC\\Updater', 'failure', function ($message) use($output) { $output->writeln($message); \OC_Config::setValue('maintenance', false); }); $updater->upgrade(); $this->postUpgradeCheck($input, $output); return self::ERROR_SUCCESS; } else { if (\OC_Config::getValue('maintenance', false)) { //Possible scenario: ownCloud core is updated but an app failed $output->writeln('<warning>ownCloud is in maintenance mode</warning>'); $output->write('<comment>Maybe an upgrade is already in process. Please check the ' . 'logfile (data/owncloud.log). If you want to re-run the ' . 'upgrade procedure, remove the "maintenance mode" from ' . 'config.php and call this script again.</comment>', true); return self::ERROR_MAINTENANCE_MODE; } else { $output->writeln('<info>ownCloud is already latest version</info>'); return self::ERROR_UP_TO_DATE; } } }
protected function setup() { parent::setUp(); $this->connection = \OC::$server->getDatabaseConnection(); // clear occasional leftover shares from other tests $this->connection->executeUpdate('DELETE FROM `*PREFIX*share`'); $this->user1 = $this->getUniqueID('user1_'); $this->user2 = $this->getUniqueID('user2_'); $userManager = \OC::$server->getUserManager(); $userManager->createUser($this->user1, 'pass'); $userManager->createUser($this->user2, 'pass'); \OC::registerShareHooks(); $this->job = new ExpireSharesJob(); }
public static function setUpBeforeClass() { // reset backend \OC_User::clearBackends(); \OC_User::useBackend('database'); // clear share hooks \OC_Hook::clear('OCP\\Share'); \OC::registerShareHooks(); \OCP\Util::connectHook('OC_Filesystem', 'setup', '\\OC\\Files\\Storage\\Shared', 'setup'); // create users self::loginHelper(self::TEST_FILES_SHARING_API_USER1, true); self::loginHelper(self::TEST_FILES_SHARING_API_USER2, true); self::loginHelper(self::TEST_FILES_SHARING_API_USER3, true); }
public static function setUpBeforeClass() { parent::setUpBeforeClass(); // reset backend \OC_User::clearBackends(); \OC_User::useBackend('database'); \OCA\Files_Encryption\Helper::registerFilesystemHooks(); \OCA\Files_Encryption\Helper::registerUserHooks(); \OCA\Files_Encryption\Helper::registerShareHooks(); \OC::registerShareHooks(); \OCP\Util::connectHook('OC_Filesystem', 'setup', '\\OC\\Files\\Storage\\Shared', 'setup'); // clear and register hooks \OC_FileProxy::clearProxies(); \OC_FileProxy::register(new \OCA\Files_Encryption\Proxy()); }
protected function setUp() { parent::setUp(); \OC_User::clearBackends(); \OC_User::useBackend('dummy'); $this->user1 = $this->getUniqueID('user1_'); $this->user2 = $this->getUniqueID('user2_'); $this->user3 = $this->getUniqueID('user3_'); $this->user4 = $this->getUniqueID('user4_'); $this->user5 = $this->getUniqueID('user5_'); $this->user6 = $this->getUniqueID('user6_'); $this->groupAndUser = $this->getUniqueID('groupAndUser_'); \OC::$server->getUserManager()->createUser($this->user1, 'pass'); \OC::$server->getUserManager()->createUser($this->user2, 'pass'); \OC::$server->getUserManager()->createUser($this->user3, 'pass'); \OC::$server->getUserManager()->createUser($this->user4, 'pass'); \OC::$server->getUserManager()->createUser($this->user5, 'pass'); \OC::$server->getUserManager()->createUser($this->user6, 'pass'); // no group \OC::$server->getUserManager()->createUser($this->groupAndUser, 'pass'); \OC_User::setUserId($this->user1); \OC_Group::clearBackends(); \OC_Group::useBackend(new \Test\Util\Group\Dummy()); $this->group1 = $this->getUniqueID('group1_'); $this->group2 = $this->getUniqueID('group2_'); \OC_Group::createGroup($this->group1); \OC_Group::createGroup($this->group2); \OC_Group::createGroup($this->groupAndUser); \OC_Group::addToGroup($this->user1, $this->group1); \OC_Group::addToGroup($this->user2, $this->group1); \OC_Group::addToGroup($this->user3, $this->group1); \OC_Group::addToGroup($this->user2, $this->group2); \OC_Group::addToGroup($this->user4, $this->group2); \OC_Group::addToGroup($this->user2, $this->groupAndUser); \OC_Group::addToGroup($this->user3, $this->groupAndUser); \OCP\Share::registerBackend('test', 'Test\\Share\\Backend'); \OC_Hook::clear('OCP\\Share'); \OC::registerShareHooks(); $this->resharing = \OC::$server->getAppConfig()->getValue('core', 'shareapi_allow_resharing', 'yes'); \OC::$server->getAppConfig()->setValue('core', 'shareapi_allow_resharing', 'yes'); // 20 Minutes in the past, 20 minutes in the future. $now = time(); $dateFormat = 'Y-m-d H:i:s'; $this->dateInPast = date($dateFormat, $now - 20 * 60); $this->dateInFuture = date($dateFormat, $now + 20 * 60); }
public static function getQuota($newUser) { // make sure that you are using correct region (where the bucket is) to get new Amazon S3 client //$client = \Aws\S3\S3Client::factory(array('region' => $region)); //$path = \OC::$SERVERROOT; $path = \OC::getRootFolder(); $str = file_get_contents($path . 'data/mount.json'); $json = json_decode($str, true); $result = array(); if ($newUser != '') { $newmountData = $json['user'][$newUser]; return $this->getSize($newUser, $newmountData); } else { foreach ($json['user'] as $username => $mountData) { $this->getSize($username, $mountData); array_push($result, $node); } return $result; } }
public static function setUpBeforeClass() { parent::setUpBeforeClass(); // enable resharing \OC::$server->getAppConfig()->setValue('core', 'shareapi_allow_resharing', 'yes'); // register share hooks \OC::registerShareHooks(); \OCA\Files_Sharing\Helper::registerHooks(); // clear and register hooks \OC_FileProxy::register(new \OCA\Files\Share\Proxy()); // create users self::loginHelper(self::TEST_ENCRYPTION_SHARE_USER1, true); self::loginHelper(self::TEST_ENCRYPTION_SHARE_USER2, true); self::loginHelper(self::TEST_ENCRYPTION_SHARE_USER3, true); self::loginHelper(self::TEST_ENCRYPTION_SHARE_USER4, true); // create group and assign users \OC_Group::createGroup(self::TEST_ENCRYPTION_SHARE_GROUP1); \OC_Group::addToGroup(self::TEST_ENCRYPTION_SHARE_USER3, self::TEST_ENCRYPTION_SHARE_GROUP1); \OC_Group::addToGroup(self::TEST_ENCRYPTION_SHARE_USER4, self::TEST_ENCRYPTION_SHARE_GROUP1); }