public static function showShare($args) { \OC_Util::checkAppEnabled('files_sharing'); $token = $args['token']; \OC_App::loadApp('files_sharing'); \OC_User::setIncognitoMode(true); require_once \OC_App::getAppPath('files_sharing') . '/public.php'; }
protected function setUpEncryptionTrait() { $isReady = \OC::$server->getEncryptionManager()->isReady(); if (!$isReady) { $this->markTestSkipped('Encryption not ready'); } \OC_App::loadApp('encryption'); $this->encryptionApp = new Application([], $isReady); $this->config = \OC::$server->getConfig(); $this->encryptionWasEnabled = $this->config->getAppValue('core', 'encryption_enabled', 'no'); $this->originalEncryptionModule = $this->config->getAppValue('core', 'default_encryption_module'); $this->config->setAppValue('core', 'default_encryption_module', \OCA\Encryption\Crypto\Encryption::ID); $this->config->setAppValue('core', 'encryption_enabled', 'yes'); $this->assertTrue(\OC::$server->getEncryptionManager()->isEnabled()); }
<?php OC_App::loadApp('bookmarks'); use OCA\Bookmarks\Controller\Lib\Bookmarks; class Test_LibBookmarks_Bookmarks extends PHPUnit_Framework_TestCase { private $userid; private $db; protected function setUp() { $this->userid = \OCP\User::getUser(); $this->db = \OC::$server->getDb(); } function testAddBookmark() { $this->cleanDB(); $this->assertCount(0, Bookmarks::findBookmarks($this->userid, $this->db, 0, 'id', array(), true, -1)); Bookmarks::addBookmark($this->userid, $this->db, 'http://owncloud.org', 'Owncloud project', array('oc', 'cloud'), 'An Awesome project'); $this->assertCount(1, Bookmarks::findBookmarks($this->userid, $this->db, 0, 'id', array(), true, -1)); } function testFindBookmarks() { $this->cleanDB(); Bookmarks::addBookmark($this->userid, $this->db, "http://www.google.de", "Google", array("one"), "PrivateNoTag", false); Bookmarks::addBookmark($this->userid, $this->db, "http://www.heise.de", "Heise", array("one", "two"), "PrivatTag", false); Bookmarks::addBookmark($this->userid, $this->db, "http://www.golem.de", "Golem", array("one"), "PublicNoTag", true); Bookmarks::addBookmark($this->userid, $this->db, "http://www.9gag.com", "9gag", array("two", "three"), "PublicTag", true); $outputPrivate = Bookmarks::findBookmarks($this->userid, $this->db, 0, "", array(), true, -1, false); $this->assertCount(4, $outputPrivate); $outputPrivateFiltered = Bookmarks::findBookmarks($this->userid, $this->db, 0, "", array("one"), true, -1, false); $this->assertCount(3, $outputPrivateFiltered);
/** * upgrades all apps within a major ownCloud upgrade. Also loads "priority" * (types authentication, filesystem, logging, in that order) afterwards. * * @throws NeedsUpdateException */ protected function doAppUpgrade() { $apps = \OC_App::getEnabledApps(); $priorityTypes = array('authentication', 'filesystem', 'logging'); $pseudoOtherType = 'other'; $stacks = array($pseudoOtherType => array()); foreach ($apps as $appId) { $priorityType = false; foreach ($priorityTypes as $type) { if (!isset($stacks[$type])) { $stacks[$type] = array(); } if (\OC_App::isType($appId, $type)) { $stacks[$type][] = $appId; $priorityType = true; break; } } if (!$priorityType) { $stacks[$pseudoOtherType][] = $appId; } } foreach ($stacks as $type => $stack) { foreach ($stack as $appId) { if (\OC_App::shouldUpgrade($appId)) { $this->emit('\\OC\\Updater', 'appUpgradeStarted', [$appId, \OC_App::getAppVersion($appId)]); \OC_App::updateApp($appId); $this->emit('\\OC\\Updater', 'appUpgrade', [$appId, \OC_App::getAppVersion($appId)]); } if ($type !== $pseudoOtherType) { // load authentication, filesystem and logging apps after // upgrading them. Other apps my need to rely on modifying // user and/or filesystem aspects. \OC_App::loadApp($appId, false); } } } }
<?php OCP\JSON::checkLoggedIn(); OCP\JSON::callCheck(); //encryption app needs to be loaded OC_App::loadApp('files_encryption'); // init encryption app $params = array('uid' => \OCP\User::getUser(), 'password' => $_POST['password']); $view = new OC\Files\View('/'); $util = new \OCA\Encryption\Util($view, \OCP\User::getUser()); $l = \OC_L10N::get('settings'); $result = $util->initEncryption($params); if ($result !== false) { try { $successful = $util->decryptAll(); } catch (\Exception $ex) { \OCP\Util::writeLog('encryption library', "Decryption finished unexpected: " . $ex->getMessage(), \OCP\Util::ERROR); $successful = false; } $util->closeEncryptionSession(); if ($successful === true) { \OCP\JSON::success(array('data' => array('message' => $l->t('Files decrypted successfully')))); } else { \OCP\JSON::error(array('data' => array('message' => $l->t('Couldn\'t decrypt your files, please check your owncloud.log or ask your administrator')))); } } else { \OCP\JSON::error(array('data' => array('message' => $l->t('Couldn\'t decrypt your files, check your password and try again')))); }
<?php OC_App::loadApp('mozilla_sync'); class Test_StorageService extends UnitTestCase { private $userName = '******'; private $userHash = 'qwegffggh'; private $password = '******'; private $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_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 tearDown() { $userId = OCA_mozilla_sync\User::userHashToId($this->userHash); if ($userId != false) { OCA_mozilla_sync\Storage::deleteStorage($userId); OCA_mozilla_sync\User::deleteUser($userId); } OC_Preferences::deleteUser($this->userName); OC_User::deleteUser($this->userName); } public function test_BasicScenario()
<?php if (!defined('PHPUNIT_RUN')) { define('PHPUNIT_RUN', 1); } require_once '/home/camila/Projects/Owncloud/owncloud/lib/base.php'; \OC::$loader->addValidRoot(\OC::$SERVERROOT . '/tests'); \OC_App::loadApp('popcornapp'); if (!class_exists('PHPUnit_Framework_TestCase')) { require_once 'PHPUnit/Autoload.php'; } OC_Hook::clear();
<?php if (!defined('PHPUNIT_RUN')) { define('PHPUNIT_RUN', 1); } require_once __DIR__ . '/../../../lib/base.php'; if (!class_exists('PHPUnit_Framework_TestCase')) { require_once 'PHPUnit/Autoload.php'; } \OC_App::loadApp('files_texteditor');
<?php /** * Copyright (c) 2012 Tom Needham <*****@*****.**> * This file is licensed under the Affero General Public License version 3 or * later. * See the COPYING-README file. */ OC_App::loadApp('provisioning_api'); class Test_Provisioning_API extends UnitTestCase { public function setUp() { } public function testAddUser() { } private function testAPIResponse($response) { $xml = new DOMDocument(); $xml->loadXML($reponse); } }
<?php if (!defined('PHPUNIT_RUN')) { define('PHPUNIT_RUN', 1); } require_once __DIR__ . '/../../../lib/base.php'; if (!class_exists('PHPUnit_Framework_TestCase')) { require_once 'PHPUnit/Autoload.php'; } \OC_App::loadApp('richdocuments'); OC_Hook::clear();
<?php if (!defined('PHPUNIT_RUN')) { define('PHPUNIT_RUN', 1); } require_once __DIR__ . '/../../../lib/base.php'; \OC::$loader->addValidRoot(\OC::$SERVERROOT . '/tests'); \OC_App::loadApp('files_pdfviewer'); if (!class_exists('PHPUnit_Framework_TestCase')) { require_once 'PHPUnit/Autoload.php'; } OC_Hook::clear();
/** * @author Joas Schilling <*****@*****.**> * * @copyright Copyright (c) 2015, ownCloud, Inc. * @license AGPL-3.0 * * This code is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License, version 3, * as published by the Free Software Foundation. * * This program 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, version 3, * along with this program. If not, see <http://www.gnu.org/licenses/> * */ if (!defined('PHPUNIT_RUN')) { define('PHPUNIT_RUN', 1); } require_once __DIR__ . '/../../../lib/base.php'; // Fix for "Autoload path not allowed: .../tests/lib/testcase.php" \OC::$loader->addValidRoot(OC::$SERVERROOT . '/tests'); // Fix for "Autoload path not allowed: .../notifications/tests/testcase.php" \OC_App::loadApp('notifications'); if (!class_exists('PHPUnit_Framework_TestCase')) { require_once 'PHPUnit/Autoload.php'; } OC_Hook::clear();
<?php define('PHPUNIT_RUN', 1); require_once __DIR__ . '/../../../lib/base.php'; require_once __DIR__ . '/../vendor/autoload.php'; if (version_compare(implode('.', \OCP\Util::getVersion()), '8.2', '>=')) { \OC::$loader->addValidRoot(OC::$SERVERROOT . '/tests'); \OC_App::loadApp('mail'); } if (!class_exists('PHPUnit_Framework_TestCase')) { require_once 'PHPUnit/Autoload.php'; } OC_Hook::clear();
<?php /** * Copyright (c) 2013 Thomas Tanghus (thomas@tanghus.net) * This file is licensed under the Affero General Public License version 3 or * later. * See the COPYING-README file. */ OC_App::loadApp('contacts'); class Test_Contacts_Backend_Datebase extends \OCA\Contacts\TestCase { protected static $schema_file = 'static://test_db_scheme'; protected static $test_prefix; protected static $backend; protected static $user; protected static $addressBooksTableName; protected static $cardsTableName; public static function xsetUpBeforeClass() { $dbfile = __DIR__ . '/../../appinfo/database.xml'; self::$test_prefix = '_' . OC_Util::generateRandomBytes('4') . '_'; $content = file_get_contents($dbfile); $content = str_replace('*dbprefix*', '*dbprefix*' . self::$test_prefix, $content); file_put_contents(self::$schema_file, $content); OC_DB::createDbFromStructure(self::$schema_file); self::$addressBooksTableName = '*PREFIX*' . self::$test_prefix . 'contacts_addressbooks'; self::$cardsTableName = '*PREFIX*' . self::$test_prefix . 'contacts_cards'; OC_User::clearBackends(); OC_User::useBackend('dummy'); self::$user = uniqid('user_'); OC_User::createUser(self::$user, 'pass');
<?php if (!defined('PHPUNIT_RUN')) { define('PHPUNIT_RUN', 1); } require_once __DIR__ . '/../../../lib/base.php'; if (!class_exists('PHPUnit_Framework_TestCase')) { require_once 'PHPUnit/Autoload.php'; } \OC_App::loadApp('documents'); OC_Hook::clear();
function testDecryptAll() { $filename = "/decryptAll" . $this->getUniqueID() . ".txt"; $datadir = \OC_Config::getValue('datadirectory', \OC::$SERVERROOT . '/data/'); $userdir = $datadir . '/' . $this->userId . '/files/'; $this->view->file_put_contents($this->userId . '/files/' . $filename, $this->dataShort); $fileInfoEncrypted = $this->view->getFileInfo($this->userId . '/files/' . $filename); $this->assertTrue($fileInfoEncrypted instanceof \OC\Files\FileInfo); $this->assertEquals($fileInfoEncrypted['encrypted'], 1); $encContent = file_get_contents($userdir . $filename); \OC_App::disable('files_encryption'); $user = \OCP\User::getUser(); $this->logoutHelper(); $this->loginHelper($user, false, false, false); $content = file_get_contents($userdir . $filename); //content should be encrypted $this->assertSame($encContent, $content); // now we load the encryption app again \OC_App::loadApp('files_encryption'); // init encryption app $params = array('uid' => \OCP\User::getUser(), 'password' => \OCP\User::getUser()); $view = new \OC\Files\View('/'); $util = new \OCA\Files_Encryption\Util($view, \OCP\User::getUser()); $result = $util->initEncryption($params); $this->assertTrue($result instanceof \OCA\Files_Encryption\Session); $successful = $util->decryptAll(); $this->assertTrue($successful); $this->logoutHelper(); $this->loginHelper($user, false, false, false); // file should be unencrypted and fileInfo should contain the correct values $content = file_get_contents($userdir . $filename); // now we should get the plain data $this->assertSame($this->dataShort, $content); $fileInfoUnencrypted = $this->view->getFileInfo($this->userId . '/files/' . $filename); $this->assertTrue($fileInfoUnencrypted instanceof \OC\Files\FileInfo); // check if mtime and etags unchanged $this->assertEquals($fileInfoEncrypted['mtime'], $fileInfoUnencrypted['mtime']); $this->assertSame($fileInfoEncrypted['etag'], $fileInfoUnencrypted['etag']); // file should no longer be encrypted $this->assertEquals(0, $fileInfoUnencrypted['encrypted']); $backupPath = $this->getBackupPath('decryptAll'); // check if the keys where moved to the backup location $this->assertTrue($this->view->is_dir($backupPath . '/keys')); $this->assertTrue($this->view->file_exists($backupPath . '/keys/' . $filename . '/fileKey')); $this->assertTrue($this->view->file_exists($backupPath . '/keys/' . $filename . '/' . $user . '.shareKey')); // cleanup $this->view->unlink($this->userId . '/files/' . $filename); $this->view->deleteAll($backupPath); \OC_App::enable('files_encryption'); }
<?php global $RUNTIME_NOAPPS; $RUNTIME_NOAPPS = true; if (!defined('PHPUNIT_RUN')) { define('PHPUNIT_RUN', 1); } require_once __DIR__ . '/../../../lib/base.php'; if (!class_exists('PHPUnit_Framework_TestCase')) { require_once 'PHPUnit/Autoload.php'; } \OC_Hook::clear(); \OC_App::loadApp('files_antivirus');
/** * ownCloud - AnnouncementCenter App * * @author Joas Schilling * @copyright 2015 Joas Schilling nickvergessen@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/>. */ if (!defined('PHPUNIT_RUN')) { define('PHPUNIT_RUN', 1); } require_once __DIR__ . '/../../../lib/base.php'; // Fix for "Autoload path not allowed: .../tests/lib/testcase.php" \OC::$loader->addValidRoot(OC::$SERVERROOT . '/tests'); // Fix for "Autoload path not allowed: .../announcementcenter/tests/testcase.php" \OC_App::loadApp('announcementcenter'); if (!class_exists('PHPUnit_Framework_TestCase')) { require_once 'PHPUnit/Autoload.php'; } OC_Hook::clear();
<?php /** * Copyright (c) 2012 Robin Appelman <*****@*****.**> * This file is licensed under the Affero General Public License version 3 or * later. * See the COPYING-README file. */ namespace Test\Files\Storage; \OC_App::loadApp('files_archive'); class Archive_Zip extends Storage { /** * @var string tmpDir */ private $tmpFile; protected function setUp() { parent::setUp(); $this->tmpFile = \OCP\Files::tmpFile('.zip'); $this->instance = new \OC\Files\Storage\Archive(array('archive' => $this->tmpFile)); } protected function tearDown() { unlink($this->tmpFile); parent::tearDown(); } } class Archive_Tar extends Storage {
list($service) = explode('/', $pathInfo); } $file = OCP\CONFIG::getAppValue('core', 'public_' . strip_tags($service)); if (is_null($file)) { header('HTTP/1.0 404 Not Found'); exit; } $parts = explode('/', $file, 2); $app = $parts[0]; // Load all required applications \OC::$REQUESTEDAPP = $app; OC_App::loadApps(array('authentication')); OC_App::loadApps(array('filesystem', 'logging')); if (!\OC::$server->getAppManager()->isInstalled($app)) { throw new Exception('App not installed: ' . $app); } OC_App::loadApp($app); OC_User::setIncognitoMode(true); $baseuri = OC::$WEBROOT . '/public.php/' . $service . '/'; require_once OC_App::getAppPath($app) . '/' . $parts[1]; } catch (\OC\ServiceUnavailableException $ex) { //show the user a detailed error page OC_Response::setStatus(OC_Response::STATUS_SERVICE_UNAVAILABLE); \OCP\Util::writeLog('remote', $ex->getMessage(), \OCP\Util::FATAL); OC_Template::printExceptionErrorPage($ex); } catch (Exception $ex) { //show the user a detailed error page OC_Response::setStatus(OC_Response::STATUS_INTERNAL_SERVER_ERROR); \OCP\Util::writeLog('remote', $ex->getMessage(), \OCP\Util::FATAL); OC_Template::printExceptionErrorPage($ex); }
<?php OC_App::loadApp('user_external'); return array('imap' => array('run' => false, 'mailbox' => '{imap.gmail.com:993/imap/ssl}INBOX', 'user' => 'foo', 'password' => 'bar'), 'smb' => array('run' => false, 'host' => 'localhost', 'user' => 'test', 'password' => 'test'), 'ftp' => array('run' => false, 'host' => 'localhost', 'user' => 'test', 'password' => 'test'));
/** * @author Joas Schilling <*****@*****.**> * @author Thomas Müller <*****@*****.**> * * @copyright Copyright (c) 2016, ownCloud GmbH. * @license AGPL-3.0 * * This code is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License, version 3, * as published by the Free Software Foundation. * * This program 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, version 3, * along with this program. If not, see <http://www.gnu.org/licenses/> * */ if (!defined('PHPUNIT_RUN')) { define('PHPUNIT_RUN', 1); } require_once __DIR__ . '/../../../../lib/base.php'; if (!class_exists('PHPUnit_Framework_TestCase')) { require_once 'PHPUnit/Autoload.php'; } \OC::$composerAutoloader->addPsr4('Test\\', OC::$SERVERROOT . '/tests/lib/', true); \OC_App::loadApp('dav'); OC_Hook::clear();
<?php if (!defined('PHPUNIT_RUN')) { define('PHPUNIT_RUN', 1); } require_once __DIR__ . '/../../../lib/base.php'; if (!class_exists('PHPUnit_Framework_TestCase')) { require_once 'PHPUnit/Autoload.php'; } OC_Hook::clear(); \OC_App::loadApp('updater');
<?php /** * Copyright (c) 2012 Robin Appelman <*****@*****.**> * This file is licensed under the Affero General Public License version 3 or * later. * See the COPYING-README file. */ OC_App::loadApp('calendar'); class Test_Calendar_Calendars extends PHPUnit_Framework_TestCase { function testBasic() { $uid = uniqid(); $this->assertEquals(OC_Calendar_Calendar::allCalendars($uid), array()); OC_User::setUserId($uid); $calId1 = OC_Calendar_Calendar::addCalendar($uid, 'test'); $all = OC_Calendar_Calendar::allCalendars($uid); $this->assertEquals(count($all), 1); $this->assertEquals($all[0]['id'], $calId1); $this->assertEquals($all[0]['displayname'], 'test'); $this->assertEquals($all[0]['uri'], 'test'); $this->assertEquals($uid, $all[0]['userid']); $calId2 = OC_Calendar_Calendar::addCalendar($uid, 'test'); $this->assertNotEquals($calId1, $calId2); $all = OC_Calendar_Calendar::allCalendars($uid); $this->assertEquals(count($all), 2); $this->assertEquals($all[1]['id'], $calId2); $this->assertEquals($all[1]['displayname'], 'test'); $this->assertEquals($all[1]['uri'], 'test1'); //$cal1=OC_Calendar_Calendar::find($calId1);
<?php if (!defined('PHPUNIT_RUN')) { define('PHPUNIT_RUN', 1); } require_once __DIR__ . '/../../../lib/base.php'; // Fix for "Autoload path not allowed: .../tests/lib/testcase.php" \OC::$loader->addValidRoot(OC::$SERVERROOT . '/tests'); // Fix for "Autoload path not allowed: .../activity/tests/testcase.php" \OC_App::loadApp('activity'); // Fix for "Autoload path not allowed: .../files/lib/activity.php" \OC_App::loadApp('files'); // Fix for "Autoload path not allowed: .../files_sharing/lib/activity.php" \OC_App::loadApp('files_sharing'); if (!class_exists('PHPUnit_Framework_TestCase')) { require_once 'PHPUnit/Autoload.php'; } OC_Hook::clear();