]> source.dussan.org Git - nextcloud-server.git/commitdiff
improve federation error messages 767/head
authorBjoern Schiessle <bjoern@schiessle.org>
Mon, 8 Aug 2016 12:56:24 +0000 (14:56 +0200)
committerBjoern Schiessle <bjoern@schiessle.org>
Tue, 9 Aug 2016 08:24:45 +0000 (10:24 +0200)
apps/federation/lib/Controller/SettingsController.php
apps/federation/lib/DbHandler.php
apps/federation/lib/TrustedServers.php
apps/federation/tests/TrustedServersTest.php

index 79eb06e0fda2d2cd4cf365d771db7da6828825e0..40cc4c084a03aab7075e0414ea3cca5a63b2e97a 100644 (file)
@@ -113,8 +113,8 @@ class SettingsController extends Controller {
                }
 
                if ($this->trustedServers->isOwnCloudServer($url) === false) {
-                       $message = 'No server to federate found';
-                       $hint = $this->l->t('No server to federate found');
+                       $message = 'No server to federate with found';
+                       $hint = $this->l->t('No server to federate with found');
                        throw new HintException($message, $hint);
                }
 
index b30ce740092d5eee14e4f8cf25060d125a56d257..c938cfb1583d690469f3abbcf9053b713b73353a 100644 (file)
@@ -89,7 +89,7 @@ class DbHandler {
                if ($result) {
                        return (int)$this->connection->lastInsertId('*PREFIX*'.$this->dbTable);
                } else {
-                       $message = 'Internal failure, Could not add ownCloud as trusted server: ' . $url;
+                       $message = 'Internal failure, Could not add trusted server: ' . $url;
                        $message_t = $this->IL10N->t('Could not add server');
                        throw new HintException($message, $message_t);
                }
index fff19e414d56b9ebd18b6b3f385e72f073943ef1..f802af594dc263d95e78b029416144e046bb9f31 100644 (file)
@@ -211,7 +211,7 @@ class TrustedServers {
        }
 
        /**
-        * check if URL point to a ownCloud server
+        * check if URL point to a ownCloud/Nextcloud server
         *
         * @param string $url
         * @return bool
@@ -219,15 +219,21 @@ class TrustedServers {
        public function isOwnCloudServer($url) {
                $isValidOwnCloud = false;
                $client = $this->httpClientService->newClient();
-               $result = $client->get(
-                       $url . '/status.php',
-                       [
-                               'timeout' => 3,
-                               'connect_timeout' => 3,
-                       ]
-               );
-               if ($result->getStatusCode() === Http::STATUS_OK) {
-                       $isValidOwnCloud = $this->checkOwnCloudVersion($result->getBody());
+               try {
+                       $result = $client->get(
+                               $url . '/status.php',
+                               [
+                                       'timeout' => 3,
+                                       'connect_timeout' => 3,
+                               ]
+                       );
+                       if ($result->getStatusCode() === Http::STATUS_OK) {
+                               $isValidOwnCloud = $this->checkOwnCloudVersion($result->getBody());
+
+                       }
+               } catch (\Exception $e) {
+                       $this->logger->debug('No Nextcloud server: ' . $e->getMessage());
+                       return false;
                }
 
                return $isValidOwnCloud;
index 63086c76002c55084b966b69f488461755912eba..1bf1475aef2258acbbf9106fc0676ee66c1209c5 100644 (file)
@@ -309,7 +309,6 @@ class TrustedServersTest extends TestCase {
        }
 
        /**
-        * @expectedException \Exception
         * @expectedExceptionMessage simulated exception
         */
        public function testIsOwnCloudServerFail() {
@@ -323,7 +322,7 @@ class TrustedServersTest extends TestCase {
                                throw new \Exception('simulated exception');
                        });
 
-               $this->trustedServers->isOwnCloudServer($server);
+               $this->assertFalse($this->trustedServers->isOwnCloudServer($server));
        }
 
        /**