* ownCloud
*
* @author Vincent Petry
+ * @author Robin McCorkell
* Copyright (c) 2013 Vincent Petry <pvince81@owncloud.com>
*
* This library is free software; you can redistribute it and/or
*
*/
-class Test_Mount_Config_Dummy_Storage {
+class Test_Mount_Config_Dummy_Storage extends \OC\Files\Storage\Common {
public function __construct($params) {
if (isset($params['simulateFail']) && $params['simulateFail'] == true) {
throw new \Exception('Simulated config validation fail');
}
}
+ public function getId() {
+ return 'dummy_storage';
+ }
+
+ public function mkdir($path) {
+ return false;
+ }
+
+ public function rmdir($path) {
+ return false;
+ }
+
+ public function opendir($path) {
+ return false;
+ }
+
+ public function filetype($path) {
+ return false;
+ }
+
+ public function file_exists($path) {
+ return false;
+ }
+
+ public function unlink($path) {
+ return false;
+ }
+
+ public function fopen($path, $mode) {
+ return false;
+ }
+
+ public function touch($path, $mtime = null) {
+ return false;
+ }
+
+ public function stat($path) {
+ return false;
+ }
+
public function test() {
return true;
}
}
+class Test_Mount_Config_Storage_No_Personal extends Test_Mount_Config_Dummy_Storage {
+}
+
class Test_Mount_Config_Hook_Test {
static $signal;
static $params;
'configuration' => array()
)
);
+ OC_Mount_Config::registerBackend('Test_Mount_Config_Storage_No_Personal', array(
+ 'backend' => 'dummy no personal',
+ 'priority' => 150,
+ 'configuration' => array()
+ )
+ );
\OC_User::createUser(self::TEST_USER1, self::TEST_USER1);
\OC_User::createUser(self::TEST_USER2, self::TEST_USER2);
'user_mounting_backends',
''
);
- $this->allBackends = OC_Mount_Config::getBackends();
OCP\Config::setAppValue(
'files_external',
'user_mounting_backends',
- implode(',', array_keys($this->allBackends))
+ 'Test_Mount_Config_Dummy_Storage'
);
OC_Mount_Config::$skipTest = true;
'password' => '12345',
);
- $this->assertEquals(true, OC_Mount_Config::addMountPoint('/ext', '\OC\Files\Storage\SFTP', $storageOptions, $mountType, $applicable, $isPersonal));
+ $this->assertEquals(true, OC_Mount_Config::addMountPoint('/ext', 'Test_Mount_Config_Dummy_Storage', $storageOptions, $mountType, $applicable, $isPersonal));
$config = $this->readGlobalConfig();
$this->assertEquals(1, count($config));
$this->assertTrue(isset($config[$mountType][$applicable]));
$this->assertTrue(isset($config[$mountType][$applicable]['/$user/files/ext']));
$this->assertEquals(
- '\OC\Files\Storage\SFTP',
+ 'Test_Mount_Config_Dummy_Storage',
$config[$mountType][$applicable]['/$user/files/ext']['class']
);
}
'password' => '12345',
);
- $this->assertEquals(true, OC_Mount_Config::addMountPoint('/ext', '\OC\Files\Storage\SFTP', $storageOptions, $mountType, $applicable, $isPersonal));
+ $this->assertEquals(true, OC_Mount_Config::addMountPoint('/ext', 'Test_Mount_Config_Dummy_Storage', $storageOptions, $mountType, $applicable, $isPersonal));
$config = $this->readUserConfig();
$this->assertEquals(1, count($config));
$this->assertTrue(isset($config[$mountType][$applicable]));
$this->assertTrue(isset($config[$mountType][$applicable]['/' . self::TEST_USER1 . '/files/ext']));
$this->assertEquals(
- '\OC\Files\Storage\SFTP',
+ 'Test_Mount_Config_Dummy_Storage',
$config[$mountType][$applicable]['/' . self::TEST_USER1 . '/files/ext']['class']
);
}
$isPersonal = true;
// local
- $this->assertFalse(OC_Mount_Config::addMountPoint('/ext', '\OC\Files\storage\local', array(), $mountType, $applicable, $isPersonal));
-
- unset($this->allBackends['\OC\Files\Storage\SFTP']);
- OCP\Config::setAppValue(
- 'files_external',
- 'user_mounting_backends',
- implode(',', array_keys($this->allBackends))
- );
+ $this->assertFalse(OC_Mount_Config::addMountPoint('/ext', '\OC\Files\Storage\Local', array(), $mountType, $applicable, $isPersonal));
$storageOptions = array(
'host' => 'localhost',
);
// non-local but forbidden
- $this->assertFalse(OC_Mount_Config::addMountPoint('/ext', '\OC\Files\Storage\SFTP', $storageOptions, $mountType, $applicable, $isPersonal));
+ $this->assertFalse(OC_Mount_Config::addMountPoint('/ext', 'Test_Mount_Config_Storage_No_Personal', $storageOptions, $mountType, $applicable, $isPersonal));
$this->assertFalse(file_exists($this->userHome . '/mount.json'));
}
$this->assertTrue(
OC_Mount_Config::addMountPoint(
'/ext',
- '\OC\Files\Storage\SMB',
+ 'Test_Mount_Config_Dummy_Storage',
$options,
$mountType,
$applicable,
// re-read config
$config = OC_Mount_Config::getSystemMountPoints();
$this->assertEquals(1, count($config));
- $this->assertEquals('\OC\Files\Storage\SMB', $config[0]['class']);
+ $this->assertEquals('Test_Mount_Config_Dummy_Storage', $config[0]['class']);
$this->assertEquals('ext', $config[0]['mountpoint']);
$this->assertEquals($expectApplicableArray, $config[0]['applicable']);
$savedOptions = $config[0]['options'];
$this->assertTrue(
OC_Mount_Config::addMountPoint(
'/ext',
- '\OC\Files\Storage\SMB',
+ 'Test_Mount_Config_Dummy_Storage',
$options,
$mountType,
$applicable,
// re-read config
$config = OC_Mount_Config::getPersonalMountPoints();
$this->assertEquals(1, count($config));
- $this->assertEquals('\OC\Files\Storage\SMB', $config[0]['class']);
+ $this->assertEquals('Test_Mount_Config_Dummy_Storage', $config[0]['class']);
$this->assertEquals('ext', $config[0]['mountpoint']);
$savedOptions = $config[0]['options'];
$this->assertEquals($options, $savedOptions);
$this->assertTrue(
OC_Mount_Config::addMountPoint(
$mountPoint,
- '\OC\Files\Storage\SMB',
+ 'Test_Mount_Config_Dummy_Storage',
$mountConfig,
$mountType,
$applicable,
$this->assertTrue(
OC_Mount_Config::addMountPoint(
$mountPoint,
- '\OC\Files\Storage\SMB',
+ 'Test_Mount_Config_Dummy_Storage',
$mountConfig,
$mountType,
$applicable,
$this->assertTrue(
OC_Mount_Config::addMountPoint(
'/ext',
- '\OC\Files\Storage\SMB',
+ 'Test_Mount_Config_Dummy_Storage',
$mountConfig,
$mountType,
$applicable,
$this->assertTrue(
OC_Mount_Config::addMountPoint(
'/ext',
- '\OC\Files\Storage\SMB',
+ 'Test_Mount_Config_Dummy_Storage',
$mountConfig,
$mountType,
$applicable,
$this->assertTrue(
OC_Mount_Config::addMountPoint(
'/ext',
- '\OC\Files\Storage\SMB',
+ 'Test_Mount_Config_Dummy_Storage',
$mountConfig,
$mountType,
$applicable,
if ($expectVisible) {
$this->assertEquals(1, count($mountPoints));
$this->assertTrue(isset($mountPoints['/' . self::TEST_USER1 . '/files/ext']));
- $this->assertEquals('\OC\Files\Storage\SMB', $mountPoints['/' . self::TEST_USER1 . '/files/ext']['class']);
+ $this->assertEquals('Test_Mount_Config_Dummy_Storage', $mountPoints['/' . self::TEST_USER1 . '/files/ext']['class']);
$this->assertEquals($mountConfig, $mountPoints['/' . self::TEST_USER1 . '/files/ext']['options']);
}
else {
$this->assertTrue(
OC_Mount_Config::addMountPoint(
'/ext',
- '\OC\Files\Storage\SMB',
+ 'Test_Mount_Config_Dummy_Storage',
$options,
OC_Mount_Config::MOUNT_TYPE_USER,
self::TEST_USER1,
$this->assertTrue(
OC_Mount_Config::addMountPoint(
'/ext',
- '\OC\Files\Storage\SMB',
+ 'Test_Mount_Config_Dummy_Storage',
$options,
OC_Mount_Config::MOUNT_TYPE_USER,
self::TEST_USER2,
$this->assertTrue(
OC_Mount_Config::addMountPoint(
'/ext',
- '\OC\Files\Storage\SMB',
+ 'Test_Mount_Config_Dummy_Storage',
$options,
OC_Mount_Config::MOUNT_TYPE_GROUP,
self::TEST_GROUP2,
$this->assertTrue(
OC_Mount_Config::addMountPoint(
'/ext',
- '\OC\Files\Storage\SMB',
+ 'Test_Mount_Config_Dummy_Storage',
$options,
OC_Mount_Config::MOUNT_TYPE_GROUP,
self::TEST_GROUP1,
// re-read config
$config = OC_Mount_Config::getSystemMountPoints();
$this->assertEquals(1, count($config));
- $this->assertEquals('\OC\Files\Storage\SMB', $config[0]['class']);
+ $this->assertEquals('Test_Mount_Config_Dummy_Storage', $config[0]['class']);
$this->assertEquals('ext', $config[0]['mountpoint']);
$this->assertEquals($options, $config[0]['options']);
$this->assertEquals(array(self::TEST_USER1, self::TEST_USER2), $config[0]['applicable']['users']);
$this->assertTrue(
OC_Mount_Config::addMountPoint(
'/ext',
- '\OC\Files\Storage\SMB',
+ 'Test_Mount_Config_Dummy_Storage',
$options1,
$mountType,
self::TEST_USER1,
$this->assertTrue(
OC_Mount_Config::addMountPoint(
'/ext',
- '\OC\Files\Storage\SMB',
+ 'Test_Mount_Config_Dummy_Storage',
$options2,
$mountType,
self::TEST_USER2,
// re-read config
$config = OC_Mount_Config::getSystemMountPoints();
$this->assertEquals(2, count($config));
- $this->assertEquals('\OC\Files\Storage\SMB', $config[0]['class']);
+ $this->assertEquals('Test_Mount_Config_Dummy_Storage', $config[0]['class']);
$this->assertEquals('ext', $config[0]['mountpoint']);
$this->assertEquals($options1, $config[0]['options']);
- $this->assertEquals('\OC\Files\Storage\SMB', $config[1]['class']);
+ $this->assertEquals('Test_Mount_Config_Dummy_Storage', $config[1]['class']);
$this->assertEquals('ext', $config[1]['mountpoint']);
$this->assertEquals($options2, $config[1]['options']);
}
$this->assertTrue(
OC_Mount_Config::addMountPoint(
'/ext',
- '\OC\Files\Storage\SMB',
+ 'Test_Mount_Config_Dummy_Storage',
$mountConfig + array('id' => $i),
$mount['mountType'],
$mount['applicable'],
*/
public function testPriorityPersistence() {
- $class = '\OC\Files\Storage\SMB';
+ $class = 'Test_Mount_Config_Dummy_Storage';
$priority = 123;
$mountConfig = array(
'host' => 'somehost',
$this->assertTrue(
OC_Mount_Config::addMountPoint(
'/ext',
- '\OC\Files\Storage\SMB',
+ 'Test_Mount_Config_Dummy_Storage',
$mountConfig,
OC_Mount_Config::MOUNT_TYPE_USER,
self::TEST_USER1,
$this->assertEquals(0, count($mountPointsMe));
$this->assertEquals(1, count($mountPointsOther));
$this->assertTrue(isset($mountPointsOther['/'.self::TEST_USER1.'/files/ext']));
- $this->assertEquals('\OC\Files\Storage\SMB',
+ $this->assertEquals('Test_Mount_Config_Dummy_Storage',
$mountPointsOther['/'.self::TEST_USER1.'/files/ext']['class']);
$this->assertEquals($mountConfig,
$mountPointsOther['/'.self::TEST_USER1.'/files/ext']['options']);