';
var SubView = OC.Backbone.View.extend({
@@ -70,7 +79,7 @@
var list = this.$('.token-list');
var tokens = this.collection.filter(function (token) {
- return parseInt(token.get('type'), 10) === _this.type;
+ return token.get('type') === _this.type;
});
list.html('');
@@ -78,7 +87,7 @@
this._toggleHeader(tokens.length > 0);
tokens.forEach(function (token) {
- var viewData = this._formatViewData(token.toJSON());
+ var viewData = this._formatViewData(token);
var html = _this.template(viewData);
var $html = $(html);
$html.find('.has-tooltip').tooltip({container: 'body'});
@@ -94,10 +103,13 @@
this.$('.hidden-when-empty').toggleClass('hidden', !show);
},
- _formatViewData: function (viewData) {
+ _formatViewData: function (token) {
+ var viewData = token.toJSON();
var ts = viewData.lastActivity * 1000;
viewData.lastActivity = OC.Util.relativeModifiedDate(ts);
viewData.lastActivityTime = OC.Util.formatDate(ts, 'LLL');
+ viewData.canScope = token.get('type') === 1;
+ viewData.showMore = viewData.canScope || viewData.canDelete;
// preserve title for cases where we format it further
viewData.title = viewData.name;
@@ -204,6 +216,8 @@
var $el = $(el);
$el.on('click', 'a.icon-delete', _.bind(_this._onDeleteToken, _this));
+ $el.on('click', '.icon-more', _.bind(_this._onConfigureToken, _this));
+ $el.on('change', 'input.filesystem', _.bind(_this._onSetTokenScope, _this));
});
this._form = $('#app-password-form');
@@ -325,6 +339,13 @@
this._addAppPasswordBtn.toggleClass('icon-loading-small', state);
},
+ _onConfigureToken: function (event) {
+ var $target = $(event.target);
+ var $row = $target.closest('tr');
+ $row.toggleClass('active');
+ var id = $row.data('id');
+ },
+
_onDeleteToken: function (event) {
var $target = $(event.target);
var $row = $target.closest('tr');
@@ -353,6 +374,24 @@
});
},
+ _onSetTokenScope: function (event) {
+ var $target = $(event.target);
+ var $row = $target.closest('tr');
+ var id = $row.data('id');
+
+ var token = this.collection.get(id);
+ if (_.isUndefined(token)) {
+ // Ignore event
+ return;
+ }
+
+ var scope = token.get('scope');
+ scope.filesystem = $target.is(":checked");
+
+ token.set('scope', scope);
+ token.save();
+ },
+
_toggleFormResult: function (showForm) {
if (showForm) {
this._result.slideUp();
diff --git a/tests/Settings/Controller/AuthSettingsControllerTest.php b/tests/Settings/Controller/AuthSettingsControllerTest.php
index 9cb49e4eb3..782c9f644e 100644
--- a/tests/Settings/Controller/AuthSettingsControllerTest.php
+++ b/tests/Settings/Controller/AuthSettingsControllerTest.php
@@ -42,6 +42,7 @@ class AuthSettingsControllerTest extends TestCase {
/** @var AuthSettingsController */
private $controller;
private $request;
+ /** @var IProvider|\PHPUnit_Framework_MockObject_MockObject */
private $tokenProvider;
private $userManager;
private $session;
@@ -94,17 +95,19 @@ class AuthSettingsControllerTest extends TestCase {
[
'id' => 100,
'name' => null,
- 'lastActivity' => null,
- 'type' => null,
+ 'lastActivity' => 0,
+ 'type' => 0,
'canDelete' => false,
'current' => true,
+ 'scope' => ['filesystem' => true]
],
[
'id' => 200,
'name' => null,
- 'lastActivity' => null,
- 'type' => null,
+ 'lastActivity' => 0,
+ 'type' => 0,
'canDelete' => true,
+ 'scope' => ['filesystem' => true]
]
], $this->controller->index());
}
@@ -141,9 +144,13 @@ class AuthSettingsControllerTest extends TestCase {
->with($newToken, $this->uid, 'User13', $password, $name, IToken::PERMANENT_TOKEN)
->will($this->returnValue($deviceToken));
+ $deviceToken->expects($this->once())
+ ->method('jsonSerialize')
+ ->will($this->returnValue(['dummy' => 'dummy', 'canDelete' => true]));
+
$expected = [
'token' => $newToken,
- 'deviceToken' => $deviceToken,
+ 'deviceToken' => ['dummy' => 'dummy', 'canDelete' => true],
'loginName' => 'User13',
];
$this->assertEquals($expected, $this->controller->create($name));
@@ -194,4 +201,26 @@ class AuthSettingsControllerTest extends TestCase {
$this->assertEquals([], $this->controller->destroy($id));
}
+ public function testUpdateToken() {
+ $token = $this->createMock(DefaultToken::class);
+
+ $this->tokenProvider->expects($this->once())
+ ->method('getTokenById')
+ ->with($this->equalTo(42))
+ ->willReturn($token);
+
+ $token->expects($this->once())
+ ->method('setScope')
+ ->with($this->equalTo([
+ 'filesystem' => true,
+ 'app' => ['dav', 'myapp']
+ ]));
+
+ $this->tokenProvider->expects($this->once())
+ ->method('updateToken')
+ ->with($this->equalTo($token));
+
+ $this->assertSame([], $this->controller->update(42, ['filesystem' => true, 'apps' => ['dav', 'myapp']]));
+ }
+
}
diff --git a/tests/lib/Authentication/Token/DefaultTokenMapperTest.php b/tests/lib/Authentication/Token/DefaultTokenMapperTest.php
index 418a4d14f6..8fe0762daa 100644
--- a/tests/lib/Authentication/Token/DefaultTokenMapperTest.php
+++ b/tests/lib/Authentication/Token/DefaultTokenMapperTest.php
@@ -27,6 +27,7 @@ use OC\Authentication\Token\DefaultToken;
use OC\Authentication\Token\DefaultTokenMapper;
use OC\Authentication\Token\IToken;
use OCP\DB\QueryBuilder\IQueryBuilder;
+use OCP\IDBConnection;
use OCP\IUser;
use Test\TestCase;
@@ -40,6 +41,8 @@ class DefaultTokenMapperTest extends TestCase {
/** @var DefaultTokenMapper */
private $mapper;
+
+ /** @var IDBConnection */
private $dbConnection;
private $time;
@@ -122,7 +125,6 @@ class DefaultTokenMapperTest extends TestCase {
}
public function testGetToken() {
- $token = '1504445f1524fc801035448a95681a9378ba2e83930c814546c56e5d6ebde221198792fd900c88ed5ead0555780dad1ebce3370d7e154941cd5de87eb419899b';
$token = new DefaultToken();
$token->setUid('user2');
$token->setLoginName('User2');
@@ -151,6 +153,42 @@ class DefaultTokenMapperTest extends TestCase {
$this->mapper->getToken($token);
}
+ public function testGetTokenById() {
+ $token = new DefaultToken();
+ $token->setUid('user2');
+ $token->setLoginName('User2');
+ $token->setPassword('971a337057853344700bbeccf836519f|UwOQwyb34sJHtqPV|036d4890f8c21d17bbc7b88072d8ef049a5c832a38e97f3e3d5f9186e896c2593aee16883f617322fa242728d0236ff32d163caeb4bd45e14ca002c57a88665f');
+ $token->setName('Firefox on Android');
+ $token->setToken('1504445f1524fc801035448a95681a9378ba2e83930c814546c56e5d6ebde221198792fd900c88ed5ead0555780dad1ebce3370d7e154941cd5de87eb419899b');
+ $token->setType(IToken::TEMPORARY_TOKEN);
+ $token->setRemember(IToken::DO_NOT_REMEMBER);
+ $token->setLastActivity($this->time - 60 * 60 * 24 * 3);
+ $token->setLastCheck($this->time - 10);
+
+ $dbToken = $this->mapper->getToken($token->getToken());
+ $token->setId($dbToken->getId()); // We don't know the ID
+ $token->resetUpdatedFields();
+
+ $dbToken = $this->mapper->getTokenById($token->getId());
+ $this->assertEquals($token, $dbToken);
+ }
+
+ /**
+ * @expectedException \OCP\AppFramework\Db\DoesNotExistException
+ */
+ public function testGetTokenByIdNotFound() {
+ $this->mapper->getTokenById(-1);
+ }
+
+ /**
+ * @expectedException \OCP\AppFramework\Db\DoesNotExistException
+ */
+ public function testGetInvalidTokenById() {
+ $id = 42;
+
+ $this->mapper->getToken($id);
+ }
+
public function testGetTokenByUser() {
$user = $this->createMock(IUser::class);
$user->expects($this->once())
diff --git a/tests/lib/Authentication/Token/DefaultTokenProviderTest.php b/tests/lib/Authentication/Token/DefaultTokenProviderTest.php
index 5e4d4f9436..8d92ee405a 100644
--- a/tests/lib/Authentication/Token/DefaultTokenProviderTest.php
+++ b/tests/lib/Authentication/Token/DefaultTokenProviderTest.php
@@ -22,9 +22,11 @@
namespace Test\Authentication\Token;
+use OC\Authentication\Exceptions\InvalidTokenException;
use OC\Authentication\Token\DefaultToken;
use OC\Authentication\Token\DefaultTokenProvider;
use OC\Authentication\Token\IToken;
+use OCP\AppFramework\Db\DoesNotExistException;
use OCP\AppFramework\Db\Mapper;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\IConfig;
@@ -376,4 +378,25 @@ class DefaultTokenProviderTest extends TestCase {
$this->tokenProvider->renewSessionToken('oldId', 'newId');
}
+ public function testGetTokenById() {
+ $token = $this->createMock(DefaultToken::class);
+
+ $this->mapper->expects($this->once())
+ ->method('getTokenById')
+ ->with($this->equalTo(42))
+ ->willReturn($token);
+
+ $this->assertSame($token, $this->tokenProvider->getTokenById(42));
+ }
+
+ public function testGetInvalidTokenById() {
+ $this->expectException(InvalidTokenException::class);
+
+ $this->mapper->expects($this->once())
+ ->method('getTokenById')
+ ->with($this->equalTo(42))
+ ->willThrowException(new DoesNotExistException('nope'));
+
+ $this->tokenProvider->getTokenById(42);
+ }
}
diff --git a/tests/lib/Authentication/Token/DefaultTokenTest.php b/tests/lib/Authentication/Token/DefaultTokenTest.php
new file mode 100644
index 0000000000..f00c32ccaf
--- /dev/null
+++ b/tests/lib/Authentication/Token/DefaultTokenTest.php
@@ -0,0 +1,49 @@
+
+ *
+ * @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 .
+ *
+ */
+
+namespace Test\Authentication\Token;
+
+use OC\Authentication\Token\DefaultToken;
+use Test\TestCase;
+
+class DefaultTokenTest extends TestCase {
+ public function testSetScopeAsArray() {
+ $scope = ['filesystem' => false];
+ $token = new DefaultToken();
+ $token->setScope($scope);
+ $this->assertEquals(json_encode($scope), $token->getScope());
+ $this->assertEquals($scope, $token->getScopeAsArray());
+ }
+
+ public function testSetScopeAsString() {
+ $scope = ['filesystem' => false];
+ $token = new DefaultToken();
+ $token->setScope(json_encode($scope));
+ $this->assertEquals(json_encode($scope), $token->getScope());
+ $this->assertEquals($scope, $token->getScopeAsArray());
+ }
+
+ public function testDefaultScope() {
+ $scope = ['filesystem' => true];
+ $token = new DefaultToken();
+ $this->assertEquals($scope, $token->getScopeAsArray());
+ }
+}
diff --git a/tests/lib/Lockdown/Filesystem/NoFSTest.php b/tests/lib/Lockdown/Filesystem/NoFSTest.php
new file mode 100644
index 0000000000..a0900ad769
--- /dev/null
+++ b/tests/lib/Lockdown/Filesystem/NoFSTest.php
@@ -0,0 +1,63 @@
+
+ *
+ * @author Robin Appelman
+ *
+ * @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 .
+ *
+ */
+
+namespace Test\Lockdown\Filesystem;
+
+use OC\Authentication\Token\DefaultToken;
+use OC\Files\Filesystem;
+use OC\Lockdown\Filesystem\NullStorage;
+use Test\Traits\UserTrait;
+
+/**
+ * @group DB
+ */
+class NoFSTest extends \Test\TestCase {
+ use UserTrait;
+
+ public function tearDown() {
+ $token = new DefaultToken();
+ $token->setScope([
+ 'filesystem' => true
+ ]);
+ \OC::$server->getLockdownManager()->setToken($token);
+ return parent::tearDown();
+ }
+
+ public function setUp() {
+ parent::setUp();
+ $token = new DefaultToken();
+ $token->setScope([
+ 'filesystem' => false
+ ]);
+
+ \OC::$server->getLockdownManager()->setToken($token);
+ $this->createUser('foo', 'var');
+ }
+
+ public function testSetupFS() {
+ \OC_Util::tearDownFS();
+ \OC_Util::setupFS('foo');
+
+ $this->assertInstanceOf(NullStorage::class, Filesystem::getStorage('/foo/files'));
+ }
+}
diff --git a/tests/lib/Lockdown/Filesystem/NullCacheTest.php b/tests/lib/Lockdown/Filesystem/NullCacheTest.php
new file mode 100644
index 0000000000..3a4e3f3a40
--- /dev/null
+++ b/tests/lib/Lockdown/Filesystem/NullCacheTest.php
@@ -0,0 +1,157 @@
+
+ *
+ * @author Roeland Jago Douma
+ *
+ * @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 .
+ *
+ */
+
+namespace Test\Lockdown\Filesystem;
+
+use OC\ForbiddenException;
+use OC\Lockdown\Filesystem\NullCache;
+use OCP\Constants;
+use OCP\Files\Cache\ICache;
+use OCP\Files\FileInfo;
+
+class NulLCacheTest extends \Test\TestCase {
+
+ /** @var NullCache */
+ private $cache;
+
+ public function setUp() {
+ parent::setUp();
+
+ $this->cache = new NullCache();
+ }
+
+ public function testGetNumericStorageId() {
+ $this->assertSame(-1, $this->cache->getNumericStorageId());
+ }
+
+ public function testGetEmpty() {
+ $this->assertNull($this->cache->get('foo'));
+ }
+
+ public function testGet() {
+ $data = $this->cache->get('');
+
+ $this->assertEquals(-1, $data['fileid']);
+ $this->assertEquals(-1, $data['parent']);
+ $this->assertEquals('', $data['name']);
+ $this->assertEquals('', $data['path']);
+ $this->assertEquals('0', $data['size']);
+ $this->assertEquals('', $data['etag']);
+ $this->assertEquals(FileInfo::MIMETYPE_FOLDER, $data['mimetype']);
+ $this->assertEquals('httpd', $data['mimepart']);
+ $this->assertEquals(Constants::PERMISSION_READ, $data['permissions']);
+ }
+
+ public function testGetFolderContents() {
+ $this->assertSame([], $this->cache->getFolderContents('foo'));
+ }
+
+ public function testGetFolderContentsById() {
+ $this->assertSame([], $this->cache->getFolderContentsById(42));
+ }
+
+ public function testPut() {
+ $this->expectException(ForbiddenException::class);
+ $this->expectExceptionMessage('This request is not allowed to access the filesystem');
+
+ $this->cache->put('foo', ['size' => 100]);
+ }
+
+ public function testInsert() {
+ $this->expectException(ForbiddenException::class);
+ $this->expectExceptionMessage('This request is not allowed to access the filesystem');
+
+ $this->cache->insert('foo', ['size' => 100]);
+ }
+
+ public function testUpdate() {
+ $this->expectException(ForbiddenException::class);
+ $this->expectExceptionMessage('This request is not allowed to access the filesystem');
+
+ $this->cache->update('foo', ['size' => 100]);
+ }
+
+ public function testGetId() {
+ $this->assertSame(-1, $this->cache->getId('foo'));
+ }
+
+ public function testGetParentId() {
+ $this->assertSame(-1, $this->cache->getParentId('foo'));
+ }
+
+ public function testInCache() {
+ $this->assertTrue($this->cache->inCache(''));
+ $this->assertFalse($this->cache->inCache('foo'));
+ }
+
+ public function testRemove() {
+ $this->expectException(ForbiddenException::class);
+ $this->expectExceptionMessage('This request is not allowed to access the filesystem');
+
+ $this->cache->remove('foo');
+ }
+
+ public function testMove() {
+ $this->expectException(ForbiddenException::class);
+ $this->expectExceptionMessage('This request is not allowed to access the filesystem');
+
+ $this->cache->move('foo', 'bar');
+ }
+
+ public function testMoveFromCache() {
+ $sourceCache = $this->createMock(ICache::class);
+
+ $this->expectException(ForbiddenException::class);
+ $this->expectExceptionMessage('This request is not allowed to access the filesystem');
+
+ $this->cache->moveFromCache($sourceCache, 'foo', 'bar');
+ }
+
+ public function testGetStatus() {
+ $this->assertSame(ICache::COMPLETE, $this->cache->getStatus('foo'));
+ }
+
+ public function testSearch() {
+ $this->assertSame([], $this->cache->search('foo'));
+ }
+
+ public function testSearchByMime() {
+ $this->assertSame([], $this->cache->searchByMime('foo'));
+ }
+
+ public function testSearchByTag() {
+ $this->assertSame([], $this->cache->searchByTag('foo', 'user'));
+ }
+
+ public function testGetIncomplete() {
+ $this->assertSame([], $this->cache->getIncomplete());
+ }
+
+ public function testGetPathById() {
+ $this->assertSame('', $this->cache->getPathById(42));
+ }
+
+ public function testNormalize() {
+ $this->assertSame('foo/ bar /', $this->cache->normalize('foo/ bar /'));
+ }
+}
diff --git a/tests/lib/Lockdown/Filesystem/NullStorageTest.php b/tests/lib/Lockdown/Filesystem/NullStorageTest.php
new file mode 100644
index 0000000000..dc99eb4c03
--- /dev/null
+++ b/tests/lib/Lockdown/Filesystem/NullStorageTest.php
@@ -0,0 +1,245 @@
+
+ *
+ * @author Roeland Jago Douma
+ *
+ * @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 .
+ *
+ */
+
+namespace Test\Lockdown\Filesystem;
+
+use Icewind\Streams\IteratorDirectory;
+use OC\ForbiddenException;
+use OC\Lockdown\Filesystem\NullCache;
+use OC\Lockdown\Filesystem\NullStorage;
+use OCP\Files\Storage;
+use Test\TestCase;
+
+class NullStorageTest extends TestCase {
+
+ /** @var NullStorage */
+ private $storage;
+
+ public function setUp() {
+ parent::setUp();
+
+ $this->storage = new NullStorage([]);
+ }
+
+ public function testGetId() {
+ $this->assertSame('null', $this->storage->getId());
+ }
+
+ public function testMkdir() {
+ $this->expectException(ForbiddenException::class);
+ $this->expectExceptionMessage('This request is not allowed to access the filesystem');
+
+ $this->storage->mkdir('foo');
+ }
+
+ public function testRmdir() {
+ $this->expectException(ForbiddenException::class);
+ $this->expectExceptionMessage('This request is not allowed to access the filesystem');
+
+ $this->storage->rmdir('foo');
+ }
+
+ public function testOpendir() {
+ $this->assertInstanceOf(IteratorDirectory::class, $this->storage->opendir('foo'));
+ }
+
+ public function testIs_dir() {
+ $this->assertTrue($this->storage->is_dir(''));
+ $this->assertFalse($this->storage->is_dir('foo'));
+ }
+
+ public function testIs_file() {
+ $this->assertFalse($this->storage->is_file('foo'));
+ }
+
+ public function testStat() {
+ $this->expectException(ForbiddenException::class);
+ $this->expectExceptionMessage('This request is not allowed to access the filesystem');
+
+ $this->storage->stat('foo');
+ }
+
+ public function testFiletype() {
+ $this->assertSame('dir', $this->storage->filetype(''));
+ $this->assertFalse($this->storage->filetype('foo'));
+ }
+
+ public function testFilesize() {
+ $this->expectException(ForbiddenException::class);
+ $this->expectExceptionMessage('This request is not allowed to access the filesystem');
+
+ $this->storage->filesize('foo');
+ }
+
+ public function testIsCreatable() {
+ $this->assertFalse($this->storage->isCreatable('foo'));
+ }
+
+ public function testIsReadable() {
+ $this->assertTrue($this->storage->isReadable(''));
+ $this->assertFalse($this->storage->isReadable('foo'));
+ }
+
+ public function testIsUpdatable() {
+ $this->assertFalse($this->storage->isUpdatable('foo'));
+ }
+
+ public function testIsDeletable() {
+ $this->assertFalse($this->storage->isDeletable('foo'));
+ }
+
+ public function testIsSharable() {
+ $this->assertFalse($this->storage->isSharable('foo'));
+ }
+
+ public function testGetPermissions() {
+ $this->assertNull($this->storage->getPermissions('foo'));
+ }
+
+ public function testFile_exists() {
+ $this->assertTrue($this->storage->file_exists(''));
+ $this->assertFalse($this->storage->file_exists('foo'));
+ }
+
+ public function testFilemtime() {
+ $this->assertFalse($this->storage->filemtime('foo'));
+ }
+
+ public function testFile_get_contents() {
+ $this->expectException(ForbiddenException::class);
+ $this->expectExceptionMessage('This request is not allowed to access the filesystem');
+
+ $this->storage->file_get_contents('foo');
+ }
+
+ public function testFile_put_contents() {
+ $this->expectException(ForbiddenException::class);
+ $this->expectExceptionMessage('This request is not allowed to access the filesystem');
+
+ $this->storage->file_put_contents('foo', 'bar');
+ }
+
+ public function testUnlink() {
+ $this->expectException(ForbiddenException::class);
+ $this->expectExceptionMessage('This request is not allowed to access the filesystem');
+
+ $this->storage->unlink('foo');
+ }
+
+ public function testRename() {
+ $this->expectException(ForbiddenException::class);
+ $this->expectExceptionMessage('This request is not allowed to access the filesystem');
+
+ $this->storage->rename('foo', 'bar');
+ }
+
+ public function testCopy() {
+ $this->expectException(ForbiddenException::class);
+ $this->expectExceptionMessage('This request is not allowed to access the filesystem');
+
+ $this->storage->copy('foo', 'bar');
+ }
+
+ public function testFopen() {
+ $this->expectException(ForbiddenException::class);
+ $this->expectExceptionMessage('This request is not allowed to access the filesystem');
+
+ $this->storage->fopen('foo', 'R');
+ }
+
+ public function testGetMimeType() {
+ $this->expectException(ForbiddenException::class);
+ $this->expectExceptionMessage('This request is not allowed to access the filesystem');
+
+ $this->storage->getMimeType('foo');
+ }
+
+ public function testHash() {
+ $this->expectException(ForbiddenException::class);
+ $this->expectExceptionMessage('This request is not allowed to access the filesystem');
+
+ $this->storage->hash('md5', 'foo', true);
+ }
+
+ public function testFree_space() {
+ $this->assertSame(0, $this->storage->free_space('foo'));
+ }
+
+ public function testTouch() {
+ $this->expectException(ForbiddenException::class);
+ $this->expectExceptionMessage('This request is not allowed to access the filesystem');
+
+ $this->storage->touch('foo');
+ }
+
+ public function testGetLocalFile() {
+ $this->assertFalse($this->storage->getLocalFile('foo'));
+ }
+
+ public function testHasUpdated() {
+ $this->assertFalse($this->storage->hasUpdated('foo', 42));
+ }
+
+ public function testGetETag() {
+ $this->assertSame('', $this->storage->getETag('foo'));
+ }
+
+ public function testIsLocal() {
+ $this->assertFalse($this->storage->isLocal());
+ }
+
+ public function testGetDirectDownload() {
+ $this->assertFalse($this->storage->getDirectDownload('foo'));
+ }
+
+ public function testCopyFromStorage() {
+ $sourceStorage = $this->createMock(Storage::class);
+
+ $this->expectException(ForbiddenException::class);
+ $this->expectExceptionMessage('This request is not allowed to access the filesystem');
+
+ $this->storage->copyFromStorage($sourceStorage, 'foo', 'bar');
+ }
+
+ public function testMoveFromStorage() {
+ $sourceStorage = $this->createMock(Storage::class);
+
+ $this->expectException(ForbiddenException::class);
+ $this->expectExceptionMessage('This request is not allowed to access the filesystem');
+
+ $this->storage->moveFromStorage($sourceStorage, 'foo', 'bar');
+ }
+
+ public function testTest() {
+ $this->assertTrue($this->storage->test());
+ return true;
+ }
+
+ public function testGetOwner() {
+ $this->assertNull($this->storage->getOwner('foo'));
+ }
+
+ public function testGetCache() {
+ $this->assertInstanceOf(NullCache::class, $this->storage->getCache('foo'));
+ }
+}
diff --git a/tests/lib/Lockdown/LockdownManagerTest.php b/tests/lib/Lockdown/LockdownManagerTest.php
new file mode 100644
index 0000000000..4cbd9d71a5
--- /dev/null
+++ b/tests/lib/Lockdown/LockdownManagerTest.php
@@ -0,0 +1,49 @@
+
+ *
+ * @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 .
+ *
+ */
+
+namespace Test\Lockdown;
+
+use OC\Authentication\Token\DefaultToken;
+use OC\Lockdown\LockdownManager;
+use Test\TestCase;
+
+class LockdownManagerTest extends TestCase {
+ public function testCanAccessFilesystemDisabled() {
+ $manager = new LockdownManager();
+ $this->assertTrue($manager->canAccessFilesystem());
+ }
+
+ public function testCanAccessFilesystemAllowed() {
+ $token = new DefaultToken();
+ $token->setScope(['filesystem' => true]);
+ $manager = new LockdownManager();
+ $manager->setToken($token);
+ $this->assertTrue($manager->canAccessFilesystem());
+ }
+
+ public function testCanAccessFilesystemNotAllowed() {
+ $token = new DefaultToken();
+ $token->setScope(['filesystem' => false]);
+ $manager = new LockdownManager();
+ $manager->setToken($token);
+ $this->assertFalse($manager->canAccessFilesystem());
+ }
+}
diff --git a/version.php b/version.php
index 42a0e7c9bd..d556386a84 100644
--- a/version.php
+++ b/version.php
@@ -25,7 +25,7 @@
// We only can count up. The 4. digit is only for the internal patchlevel to trigger DB upgrades
// between betas, final and RCs. This is _not_ the public version number. Reset minor/patchlevel
// when updating major/minor version number.
-$OC_Version = array(11, 0, 0, 0);
+$OC_Version = array(11, 0, 0, 1);
// The human readable string
$OC_VersionString = '11.0 alpha';