summaryrefslogtreecommitdiffstats
path: root/tests/lib/User
diff options
context:
space:
mode:
authorJulien Veyssier <eneiluj@posteo.net>2021-07-29 13:04:41 +0200
committernpmbuildbot-nextcloud[bot] <npmbuildbot-nextcloud[bot]@users.noreply.github.com>2021-07-29 19:31:36 +0000
commit416d10f76c9b05a5a1e51058486f6e5cffd6c498 (patch)
treecf4efa06c62498d5bc15d83b7cf8d277b7235643 /tests/lib/User
parent6f1c2ed50b036e5f910be48ed84e6e2a9a8e4a89 (diff)
downloadnextcloud-server-416d10f76c9b05a5a1e51058486f6e5cffd6c498.tar.gz
nextcloud-server-416d10f76c9b05a5a1e51058486f6e5cffd6c498.zip
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: npmbuildbot-nextcloud[bot] <npmbuildbot-nextcloud[bot]@users.noreply.github.com>
Diffstat (limited to 'tests/lib/User')
-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