Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorChristopher Ng <chrng8@gmail.com>2021-08-20 03:41:49 +0300
committernextcloud-command <nextcloud-command@users.noreply.github.com>2021-08-20 03:52:42 +0300
commite3be5d49d3e04513f9935f6c1990e1caff90dce5 (patch)
tree2627d6a9af388e79374dc669f963a550509f7b4e /tests
parentc485aad988b124244c867f5c5d8396e902276d95 (diff)
refs #21045 add app config to disable unlimited quota and to set max quota
avoid unlimited quota as default_quota fallback value if unlimited quota is not allowed avoid getting/setting/displaying unlimited default quota if not allowed implement tests for unlimited quota restrictions Signed-off-by: Julien Veyssier <eneiluj@posteo.net> Signed-off-by: Christopher Ng <chrng8@gmail.com> Signed-off-by: nextcloud-command <nextcloud-command@users.noreply.github.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/User/UserTest.php65
1 files changed, 65 insertions, 0 deletions
diff --git a/tests/lib/User/UserTest.php b/tests/lib/User/UserTest.php
index 629a5632d61..2366bf45321 100644
--- a/tests/lib/User/UserTest.php
+++ b/tests/lib/User/UserTest.php
@@ -724,6 +724,71 @@ class UserTest extends TestCase {
$user->setQuota('23 TB');
}
+ public function testGetDefaultUnlimitedQuota() {
+ /**
+ * @var UserInterface | \PHPUnit\Framework\MockObject\MockObject $backend
+ */
+ $backend = $this->createMock(\Test\Util\User\Dummy::class);
+
+ /** @var PublicEmitter|\PHPUnit\Framework\MockObject\MockObject $emitter */
+ $emitter = $this->createMock(PublicEmitter::class);
+ $emitter->expects($this->never())
+ ->method('emit');
+
+ $config = $this->createMock(IConfig::class);
+ $user = new User('foo', $backend, $this->dispatcher, $emitter, $config);
+
+ $userValueMap = [
+ ['foo', 'files', 'quota', 'default', 'default'],
+ ];
+ $appValueMap = [
+ ['files', 'default_quota', 'none', 'none'],
+ // allow unlimited quota
+ ['files', 'allow_unlimited_quota', '1', '1'],
+ ];
+ $config->method('getUserValue')
+ ->will($this->returnValueMap($userValueMap));
+ $config->method('getAppValue')
+ ->will($this->returnValueMap($appValueMap));
+
+ $quota = $user->getQuota();
+ $this->assertEquals('none', $quota);
+ }
+
+ public function testGetDefaultUnlimitedQuotaForbidden() {
+ /**
+ * @var UserInterface | \PHPUnit\Framework\MockObject\MockObject $backend
+ */
+ $backend = $this->createMock(\Test\Util\User\Dummy::class);
+
+ /** @var PublicEmitter|\PHPUnit\Framework\MockObject\MockObject $emitter */
+ $emitter = $this->createMock(PublicEmitter::class);
+ $emitter->expects($this->never())
+ ->method('emit');
+
+ $config = $this->createMock(IConfig::class);
+ $user = new User('foo', $backend, $this->dispatcher, $emitter, $config);
+
+ $userValueMap = [
+ ['foo', 'files', 'quota', 'default', 'default'],
+ ];
+ $appValueMap = [
+ ['files', 'default_quota', 'none', 'none'],
+ // do not allow unlimited quota
+ ['files', 'allow_unlimited_quota', '1', '0'],
+ ['files', 'quota_preset', '1 GB, 5 GB, 10 GB', '1 GB, 5 GB, 10 GB'],
+ // expect seeing 1 GB used as fallback value
+ ['files', 'default_quota', '1 GB', '1 GB'],
+ ];
+ $config->method('getUserValue')
+ ->will($this->returnValueMap($userValueMap));
+ $config->method('getAppValue')
+ ->will($this->returnValueMap($appValueMap));
+
+ $quota = $user->getQuota();
+ $this->assertEquals('1 GB', $quota);
+ }
+
public function testSetQuotaAddressNoChange() {
/**
* @var UserInterface | \PHPUnit\Framework\MockObject\MockObject $backend