Skip to content

Commit

Permalink
fixup! dont offer to edit external config settings if we can't edit them
Browse files Browse the repository at this point in the history
  • Loading branch information
juliushaertl committed Dec 28, 2020
1 parent d0fe9b4 commit ce45787
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,11 @@

use OCA\Files_External\Controller\GlobalStoragesController;
use OCA\Files_External\Service\BackendService;
use OCP\IGroupManager;
use OCP\IL10N;
use OCP\ILogger;
use OCP\IRequest;
use OCP\IUserSession;

class GlobalStoragesControllerTest extends StoragesControllerTest {
protected function setUp(): void {
Expand All @@ -47,7 +49,9 @@ protected function setUp(): void {
$this->createMock(IRequest::class),
$this->createMock(IL10N::class),
$this->service,
$this->createMock(ILogger::class)
$this->createMock(ILogger::class),
$this->userSession,
$this->createMock(IGroupManager::class)
);
}
}
17 changes: 15 additions & 2 deletions apps/files_external/tests/Controller/StoragesControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,12 @@
use OCA\Files_External\Controller\GlobalStoragesController;
use OCA\Files_External\Lib\Auth\AuthMechanism;
use OCA\Files_External\Lib\Backend\Backend;

use OCA\Files_External\Lib\StorageConfig;
use OCA\Files_External\NotFoundException;
use OCA\Files_External\Service\GlobalStoragesService;
use OCP\AppFramework\Http;
use OCP\IUser;
use OCP\IUserSession;

abstract class StoragesControllerTest extends \Test\TestCase {

Expand All @@ -49,7 +50,16 @@ abstract class StoragesControllerTest extends \Test\TestCase {
*/
protected $service;

/** @var IUserSession */
protected $userSession;

protected function setUp(): void {
$user = $this->createMock(IUser::class);
$user->method('getUID')
->willReturn('test');
$this->userSession = $this->createMock(IUserSession::class);
$this->userSession->method('getUser')
->willReturn($user);
\OCA\Files_External\MountConfig::$skipTest = true;
}

Expand Down Expand Up @@ -337,8 +347,11 @@ public function testGetStorage() {
->willReturn($storageConfig);
$response = $this->controller->show(1);

$expected = $storageConfig->jsonSerialize();
$expected['can_edit'] = false;

$this->assertEquals(Http::STATUS_OK, $response->getStatus());
$this->assertEquals($storageConfig, $response->getData());
$this->assertEquals($expected, $response->getData());
}

public function validateStorageProvider() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
use OCA\Files_External\Lib\StorageConfig;
use OCA\Files_External\Service\BackendService;
use OCP\AppFramework\Http;
use OCP\IGroupManager;
use OCP\IL10N;
use OCP\ILogger;
use OCP\IRequest;
Expand All @@ -57,8 +58,9 @@ protected function setUp(): void {
$this->createMock(IRequest::class),
$this->createMock(IL10N::class),
$this->service,
$this->createMock(IUserSession::class),
$this->createMock(ILogger::class)
$this->createMock(ILogger::class),
$this->userSession,
$this->createMock(IGroupManager::class)
);
}

Expand Down

0 comments on commit ce45787

Please sign in to comment.