support string values ('true' and 'false') for configuring the secure parameter on external storage backends

fixes #78
remotes/origin/stable4
Robin Appelman 2012-11-05 16:39:03 +07:00
parent 4b86c43f97
commit 3cd31eee6e
4 changed files with 45 additions and 3 deletions

@ -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;

@ -268,7 +268,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;
}

@ -23,7 +23,15 @@ class OC_FileStorage_DAV extends OC_Filestorage_Common{
$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;

@ -26,5 +26,23 @@ if(!is_array($config) or !isset($config['ftp']) or !$config['ftp']['run']){
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(''));
}
}