diff options
Diffstat (limited to 'tests/lib/Lockdown/LockdownManagerTest.php')
-rw-r--r-- | tests/lib/Lockdown/LockdownManagerTest.php | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/tests/lib/Lockdown/LockdownManagerTest.php b/tests/lib/Lockdown/LockdownManagerTest.php new file mode 100644 index 00000000000..973dec6d1f2 --- /dev/null +++ b/tests/lib/Lockdown/LockdownManagerTest.php @@ -0,0 +1,47 @@ +<?php + +/** + * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ + +namespace Test\Lockdown; + +use OC\Authentication\Token\PublicKeyToken; +use OC\Lockdown\LockdownManager; +use OCP\Authentication\Token\IToken; +use OCP\ISession; +use Test\TestCase; + +class LockdownManagerTest extends TestCase { + private $sessionCallback; + + protected function setUp(): void { + parent::setUp(); + + $this->sessionCallback = function () { + return $this->createMock(ISession::class); + }; + } + + public function testCanAccessFilesystemDisabled(): void { + $manager = new LockdownManager($this->sessionCallback); + $this->assertTrue($manager->canAccessFilesystem()); + } + + public function testCanAccessFilesystemAllowed(): void { + $token = new PublicKeyToken(); + $token->setScope([IToken::SCOPE_FILESYSTEM => true]); + $manager = new LockdownManager($this->sessionCallback); + $manager->setToken($token); + $this->assertTrue($manager->canAccessFilesystem()); + } + + public function testCanAccessFilesystemNotAllowed(): void { + $token = new PublicKeyToken(); + $token->setScope([IToken::SCOPE_FILESYSTEM => false]); + $manager = new LockdownManager($this->sessionCallback); + $manager->setToken($token); + $this->assertFalse($manager->canAccessFilesystem()); + } +} |