Exemplo n.º 1
0
 public function testOC()
 {
     \OC\Files\Filesystem::clearMounts();
     $storage = new \OC\Files\Storage\Temporary(array());
     $storage->file_put_contents('foo.txt', 'asd');
     \OC\Files\Filesystem::mount($storage, array(), '/');
     $this->assertTrue(file_exists('oc:///foo.txt'));
     $this->assertEquals('asd', file_get_contents('oc:///foo.txt'));
     $this->assertEquals(array('.', '..', 'foo.txt'), scandir('oc:///'));
     file_put_contents('oc:///bar.txt', 'qwerty');
     $this->assertEquals('qwerty', $storage->file_get_contents('bar.txt'));
     $this->assertEquals(array('.', '..', 'bar.txt', 'foo.txt'), scandir('oc:///'));
     $this->assertEquals('qwerty', file_get_contents('oc:///bar.txt'));
     $fh = fopen('oc:///bar.txt', 'rb');
     $this->assertSame(0, ftell($fh));
     $content = fread($fh, 4);
     $this->assertSame(4, ftell($fh));
     $this->assertSame('qwer', $content);
     $content = fread($fh, 1);
     $this->assertSame(5, ftell($fh));
     $this->assertSame(0, fseek($fh, 0));
     $this->assertSame(0, ftell($fh));
     unlink('oc:///foo.txt');
     $this->assertEquals(array('.', '..', 'bar.txt'), scandir('oc:///'));
 }
Exemplo n.º 2
0
 public function tearDown()
 {
     foreach ($this->storages as $storage) {
         $storage->getCache()->clear();
     }
     \OC\Files\Filesystem::clearMounts();
 }
Exemplo n.º 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();
 }
Exemplo n.º 4
0
	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');
	}
Exemplo n.º 5
0
 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');
 }
Exemplo n.º 6
0
 protected function tearDown()
 {
     \OC_User::setUserId($this->user);
     \OC_Config::setValue('cachedirectory', $this->datadir);
     // Restore the original mount point
     \OC\Files\Filesystem::clearMounts();
     \OC\Files\Filesystem::mount($this->storage, array(), '/');
     parent::tearDown();
 }
Exemplo n.º 7
0
 public function setUp()
 {
     $this->storage = new Temporary(array());
     Filesystem::clearMounts();
     Filesystem::mount($this->storage, array(), '/');
     $this->view = new View('');
     $this->updater = new \OC\Files\Cache\Updater($this->view);
     $this->cache = $this->storage->getCache();
 }
Exemplo n.º 8
0
 protected function tearDown()
 {
     foreach ($this->storages as $storage) {
         $storage->getCache()->clear();
     }
     \OC\Files\Filesystem::clearMounts();
     \OC\Files\Filesystem::mount($this->originalStorage, array(), '/');
     parent::tearDown();
 }
Exemplo n.º 9
0
 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;
 }
Exemplo n.º 10
0
 protected function tearDown()
 {
     foreach ($this->tmpDirs as $dir) {
         \OC_Helper::rmdirr($dir);
     }
     \OC\Files\Filesystem::clearMounts();
     \OC\Files\Filesystem::mount($this->originalStorage, array(), '/');
     \OC_User::setUserId('');
     parent::tearDown();
 }
Exemplo n.º 11
0
 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;
 }
Exemplo n.º 12
0
 protected function setUp()
 {
     parent::setUp();
     $this->user = $this->getUniqueID('user_');
     \OC::$server->getUserManager()->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;
 }
Exemplo n.º 13
0
 public function setUp()
 {
     parent::setUp();
     \OC_User::clearBackends();
     \OC_User::useBackend(new \OC_User_Dummy());
     \OC\Files\Filesystem::clearMounts();
     //login
     \OC_User::createUser('test', 'test');
     \OC::$server->getSession()->set('user_id', 'test');
     $this->storage = new \OC\Files\Storage\Temporary(array());
     \OC\Files\Filesystem::init('test', '');
     \OC\Files\Filesystem::clearMounts();
     \OC\Files\Filesystem::mount($this->storage, array(), '/');
     \OC\Files\Filesystem::file_put_contents('file1', self::CONTENT);
     $this->config->method('getAvChunkSize')->willReturn('1024');
 }
Exemplo n.º 14
0
 public function testOC()
 {
     \OC\Files\Filesystem::clearMounts();
     $storage = new \OC\Files\Storage\Temporary(array());
     $storage->file_put_contents('foo.txt', 'asd');
     \OC\Files\Filesystem::mount($storage, array(), '/');
     $this->assertTrue(file_exists('oc:///foo.txt'));
     $this->assertEquals('asd', file_get_contents('oc:///foo.txt'));
     $this->assertEquals(array('.', '..', 'foo.txt'), scandir('oc:///'));
     file_put_contents('oc:///bar.txt', 'qwerty');
     $this->assertEquals('qwerty', $storage->file_get_contents('bar.txt'));
     $this->assertEquals(array('.', '..', 'bar.txt', 'foo.txt'), scandir('oc:///'));
     $this->assertEquals('qwerty', file_get_contents('oc:///bar.txt'));
     unlink('oc:///foo.txt');
     $this->assertEquals(array('.', '..', 'bar.txt'), scandir('oc:///'));
 }
Exemplo n.º 15
0
 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();
     $textData = "sample file\n";
     $this->storage = new \OC\Files\Storage\Temporary(array());
     $this->storage->file_put_contents(self::TEST_CLEAN_FILENAME, $textData);
     $this->storage->file_put_contents(self::TEST_INFECTED_FILENAME, $textData);
     \OC\Files\Filesystem::mount($this->storage, array(), '/');
     $this->config['av_mode'] = \OCP\Config::getAppValue('files_antivirus', 'av_mode', null);
     $this->config['av_path'] = \OCP\Config::getAppValue('files_antivirus', 'av_path', null);
     \OCP\Config::setAppValue('files_antivirus', 'av_mode', 'executable');
     \OCP\Config::setAppValue('files_antivirus', 'av_path', __DIR__ . '/avir.sh');
 }
Exemplo n.º 16
0
 function testCacheIncompleteFolder()
 {
     $storage1 = $this->getTestStorage(false);
     \OC\Files\Filesystem::clearMounts();
     \OC\Files\Filesystem::mount($storage1, array(), '/incomplete');
     $rootView = new \OC\Files\View('/incomplete');
     $entries = $rootView->getDirectoryContent('/');
     $this->assertEquals(3, count($entries));
     // /folder will already be in the cache but not scanned
     $entries = $rootView->getDirectoryContent('/folder');
     $this->assertEquals(1, count($entries));
 }
Exemplo n.º 17
0
 public function setUp()
 {
     \OC_User::setUserId('');
     \OC\Files\Filesystem::clearMounts();
 }
Exemplo n.º 18
0
 public function testOC()
 {
     // FIXME: use proper tearDown with $this->loginAsUser() and $this->logout()
     // (would currently break the tests for some reason)
     $originalStorage = \OC\Files\Filesystem::getStorage('/');
     \OC\Files\Filesystem::clearMounts();
     $storage = new \OC\Files\Storage\Temporary(array());
     $storage->file_put_contents('foo.txt', 'asd');
     \OC\Files\Filesystem::mount($storage, array(), '/');
     $this->assertTrue(file_exists('oc:///foo.txt'));
     $this->assertEquals('asd', file_get_contents('oc:///foo.txt'));
     $this->assertEquals(array('.', '..', 'foo.txt'), scandir('oc:///'));
     file_put_contents('oc:///bar.txt', 'qwerty');
     $this->assertEquals('qwerty', $storage->file_get_contents('bar.txt'));
     $this->assertEquals(array('.', '..', 'bar.txt', 'foo.txt'), scandir('oc:///'));
     $this->assertEquals('qwerty', file_get_contents('oc:///bar.txt'));
     $fh = fopen('oc:///bar.txt', 'rb');
     $this->assertSame(0, ftell($fh));
     $content = fread($fh, 4);
     $this->assertSame(4, ftell($fh));
     $this->assertSame('qwer', $content);
     $content = fread($fh, 1);
     $this->assertSame(5, ftell($fh));
     $this->assertSame(0, fseek($fh, 0));
     $this->assertSame(0, ftell($fh));
     unlink('oc:///foo.txt');
     $this->assertEquals(array('.', '..', 'bar.txt'), scandir('oc:///'));
     \OC\Files\Filesystem::clearMounts();
     \OC\Files\Filesystem::mount($originalStorage, array(), '/');
 }
Exemplo n.º 19
0
 public function setUp()
 {
     \OC\Files\Filesystem::clearMounts();
 }
Exemplo n.º 20
0
 protected function tearDown()
 {
     Filesystem::clearMounts();
     $this->logout();
     parent::tearDown();
 }
Exemplo n.º 21
0
 protected function tearDown()
 {
     \OC\Files\Filesystem::clearMounts();
     \OC\Files\Filesystem::mount($this->originalStorage, array(), '/');
     parent::tearDown();
 }
Exemplo n.º 22
0
 /**
  * clear all mounts and storage backends
  *
  * @deprecated OC_Filesystem is replaced by \OC\Files\Filesystem
  */
 public static function clearMounts()
 {
     \OC\Files\Filesystem::clearMounts();
 }
Exemplo n.º 23
0
 protected function tearDown()
 {
     $this->instance->remove('hack', 'hack');
     \OC_User::setUserId($this->user);
     \OC::$server->getConfig()->setSystemValue('cachedirectory', $this->datadir);
     // Restore the original mount point
     \OC\Files\Filesystem::clearMounts();
     \OC\Files\Filesystem::mount($this->storage, array(), '/');
     parent::tearDown();
 }