2016-11-10 17:57:31 +03:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* @copyright Copyright (c) 2016 Robin Appelman <robin@icewind.nl>
|
|
|
|
*
|
|
|
|
* @license GNU AGPL version 3 or any later version
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License as
|
|
|
|
* published by the Free Software Foundation, either version 3 of the
|
|
|
|
* License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace Test\Lockdown;
|
|
|
|
|
|
|
|
use OC\Authentication\Token\DefaultToken;
|
|
|
|
use OC\Lockdown\LockdownManager;
|
2017-02-17 17:40:20 +03:00
|
|
|
use OCP\ISession;
|
2016-11-10 17:57:31 +03:00
|
|
|
use Test\TestCase;
|
|
|
|
|
|
|
|
class LockdownManagerTest extends TestCase {
|
2017-02-17 17:40:20 +03:00
|
|
|
private $sessionCallback;
|
|
|
|
|
2019-11-21 18:40:38 +03:00
|
|
|
public function setUp(): void {
|
2017-02-17 17:40:20 +03:00
|
|
|
parent::setUp();
|
|
|
|
|
|
|
|
$this->sessionCallback = function() {
|
|
|
|
return $this->createMock(ISession::class);
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2016-11-10 17:57:31 +03:00
|
|
|
public function testCanAccessFilesystemDisabled() {
|
2017-02-17 17:40:20 +03:00
|
|
|
$manager = new LockdownManager($this->sessionCallback);
|
2016-11-10 17:57:31 +03:00
|
|
|
$this->assertTrue($manager->canAccessFilesystem());
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testCanAccessFilesystemAllowed() {
|
|
|
|
$token = new DefaultToken();
|
|
|
|
$token->setScope(['filesystem' => true]);
|
2017-02-17 17:40:20 +03:00
|
|
|
$manager = new LockdownManager($this->sessionCallback);
|
2016-11-10 17:57:31 +03:00
|
|
|
$manager->setToken($token);
|
|
|
|
$this->assertTrue($manager->canAccessFilesystem());
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testCanAccessFilesystemNotAllowed() {
|
|
|
|
$token = new DefaultToken();
|
|
|
|
$token->setScope(['filesystem' => false]);
|
2017-02-17 17:40:20 +03:00
|
|
|
$manager = new LockdownManager($this->sessionCallback);
|
2016-11-10 17:57:31 +03:00
|
|
|
$manager->setToken($token);
|
|
|
|
$this->assertFalse($manager->canAccessFilesystem());
|
|
|
|
}
|
|
|
|
}
|