summaryrefslogtreecommitdiffstats
path: root/apps/files_external/tests
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2015-03-26 19:24:37 +0100
committerVincent Petry <pvince81@owncloud.com>2015-03-26 19:24:37 +0100
commit58b4c2c0e53ff5ef6e261426ecb2b94d9791da71 (patch)
tree5474559ea90ba4fa1c1438a33fbd1bc0c0824479 /apps/files_external/tests
parentca6b715b31bbfea7724dd8659e2a1e61098a31a5 (diff)
downloadnextcloud-server-58b4c2c0e53ff5ef6e261426ecb2b94d9791da71.tar.gz
nextcloud-server-58b4c2c0e53ff5ef6e261426ecb2b94d9791da71.zip
Make sure mountOptions keep their data type
str_replace for $user substitution was converting the data type of mountOptions to string. This fix prevents this to happen by making sure only strings are processed by substitution. Also added a int conversion when reading the watcher policy
Diffstat (limited to 'apps/files_external/tests')
-rw-r--r--apps/files_external/tests/mountconfig.php51
1 files changed, 50 insertions, 1 deletions
diff --git a/apps/files_external/tests/mountconfig.php b/apps/files_external/tests/mountconfig.php
index 645f0c64e11..4bc8429db23 100644
--- a/apps/files_external/tests/mountconfig.php
+++ b/apps/files_external/tests/mountconfig.php
@@ -120,7 +120,6 @@ class Test_Mount_Config extends \Test\TestCase {
private $dataDir;
private $userHome;
private $oldAllowedBackends;
- private $allBackends;
const TEST_USER1 = 'user1';
const TEST_USER2 = 'user2';
@@ -210,6 +209,11 @@ class Test_Mount_Config extends \Test\TestCase {
return json_decode(file_get_contents($configFile), true);
}
+ private function writeGlobalConfig($config) {
+ $configFile = $this->dataDir . '/mount.json';
+ file_put_contents($configFile, json_encode($config));
+ }
+
/**
* Reads the user config, for checking
*/
@@ -627,6 +631,51 @@ class Test_Mount_Config extends \Test\TestCase {
$this->assertEquals($mountConfig, $savedMountConfig);
}
+ public function testVariableSubstitution() {
+ $legacyBackendOptions = [
+ 'user' => 'someuser',
+ 'password' => 'somepassword',
+ 'replacethis' => '$user',
+ ];
+ $legacyBackendOptions = \OC_Mount_Config::encryptPasswords($legacyBackendOptions);
+
+ $legacyConfig = [
+ 'class' => '\OC\Files\Storage\SMB',
+ 'options' => $legacyBackendOptions,
+ 'mountOptions' => ['preview' => false, 'int' => 1],
+ ];
+ // different mount options
+ $legacyConfig2 = [
+ 'class' => '\OC\Files\Storage\SMB',
+ 'options' => $legacyBackendOptions,
+ 'mountOptions' => ['preview' => true, 'string' => 'abc'],
+ ];
+
+ $json = [
+ 'user' => [
+ self::TEST_USER1 => [
+ '/$user/files/somemount' => $legacyConfig,
+ '/$user/files/anothermount' => $legacyConfig2,
+ ],
+ ],
+ ];
+
+ $this->writeGlobalConfig($json);
+
+ // re-read config, password was read correctly
+ $config = OC_Mount_Config::getAbsoluteMountPoints(self::TEST_USER1);
+
+ $config1 = $config['/' . self::TEST_USER1 . '/files/somemount'];
+ $config2 = $config['/' . self::TEST_USER1 . '/files/anothermount'];
+
+ $this->assertSame(self::TEST_USER1, $config1['options']['replacethis']);
+ $this->assertSame(self::TEST_USER1, $config1['options']['replacethis']);
+ $this->assertSame(1, $config1['mountOptions']['int']);
+ $this->assertSame(true, $config2['mountOptions']['preview']);
+ $this->assertSame('abc', $config2['mountOptions']['string']);
+ }
+
+
public function mountDataProvider() {
return array(
// Tests for visible mount points