summaryrefslogtreecommitdiffstats
path: root/apps/files_external/tests
diff options
context:
space:
mode:
authorRobin McCorkell <rmccorkell@owncloud.com>2015-09-23 16:00:21 +0100
committerRobin McCorkell <rmccorkell@owncloud.com>2015-09-23 16:00:21 +0100
commit97c4691c052b3f7b344cfc4fff7d4719ba587686 (patch)
tree88c7f3fc833adbe8e7152fcb00dfe02d5a4ef53b /apps/files_external/tests
parent24043333008b12dfbe7374cb318d9041717b87e0 (diff)
downloadnextcloud-server-97c4691c052b3f7b344cfc4fff7d4719ba587686.tar.gz
nextcloud-server-97c4691c052b3f7b344cfc4fff7d4719ba587686.zip
Unit tests for storage validation in service
Diffstat (limited to 'apps/files_external/tests')
-rw-r--r--apps/files_external/tests/service/storagesservicetest.php46
-rw-r--r--apps/files_external/tests/service/userglobalstoragesservicetest.php10
2 files changed, 56 insertions, 0 deletions
diff --git a/apps/files_external/tests/service/storagesservicetest.php b/apps/files_external/tests/service/storagesservicetest.php
index 28220c9bc2e..ddf52e6272e 100644
--- a/apps/files_external/tests/service/storagesservicetest.php
+++ b/apps/files_external/tests/service/storagesservicetest.php
@@ -305,6 +305,52 @@ abstract class StoragesServiceTest extends \Test\TestCase {
);
}
+ public function testGetStoragesBackendNotVisible() {
+ $backend = $this->backendService->getBackend('identifier:\OCA\Files_External\Lib\Backend\SMB');
+ $backend->expects($this->once())
+ ->method('isVisibleFor')
+ ->with($this->service->getVisibilityType())
+ ->willReturn(false);
+ $authMechanism = $this->backendService->getAuthMechanism('identifier:\Auth\Mechanism');
+ $authMechanism->method('isVisibleFor')
+ ->with($this->service->getVisibilityType())
+ ->willReturn(true);
+
+ $storage = new StorageConfig(255);
+ $storage->setMountPoint('mountpoint');
+ $storage->setBackend($backend);
+ $storage->setAuthMechanism($authMechanism);
+ $storage->setBackendOptions(['password' => 'testPassword']);
+
+ $newStorage = $this->service->addStorage($storage);
+
+ $this->assertCount(1, $this->service->getAllStorages());
+ $this->assertEmpty($this->service->getStorages());
+ }
+
+ public function testGetStoragesAuthMechanismNotVisible() {
+ $backend = $this->backendService->getBackend('identifier:\OCA\Files_External\Lib\Backend\SMB');
+ $backend->method('isVisibleFor')
+ ->with($this->service->getVisibilityType())
+ ->willReturn(true);
+ $authMechanism = $this->backendService->getAuthMechanism('identifier:\Auth\Mechanism');
+ $authMechanism->expects($this->once())
+ ->method('isVisibleFor')
+ ->with($this->service->getVisibilityType())
+ ->willReturn(false);
+
+ $storage = new StorageConfig(255);
+ $storage->setMountPoint('mountpoint');
+ $storage->setBackend($backend);
+ $storage->setAuthMechanism($authMechanism);
+ $storage->setBackendOptions(['password' => 'testPassword']);
+
+ $newStorage = $this->service->addStorage($storage);
+
+ $this->assertCount(1, $this->service->getAllStorages());
+ $this->assertEmpty($this->service->getStorages());
+ }
+
public static function createHookCallback($params) {
self::$hookCalls[] = array(
'signal' => Filesystem::signal_create_mount,
diff --git a/apps/files_external/tests/service/userglobalstoragesservicetest.php b/apps/files_external/tests/service/userglobalstoragesservicetest.php
index 8b4b9b0163e..b6dc952605d 100644
--- a/apps/files_external/tests/service/userglobalstoragesservicetest.php
+++ b/apps/files_external/tests/service/userglobalstoragesservicetest.php
@@ -247,6 +247,16 @@ class UserGlobalStoragesServiceTest extends GlobalStoragesServiceTest {
}
}
+ public function testGetStoragesBackendNotVisible() {
+ // we don't test this here
+ $this->assertTrue(true);
+ }
+
+ public function testGetStoragesAuthMechanismNotVisible() {
+ // we don't test this here
+ $this->assertTrue(true);
+ }
+
public function testHooksAddStorage($a = null, $b = null, $c = null) {
// we don't test this here
$this->assertTrue(true);