summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorLukas Reschke <lukas@statuscode.ch>2016-09-29 11:56:07 +0200
committerGitHub <noreply@github.com>2016-09-29 11:56:07 +0200
commit8a14f4a8990e2659bc42cb65c77fce9a5d4fa96f (patch)
tree8ed624a7e9d798f9f0d7f96a080a618dc9f2a166 /apps
parent4b873b35b7865a553ecef1d0c85dee2f424f9f61 (diff)
parent498b7399c1f5e692e905c3cea72f3595b9120eb1 (diff)
downloadnextcloud-server-8a14f4a8990e2659bc42cb65c77fce9a5d4fa96f.tar.gz
nextcloud-server-8a14f4a8990e2659bc42cb65c77fce9a5d4fa96f.zip
Merge pull request #1567 from nextcloud/inject-http-service
Inject IHTTPClientService
Diffstat (limited to 'apps')
-rw-r--r--apps/files_sharing/lib/External/MountProvider.php1
-rw-r--r--apps/files_sharing/lib/External/Storage.php4
-rw-r--r--apps/files_sharing/tests/ExternalStorageTest.php22
3 files changed, 24 insertions, 3 deletions
diff --git a/apps/files_sharing/lib/External/MountProvider.php b/apps/files_sharing/lib/External/MountProvider.php
index f46bb009ab0..3f2f39a74f7 100644
--- a/apps/files_sharing/lib/External/MountProvider.php
+++ b/apps/files_sharing/lib/External/MountProvider.php
@@ -56,6 +56,7 @@ class MountProvider implements IMountProvider {
$mountPoint = '/' . $user->getUID() . '/files/' . ltrim($data['mountpoint'], '/');
$data['mountpoint'] = $mountPoint;
$data['certificateManager'] = \OC::$server->getCertificateManager($user->getUID());
+ $data['HttpClientService'] = \OC::$server->getHTTPClientService();
return new Mount(self::STORAGE, $mountPoint, $data, $manager, $storageFactory);
}
diff --git a/apps/files_sharing/lib/External/Storage.php b/apps/files_sharing/lib/External/Storage.php
index caa2bcf2a79..93f3571e803 100644
--- a/apps/files_sharing/lib/External/Storage.php
+++ b/apps/files_sharing/lib/External/Storage.php
@@ -64,10 +64,10 @@ class Storage extends DAV implements ISharedStorage {
public function __construct($options) {
$this->memcacheFactory = \OC::$server->getMemCacheFactory();
- $this->httpClient = \OC::$server->getHTTPClientService();
+ $this->httpClient = $options['HttpClientService'];
$discoveryManager = new DiscoveryManager(
$this->memcacheFactory,
- \OC::$server->getHTTPClientService()
+ $this->httpClient
);
$this->manager = $options['manager'];
diff --git a/apps/files_sharing/tests/ExternalStorageTest.php b/apps/files_sharing/tests/ExternalStorageTest.php
index e84d2bb0e17..49b72be1391 100644
--- a/apps/files_sharing/tests/ExternalStorageTest.php
+++ b/apps/files_sharing/tests/ExternalStorageTest.php
@@ -25,6 +25,9 @@
*/
namespace OCA\Files_Sharing\Tests;
+use OCP\Http\Client\IClient;
+use OCP\Http\Client\IClientService;
+use OCP\Http\Client\IResponse;
/**
* Tests for the external Storage class for remote shares.
@@ -69,6 +72,22 @@ class ExternalStorageTest extends \Test\TestCase {
private function getTestStorage($uri) {
$certificateManager = \OC::$server->getCertificateManager();
+ $httpClientService = $this->createMock(IClientService::class);
+ $client = $this->createMock(IClient::class);
+ $response = $this->createMock(IResponse::class);
+ $client
+ ->expects($this->any())
+ ->method('get')
+ ->willReturn($response);
+ $client
+ ->expects($this->any())
+ ->method('post')
+ ->willReturn($response);
+ $httpClientService
+ ->expects($this->any())
+ ->method('newClient')
+ ->willReturn($client);
+
return new TestSharingExternalStorage(
array(
'remote' => $uri,
@@ -77,7 +96,8 @@ class ExternalStorageTest extends \Test\TestCase {
'token' => 'abcdef',
'password' => '',
'manager' => null,
- 'certificateManager' => $certificateManager
+ 'certificateManager' => $certificateManager,
+ 'HttpClientService' => $httpClientService,
)
);
}