Make connectivity check domains configurable
Signed-off-by: Sylvia van Os <sylvia@hackerchick.me>
This commit is contained in:
parent
b7767a51f1
commit
935bb25639
|
@ -656,6 +656,26 @@ $CONFIG = array(
|
||||||
*/
|
*/
|
||||||
'has_internet_connection' => true,
|
'has_internet_connection' => true,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Which domains to request to determine the availability of an Internet
|
||||||
|
* connection. If none of these hosts are reachable, the administration panel
|
||||||
|
* will show a warning. Set to an empty list to not do any such checks (warning
|
||||||
|
* will still be shown).
|
||||||
|
*
|
||||||
|
* Defaults to the following domains:
|
||||||
|
*
|
||||||
|
* - www.nextcloud.com
|
||||||
|
* - www.startpage.com
|
||||||
|
* - www.eff.org
|
||||||
|
* - www.edri.org
|
||||||
|
*/
|
||||||
|
'connectivity_check_domains' => array(
|
||||||
|
'www.nextcloud.com',
|
||||||
|
'www.startpage.com',
|
||||||
|
'www.eff.org',
|
||||||
|
'www.edri.org'
|
||||||
|
),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allows Nextcloud to verify a working .well-known URL redirects. This is done
|
* Allows Nextcloud to verify a working .well-known URL redirects. This is done
|
||||||
* by attempting to make a request from JS to
|
* by attempting to make a request from JS to
|
||||||
|
|
|
@ -130,11 +130,9 @@ class CheckSetupController extends Controller {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$siteArray = ['www.nextcloud.com',
|
$siteArray = $this->config->getSystemValue('connectivity_check_domains', [
|
||||||
'www.startpage.com',
|
'www.nextcloud.com', 'www.startpage.com', 'www.eff.org', 'www.edri.org'
|
||||||
'www.eff.org',
|
]);
|
||||||
'www.edri.org',
|
|
||||||
];
|
|
||||||
|
|
||||||
foreach($siteArray as $site) {
|
foreach($siteArray as $site) {
|
||||||
if ($this->isSiteReachable($site)) {
|
if ($this->isSiteReachable($site)) {
|
||||||
|
|
|
@ -189,11 +189,16 @@ class CheckSetupControllerTest extends TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testIsInternetConnectionWorkingCorrectly() {
|
public function testIsInternetConnectionWorkingCorrectly() {
|
||||||
$this->config->expects($this->once())
|
$this->config->expects($this->at(0))
|
||||||
->method('getSystemValue')
|
->method('getSystemValue')
|
||||||
->with('has_internet_connection', true)
|
->with('has_internet_connection', true)
|
||||||
->will($this->returnValue(true));
|
->will($this->returnValue(true));
|
||||||
|
|
||||||
|
$this->config->expects($this->at(1))
|
||||||
|
->method('getSystemValue')
|
||||||
|
->with('connectivity_check_domains', ['www.nextcloud.com', 'www.startpage.com', 'www.eff.org', 'www.edri.org'])
|
||||||
|
->will($this->returnValue(['www.nextcloud.com', 'www.startpage.com', 'www.eff.org', 'www.edri.org']));
|
||||||
|
|
||||||
$client = $this->getMockBuilder('\OCP\Http\Client\IClient')
|
$client = $this->getMockBuilder('\OCP\Http\Client\IClient')
|
||||||
->disableOriginalConstructor()->getMock();
|
->disableOriginalConstructor()->getMock();
|
||||||
$client->expects($this->any())
|
$client->expects($this->any())
|
||||||
|
@ -213,11 +218,16 @@ class CheckSetupControllerTest extends TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testIsInternetConnectionFail() {
|
public function testIsInternetConnectionFail() {
|
||||||
$this->config->expects($this->once())
|
$this->config->expects($this->at(0))
|
||||||
->method('getSystemValue')
|
->method('getSystemValue')
|
||||||
->with('has_internet_connection', true)
|
->with('has_internet_connection', true)
|
||||||
->will($this->returnValue(true));
|
->will($this->returnValue(true));
|
||||||
|
|
||||||
|
$this->config->expects($this->at(1))
|
||||||
|
->method('getSystemValue')
|
||||||
|
->with('connectivity_check_domains', ['www.nextcloud.com', 'www.startpage.com', 'www.eff.org', 'www.edri.org'])
|
||||||
|
->will($this->returnValue(['www.nextcloud.com', 'www.startpage.com', 'www.eff.org', 'www.edri.org']));
|
||||||
|
|
||||||
$client = $this->getMockBuilder('\OCP\Http\Client\IClient')
|
$client = $this->getMockBuilder('\OCP\Http\Client\IClient')
|
||||||
->disableOriginalConstructor()->getMock();
|
->disableOriginalConstructor()->getMock();
|
||||||
$client->expects($this->any())
|
$client->expects($this->any())
|
||||||
|
@ -338,14 +348,18 @@ class CheckSetupControllerTest extends TestCase {
|
||||||
->with('core', 'cronErrors')
|
->with('core', 'cronErrors')
|
||||||
->willReturn('');
|
->willReturn('');
|
||||||
$this->config->expects($this->at(2))
|
$this->config->expects($this->at(2))
|
||||||
|
->method('getSystemValue')
|
||||||
|
->with('connectivity_check_domains', ['www.nextcloud.com', 'www.startpage.com', 'www.eff.org', 'www.edri.org'])
|
||||||
|
->will($this->returnValue(['www.nextcloud.com', 'www.startpage.com', 'www.eff.org', 'www.edri.org']));
|
||||||
|
$this->config->expects($this->at(3))
|
||||||
->method('getSystemValue')
|
->method('getSystemValue')
|
||||||
->with('memcache.local', null)
|
->with('memcache.local', null)
|
||||||
->will($this->returnValue('SomeProvider'));
|
->will($this->returnValue('SomeProvider'));
|
||||||
$this->config->expects($this->at(3))
|
$this->config->expects($this->at(4))
|
||||||
->method('getSystemValue')
|
->method('getSystemValue')
|
||||||
->with('has_internet_connection', true)
|
->with('has_internet_connection', true)
|
||||||
->will($this->returnValue(true));
|
->will($this->returnValue(true));
|
||||||
$this->config->expects($this->at(4))
|
$this->config->expects($this->at(5))
|
||||||
->method('getSystemValue')
|
->method('getSystemValue')
|
||||||
->with('appstoreenabled', true)
|
->with('appstoreenabled', true)
|
||||||
->will($this->returnValue(false));
|
->will($this->returnValue(false));
|
||||||
|
|
Loading…
Reference in New Issue