public function testDependencyGetBackend() { // is the backend listed? Test_Mount_Config_Dummy_Backend::$checkDependencies = true; $backEnds = OC_Mount_Config::getBackends(); $this->assertArrayHasKey('Test_Mount_Config_Dummy_Backend', $backEnds); // backend shall not be listed Test_Mount_Config_Dummy_Backend::$checkDependencies = false; $backEnds = OC_Mount_Config::getBackends(); $this->assertArrayNotHasKey('Test_Mount_Config_Dummy_Backend', $backEnds); }
/** * Validate storage config * * @param StorageConfig $storage storage config * * @return DataResponse|null returns response in case of validation error */ protected function validate(StorageConfig $storage) { $mountPoint = $storage->getMountPoint(); if ($mountPoint === '' || $mountPoint === '/') { return new DataResponse(array('message' => (string) $this->l10n->t('Invalid mount point')), Http::STATUS_UNPROCESSABLE_ENTITY); } // TODO: validate that other attrs are set $backends = \OC_Mount_Config::getBackends(); if (!isset($backends[$storage->getBackendClass()])) { // invalid backend return new DataResponse(array('message' => (string) $this->l10n->t('Invalid storage backend "%s"', array($storage->getBackendClass()))), Http::STATUS_UNPROCESSABLE_ENTITY); } return null; }
public function setUp() { \OC_User::createUser(self::TEST_USER1, self::TEST_USER1); \OC_User::createUser(self::TEST_USER2, self::TEST_USER2); \OC_Group::createGroup(self::TEST_GROUP1); \OC_Group::addToGroup(self::TEST_USER1, self::TEST_GROUP1); \OC_Group::createGroup(self::TEST_GROUP2); \OC_Group::addToGroup(self::TEST_USER2, self::TEST_GROUP2); \OC_User::setUserId(self::TEST_USER1); $this->userHome = \OC_User::getHome(self::TEST_USER1); mkdir($this->userHome); $this->dataDir = \OC_Config::getValue('datadirectory', \OC::$SERVERROOT . '/data/'); $this->oldAllowedBackends = OCP\Config::getAppValue('files_external', 'user_mounting_backends', ''); $this->allBackends = OC_Mount_Config::getBackends(); OCP\Config::setAppValue('files_external', 'user_mounting_backends', implode(',', array_keys($this->allBackends))); OC_Mount_Config::$skipTest = true; }
* version 3 of the License, or any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU AFFERO GENERAL PUBLIC LICENSE for more details. * * You should have received a copy of the GNU Affero General Public * License along with this library. If not, see <http://www.gnu.org/licenses/>. */ OC_Util::checkAdminUser(); OCP\Util::addScript('files_external', 'settings'); OCP\Util::addscript('3rdparty', 'chosen/chosen.jquery.min'); OCP\Util::addStyle('files_external', 'settings'); OCP\Util::addStyle('3rdparty', 'chosen/chosen'); $backends = OC_Mount_Config::getBackends(); $personal_backends = array(); $enabled_backends = explode(',', OCP\Config::getAppValue('files_external', 'user_mounting_backends', '')); foreach ($backends as $class => $backend) { if ($class != '\\OC\\Files\\Storage\\Local') { $personal_backends[$class] = array('backend' => $backend['backend'], 'enabled' => in_array($class, $enabled_backends)); } } $tmpl = new OCP\Template('files_external', 'settings'); $tmpl->assign('isAdminPage', true); $tmpl->assign('mounts', OC_Mount_Config::getSystemMountPoints()); $tmpl->assign('backends', $backends); $tmpl->assign('personal_backends', $personal_backends); $tmpl->assign('groups', OC_Group::getGroups()); $tmpl->assign('users', OCP\User::getUsers()); $tmpl->assign('userDisplayNames', OC_User::getDisplayNames());
/** * ownCloud * * @author Michael Gapczynski * @copyright 2012 Michael Gapczynski mtgap@owncloud.com * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE * License as published by the Free Software Foundation; either * version 3 of the License, or any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU AFFERO GENERAL PUBLIC LICENSE for more details. * * You should have received a copy of the GNU Affero General Public * License along with this library. If not, see <http://www.gnu.org/licenses/>. */ OCP\Util::addScript('files_external', 'settings'); OCP\Util::addscript('3rdparty', 'chosen/chosen.jquery.min'); OCP\Util::addStyle('files_external', 'settings'); OCP\Util::addStyle('3rdparty', 'chosen/chosen'); $tmpl = new OCP\Template('files_external', 'settings'); $tmpl->assign('isAdminPage', true, false); $tmpl->assign('mounts', OC_Mount_Config::getSystemMountPoints()); $tmpl->assign('backends', OC_Mount_Config::getBackends()); $tmpl->assign('groups', OC_Group::getGroups()); $tmpl->assign('users', OCP\User::getUsers()); $tmpl->assign('allowUserMounting', OCP\Config::getAppValue('files_external', 'allow_user_mounting', 'yes')); return $tmpl->fetchPage();
protected function setUp() { parent::setUp(); OC_Mount_Config::registerBackend('Test_Mount_Config_Dummy_Storage', array('backend' => 'dummy', 'priority' => 150, 'configuration' => array())); \OC_User::createUser(self::TEST_USER1, self::TEST_USER1); \OC_User::createUser(self::TEST_USER2, self::TEST_USER2); \OC_Group::createGroup(self::TEST_GROUP1); \OC_Group::createGroup(self::TEST_GROUP1B); \OC_Group::addToGroup(self::TEST_USER1, self::TEST_GROUP1); \OC_Group::addToGroup(self::TEST_USER1, self::TEST_GROUP1B); \OC_Group::createGroup(self::TEST_GROUP2); \OC_Group::createGroup(self::TEST_GROUP2B); \OC_Group::addToGroup(self::TEST_USER2, self::TEST_GROUP2); \OC_Group::addToGroup(self::TEST_USER2, self::TEST_GROUP2B); \OC_User::setUserId(self::TEST_USER1); $this->userHome = \OC_User::getHome(self::TEST_USER1); @mkdir($this->userHome); $this->dataDir = \OC_Config::getValue('datadirectory', \OC::$SERVERROOT . '/data/'); $this->oldAllowedBackends = OCP\Config::getAppValue('files_external', 'user_mounting_backends', ''); $this->allBackends = OC_Mount_Config::getBackends(); OCP\Config::setAppValue('files_external', 'user_mounting_backends', implode(',', array_keys($this->allBackends))); OC_Mount_Config::$skipTest = true; Test_Mount_Config_Hook_Test::setupHooks(); }