From 356eef07398f8829a2558eee809599be60441b59 Mon Sep 17 00:00:00 2001 From: Vincent Petry Date: Wed, 6 Nov 2013 11:57:04 +0100 Subject: Quota storage wrapper is now used for all users in sharing mode When accessing a shared folder, the folder's owner appears as mountpoint but wasn't wrapped by a quota storage wrapper. This fix makes sure that all home storages are wrapped by a quota storage wrapper, if applicable, to make sure quotas are respected when uploading into shared folders. --- tests/lib/util.php | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) (limited to 'tests') diff --git a/tests/lib/util.php b/tests/lib/util.php index d607a3e7725..852caaeccc3 100644 --- a/tests/lib/util.php +++ b/tests/lib/util.php @@ -93,6 +93,55 @@ class Test_Util extends PHPUnit_Framework_TestCase { $this->assertStringStartsWith('oc', OC_Util::getInstanceId()); } + /** + * Tests that the home storage is not wrapped when no quota exists. + */ + function testHomeStorageWrapperWithoutQuota() { + $user1 = uniqid(); + \OC_User::createUser($user1, 'test'); + OC_Preferences::setValue($user1, 'files', 'quota', 'none'); + \OC_User::setUserId($user1); + + \OC_Util::setupFS($user1); + + $userMount = \OC\Files\Filesystem::getMountManager()->find('/' . $user1 . '/'); + $this->assertNotNull($userMount); + $this->assertNotInstanceOf('\OC\Files\Storage\Wrapper\Quota', $userMount->getStorage()); + + // clean up + \OC_User::setUserId(''); + \OC_User::deleteUser($user1); + OC_Preferences::deleteUser($user1); + \OC_Util::tearDownFS(); + } + + /** + * Tests that the home storage is not wrapped when no quota exists. + */ + function testHomeStorageWrapperWithQuota() { + $user1 = uniqid(); + \OC_User::createUser($user1, 'test'); + OC_Preferences::setValue($user1, 'files', 'quota', '1024'); + \OC_User::setUserId($user1); + + \OC_Util::setupFS($user1); + + $userMount = \OC\Files\Filesystem::getMountManager()->find('/' . $user1 . '/'); + $this->assertNotNull($userMount); + $this->assertInstanceOf('\OC\Files\Storage\Wrapper\Quota', $userMount->getStorage()); + + // ensure that root wasn't wrapped + $rootMount = \OC\Files\Filesystem::getMountManager()->find('/'); + $this->assertNotNull($rootMount); + $this->assertNotInstanceOf('\OC\Files\Storage\Wrapper\Quota', $rootMount->getStorage()); + + // clean up + \OC_User::setUserId(''); + \OC_User::deleteUser($user1); + OC_Preferences::deleteUser($user1); + \OC_Util::tearDownFS(); + } + /** * @dataProvider baseNameProvider */ -- cgit v1.2.3