Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,6 @@ protected function setUp() {
self::loginHelper(self::TEST_FILES_SHARING_API_USER1);
\OC\Share\Share::registerBackend('test', 'Test\Share\Backend');

$config = $this->getMockBuilder(IConfig::class)
->disableOriginalConstructor()->getMock();
$clientService = $this->getMockBuilder(IClientService::class)->getMock();
$httpHelperMock = $this->getMockBuilder('\OC\HTTPHelper')
->setConstructorArgs([$config, $clientService])
->getMock();
$httpHelperMock->expects($this->any())->method('post')->with($this->anything())->will($this->returnValue(true));
$this->share = $this->getMockBuilder(IShare::class)->getMock();
$this->federatedShareProvider = $this->getMockBuilder('OCA\FederatedFileSharing\FederatedShareProvider')
->disableOriginalConstructor()->getMock();
Expand All @@ -110,8 +103,6 @@ protected function setUp() {

$this->cloudIdManager = new CloudIdManager();

$this->registerHttpHelper($httpHelperMock);

$this->s2s = new RequestHandlerController(
'federatedfilesharing',
\OC::$server->getRequest(),
Expand All @@ -134,32 +125,9 @@ protected function tearDown() {
$query = \OCP\DB::prepare('DELETE FROM `*PREFIX*share`');
$query->execute();

$this->restoreHttpHelper();

parent::tearDown();
}

/**
* Register an http helper mock for testing purposes.
* @param \OC\HTTPHelper $httpHelper helper mock
*/
private function registerHttpHelper($httpHelper) {
$this->oldHttpHelper = \OC::$server->query('HTTPHelper');
\OC::$server->registerService('HTTPHelper', function ($c) use ($httpHelper) {
return $httpHelper;
});
}

/**
* Restore the original http helper
*/
private function restoreHttpHelper() {
$oldHttpHelper = $this->oldHttpHelper;
\OC::$server->registerService('HTTPHelper', function ($c) use ($oldHttpHelper) {
return $oldHttpHelper;
});
}

/**
* @medium
*/
Expand Down
16 changes: 15 additions & 1 deletion apps/files_sharing/tests/Controller/ShareAPIControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2068,7 +2068,7 @@ public function dataFormatShare() {
'file_parent' => 1,
'file_target' => 'myTarget',
'share_with' => 'user@server.com',
'share_with_displayname' => 'user@server.com',
'share_with_displayname' => 'foobar',
'mail_send' => 0,
'mimetype' => 'myFolderMimeType',
], $share, [], false
Expand Down Expand Up @@ -2127,6 +2127,20 @@ public function testFormatShare(array $expects, \OCP\Share\IShare $share, array
->will($this->returnArgument(0));
}

$cm = $this->createMock(\OCP\Contacts\IManager::class);
$this->overwriteService(\OCP\Contacts\IManager::class, $cm);

$cm->method('search')
->with('user@server.com', ['CLOUD'])
->willReturn([
[
'CLOUD' => [
'user@server.com',
],
'FN' => 'foobar',
],
]);

try {
$result = $this->invokePrivate($this->ocs, 'formatShare', [$share]);
$this->assertFalse($exception);
Expand Down
1 change: 0 additions & 1 deletion lib/composer/composer/autoload_classmap.php
Original file line number Diff line number Diff line change
Expand Up @@ -696,7 +696,6 @@
'OC\\Group\\Group' => $baseDir . '/lib/private/Group/Group.php',
'OC\\Group\\Manager' => $baseDir . '/lib/private/Group/Manager.php',
'OC\\Group\\MetaData' => $baseDir . '/lib/private/Group/MetaData.php',
'OC\\HTTPHelper' => $baseDir . '/lib/private/HTTPHelper.php',
'OC\\HintException' => $baseDir . '/lib/private/HintException.php',
'OC\\Hooks\\BasicEmitter' => $baseDir . '/lib/private/Hooks/BasicEmitter.php',
'OC\\Hooks\\Emitter' => $baseDir . '/lib/private/Hooks/Emitter.php',
Expand Down
1 change: 0 additions & 1 deletion lib/composer/composer/autoload_static.php
Original file line number Diff line number Diff line change
Expand Up @@ -726,7 +726,6 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c
'OC\\Group\\Group' => __DIR__ . '/../../..' . '/lib/private/Group/Group.php',
'OC\\Group\\Manager' => __DIR__ . '/../../..' . '/lib/private/Group/Manager.php',
'OC\\Group\\MetaData' => __DIR__ . '/../../..' . '/lib/private/Group/MetaData.php',
'OC\\HTTPHelper' => __DIR__ . '/../../..' . '/lib/private/HTTPHelper.php',
'OC\\HintException' => __DIR__ . '/../../..' . '/lib/private/HintException.php',
'OC\\Hooks\\BasicEmitter' => __DIR__ . '/../../..' . '/lib/private/Hooks/BasicEmitter.php',
'OC\\Hooks\\Emitter' => __DIR__ . '/../../..' . '/lib/private/Hooks/Emitter.php',
Expand Down
120 changes: 0 additions & 120 deletions lib/private/HTTPHelper.php

This file was deleted.

17 changes: 0 additions & 17 deletions lib/private/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -630,13 +630,6 @@ public function __construct($webRoot, \OC\Config $config) {
});
$this->registerAlias('DatabaseConnection', IDBConnection::class);

$this->registerService('HTTPHelper', function (Server $c) {
$config = $c->getConfig();
return new HTTPHelper(
$config,
$c->getHTTPClientService()
);
});

$this->registerService(\OCP\Http\Client\IClientService::class, function (Server $c) {
$user = \OC_User::getUser();
Expand Down Expand Up @@ -1582,16 +1575,6 @@ public function getCredentialsManager() {
return $this->query('CredentialsManager');
}

/**
* Returns an instance of the HTTP helper class
*
* @deprecated Use getHTTPClientService()
* @return \OC\HTTPHelper
*/
public function getHTTPHelper() {
return $this->query('HTTPHelper');
}

/**
* Get the certificate manager for the user
*
Expand Down
17 changes: 16 additions & 1 deletion lib/private/Share/Share.php
Original file line number Diff line number Diff line change
Expand Up @@ -1991,7 +1991,22 @@ private static function tryHttpPostToShareEndpoint($remoteDomain, $urlSuffix, ar
while ($result['success'] === false && $try < 2) {
$federationEndpoints = $discoveryService->discover($protocol . $remoteDomain, 'FEDERATED_SHARING');
$endpoint = isset($federationEndpoints['share']) ? $federationEndpoints['share'] : '/ocs/v2.php/cloud/shares';
$result = \OC::$server->getHTTPHelper()->post($protocol . $remoteDomain . $endpoint . $urlSuffix . '?format=' . self::RESPONSE_FORMAT, $fields);
$client = \OC::$server->getHTTPClientService()->newClient();

try {
$response = $client->post(
$protocol . $remoteDomain . $endpoint . $urlSuffix . '?format=' . self::RESPONSE_FORMAT,
[
'body' => $fields,
'connect_timeout' => 10,
]
);

$result = ['success' => true, 'result' => $response->getBody()];
} catch (\Exception $e) {
$result = ['success' => false, 'result' => $e->getMessage()];
}

$try++;
$protocol = 'http://';
}
Expand Down
8 changes: 0 additions & 8 deletions lib/public/IServerContainer.php
Original file line number Diff line number Diff line change
Expand Up @@ -347,14 +347,6 @@ public function getCertificateManager($userId = null);
*/
public function createEventSource();

/**
* Returns an instance of the HTTP helper class
* @return \OC\HTTPHelper
* @deprecated 8.1.0 Use \OCP\Http\Client\IClientService
* @since 8.0.0
*/
public function getHTTPHelper();

/**
* Returns an instance of the HTTP client service
*
Expand Down
Loading