[Pkg-owncloud-commits] [owncloud] 23/34: Allow specifying protocol in ext storage OC config
David Prévot
taffit at moszumanska.debian.org
Fri Oct 17 01:32:17 UTC 2014
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository owncloud.
commit 361d6892c98ed5f01026919c5aa33e734e4f47d9
Author: Vincent Petry <pvince81 at owncloud.com>
Date: Mon Oct 13 17:15:58 2014 +0200
Allow specifying protocol in ext storage OC config
Allow specifying a protocol in the host field when mounting another
ownCloud instance. Note that this was already possible with the WebDAV
config but this bug made it inconsistent.
---
apps/files_external/lib/owncloud.php | 8 +++
apps/files_external/tests/owncloudfunctions.php | 83 +++++++++++++++++++++++++
lib/private/files/storage/dav.php | 4 +-
3 files changed, 93 insertions(+), 2 deletions(-)
diff --git a/apps/files_external/lib/owncloud.php b/apps/files_external/lib/owncloud.php
index 9831410..04a1e95 100644
--- a/apps/files_external/lib/owncloud.php
+++ b/apps/files_external/lib/owncloud.php
@@ -22,6 +22,14 @@ class OwnCloud extends \OC\Files\Storage\DAV{
// extract context path from host if specified
// (owncloud install path on 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 = '';
$hostSlashPos = strpos($host, '/');
if ($hostSlashPos !== false){
diff --git a/apps/files_external/tests/owncloudfunctions.php b/apps/files_external/tests/owncloudfunctions.php
new file mode 100644
index 0000000..57608ff
--- /dev/null
+++ b/apps/files_external/tests/owncloudfunctions.php
@@ -0,0 +1,83 @@
+<?php
+/**
+ * Copyright (c) 2014 Vincent Petry <pvince81 at 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());
+ }
+}
diff --git a/lib/private/files/storage/dav.php b/lib/private/files/storage/dav.php
index 0ba69fd..fb3fd1e 100644
--- a/lib/private/files/storage/dav.php
+++ b/lib/private/files/storage/dav.php
@@ -58,7 +58,7 @@ class DAV extends \OC\Files\Storage\Common {
$this->root .= '/';
}
} else {
- throw new \Exception();
+ throw new \Exception('Invalid webdav storage configuration');
}
}
@@ -85,7 +85,7 @@ class DAV extends \OC\Files\Storage\Common {
return 'webdav::' . $this->user . '@' . $this->host . '/' . $this->root;
}
- protected function createBaseUri() {
+ public function createBaseUri() {
$baseUri = 'http';
if ($this->secure) {
$baseUri .= 's';
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git
More information about the Pkg-owncloud-commits
mailing list