summaryrefslogtreecommitdiffstats
path: root/apps/files_external/tests
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files_external/tests')
-rw-r--r--apps/files_external/tests/controller/storagescontrollertest.php16
-rw-r--r--apps/files_external/tests/controller/userstoragescontrollertest.php16
-rw-r--r--apps/files_external/tests/service/backendservicetest.php28
3 files changed, 27 insertions, 33 deletions
diff --git a/apps/files_external/tests/controller/storagescontrollertest.php b/apps/files_external/tests/controller/storagescontrollertest.php
index 2b0ee7a14ea..c43761f3bcb 100644
--- a/apps/files_external/tests/controller/storagescontrollertest.php
+++ b/apps/files_external/tests/controller/storagescontrollertest.php
@@ -75,10 +75,12 @@ abstract class StoragesControllerTest extends \Test\TestCase {
$authMech = $this->getAuthMechMock();
$authMech->method('validateStorage')
->willReturn(true);
+ $authMech->method('isPermitted')
+ ->willReturn(true);
$backend = $this->getBackendMock();
$backend->method('validateStorage')
->willReturn(true);
- $backend->method('isVisibleFor')
+ $backend->method('isPermitted')
->willReturn(true);
$storageConfig = new StorageConfig(1);
@@ -114,10 +116,12 @@ abstract class StoragesControllerTest extends \Test\TestCase {
$authMech = $this->getAuthMechMock();
$authMech->method('validateStorage')
->willReturn(true);
+ $authMech->method('isPermitted')
+ ->willReturn(true);
$backend = $this->getBackendMock();
$backend->method('validateStorage')
->willReturn(true);
- $backend->method('isVisibleFor')
+ $backend->method('isPermitted')
->willReturn(true);
$storageConfig = new StorageConfig(1);
@@ -245,10 +249,12 @@ abstract class StoragesControllerTest extends \Test\TestCase {
$authMech = $this->getAuthMechMock();
$authMech->method('validateStorage')
->willReturn(true);
+ $authMech->method('isPermitted')
+ ->willReturn(true);
$backend = $this->getBackendMock();
$backend->method('validateStorage')
->willReturn(true);
- $backend->method('isVisibleFor')
+ $backend->method('isPermitted')
->willReturn(true);
$storageConfig = new StorageConfig(255);
@@ -332,12 +338,14 @@ abstract class StoragesControllerTest extends \Test\TestCase {
$backend = $this->getBackendMock();
$backend->method('validateStorage')
->willReturn($backendValidate);
- $backend->method('isVisibleFor')
+ $backend->method('isPermitted')
->willReturn(true);
$authMech = $this->getAuthMechMock();
$authMech->method('validateStorage')
->will($this->returnValue($authMechValidate));
+ $authMech->method('isPermitted')
+ ->willReturn(true);
$storageConfig = new StorageConfig();
$storageConfig->setMountPoint('mount');
diff --git a/apps/files_external/tests/controller/userstoragescontrollertest.php b/apps/files_external/tests/controller/userstoragescontrollertest.php
index 9f1a8df8d2e..b61174b0797 100644
--- a/apps/files_external/tests/controller/userstoragescontrollertest.php
+++ b/apps/files_external/tests/controller/userstoragescontrollertest.php
@@ -49,15 +49,21 @@ class UserStoragesControllerTest extends StoragesControllerTest {
}
public function testAddOrUpdateStorageDisallowedBackend() {
- $backend = $this->getBackendMock();
- $backend->method('isVisibleFor')
- ->with(BackendService::VISIBILITY_PERSONAL)
+ $backend1 = $this->getBackendMock();
+ $backend1->expects($this->once())
+ ->method('isPermitted')
+ ->with(BackendService::USER_PERSONAL, BackendService::PERMISSION_CREATE)
+ ->willReturn(false);
+ $backend2 = $this->getBackendMock();
+ $backend2->expects($this->once())
+ ->method('isPermitted')
+ ->with(BackendService::USER_PERSONAL, BackendService::PERMISSION_MODIFY)
->willReturn(false);
$authMech = $this->getAuthMechMock();
$storageConfig = new StorageConfig(1);
$storageConfig->setMountPoint('mount');
- $storageConfig->setBackend($backend);
+ $storageConfig->setBackend($backend1);
$storageConfig->setAuthMechanism($authMech);
$storageConfig->setBackendOptions([]);
@@ -82,6 +88,8 @@ class UserStoragesControllerTest extends StoragesControllerTest {
$this->assertEquals(Http::STATUS_UNPROCESSABLE_ENTITY, $response->getStatus());
+ $storageConfig->setBackend($backend2);
+
$response = $this->controller->update(
1,
'mount',
diff --git a/apps/files_external/tests/service/backendservicetest.php b/apps/files_external/tests/service/backendservicetest.php
index 08f6b9bf988..b37b5e9b466 100644
--- a/apps/files_external/tests/service/backendservicetest.php
+++ b/apps/files_external/tests/service/backendservicetest.php
@@ -83,11 +83,11 @@ class BackendServiceTest extends \Test\TestCase {
$backendAllowed = $this->getBackendMock('\User\Mount\Allowed');
$backendAllowed->expects($this->never())
- ->method('removeVisibility');
+ ->method('removePermission');
$backendNotAllowed = $this->getBackendMock('\User\Mount\NotAllowed');
$backendNotAllowed->expects($this->once())
- ->method('removeVisibility')
- ->with(BackendService::VISIBILITY_PERSONAL);
+ ->method('removePermission')
+ ->with(BackendService::USER_PERSONAL, BackendService::PERMISSION_CREATE | BackendService::PERMISSION_MOUNT);
$backendAlias = $this->getMockBuilder('\OCA\Files_External\Lib\Backend\Backend')
->disableOriginalConstructor()
@@ -126,27 +126,5 @@ class BackendServiceTest extends \Test\TestCase {
$this->assertArrayNotHasKey('identifier:\Backend\NotAvailable', $availableBackends);
}
- public function testGetUserBackends() {
- $service = new BackendService($this->config, $this->l10n);
-
- $backendAllowed = $this->getBackendMock('\User\Mount\Allowed');
- $backendAllowed->expects($this->once())
- ->method('isVisibleFor')
- ->with(BackendService::VISIBILITY_PERSONAL)
- ->will($this->returnValue(true));
- $backendNotAllowed = $this->getBackendMock('\User\Mount\NotAllowed');
- $backendNotAllowed->expects($this->once())
- ->method('isVisibleFor')
- ->with(BackendService::VISIBILITY_PERSONAL)
- ->will($this->returnValue(false));
-
- $service->registerBackend($backendAllowed);
- $service->registerBackend($backendNotAllowed);
-
- $userBackends = $service->getBackendsVisibleFor(BackendService::VISIBILITY_PERSONAL);
- $this->assertArrayHasKey('identifier:\User\Mount\Allowed', $userBackends);
- $this->assertArrayNotHasKey('identifier:\User\Mount\NotAllowed', $userBackends);
- }
-
}