summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLukas Reschke <lukas@owncloud.com>2016-05-09 11:25:58 +0200
committerVincent Petry <pvince81@owncloud.com>2016-05-13 16:15:07 +0200
commit9a80ea4eed76218b87f1f21bca8297badd6a2f4e (patch)
treec4bffc596b8c8d3b20774cf8fa32852aff5345d7
parent63769d54c36eb0f824bc937cd3985b2e7242a127 (diff)
downloadnextcloud-server-9a80ea4eed76218b87f1f21bca8297badd6a2f4e.tar.gz
nextcloud-server-9a80ea4eed76218b87f1f21bca8297badd6a2f4e.zip
Make update server URL configurable
Currently testing the updates is a big problem and not really super easy possible. Since we now have a new updater server we should also make this configurable so that people can properly test updates.
-rw-r--r--config/config.sample.php5
-rw-r--r--lib/private/updater.php7
-rw-r--r--tests/lib/updater.php90
3 files changed, 38 insertions, 64 deletions
diff --git a/config/config.sample.php b/config/config.sample.php
index d6e47a38e02..cc38ebeff63 100644
--- a/config/config.sample.php
+++ b/config/config.sample.php
@@ -412,6 +412,11 @@ $CONFIG = array(
'updatechecker' => true,
/**
+ * URL that ownCloud should use to look for updates
+ */
+'updater.server.url' => 'https://updates.owncloud.com/server/',
+
+/**
* Is ownCloud connected to the Internet or running in a closed network?
*/
'has_internet_connection' => true,
diff --git a/lib/private/updater.php b/lib/private/updater.php
index 8f4b81cec65..1b0764c8e1f 100644
--- a/lib/private/updater.php
+++ b/lib/private/updater.php
@@ -127,19 +127,16 @@ class Updater extends BasicEmitter {
/**
* Check if a new version is available
*
- * @param string $updaterUrl the url to check, i.e. 'http://apps.owncloud.com/updater.php'
* @return array|bool
*/
- public function check($updaterUrl = null) {
+ public function check() {
// Look up the cache - it is invalidated all 30 minutes
if (((int)$this->config->getAppValue('core', 'lastupdatedat') + 1800) > time()) {
return json_decode($this->config->getAppValue('core', 'lastupdateResult'), true);
}
- if (is_null($updaterUrl)) {
- $updaterUrl = 'https://updates.owncloud.com/server/';
- }
+ $updaterUrl = $this->config->getSystemValue('updater.server.url', 'https://updates.owncloud.com/server/');
$this->config->setAppValue('core', 'lastupdatedat', time());
diff --git a/tests/lib/updater.php b/tests/lib/updater.php
index 763858acf5d..5fc2a9cc2f2 100644
--- a/tests/lib/updater.php
+++ b/tests/lib/updater.php
@@ -202,20 +202,25 @@ class UpdaterTest extends \Test\TestCase {
->will($this->returnValue(0));
$this->config
->expects($this->at(1))
+ ->method('getSystemValue')
+ ->with('updater.server.url', 'https://updates.owncloud.com/server/')
+ ->willReturn('https://updates.owncloud.com/server/');
+ $this->config
+ ->expects($this->at(2))
->method('setAppValue')
->with('core', 'lastupdatedat', $this->isType('integer'));
$this->config
- ->expects($this->at(3))
+ ->expects($this->at(4))
->method('getAppValue')
->with('core', 'installedat')
->will($this->returnValue('installedat'));
$this->config
- ->expects($this->at(4))
+ ->expects($this->at(5))
->method('getAppValue')
->with('core', 'lastupdatedat')
->will($this->returnValue('lastupdatedat'));
$this->config
- ->expects($this->at(5))
+ ->expects($this->at(6))
->method('setAppValue')
->with('core', 'lastupdateResult', json_encode($expectedResult));
@@ -243,20 +248,25 @@ class UpdaterTest extends \Test\TestCase {
->will($this->returnValue(0));
$this->config
->expects($this->at(1))
+ ->method('getSystemValue')
+ ->with('updater.server.url', 'https://updates.owncloud.com/server/')
+ ->willReturn('https://updates.owncloud.com/server/');
+ $this->config
+ ->expects($this->at(2))
->method('setAppValue')
->with('core', 'lastupdatedat', $this->isType('integer'));
$this->config
- ->expects($this->at(3))
+ ->expects($this->at(4))
->method('getAppValue')
->with('core', 'installedat')
->will($this->returnValue('installedat'));
$this->config
- ->expects($this->at(4))
+ ->expects($this->at(5))
->method('getAppValue')
->with('core', 'lastupdatedat')
->will($this->returnValue('lastupdatedat'));
$this->config
- ->expects($this->at(5))
+ ->expects($this->at(6))
->method('setAppValue')
->with('core', 'lastupdateResult', 'false');
@@ -270,54 +280,6 @@ class UpdaterTest extends \Test\TestCase {
$this->assertSame([], $this->updater->check());
}
- public function testCheckWithUpdateUrl() {
- $expectedResult = [
- 'version' => '8.0.4.2',
- 'versionstring' => 'ownCloud 8.0.4',
- 'url' => 'https://download.owncloud.org/community/owncloud-8.0.4.zip',
- 'web' => 'http://doc.owncloud.org/server/8.0/admin_manual/maintenance/upgrade.html',
- ];
-
- $this->config
- ->expects($this->at(0))
- ->method('getAppValue')
- ->with('core', 'lastupdatedat')
- ->will($this->returnValue(0));
- $this->config
- ->expects($this->at(1))
- ->method('setAppValue')
- ->with('core', 'lastupdatedat', $this->isType('integer'));
- $this->config
- ->expects($this->at(3))
- ->method('getAppValue')
- ->with('core', 'installedat')
- ->will($this->returnValue('installedat'));
- $this->config
- ->expects($this->at(4))
- ->method('getAppValue')
- ->with('core', 'lastupdatedat')
- ->will($this->returnValue('lastupdatedat'));
- $this->config
- ->expects($this->at(5))
- ->method('setAppValue')
- ->with('core', 'lastupdateResult', json_encode($expectedResult));
-
- $updateXml = '<?xml version="1.0"?>
-<owncloud>
- <version>8.0.4.2</version>
- <versionstring>ownCloud 8.0.4</versionstring>
- <url>https://download.owncloud.org/community/owncloud-8.0.4.zip</url>
- <web>http://doc.owncloud.org/server/8.0/admin_manual/maintenance/upgrade.html</web>
-</owncloud>';
- $this->httpHelper
- ->expects($this->once())
- ->method('getUrlContent')
- ->with($this->buildUpdateUrl('https://myupdater.com/'))
- ->will($this->returnValue($updateXml));
-
- $this->assertSame($expectedResult, $this->updater->check('https://myupdater.com/'));
- }
-
public function testCheckWithEmptyValidXmlResponse() {
$expectedResult = [
'version' => '',
@@ -333,15 +295,20 @@ class UpdaterTest extends \Test\TestCase {
->will($this->returnValue(0));
$this->config
->expects($this->at(1))
+ ->method('getSystemValue')
+ ->with('updater.server.url', 'https://updates.owncloud.com/server/')
+ ->willReturn('https://updates.owncloud.com/server/');
+ $this->config
+ ->expects($this->at(2))
->method('setAppValue')
->with('core', 'lastupdatedat', $this->isType('integer'));
$this->config
- ->expects($this->at(3))
+ ->expects($this->at(4))
->method('getAppValue')
->with('core', 'installedat')
->will($this->returnValue('installedat'));
$this->config
- ->expects($this->at(4))
+ ->expects($this->at(5))
->method('getAppValue')
->with('core', 'lastupdatedat')
->will($this->returnValue('lastupdatedat'));
@@ -372,20 +339,25 @@ class UpdaterTest extends \Test\TestCase {
->will($this->returnValue(0));
$this->config
->expects($this->at(1))
+ ->method('getSystemValue')
+ ->with('updater.server.url', 'https://updates.owncloud.com/server/')
+ ->willReturn('https://updates.owncloud.com/server/');
+ $this->config
+ ->expects($this->at(2))
->method('setAppValue')
->with('core', 'lastupdatedat', $this->isType('integer'));
$this->config
- ->expects($this->at(3))
+ ->expects($this->at(4))
->method('getAppValue')
->with('core', 'installedat')
->will($this->returnValue('installedat'));
$this->config
- ->expects($this->at(4))
+ ->expects($this->at(5))
->method('getAppValue')
->with('core', 'lastupdatedat')
->will($this->returnValue('lastupdatedat'));
$this->config
- ->expects($this->at(5))
+ ->expects($this->at(6))
->method('setAppValue')
->with('core', 'lastupdateResult', json_encode($expectedResult));