Skip to content

Commit

Permalink
Merge pull request #24515 from owncloud/stable8-updater-server-config…
Browse files Browse the repository at this point in the history
…urable

[stable8] Make update server URL configurable
  • Loading branch information
Vincent Petry committed May 17, 2016
2 parents 42c782f + 642099b commit 8cee246
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
5 changes: 5 additions & 0 deletions config/config.sample.php
Original file line number Diff line number Diff line change
Expand Up @@ -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?
*/
Expand Down
7 changes: 2 additions & 5 deletions lib/private/updater.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());

Expand Down
12 changes: 6 additions & 6 deletions tests/lib/updater.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function testEmptyResponse(){

public function testValidEmptyXmlResponse(){
$updater = $this->getUpdaterMock(
'<?xml version="1.0"?><owncloud><version></version><versionstring></versionstring><url></url><web></web></owncloud>'
'<?xml version="1.0"?><owncloud><version></version><versionstring></versionstring><url></url><web></web></owncloud>'
);
$result = array_map('strval', $updater->check());

Expand All @@ -66,7 +66,7 @@ public function testValidEmptyXmlResponse(){

public function testValidUpdateResponse(){
$newUpdater = $this->getUpdaterMock(
'<?xml version="1.0"?>
'<?xml version="1.0"?>
<owncloud>
<version>7.0.3.4</version>
<versionstring>ownCloud 7.0.3</versionstring>
Expand All @@ -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));
Expand Down

0 comments on commit 8cee246

Please sign in to comment.