Exemple #1
0
 public static function 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
     \Test_Encryption_Util::loginHelper(\Test_Encryption_Hooks::TEST_ENCRYPTION_HOOKS_USER1, true);
     \Test_Encryption_Util::loginHelper(\Test_Encryption_Hooks::TEST_ENCRYPTION_HOOKS_USER2, true);
 }
Exemple #2
0
 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);
 }
Exemple #3
0
 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();
 }
Exemple #4
0
 public static function tearDownAfterClass()
 {
     // cleanup test user
     \OC_User::deleteUser(\Test_Encryption_Helper::TEST_ENCRYPTION_HELPER_USER1);
     \OC_User::deleteUser(\Test_Encryption_Helper::TEST_ENCRYPTION_HELPER_USER2);
     \OC_Hook::clear();
     \OC_FileProxy::clearProxies();
 }
Exemple #5
0
 public static function setupHooks()
 {
     // Filesystem related hooks
     Helper::registerFilesystemHooks();
     // clear and register hooks
     \OC_FileProxy::clearProxies();
     \OC_FileProxy::register(new Files_Encryption\Proxy());
 }
Exemple #6
0
 public static function tearDownAfterClass()
 {
     \OC_Hook::clear();
     \OC_FileProxy::clearProxies();
     // Delete keys in /data/
     $view = new \OC\Files\View('/');
     $view->deleteAll('files_encryption');
     parent::tearDownAfterClass();
 }
Exemple #7
0
 public static function tearDownAfterClass()
 {
     \OC_Hook::clear();
     \OC_FileProxy::clearProxies();
     // Delete keys in /data/
     $view = new \OC\Files\View('/');
     $view->rmdir('public-keys');
     $view->rmdir('owncloud_private_key');
 }
Exemple #8
0
 public static function tearDownAfterClass()
 {
     // cleanup test user
     \OC_User::deleteUser(\Test_Encryption_Stream::TEST_ENCRYPTION_STREAM_USER1);
     \OC_Hook::clear();
     \OC_FileProxy::clearProxies();
     // Delete keys in /data/
     $view = new \OC\Files\View('/');
     $view->rmdir('public-keys');
     $view->rmdir('owncloud_private_key');
 }
 public static function setUpBeforeClass()
 {
     // reset backend
     \OC_User::clearBackends();
     \OC_User::useBackend('database');
     // Filesystem related hooks
     \OCA\Encryption\Helper::registerFilesystemHooks();
     // clear and register hooks
     \OC_FileProxy::clearProxies();
     \OC_FileProxy::register(new OCA\Encryption\Proxy());
     // create test user
     \Test_Encryption_Util::loginHelper(\Test_Encryption_Stream::TEST_ENCRYPTION_STREAM_USER1, true);
 }
 public static function setUpBeforeClass()
 {
     // reset backend
     \OC_User::clearBackends();
     \OC_User::useBackend('database');
     // Filesystem related hooks
     \OCA\Encryption\Helper::registerFilesystemHooks();
     // clear and register hooks
     \OC_FileProxy::clearProxies();
     \OC_FileProxy::register(new OCA\Encryption\Proxy());
     // disable file proxy by default
     \OC_FileProxy::$enabled = false;
     // create test user
     \OC_User::deleteUser(\Test_Encryption_Keymanager::TEST_USER);
     \Test_Encryption_Util::loginHelper(\Test_Encryption_Keymanager::TEST_USER, true);
 }
Exemple #11
0
 public static function tearDownAfterClass()
 {
     \OC_FileProxy::$enabled = true;
     // cleanup test user
     \OC_User::deleteUser(\Test_Encryption_Keymanager::TEST_USER);
     // reset app files_trashbin
     if (self::$stateFilesTrashbin) {
         OC_App::enable('files_trashbin');
     }
     \OC_Hook::clear();
     \OC_FileProxy::clearProxies();
     // Delete keys in /data/
     $view = new \OC\Files\View('/');
     $view->rmdir('public-keys');
     $view->rmdir('owncloud_private_key');
 }
 public function setUp()
 {
     //set testing key
     $_SESSION['enckey'] = md5(time());
     //clear all proxies and hooks so we can do clean testing
     OC_FileProxy::clearProxies();
     OC_Hook::clear('OC_Filesystem');
     //enable only the encryption hook
     OC_FileProxy::register(new OC_FileProxy_Encryption());
     //set up temporary storage
     OC_Filesystem::clearMounts();
     OC_Filesystem::mount('OC_Filestorage_Temporary', array(), '/');
     //set up the users home folder in the temp storage
     $rootView = new OC_FilesystemView('');
     $rootView->mkdir('/' . OC_User::getUser());
     $rootView->mkdir('/' . OC_User::getUser() . '/files');
 }
Exemple #13
0
 public static function setUpBeforeClass()
 {
     // reset backend
     \OC_User::clearBackends();
     \OC_User::useBackend('database');
     // Filesystem related hooks
     \OCA\Encryption\Helper::registerFilesystemHooks();
     // clear and register hooks
     \OC_FileProxy::clearProxies();
     \OC_FileProxy::register(new OCA\Encryption\Proxy());
     // create test user
     \Test_Encryption_Util::loginHelper(\Test_Encryption_Util::TEST_ENCRYPTION_UTIL_USER1, true);
     \Test_Encryption_Util::loginHelper(\Test_Encryption_Util::TEST_ENCRYPTION_UTIL_USER2, true);
     \Test_Encryption_Util::loginHelper(\Test_Encryption_Util::TEST_ENCRYPTION_UTIL_LEGACY_USER, true);
     // create groups
     \OC_Group::createGroup(self::TEST_ENCRYPTION_UTIL_GROUP1);
     \OC_Group::createGroup(self::TEST_ENCRYPTION_UTIL_GROUP2);
     // add user 1 to group1
     \OC_Group::addToGroup(self::TEST_ENCRYPTION_UTIL_USER1, self::TEST_ENCRYPTION_UTIL_GROUP1);
 }
Exemple #14
0
 public function setUp()
 {
     $this->oldConfig = OCP\Config::getAppValue('files_encryption', 'enable_encryption', 'true');
     OCP\Config::setAppValue('files_encryption', 'enable_encryption', 'true');
     $this->oldKey = isset($_SESSION['enckey']) ? $_SESSION['enckey'] : null;
     //set testing key
     $_SESSION['enckey'] = md5(time());
     //clear all proxies and hooks so we can do clean testing
     OC_FileProxy::clearProxies();
     OC_Hook::clear('OC_Filesystem');
     //enable only the encryption hook
     OC_FileProxy::register(new OC_FileProxy_Encryption());
     //set up temporary storage
     OC_Filesystem::clearMounts();
     OC_Filesystem::mount('OC_Filestorage_Temporary', array(), '/');
     //set up the users home folder in the temp storage
     $rootView = new OC_FilesystemView('');
     $rootView->mkdir('/' . OC_User::getUser());
     $rootView->mkdir('/' . OC_User::getUser() . '/files');
 }
Exemple #15
0
 public static function setUpBeforeClass()
 {
     // reset backend
     \OC_User::clearBackends();
     \OC_User::useBackend('database');
     // Filesystem related hooks
     \OCA\Encryption\Helper::registerFilesystemHooks();
     // clear and register hooks
     \OC_FileProxy::clearProxies();
     \OC_FileProxy::register(new OCA\Encryption\Proxy());
     // disable file proxy by default
     \OC_FileProxy::$enabled = false;
     // remember files_trashbin state
     self::$stateFilesTrashbin = OC_App::isEnabled('files_trashbin');
     // we don't want to tests with app files_trashbin enabled
     \OC_App::disable('files_trashbin');
     // create test user
     \OC_User::deleteUser(\Test_Encryption_Keymanager::TEST_USER);
     \Test_Encryption_Util::loginHelper(\Test_Encryption_Keymanager::TEST_USER, true);
 }
Exemple #16
0
 public static function setUpBeforeClass()
 {
     // 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
     \Test_Encryption_Util::loginHelper(\Test_Encryption_Hooks::TEST_ENCRYPTION_HOOKS_USER1, true);
     \Test_Encryption_Util::loginHelper(\Test_Encryption_Hooks::TEST_ENCRYPTION_HOOKS_USER2, true);
 }
Exemple #17
0
 public static function setUpBeforeClass()
 {
     // reset backend
     \OC_User::clearBackends();
     \OC_User::useBackend('database');
     // Filesystem related hooks
     \OCA\Encryption\Helper::registerFilesystemHooks();
     // clear and register hooks
     \OC_FileProxy::clearProxies();
     \OC_FileProxy::register(new OCA\Encryption\Proxy());
     // disable file proxy by default
     \OC_FileProxy::$enabled = false;
     // setup filesystem
     \OC_Util::tearDownFS();
     \OC_User::setUserId('');
     \OC\Files\Filesystem::tearDown();
     \OC_Util::setupFS('admin');
     \OC_User::setUserId('admin');
     // login admin
     $params['uid'] = 'admin';
     $params['password'] = '******';
     OCA\Encryption\Hooks::login($params);
 }
Exemple #18
0
 public function setUp()
 {
     //clear all proxies and hooks so we can do clean testing
     OC_FileProxy::clearProxies();
     OC_Hook::clear('OC_Filesystem');
     //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_Filesystem::clearMounts();
     OC_Filesystem::mount('OC_Filestorage_Temporary', array(), '/');
     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_FilesystemView('');
     $rootView->mkdir('/test');
     $this->instance = new OC_Cache_File();
 }
 private function cleanProxies()
 {
     $proxies = OC_FileProxy::getProxies();
     OC_FileProxy::clearProxies();
     return count($proxies) > 0;
 }
 private function cleanProxies()
 {
     $proxies = OC_FileProxy::getProxies();
     OC_FileProxy::clearProxies();
     // reenable in case some test failed to reenable them
     OC_FileProxy::$enabled = true;
     return count($proxies) > 0;
 }
 public static function tearDownAfterClass()
 {
     // cleanup test user
     \OC_User::deleteUser(self::TEST_ENCRYPTION_TRASHBIN_USER1);
     \OC_Hook::clear();
     \OC_FileProxy::clearProxies();
     // Delete keys in /data/
     $view = new \OC\Files\View('/');
     $view->rmdir('public-keys');
     $view->rmdir('owncloud_private_key');
     parent::tearDownAfterClass();
 }
 /**
  * Clean up the list of file proxies
  *
  * Also reenables file proxies, in case a test disabled them
  */
 protected static function tearDownAfterClassCleanProxies()
 {
     \OC_FileProxy::$enabled = true;
     \OC_FileProxy::clearProxies();
 }
Exemple #23
0
 public static function tearDownAfterClass()
 {
     // clean group
     \OC_Group::deleteGroup(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_GROUP1);
     // cleanup users
     \OC_User::deleteUser(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1);
     \OC_User::deleteUser(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2);
     \OC_User::deleteUser(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER3);
     \OC_User::deleteUser(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER4);
     \OC_Hook::clear();
     \OC_FileProxy::clearProxies();
     // Delete keys in /data/
     $view = new \OC\Files\View('/');
     $view->rmdir('public-keys');
     $view->rmdir('owncloud_private_key');
 }
Exemple #24
0
<?php

define('PHPUNIT_RUN', 1);
$configDir = getenv('CONFIG_DIR');
if ($configDir) {
    define('PHPUNIT_CONFIG_DIR', $configDir);
}
require_once __DIR__ . '/../lib/base.php';
// load minimum set of apps
OC_App::loadApps(array('authentication'));
OC_App::loadApps(array('filesystem', 'logging'));
if (!class_exists('PHPUnit_Framework_TestCase')) {
    require_once 'PHPUnit/Autoload.php';
}
OC_Hook::clear();
OC_Log::$enabled = false;
OC_FileProxy::clearProxies();