From 642099ba324d93a39fbae904e15b6405ea732114 Mon Sep 17 00:00:00 2001 From: Lukas Reschke Date: Mon, 9 May 2016 11:25:58 +0200 Subject: [PATCH] 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. --- config/config.sample.php | 5 +++++ lib/private/updater.php | 7 ++----- tests/lib/updater.php | 12 ++++++------ 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/config/config.sample.php b/config/config.sample.php index d4b47cee2da7..5b1739c2f5fc 100644 --- a/config/config.sample.php +++ b/config/config.sample.php @@ -431,6 +431,11 @@ */ '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? */ diff --git a/lib/private/updater.php b/lib/private/updater.php index 6ceff8dd9348..60010f27d6ab 100644 --- a/lib/private/updater.php +++ b/lib/private/updater.php @@ -98,19 +98,16 @@ public function setSkip3rdPartyAppsDisable($flag) { /** * Check if a new version is available * - * @param string $updaterUrl the url to check, i.e. 'https://updates.owncloud.com/server/' * @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 7a1bc48e1a88..49438ff8caf2 100644 --- a/tests/lib/updater.php +++ b/tests/lib/updater.php @@ -50,7 +50,7 @@ public function testEmptyResponse(){ public function testValidEmptyXmlResponse(){ $updater = $this->getUpdaterMock( - '' + '' ); $result = array_map('strval', $updater->check()); @@ -66,7 +66,7 @@ public function testValidEmptyXmlResponse(){ public function testValidUpdateResponse(){ $newUpdater = $this->getUpdaterMock( - ' + ' 7.0.3.4 ownCloud 7.0.3 @@ -89,14 +89,14 @@ public function testValidUpdateResponse(){ protected function getUpdaterMock($content){ // Invalidate cache $mockedConfig = $this->getMockBuilder('\OCP\IConfig') - ->disableOriginalConstructor() - ->getMock() + ->disableOriginalConstructor() + ->getMock() ; $certificateManager = $this->getMock('\OCP\ICertificateManager'); $mockedHTTPHelper = $this->getMockBuilder('\OC\HTTPHelper') - ->setConstructorArgs(array(\OC::$server->getConfig(), $certificateManager)) - ->getMock() + ->setConstructorArgs(array(\OC::$server->getConfig(), $certificateManager)) + ->getMock() ; $mockedHTTPHelper->expects($this->once())->method('getUrlContent')->will($this->returnValue($content));