public function setUp() { // remember files_encryption state $this->stateFilesEncryption = \OC_App::isEnabled('files_encryption'); // we want to tests with the encryption app disabled \OC_App::disable('files_encryption'); $this->storage = new \OC\Files\Storage\Temporary(array()); $textData = "dummy file data\n"; $imgData = file_get_contents(\OC::$SERVERROOT . '/core/img/logo.png'); $this->storage->mkdir('folder'); $this->storage->file_put_contents('foo.txt', $textData); $this->storage->file_put_contents('foo.png', $imgData); $this->storage->file_put_contents('folder/bar.txt', $textData); $this->storage->file_put_contents('folder/bar2.txt', $textData); $this->scanner = $this->storage->getScanner(); $this->scanner->scan(''); $this->cache = $this->storage->getCache(); \OC\Files\Filesystem::tearDown(); if (!self::$user) { self::$user = uniqid(); } \OC_User::createUser(self::$user, 'password'); \OC_User::setUserId(self::$user); \OC\Files\Filesystem::init(self::$user, '/' . self::$user . '/files'); Filesystem::clearMounts(); Filesystem::mount($this->storage, array(), '/' . self::$user . '/files'); \OC_Hook::clear('OC_Filesystem'); }
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(); \OC_User::createUser(self::TEST_ENCRYPTION_MIGRATION_USER1, 'foo'); \OC_User::createUser(self::TEST_ENCRYPTION_MIGRATION_USER2, 'foo'); \OC_User::createUser(self::TEST_ENCRYPTION_MIGRATION_USER3, 'foo'); }
protected function setUp() { parent::setUp(); $this->storage = new \OC\Files\Storage\Temporary(array()); $textData = "dummy file data\n"; $imgData = file_get_contents(\OC::$SERVERROOT . '/core/img/logo.png'); $this->storage->mkdir('folder'); $this->storage->file_put_contents('foo.txt', $textData); $this->storage->file_put_contents('foo.png', $imgData); $this->storage->file_put_contents('folder/bar.txt', $textData); $this->storage->file_put_contents('folder/bar2.txt', $textData); $this->scanner = $this->storage->getScanner(); $this->scanner->scan(''); $this->cache = $this->storage->getCache(); if (!self::$user) { self::$user = $this->getUniqueID(); } \OC_User::createUser(self::$user, 'password'); $this->loginAsUser(self::$user); Filesystem::init(self::$user, '/' . self::$user . '/files'); Filesystem::clearMounts(); Filesystem::mount($this->storage, array(), '/' . self::$user . '/files'); \OC_Hook::clear('OC_Filesystem'); }
public function setUp() { if (!getenv('RUN_OBJECTSTORE_TESTS')) { $this->markTestSkipped('objectstore tests are unreliable on travis'); } \OC_App::disable('files_sharing'); \OC_App::disable('files_versions'); // reset backend \OC_User::clearBackends(); \OC_User::useBackend('database'); // create users $users = array('test'); foreach ($users as $userName) { \OC_User::deleteUser($userName); \OC_User::createUser($userName, $userName); } // main test user $userName = '******'; \OC_Util::tearDownFS(); \OC_User::setUserId(''); \OC\Files\Filesystem::tearDown(); \OC_User::setUserId('test'); $testContainer = 'oc-test-container-' . substr(md5(rand()), 0, 7); $params = array('username' => 'facebook100000330192569', 'password' => 'Dbdj1sXnRSHxIGc4', 'container' => $testContainer, 'autocreate' => true, 'region' => 'RegionOne', 'url' => 'http://8.21.28.222:5000/v2.0', 'tenantName' => 'facebook100000330192569', 'serviceName' => 'swift', 'user' => \OC_User::getManager()->get($userName)); $this->objectStorage = new ObjectStoreToTest($params); $params['objectstore'] = $this->objectStorage; $this->instance = new ObjectStoreStorage($params); }
public function setUp() { //clear all proxies and hooks so we can do clean testing \OC_FileProxy::clearProxies(); \OC_Hook::clear('OC_Filesystem'); //disabled atm //enable only the encryption hook if needed //if(OC_App::isEnabled('files_encryption')) { // OC_FileProxy::register(new OC_FileProxy_Encryption()); //} //set up temporary storage \OC\Files\Filesystem::clearMounts(); $storage = new \OC\Files\Storage\Temporary(array()); \OC\Files\Filesystem::mount($storage, array(), '/'); $datadir = str_replace('local::', '', $storage->getId()); $this->datadir = \OC_Config::getValue('cachedirectory', \OC::$SERVERROOT . '/data/cache'); \OC_Config::setValue('cachedirectory', $datadir); \OC_User::clearBackends(); \OC_User::useBackend(new \OC_User_Dummy()); //login \OC_User::createUser('test', 'test'); $this->user = \OC_User::getUser(); \OC_User::setUserId('test'); //set up the users dir $rootView = new \OC\Files\View(''); $rootView->mkdir('/test'); $this->instance = new \OC\Cache\File(); }
protected function setUp() { parent::setUp(); //clear all proxies and hooks so we can do clean testing \OC_Hook::clear('OC_Filesystem'); //set up temporary storage $this->storage = \OC\Files\Filesystem::getStorage('/'); \OC\Files\Filesystem::clearMounts(); $storage = new \OC\Files\Storage\Temporary(array()); \OC\Files\Filesystem::mount($storage, array(), '/'); $datadir = str_replace('local::', '', $storage->getId()); $config = \OC::$server->getConfig(); $this->datadir = $config->getSystemValue('cachedirectory', \OC::$SERVERROOT . '/data/cache'); $config->setSystemValue('cachedirectory', $datadir); \OC_User::clearBackends(); \OC_User::useBackend(new \Test\Util\User\Dummy()); //login \OC_User::createUser('test', 'test'); $this->user = \OC_User::getUser(); \OC_User::setUserId('test'); //set up the users dir $this->rootView = new \OC\Files\View(''); $this->rootView->mkdir('/test'); $this->instance = new \OC\Cache\File(); // forces creation of cache folder for subsequent tests $this->instance->set('hack', 'hack'); }
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(); }
protected function setUp() { parent::setUp(); if (!getenv('RUN_OBJECTSTORE_TESTS')) { $this->markTestSkipped('objectstore tests are unreliable in some environments'); } // reset backend \OC_User::clearBackends(); \OC_User::useBackend('database'); // create users $users = array('test'); foreach ($users as $userName) { \OC_User::deleteUser($userName); \OC_User::createUser($userName, $userName); } // main test user \OC_Util::tearDownFS(); \OC_User::setUserId(''); \OC\Files\Filesystem::tearDown(); \OC_User::setUserId('test'); $config = \OC::$server->getConfig()->getSystemValue('objectstore'); $this->objectStorage = new ObjectStoreToTest($config['arguments']); $config['objectstore'] = $this->objectStorage; $this->instance = new ObjectStoreStorage($config); }
protected function setUp() { $app = new Application(); $this->container = $app->getContainer(); $this->container['Config'] = $this->getMockBuilder('\\OCP\\IConfig')->disableOriginalConstructor()->getMock(); $this->container['AppName'] = 'files_sharing'; $this->container['UserSession'] = $this->getMockBuilder('\\OC\\User\\Session')->disableOriginalConstructor()->getMock(); $this->container['URLGenerator'] = $this->getMockBuilder('\\OC\\URLGenerator')->disableOriginalConstructor()->getMock(); $this->urlGenerator = $this->container['URLGenerator']; $this->shareController = $this->container['ShareController']; // Store current user $this->oldUser = \OC_User::getUser(); // Create a dummy user $this->user = \OC::$server->getSecureRandom()->getLowStrengthGenerator()->generate(12, ISecureRandom::CHAR_LOWER); \OC_User::createUser($this->user, $this->user); \OC_Util::tearDownFS(); \OC_User::setUserId(''); Filesystem::tearDown(); \OC_User::setUserId($this->user); \OC_Util::setupFS($this->user); // Create a dummy shared file $view = new View('/' . $this->user . '/files'); $view->file_put_contents('file1.txt', 'I am such an awesome shared file!'); $this->token = \OCP\Share::shareItem(Filesystem::getFileInfo('file1.txt')->getType(), Filesystem::getFileInfo('file1.txt')->getId(), \OCP\Share::SHARE_TYPE_LINK, 'IAmPasswordProtected!', 1); }
public function setUp() { OC_User::clearBackends(); OC_User::useBackend('dummy'); $this->user = uniqid('user_'); $this->objectType = uniqid('type_'); OC_User::createUser($this->user, 'pass'); OC_User::setUserId($this->user); }
public function setUp() { $this->user = '******' . uniqid(); \OC_User::createUser($this->user, $this->user); \OC\Files\Filesystem::tearDown(); \OC_User::setUserId($this->user); \OC\Files\Filesystem::init($this->user, '/' . $this->user . '/files'); \OC\Files\Filesystem::clearMounts(); $this->storageMock = null; }
public function setUp() { OCA_mozilla_sync\Utils::setTestState(); // Create Owncloud Test User OC_User::createUser($this->userName, $this->password); OC_Preferences::setValue($this->userName, 'settings', 'email', $this->email); OCA_mozilla_sync\OutputData::$outputFlag = OCA_mozilla_sync\OutputData::ConstOutputBuffer; OCA_mozilla_sync\Utils::setTestState(); OCA_mozilla_sync\User::createUser($this->userHash, $this->password, $this->email); }
public function setUp() { OCA_mozilla_sync\Utils::setTestState(); // Create ownCloud Test User OC_User::createUser($this->userName, $this->password); OC_User::setUserId($this->userName); \OC::$server->getConfig()->setUserValue($this->userName, 'settings', 'email', $this->email); OCA_mozilla_sync\OutputData::$outputFlag = OCA_mozilla_sync\OutputData::ConstOutputBuffer; OCA_mozilla_sync\Utils::setTestState(); OCA_mozilla_sync\User::createUser($this->userHash, $this->password, $this->email); }
/** * Generates a test user and sets up their file system * @return string the test users id */ public function generateUser() { $username = uniqid(); \OC_User::createUser($username, 'password'); \OC_Util::tearDownFS(); \OC_User::setUserId(''); \OC\Files\Filesystem::tearDown(); \OC_Util::setupFS($username); $this->users[] = $username; return $username; }
public static function firstLogin($userInfo, $authInfo) { $userID = $userInfo->getUserId(); $password = RequestManager::getRequest(ISingleSignOnRequest::USERPASSWORDGENERATOR) ? RequestManager::send(ISingleSignOnRequest::USERPASSWORDGENERATOR) : $userID; $user = \OC_User::createUser($userID, $password); if (class_exists('\\OCA\\SingleSignOn\\UserInfoSetter')) { UserInfoSetter::setInfo($user, $userInfo); } self::wirteAuthInfoToSession($authInfo); return \OC_User::login($userID, $password); }
function setUp() { $this->username = OC_Util::generateRandomBytes(20); OC_User::createUser($this->username, OC_Util::generateRandomBytes(20)); \OC_Util::tearDownFS(); \OC_User::setUserId(''); \OC\Files\Filesystem::tearDown(); \OC_Util::setupFS($this->username); $this->user = \OC::$server->getUserManager()->get($this->username); $this->certificateManager = new CertificateManager($this->user); }
protected function setUp() { parent::setUp(); $this->username = $this->getUniqueID('', 20); OC_User::createUser($this->username, $this->getUniqueID('', 20)); \OC_Util::tearDownFS(); \OC_User::setUserId(''); \OC\Files\Filesystem::tearDown(); \OC_Util::setupFS($this->username); $this->certificateManager = new CertificateManager($this->username, new \OC\Files\View()); }
public function setUp() { OCA_mozilla_sync\Utils::setTestState(); // Create ownCloud Test User OC_User::createUser($this->userName, $this->password); OC_User::setUserId($this->userName); OC_Preferences::setValue($this->userName, 'settings', 'email', $this->email); OCA_mozilla_sync\OutputData::$outputFlag = OCA_mozilla_sync\OutputData::ConstOutputBuffer; OCA_mozilla_sync\Utils::setTestState(); $this->urlParser = new OCA_mozilla_sync\UrlParser('/1.0/' . $this->userHash); }
function prepareSettings($dataDir, $userId) { // hard-coded string as we want a predictable fixed length // no data will be written there $this->dataDir = $dataDir; \OCP\Config::setSystemValue('datadirectory', $this->dataDir); $this->user = $userId; $this->legacyStorageId = 'local::' . $this->dataDir . $this->user . '/'; $this->newStorageId = 'home::' . $this->user; \OC_User::createUser($this->user, $this->user); }
/** * Generates a temp user * @param int $num number of users to generate * @return array */ protected function generateUsers($num = 1) { $users = array(); for ($i = 0; $i < $num; $i++) { $user = $this->getUniqueID(); \OC_User::createUser($user, 'password'); $this->users[] = $user; $users[] = $user; } return count($users) == 1 ? reset($users) : $users; }
public function setUp() { parent::setUp(); //Bgscanner requires at least one user on the current instance $userManager = $this->application->getContainer()->query('ServerContainer')->getUserManager(); $results = $userManager->search('', 1, 0); if (!count($results)) { \OC_User::createUser('test', 'test'); } $this->scannerFactory = new ScannerFactory($this->config, $this->container->query('Logger')); }
public function setUp() { \OC_User::clearBackends(); \OC_User::useBackend(new \OC_User_Dummy()); //login \OC_User::createUser('test', 'test'); $this->user = \OC_User::getUser(); \OC_User::setUserId('test'); \OC\Files\Filesystem::clearMounts(); $this->tempStorage = null; }
private function createUser($uid) { if (preg_match('/[^a-zA-Z0-9 _\\.@\\-]/', $uid)) { OCP\Util::writeLog('saml', 'Invalid username "' . $uid . '", allowed chars "a-zA-Z0-9" and "_.@-" ', OCP\Util::DEBUG); return false; } else { $random_password = \OC::$server->getSecureRandom()->getMediumStrengthGenerator()->generate(64); OCP\Util::writeLog('user_openam', 'Creating new user: ' . $uid, OCP\Util::DEBUG); OC_User::createUser($uid, $random_password); return $uid; } }
public function testCreateUser() { $this->backend->expects($this->any())->method('implementsActions')->will($this->returnCallback(function ($actions) { if ($actions === \OC_USER_BACKEND_CREATE_USER) { return true; } else { return false; } })); $user = \OC_User::createUser('newuser', 'newpassword'); $this->assertEquals('newuser', $user->getUid()); }
protected function setUp() { parent::setUp(); $this->user = $this->getUniqueID('user_'); \OC_User::createUser($this->user, $this->user); $this->storage = \OC\Files\Filesystem::getStorage('/'); \OC\Files\Filesystem::tearDown(); \OC_User::setUserId($this->user); \OC\Files\Filesystem::init($this->user, '/' . $this->user . '/files'); \OC\Files\Filesystem::clearMounts(); $this->storageMock = null; }
public static function post_login($parameters) { $uid = $parameters['uid']; $samlBackend = new OC_USER_SAML(); if ($samlBackend->auth->isAuthenticated()) { $attributes = $samlBackend->auth->getAttributes(); if (array_key_exists($samlBackend->usernameMapping, $attributes) && $attributes[$samlBackend->usernameMapping][0] == $uid) { $attributes = $samlBackend->auth->getAttributes(); if (array_key_exists($samlBackend->mailMapping, $attributes)) { $saml_email = $attributes[$samlBackend->mailMapping][0]; } if (array_key_exists($samlBackend->groupMapping, $attributes)) { $saml_groups = $attributes[$samlBackend->groupMapping]; } else { if (!empty($samlBackend->defaultGroup)) { $saml_groups = array($samlBackend->defaultGroup); OC_Log::write('saml', 'Using default group "' . $samlBackend->defaultGroup . '" for the user: '******'/[^a-zA-Z0-9 _\\.@\\-]/', $uid)) { OC_Log::write('saml', 'Invalid username "' . $uid . '", allowed chars "a-zA-Z0-9" and "_.@-" ', OC_Log::DEBUG); return false; } else { $random_password = random_password(); OC_Log::write('saml', 'Creating new user: '******'saml', 'Updating data of the user: ' . $uid, OC_Log::DEBUG); if (isset($saml_email)) { update_mail($uid, $saml_email); } if (isset($saml_groups)) { update_groups($uid, $saml_groups, $samlBackend->protectedGroups, false); } } } return true; } } return false; }
protected function setUp() { parent::setUp(); \OC_User::clearBackends(); \OC_User::useBackend(new \OC_User_Dummy()); //login \OC_User::createUser('test', 'test'); $this->user = \OC_User::getUser(); \OC_User::setUserId('test'); $this->originalStorage = \OC\Files\Filesystem::getStorage('/'); \OC\Files\Filesystem::clearMounts(); $this->tempStorage = null; }
protected function setUp() { parent::setUp(); $this->username = $this->getUniqueID('', 20); OC_User::createUser($this->username, $this->getUniqueID('', 20)); \OC_Util::tearDownFS(); \OC_User::setUserId(''); \OC\Files\Filesystem::tearDown(); \OC_Util::setupFS($this->username); $config = $this->getMock('OCP\\IConfig'); $config->expects($this->any())->method('getSystemValue')->with('installed', false)->willReturn(true); $this->certificateManager = new CertificateManager($this->username, new \OC\Files\View(), $config); }
protected function setUp() { parent::setUp(); \OC_User::clearBackends(); \OC_User::useBackend(new \OC_User_Dummy()); //login \OC_User::createUser('test', 'test'); $this->user = \OC_User::getUser(); $this->loginAsUser('test'); // clear mounts but somehow keep the root storage // that was initialized above... \OC\Files\Filesystem::clearMounts(); $this->tempStorage = null; }