]> source.dussan.org Git - nextcloud-server.git/commitdiff
Increase fed share timeout from 3 to 10 + unit tests
authorVincent Petry <pvince81@owncloud.com>
Tue, 21 Jun 2016 15:37:44 +0000 (17:37 +0200)
committerVincent Petry <pvince81@owncloud.com>
Wed, 22 Jun 2016 08:29:40 +0000 (10:29 +0200)
apps/federatedfilesharing/lib/DiscoveryManager.php
apps/federatedfilesharing/lib/Notifications.php
apps/federatedfilesharing/tests/DiscoveryManagerTest.php
apps/files_sharing/ajax/external.php
apps/files_sharing/lib/External/Storage.php

index bf8dfeb31dcfdc9b37ad418426c08e5736f3599e..25af0a40fd540f143a2cd7ace2d18d7315598c4d 100644 (file)
@@ -85,8 +85,8 @@ class DiscoveryManager {
                // Read the data from the response body
                try {
                        $response = $this->client->get($remote . '/ocs-provider/', [
-                               'timeout' => 3,
-                               'connect_timeout' => 3,
+                               'timeout' => 10,
+                               'connect_timeout' => 10,
                        ]);
                        if($response->getStatusCode() === 200) {
                                $decodedService = json_decode($response->getBody(), true);
index 575521d564dd792d574c02f4c152e930d9cfc8ae..fefa959ba375599066ebeadf7ee74e9113ddbeec 100644 (file)
@@ -288,8 +288,8 @@ class Notifications {
                        try {
                                $response = $client->post($protocol . $remoteDomain . $endpoint . $urlSuffix . '?format=' . self::RESPONSE_FORMAT, [
                                        'body' => $fields,
-                                       'timeout' => 3,
-                                       'connect_timeout' => 3,
+                                       'timeout' => 10,
+                                       'connect_timeout' => 10,
                                ]);
                                $result['result'] = $response->getBody();
                                $result['success'] = true;
index 73f79b2c169a8d2b6684fff5ec1542f493b94598..a9c324f02442baaf4e76cf49ccc13fa6b31a8022 100644 (file)
@@ -77,7 +77,10 @@ class DiscoveryManagerTest extends \Test\TestCase {
                $this->client
                        ->expects($this->once())
                        ->method('get')
-                       ->with('https://myhost.com/ocs-provider/', [])
+                       ->with('https://myhost.com/ocs-provider/', [
+                               'timeout' => 10,
+                               'connect_timeout' => 10,
+                       ])
                        ->willReturn($response);
                $this->cache
                        ->expects($this->at(0))
@@ -111,7 +114,10 @@ class DiscoveryManagerTest extends \Test\TestCase {
                $this->client
                        ->expects($this->once())
                        ->method('get')
-                       ->with('https://myhost.com/ocs-provider/', [])
+                       ->with('https://myhost.com/ocs-provider/', [
+                               'timeout' => 10,
+                               'connect_timeout' => 10,
+                       ])
                        ->willReturn($response);
 
                $expectedResult = '/public.php/MyCustomEndpoint/';
@@ -131,7 +137,10 @@ class DiscoveryManagerTest extends \Test\TestCase {
                $this->client
                        ->expects($this->once())
                        ->method('get')
-                       ->with('https://myhost.com/ocs-provider/', [])
+                       ->with('https://myhost.com/ocs-provider/', [
+                               'timeout' => 10,
+                               'connect_timeout' => 10,
+                       ])
                        ->willReturn($response);
 
                $expectedResult = '/public.php/webdav';
@@ -151,7 +160,10 @@ class DiscoveryManagerTest extends \Test\TestCase {
                $this->client
                        ->expects($this->once())
                        ->method('get')
-                       ->with('https://myhost.com/ocs-provider/', [])
+                       ->with('https://myhost.com/ocs-provider/', [
+                               'timeout' => 10,
+                               'connect_timeout' => 10,
+                       ])
                        ->willReturn($response);
 
                $expectedResult = '/ocs/v2.php/cloud/MyCustomShareEndpoint';
@@ -171,7 +183,10 @@ class DiscoveryManagerTest extends \Test\TestCase {
                $this->client
                        ->expects($this->once())
                        ->method('get')
-                       ->with('https://myhost.com/ocs-provider/', [])
+                       ->with('https://myhost.com/ocs-provider/', [
+                               'timeout' => 10,
+                               'connect_timeout' => 10,
+                       ])
                        ->willReturn($response);
                $this->cache
                        ->expects($this->at(0))
index 6a0a4dfc06b7ca5d49a567a3e225ad75c0c71f4a..4a7a6096c911f802cc062bfcc967e7e8125c7e28 100644 (file)
@@ -78,8 +78,8 @@ $externalManager = new \OCA\Files_Sharing\External\Manager(
 if (substr($remote, 0, 5) === 'https') {
        try {
                \OC::$server->getHTTPClientService()->newClient()->get($remote, [
-                       'timeout' => 3,
-                       'connect_timeout' => 3,
+                       'timeout' => 10,
+                       'connect_timeout' => 10,
                ])->getBody();
        } catch (\Exception $e) {
                \OCP\JSON::error(array('data' => array('message' => $l->t('Invalid or untrusted SSL certificate'))));
index 7302de5f934de7f4443c35ec9901cf832f10e944..29b9c7b563cac755cb4a8501b4833038f1755a2a 100644 (file)
@@ -255,8 +255,8 @@ class Storage extends DAV implements ISharedStorage {
                $client = $this->httpClient->newClient();
                try {
                        $result = $client->get($url, [
-                               'timeout' => 3,
-                               'connect_timeout' => 3,
+                               'timeout' => 10,
+                               'connect_timeout' => 10,
                        ])->getBody();
                        $data = json_decode($result);
                        $returnValue = (is_object($data) && !empty($data->version));
@@ -306,8 +306,8 @@ class Storage extends DAV implements ISharedStorage {
                try {
                        $response = $client->post($url, [
                                'body' => ['password' => $password],
-                               'timeout' => 3,
-                               'connect_timeout' => 3,
+                               'timeout' => 10,
+                               'connect_timeout' => 10,
                        ]);
                } catch (\GuzzleHttp\Exception\RequestException $e) {
                        if ($e->getCode() === 401 || $e->getCode() === 403) {