0
0
Fork 0
mirror of https://github.com/nextcloud/server.git synced 2025-05-03 13:30:32 +00:00
nextcloud_server/tests/lib/Lockdown/LockdownManagerTest.php
Arthur Schiwon f6d6efef3a
refactor(Token): introduce scope constants
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
2024-06-05 19:01:14 +02:00

46 lines
1.3 KiB
PHP

<?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() {
$manager = new LockdownManager($this->sessionCallback);
$this->assertTrue($manager->canAccessFilesystem());
}
public function testCanAccessFilesystemAllowed() {
$token = new PublicKeyToken();
$token->setScope([IToken::SCOPE_FILESYSTEM => true]);
$manager = new LockdownManager($this->sessionCallback);
$manager->setToken($token);
$this->assertTrue($manager->canAccessFilesystem());
}
public function testCanAccessFilesystemNotAllowed() {
$token = new PublicKeyToken();
$token->setScope([IToken::SCOPE_FILESYSTEM => false]);
$manager = new LockdownManager($this->sessionCallback);
$manager->setToken($token);
$this->assertFalse($manager->canAccessFilesystem());
}
}