aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2012-11-05 16:39:03 +0100
committerRobin Appelman <icewind@owncloud.com>2012-11-05 16:46:47 +0100
commit9691d5671319eb0354c65827efeef799c84a3051 (patch)
tree647ffa3d1e5dbb71ea42c5c8f49232c36c2bf9ad
parent92829e8f94f3dc5155773efdeaf3629166a3e1fd (diff)
downloadnextcloud-server-9691d5671319eb0354c65827efeef799c84a3051.tar.gz
nextcloud-server-9691d5671319eb0354c65827efeef799c84a3051.zip
support string values ('true' and 'false') for configuring the secure parameter on external storage backends
fixes #78
-rw-r--r--apps/files_external/lib/ftp.php10
-rw-r--r--apps/files_external/lib/swift.php10
-rw-r--r--apps/files_external/lib/webdav.php10
-rw-r--r--apps/files_external/tests/ftp.php18
4 files changed, 45 insertions, 3 deletions
diff --git a/apps/files_external/lib/ftp.php b/apps/files_external/lib/ftp.php
index 261141455cc..da4feac7682 100644
--- a/apps/files_external/lib/ftp.php
+++ b/apps/files_external/lib/ftp.php
@@ -19,7 +19,15 @@ class OC_FileStorage_FTP extends OC_FileStorage_StreamWrapper{
$this->host=$params['host'];
$this->user=$params['user'];
$this->password=$params['password'];
- $this->secure=isset($params['secure'])?(bool)$params['secure']:false;
+ if(isset($params['secure'])){
+ if(is_string($params['secure'])){
+ $this->secure = ($params['secure'] === 'true');
+ }else{
+ $this->secure = (bool)$params['secure'];
+ }
+ }else{
+ $this->secure = false;
+ }
$this->root=isset($params['root'])?$params['root']:'/';
if(!$this->root || $this->root[0]!='/') {
$this->root='/'.$this->root;
diff --git a/apps/files_external/lib/swift.php b/apps/files_external/lib/swift.php
index 4b0b8c25fda..3268a6165d5 100644
--- a/apps/files_external/lib/swift.php
+++ b/apps/files_external/lib/swift.php
@@ -271,7 +271,15 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{
$this->host=$params['host'];
$this->user=$params['user'];
$this->root=isset($params['root'])?$params['root']:'/';
- $this->secure=isset($params['secure'])?(bool)$params['secure']:true;
+ if(isset($params['secure'])){
+ if(is_string($params['secure'])){
+ $this->secure = ($params['secure'] === 'true');
+ }else{
+ $this->secure = (bool)$params['secure'];
+ }
+ }else{
+ $this->secure = false;
+ }
if(!$this->root || $this->root[0]!='/') {
$this->root='/'.$this->root;
}
diff --git a/apps/files_external/lib/webdav.php b/apps/files_external/lib/webdav.php
index 5e185839158..38214d58a80 100644
--- a/apps/files_external/lib/webdav.php
+++ b/apps/files_external/lib/webdav.php
@@ -27,7 +27,15 @@ class OC_FileStorage_DAV extends OC_Filestorage_Common{
$this->host=$host;
$this->user=$params['user'];
$this->password=$params['password'];
- $this->secure=(isset($params['secure']) && $params['secure'] == 'true')?true:false;
+ if(isset($params['secure'])){
+ if(is_string($params['secure'])){
+ $this->secure = ($params['secure'] === 'true');
+ }else{
+ $this->secure = (bool)$params['secure'];
+ }
+ }else{
+ $this->secure = false;
+ }
$this->root=isset($params['root'])?$params['root']:'/';
if(!$this->root || $this->root[0]!='/') {
$this->root='/'.$this->root;
diff --git a/apps/files_external/tests/ftp.php b/apps/files_external/tests/ftp.php
index 4549c420410..80288b59114 100644
--- a/apps/files_external/tests/ftp.php
+++ b/apps/files_external/tests/ftp.php
@@ -24,4 +24,22 @@ class Test_Filestorage_FTP extends Test_FileStorage {
OCP\Files::rmdirr($this->instance->constructUrl(''));
}
}
+
+ public function testConstructUrl(){
+ $config = array ( 'host' => 'localhost', 'user' => 'ftp', 'password' => 'ftp', 'root' => '/', 'secure' => false );
+ $instance = new OC_Filestorage_FTP($config);
+ $this->assertEqual('ftp://ftp:ftp@localhost/', $instance->constructUrl(''));
+
+ $config['secure'] = true;
+ $instance = new OC_Filestorage_FTP($config);
+ $this->assertEqual('ftps://ftp:ftp@localhost/', $instance->constructUrl(''));
+
+ $config['secure'] = 'false';
+ $instance = new OC_Filestorage_FTP($config);
+ $this->assertEqual('ftp://ftp:ftp@localhost/', $instance->constructUrl(''));
+
+ $config['secure'] = 'true';
+ $instance = new OC_Filestorage_FTP($config);
+ $this->assertEqual('ftps://ftp:ftp@localhost/', $instance->constructUrl(''));
+ }
}