Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSylvia van Os <sylvia@hackerchick.me>2018-11-22 12:14:27 +0300
committerSylvia van Os <sylvia@hackerchick.me>2018-11-22 12:57:16 +0300
commit935bb256398a6ebab4e882fc740487dfbd401f73 (patch)
treefdbce36b7d183b1e76fa2067c75af36e3d3eda91
parentb7767a51f140d3f588278f053f3a9e1eb84e4346 (diff)
Make connectivity check domains configurable
Signed-off-by: Sylvia van Os <sylvia@hackerchick.me>
-rw-r--r--config/config.sample.php20
-rw-r--r--settings/Controller/CheckSetupController.php8
-rw-r--r--tests/Settings/Controller/CheckSetupControllerTest.php26
3 files changed, 43 insertions, 11 deletions
diff --git a/config/config.sample.php b/config/config.sample.php
index 902bfa6e44d..5190e46ad7f 100644
--- a/config/config.sample.php
+++ b/config/config.sample.php
@@ -657,6 +657,26 @@ $CONFIG = array(
'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
* by attempting to make a request from JS to
* https://your-domain.com/.well-known/caldav/
diff --git a/settings/Controller/CheckSetupController.php b/settings/Controller/CheckSetupController.php
index ba56c72dccf..5da84eca68d 100644
--- a/settings/Controller/CheckSetupController.php
+++ b/settings/Controller/CheckSetupController.php
@@ -130,11 +130,9 @@ class CheckSetupController extends Controller {
return false;
}
- $siteArray = ['www.nextcloud.com',
- 'www.startpage.com',
- 'www.eff.org',
- 'www.edri.org',
- ];
+ $siteArray = $this->config->getSystemValue('connectivity_check_domains', [
+ 'www.nextcloud.com', 'www.startpage.com', 'www.eff.org', 'www.edri.org'
+ ]);
foreach($siteArray as $site) {
if ($this->isSiteReachable($site)) {
diff --git a/tests/Settings/Controller/CheckSetupControllerTest.php b/tests/Settings/Controller/CheckSetupControllerTest.php
index ff565f3734b..7731e08eed0 100644
--- a/tests/Settings/Controller/CheckSetupControllerTest.php
+++ b/tests/Settings/Controller/CheckSetupControllerTest.php
@@ -189,10 +189,15 @@ class CheckSetupControllerTest extends TestCase {
}
public function testIsInternetConnectionWorkingCorrectly() {
- $this->config->expects($this->once())
+ $this->config->expects($this->at(0))
->method('getSystemValue')
->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')
->disableOriginalConstructor()->getMock();
@@ -213,10 +218,15 @@ class CheckSetupControllerTest extends TestCase {
}
public function testIsInternetConnectionFail() {
- $this->config->expects($this->once())
+ $this->config->expects($this->at(0))
->method('getSystemValue')
->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')
->disableOriginalConstructor()->getMock();
@@ -339,13 +349,17 @@ class CheckSetupControllerTest extends TestCase {
->willReturn('');
$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')
->with('memcache.local', null)
->will($this->returnValue('SomeProvider'));
- $this->config->expects($this->at(3))
+ $this->config->expects($this->at(4))
->method('getSystemValue')
->with('has_internet_connection', true)
->will($this->returnValue(true));
- $this->config->expects($this->at(4))
+ $this->config->expects($this->at(5))
->method('getSystemValue')
->with('appstoreenabled', true)
->will($this->returnValue(false));