5 ); public function setUp() { } public function tearDown() { LoggedInTest::tearDownAfterClass(); LoggedInTest::setupBeforeClass(); // Re-init, since they look at user, fstab, etc. // Also, further tests that access the filesystem fail if we don't Vfs::clearstatcache(); Vfs::init_static(); Vfs\StreamWrapper::init_static(); // Need to ask about mounts, or other tests fail Vfs::mount(); $backup = Vfs::$is_root; Vfs::$is_root = true; // Remove any added files (as root to limit versioning issues) Vfs::remove($this->files); // Remove any mounts foreach($this->mounts as $mount) { Vfs::umount($mount); } // Remove any added shares foreach($this->shares as $share) { Sharing::delete($share); } foreach($this->entries as $entry) { list($callback, $params) = $entry; call_user_func_array($callback, $params); } Vfs::$is_root = $backup; } /** * Test to make sure a readonly link to home gives just readonly access, * and just to user's home */ public function testHomeReadonly() { $dir = Vfs::get_home_dir().'/'; $this->checkDirectory($dir, Sharing::READONLY); } /** * Test to make sure a writable link to home gives write access, but just * to user's home */ public function testHomeWritable() { $dir = Vfs::get_home_dir().'/'; $this->checkDirectory($dir, Sharing::WRITABLE); } /** * Test for a readonly share of a path with versioning turned on */ public function testVersioningReadonly() { $this->files[] = $dir = Vfs::get_home_dir().'/versioned/'; // Create versioned directory if(Vfs::is_dir($dir)) Vfs::remove($dir); Vfs::mkdir($dir); $this->assertTrue(Vfs::is_writable($dir), "Unable to write to '$dir' as expected"); $this->mountVersioned($dir); $this->checkDirectory($dir, Sharing::READONLY); } /** * Test for a writable share of a path with versioning turned on */ public function testVersioningWritable() { $this->files[] = $dir = Vfs::get_home_dir().'/versioned/'; // Create versioned directory if(Vfs::is_dir($dir)) Vfs::remove($dir); Vfs::mkdir($dir); $this->assertTrue(Vfs::is_writable($dir), "Unable to write to '$dir' as expected"); $this->mountVersioned($dir); $this->checkDirectory($dir, Sharing::WRITABLE); } /** * Test for a readonly share of a path from the filesystem */ public function testFilesystemReadonly() { // Don't add to files list or it deletes the folder from filesystem $dir = '/filesystem/'; // Mount filesystem directory if(Vfs::is_dir($dir)) Vfs::remove($dir); $this->mountFilesystem($dir); $this->assertTrue(Vfs::is_writable($dir), "Unable to write to '$dir' as expected"); $this->checkDirectory($dir, Sharing::READONLY); // Test folder in filesystem already has this file in it // It should be picked up normally, but an explicit check can't hurt $this->checkOneFile('/filesystem_test.txt', Sharing::READONLY); } /** * Test for a readonly share of a path from the filesystem */ public function testFilesystemWritable() { // Don't add to files list or it deletes the folder from filesystem $dir = '/filesystem/'; // Mount filesystem directory if(Vfs::is_dir($dir)) Vfs::remove($dir); $this->mountFilesystem($dir); $this->assertTrue(Vfs::is_writable($dir), "Unable to write to '$dir' as expected"); $this->checkDirectory($dir, Sharing::WRITABLE); // Test folder in filesystem already has this file in it // It should be picked up normally, but an explicit check can't hurt $this->checkOneFile('/filesystem_test.txt', Sharing::WRITABLE); } /** * Test for a readonly share of an application entry's filesystem (/apps) */ public function testLinksReadonly() { // Create an infolog entry for testing purposes $info_id = $this->make_infolog(); $bo = new \infolog_bo(); $dir = "/apps/infolog/$info_id/"; $this->assertTrue(Vfs::is_writable($dir), "Unable to write to '$dir' as expected"); $this->checkDirectory($dir, Sharing::READONLY); // Can't delete it here, we're still the anonymous user until after $this->entries[] = Array(Array($bo, 'delete'), Array($info_id, false, false, true)); } /** * Test for a writable share of an application entry's filesystem (/apps) */ public function testLinksWritable() { // Create an infolog entry for testing purposes $bo = new \infolog_bo(); $info_id = $this->make_infolog(); $dir = "/apps/infolog/$info_id/"; $this->assertTrue(Vfs::is_writable($dir), "Unable to write to '$dir' as expected"); $this->checkDirectory($dir, Sharing::WRITABLE); // Can't delete it here, we're still the anonymous user until after $this->entries[] = Array(Array($bo, 'delete'), Array($info_id, false, false, true)); } /** * Test merge stream wrapper */ public function testMergeReadonly() { if(!class_exists("\EGroupware\Stylite\Vfs\Merge\StreamWrapper")) { $this->markTestAsSkipped(); return; } // Don't add to files list or it deletes the folder from filesystem $dir = '/merged/'; // Mount filesystem directory if(Vfs::is_dir($dir)) Vfs::remove($dir); $this->mountMerge($dir); $this->assertTrue( Vfs::is_writable($dir), "Unable to write to '$dir' as expected, check {$GLOBALS['egw_info']['user']['account_lid']} is in Admin group (Merge requirement)" ); $this->checkDirectory($dir, Sharing::READONLY); // Test folder in filesystem already has this file in it // It should be picked up normally, but an explicit check can't hurt $this->checkOneFile('/filesystem_test.txt', Sharing::READONLY); } /** * Test merge stream wrapper */ public function testMergeWritable() { if(!class_exists("\EGroupware\Stylite\Vfs\Merge\StreamWrapper")) { $this->markTestAsSkipped(); return; } // Don't add to files list or it deletes the folder from filesystem $dir = '/merged/'; // Mount filesystem directory if(Vfs::is_dir($dir)) Vfs::remove($dir); $this->mountMerge($dir); $this->assertTrue( Vfs::is_writable($dir), "Unable to write to '$dir' as expected, check {$GLOBALS['egw_info']['user']['account_lid']} is in Admin group (Merge requirement)" ); $this->checkDirectory($dir, Sharing::WRITABLE); // Test folder in filesystem already has this file in it // It should be picked up normally, but an explicit check can't hurt $this->checkOneFile('/filesystem_test.txt', Sharing::WRITABLE); } }