123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- <?php
- namespace Test\Lockdown;
- use OC\Authentication\Token\PublicKeyToken;
- use OC\Lockdown\LockdownManager;
- 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(['filesystem' => true]);
- $manager = new LockdownManager($this->sessionCallback);
- $manager->setToken($token);
- $this->assertTrue($manager->canAccessFilesystem());
- }
- public function testCanAccessFilesystemNotAllowed() {
- $token = new PublicKeyToken();
- $token->setScope(['filesystem' => false]);
- $manager = new LockdownManager($this->sessionCallback);
- $manager->setToken($token);
- $this->assertFalse($manager->canAccessFilesystem());
- }
- }
|