Skip to content
Snippets Groups Projects
Commit 46501016 authored by Vincent Petry's avatar Vincent Petry
Browse files

Merge pull request #11548 from owncloud/extstorage-ocfields

Allow specifying protocol in ext storage OC config
parents dd0b1e83 ab5149f5
Branches
No related tags found
No related merge requests found
...@@ -22,6 +22,14 @@ class OwnCloud extends \OC\Files\Storage\DAV{ ...@@ -22,6 +22,14 @@ class OwnCloud extends \OC\Files\Storage\DAV{
// extract context path from host if specified // extract context path from host if specified
// (owncloud install path on host) // (owncloud install path on host)
$host = $params['host']; $host = $params['host'];
// strip protocol
if (substr($host, 0, 8) == "https://") {
$host = substr($host, 8);
$params['secure'] = true;
} else if (substr($host, 0, 7) == "http://") {
$host = substr($host, 7);
$params['secure'] = false;
}
$contextPath = ''; $contextPath = '';
$hostSlashPos = strpos($host, '/'); $hostSlashPos = strpos($host, '/');
if ($hostSlashPos !== false){ if ($hostSlashPos !== false){
......
<?php
/**
* Copyright (c) 2014 Vincent Petry <pvince81@owncloud.com>
* This file is licensed under the Affero General Public License version 3 or
* later.
* See the COPYING-README file.
*/
namespace Test\Files\Storage;
class OwnCloudFunctions extends \PHPUnit_Framework_TestCase {
function configUrlProvider() {
return array(
array(
array(
'host' => 'testhost',
'root' => 'testroot',
'secure' => false
),
'http://testhost/remote.php/webdav/testroot/',
),
array(
array(
'host' => 'testhost',
'root' => 'testroot',
'secure' => true
),
'https://testhost/remote.php/webdav/testroot/',
),
array(
array(
'host' => 'http://testhost',
'root' => 'testroot',
'secure' => false
),
'http://testhost/remote.php/webdav/testroot/',
),
array(
array(
'host' => 'https://testhost',
'root' => 'testroot',
'secure' => false
),
'https://testhost/remote.php/webdav/testroot/',
),
array(
array(
'host' => 'https://testhost/testroot',
'root' => '',
'secure' => false
),
'https://testhost/testroot/remote.php/webdav/',
),
array(
array(
'host' => 'https://testhost/testroot',
'root' => 'subdir',
'secure' => false
),
'https://testhost/testroot/remote.php/webdav/subdir/',
),
array(
array(
'host' => 'http://testhost/testroot',
'root' => 'subdir',
'secure' => true
),
'http://testhost/testroot/remote.php/webdav/subdir/',
),
);
}
/**
* @dataProvider configUrlProvider
*/
public function testConfig($config, $expectedUri) {
$config['user'] = 'someuser';
$config['password'] = 'somepassword';
$instance = new \OC\Files\Storage\OwnCloud($config);
$this->assertEquals($expectedUri, $instance->createBaseUri());
}
}
...@@ -58,7 +58,7 @@ class DAV extends \OC\Files\Storage\Common { ...@@ -58,7 +58,7 @@ class DAV extends \OC\Files\Storage\Common {
$this->root .= '/'; $this->root .= '/';
} }
} else { } else {
throw new \Exception(); throw new \Exception('Invalid webdav storage configuration');
} }
} }
...@@ -85,7 +85,7 @@ class DAV extends \OC\Files\Storage\Common { ...@@ -85,7 +85,7 @@ class DAV extends \OC\Files\Storage\Common {
return 'webdav::' . $this->user . '@' . $this->host . '/' . $this->root; return 'webdav::' . $this->user . '@' . $this->host . '/' . $this->root;
} }
protected function createBaseUri() { public function createBaseUri() {
$baseUri = 'http'; $baseUri = 'http';
if ($this->secure) { if ($this->secure) {
$baseUri .= 's'; $baseUri .= 's';
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment