diff options
author | Robin McCorkell <rmccorkell@karoshi.org.uk> | 2015-03-26 21:36:34 +0000 |
---|---|---|
committer | Robin McCorkell <rmccorkell@karoshi.org.uk> | 2015-03-26 21:36:34 +0000 |
commit | c2909355bf66c92e46c9fbea39497ba91dbe37a0 (patch) | |
tree | c832f4ba40ba1728ddd82bc5684ca6b4aa9eb3b6 /apps/files_external/tests/mountconfig.php | |
parent | fc59a37ae7e28ad8ef7a0a383e87024ff942408d (diff) | |
parent | 58b4c2c0e53ff5ef6e261426ecb2b94d9791da71 (diff) | |
download | nextcloud-server-c2909355bf66c92e46c9fbea39497ba91dbe37a0.tar.gz nextcloud-server-c2909355bf66c92e46c9fbea39497ba91dbe37a0.zip |
Merge pull request #14925 from owncloud/ext-mountoptions-ui
Mount options GUI for external storage
Diffstat (limited to 'apps/files_external/tests/mountconfig.php')
-rw-r--r-- | apps/files_external/tests/mountconfig.php | 51 |
1 files changed, 50 insertions, 1 deletions
diff --git a/apps/files_external/tests/mountconfig.php b/apps/files_external/tests/mountconfig.php index a3b993f5018..b76ba0a39a6 100644 --- a/apps/files_external/tests/mountconfig.php +++ b/apps/files_external/tests/mountconfig.php @@ -123,7 +123,6 @@ class Test_Mount_Config extends \Test\TestCase { private $dataDir; private $userHome; private $oldAllowedBackends; - private $allBackends; const TEST_USER1 = 'user1'; const TEST_USER2 = 'user2'; @@ -213,6 +212,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 */ @@ -630,6 +634,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 |