summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorLukas Reschke <lukas@owncloud.com>2015-03-16 11:28:23 +0100
committerLukas Reschke <lukas@owncloud.com>2015-03-25 16:04:41 +0100
commit5f044ebf1bc6f45acec2e79dc05185acd0405f42 (patch)
tree8bc8797ef55588d3aab1b160acb3e2f5576d460f /apps
parent13904a7f8979a87492ac765e05017eb1e4b69588 (diff)
downloadnextcloud-server-5f044ebf1bc6f45acec2e79dc05185acd0405f42.tar.gz
nextcloud-server-5f044ebf1bc6f45acec2e79dc05185acd0405f42.zip
Add wrapper for Guzzle
Diffstat (limited to 'apps')
-rwxr-xr-xapps/files_encryption/tests/share.php4
-rw-r--r--apps/files_sharing/lib/controllers/sharecontroller.php2
-rw-r--r--apps/files_sharing/lib/external/storage.php36
-rw-r--r--apps/files_sharing/tests/server2server.php4
4 files changed, 17 insertions, 29 deletions
diff --git a/apps/files_encryption/tests/share.php b/apps/files_encryption/tests/share.php
index a59838ede1c..8ab6a01c02e 100755
--- a/apps/files_encryption/tests/share.php
+++ b/apps/files_encryption/tests/share.php
@@ -122,9 +122,9 @@ class Share extends TestCase {
private function createMocks() {
$config = $this->getMockBuilder('\OCP\IConfig')
->disableOriginalConstructor()->getMock();
- $certificateManager = $this->getMock('\OCP\ICertificateManager');
+ $clientService = $this->getMock('\OCP\Http\Client\IClientService');
$httpHelperMock = $this->getMockBuilder('\OC\HTTPHelper')
- ->setConstructorArgs(array($config, $certificateManager))
+ ->setConstructorArgs([$config, $clientService])
->getMock();
$httpHelperMock->expects($this->any())->method('post')->with($this->anything())->will($this->returnValue(array('success' => true, 'result' => "{'ocs' : { 'meta' : { 'statuscode' : 100 }}}")));
diff --git a/apps/files_sharing/lib/controllers/sharecontroller.php b/apps/files_sharing/lib/controllers/sharecontroller.php
index 2f69583b412..f9b85913a08 100644
--- a/apps/files_sharing/lib/controllers/sharecontroller.php
+++ b/apps/files_sharing/lib/controllers/sharecontroller.php
@@ -11,6 +11,7 @@
namespace OCA\Files_Sharing\Controllers;
+use Hoa\Core\Data\Data;
use OC;
use OC\Files\Filesystem;
use OC_Files;
@@ -30,6 +31,7 @@ use OCA\Files_Sharing\Helper;
use OCP\User;
use OCP\Util;
use OCA\Files_Sharing\Activity;
+use OCP\AppFramework\Http\DataResponse;
/**
* Class ShareController
diff --git a/apps/files_sharing/lib/external/storage.php b/apps/files_sharing/lib/external/storage.php
index 51c4a36029e..ade789e310a 100644
--- a/apps/files_sharing/lib/external/storage.php
+++ b/apps/files_sharing/lib/external/storage.php
@@ -210,37 +210,23 @@ class Storage extends DAV implements ISharedStorage {
}
}
+ /**
+ * @return mixed
+ * @throws ForbiddenException
+ * @throws NotFoundException
+ * @throws \Exception
+ */
public function getShareInfo() {
$remote = $this->getRemote();
$token = $this->getToken();
$password = $this->getPassword();
$url = rtrim($remote, '/') . '/index.php/apps/files_sharing/shareinfo?t=' . $token;
- $ch = curl_init();
-
- curl_setopt($ch, CURLOPT_URL, $url);
- curl_setopt($ch, CURLOPT_POST, 1);
- curl_setopt($ch, CURLOPT_POSTFIELDS,
- http_build_query(array('password' => $password)));
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
-
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
- curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
- $path = $this->certificateManager->getCertificateBundle();
- if (is_readable($path)) {
- curl_setopt($ch, CURLOPT_CAINFO, $path);
- }
-
- $result = curl_exec($ch);
-
- $status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
- $errorMessage = curl_error($ch);
- curl_close($ch);
- if (!empty($errorMessage)) {
- throw new \Exception($errorMessage);
- }
+ // TODO: DI
+ $client = \OC::$server->getHTTPClientService()->newClient();
+ $response = $client->post($url, ['body' => ['password' => $password]]);
- switch ($status) {
+ switch ($response->getStatusCode()) {
case 401:
case 403:
throw new ForbiddenException();
@@ -250,6 +236,6 @@ class Storage extends DAV implements ISharedStorage {
throw new \Exception();
}
- return json_decode($result, true);
+ return json_decode($response->getBody(), true);
}
}
diff --git a/apps/files_sharing/tests/server2server.php b/apps/files_sharing/tests/server2server.php
index 6e9c0dd0ddd..f582be3a86a 100644
--- a/apps/files_sharing/tests/server2server.php
+++ b/apps/files_sharing/tests/server2server.php
@@ -48,9 +48,9 @@ class Test_Files_Sharing_S2S_OCS_API extends TestCase {
$config = $this->getMockBuilder('\OCP\IConfig')
->disableOriginalConstructor()->getMock();
- $certificateManager = $this->getMock('\OCP\ICertificateManager');
+ $clientService = $this->getMock('\OCP\Http\Client\IClientService');
$httpHelperMock = $this->getMockBuilder('\OC\HTTPHelper')
- ->setConstructorArgs(array($config, $certificateManager))
+ ->setConstructorArgs([$config, $clientService])
->getMock();
$httpHelperMock->expects($this->any())->method('post')->with($this->anything())->will($this->returnValue(true));