diff options
author | Vincent Petry <pvince81@owncloud.com> | 2015-04-15 16:21:41 +0200 |
---|---|---|
committer | Vincent Petry <pvince81@owncloud.com> | 2015-04-15 16:25:47 +0200 |
commit | a6c5d65fd621178c8d3899d5a43295edcc4840a2 (patch) | |
tree | 24fa13735e2890f737537ebb4f82c22ddaf4026a /apps/files_external/tests | |
parent | 1a2475227b6777e016ec931ddae533437bfbb2dd (diff) | |
download | nextcloud-server-a6c5d65fd621178c8d3899d5a43295edcc4840a2.tar.gz nextcloud-server-a6c5d65fd621178c8d3899d5a43295edcc4840a2.zip |
Fix SFTP storage id to be compatible with older ids
Remove port from SFTP storage id if it is 22.
This will prevent recreating a different storage entry due to id
mismatch after upgrade.
Diffstat (limited to 'apps/files_external/tests')
-rw-r--r-- | apps/files_external/tests/backends/sftp.php | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/apps/files_external/tests/backends/sftp.php b/apps/files_external/tests/backends/sftp.php index e619fd7e13d..ae800326e58 100644 --- a/apps/files_external/tests/backends/sftp.php +++ b/apps/files_external/tests/backends/sftp.php @@ -47,4 +47,61 @@ class SFTP extends Storage { parent::tearDown(); } + + /** + * @dataProvider configProvider + */ + public function testStorageId($config, $expectedStorageId) { + $instance = new \OC\Files\Storage\SFTP($config); + $this->assertEquals($expectedStorageId, $instance->getId()); + } + + function configProvider() { + return [ + [ + // no root path + [ + 'run' => true, + 'host' => 'somehost', + 'user' => 'someuser', + 'password' => 'somepassword', + 'root' => '', + ], + 'sftp::someuser@somehost//', + ], + [ + // without leading nor trailing slash + [ + 'run' => true, + 'host' => 'somehost', + 'user' => 'someuser', + 'password' => 'somepassword', + 'root' => 'remotedir/subdir', + ], + 'sftp::someuser@somehost//remotedir/subdir/', + ], + [ + // regular path + [ + 'run' => true, + 'host' => 'somehost', + 'user' => 'someuser', + 'password' => 'somepassword', + 'root' => '/remotedir/subdir/', + ], + 'sftp::someuser@somehost//remotedir/subdir/', + ], + [ + // different port + [ + 'run' => true, + 'host' => 'somehost:8822', + 'user' => 'someuser', + 'password' => 'somepassword', + 'root' => 'remotedir/subdir/', + ], + 'sftp::someuser@somehost:8822//remotedir/subdir/', + ], + ]; + } } |