diff options
author | Roeland Jago Douma <roeland@famdouma.nl> | 2018-03-13 16:30:41 +0100 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2018-03-13 21:54:56 +0100 |
commit | 7785c3752fbfef792cd33dc5da2ee63e8263b9fa (patch) | |
tree | 66b68c5f9ce30ec87c51aebc7d9ffe0c14b30d2f /tests/lib | |
parent | ede723f1b19c4c1afb7627af85c1e2f8d8a31386 (diff) | |
download | nextcloud-server-7785c3752fbfef792cd33dc5da2ee63e8263b9fa.tar.gz nextcloud-server-7785c3752fbfef792cd33dc5da2ee63e8263b9fa.zip |
Remove deprecated HTTPHelper
* Remove the HTTP Helper
* Remove from Server Containter
* Removed legacy share tests that use it
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'tests/lib')
-rw-r--r-- | tests/lib/HTTPHelperTest.php | 123 | ||||
-rw-r--r-- | tests/lib/ServerTest.php | 1 | ||||
-rw-r--r-- | tests/lib/Share/ShareTest.php | 82 |
3 files changed, 0 insertions, 206 deletions
diff --git a/tests/lib/HTTPHelperTest.php b/tests/lib/HTTPHelperTest.php deleted file mode 100644 index d39cc34c464..00000000000 --- a/tests/lib/HTTPHelperTest.php +++ /dev/null @@ -1,123 +0,0 @@ -<?php -/** - * Copyright (c) 2014 Lukas Reschke <lukas@owncloud.com> - * This file is licensed under the Affero General Public License version 3 or - * later. - * See the COPYING-README file. - */ - -namespace Test; - -use OCP\Http\Client\IClientService; -use OCP\IConfig; - -class HTTPHelperTest extends \Test\TestCase { - - /** @var \OCP\IConfig*/ - private $config; - /** @var \OC\HTTPHelper */ - private $httpHelperMock; - /** @var \OCP\Http\Client\IClientService */ - private $clientService; - - protected function setUp() { - parent::setUp(); - - $this->config = $this->getMockBuilder(IConfig::class) - ->disableOriginalConstructor()->getMock(); - $this->clientService = $this->createMock(IClientService::class); - $this->httpHelperMock = $this->getMockBuilder('\OC\HTTPHelper') - ->setConstructorArgs(array($this->config, $this->clientService)) - ->setMethods(array('getHeaders')) - ->getMock(); - } - - public function isHttpTestData() { - return array( - array('http://wwww.owncloud.org/enterprise/', true), - array('https://wwww.owncloud.org/enterprise/', true), - array('HTTPS://WWW.OWNCLOUD.ORG', true), - array('HTTP://WWW.OWNCLOUD.ORG', true), - array('FILE://WWW.OWNCLOUD.ORG', false), - array('file://www.owncloud.org', false), - array('FTP://WWW.OWNCLOUD.ORG', false), - array('ftp://www.owncloud.org', false), - ); - } - - /** - * @dataProvider isHttpTestData - */ - public function testIsHTTP($url, $expected) { - $this->assertSame($expected, $this->httpHelperMock->isHTTPURL($url)); - } - - public function testPostSuccess() { - $client = $this->getMockBuilder('\OCP\Http\Client\IClient') - ->disableOriginalConstructor()->getMock(); - $this->clientService - ->expects($this->once()) - ->method('newClient') - ->will($this->returnValue($client)); - $response = $this->getMockBuilder('\OCP\Http\Client\IResponse') - ->disableOriginalConstructor()->getMock(); - $client - ->expects($this->once()) - ->method('post') - ->with( - 'https://owncloud.org', - [ - 'body' => [ - 'Foo' => 'Bar', - ], - 'connect_timeout' => 10, - - ] - ) - ->will($this->returnValue($response)); - $response - ->expects($this->once()) - ->method('getBody') - ->will($this->returnValue('Body of the requested page')); - - - $response = $this->httpHelperMock->post('https://owncloud.org', ['Foo' => 'Bar']); - $expected = [ - 'success' => true, - 'result' => 'Body of the requested page' - ]; - $this->assertSame($expected, $response); - } - - public function testPostException() { - $client = $this->getMockBuilder('\OCP\Http\Client\IClient') - ->disableOriginalConstructor()->getMock(); - $this->clientService - ->expects($this->once()) - ->method('newClient') - ->will($this->returnValue($client)); - $client - ->expects($this->once()) - ->method('post') - ->with( - 'https://owncloud.org', - [ - 'body' => [ - 'Foo' => 'Bar', - ], - 'connect_timeout' => 10, - - ] - ) - ->will($this->throwException(new \Exception('Something failed'))); - - - $response = $this->httpHelperMock->post('https://owncloud.org', ['Foo' => 'Bar']); - $expected = [ - 'success' => false, - 'result' => 'Something failed' - ]; - $this->assertSame($expected, $response); - } - -} diff --git a/tests/lib/ServerTest.php b/tests/lib/ServerTest.php index 63642c997ab..e76b2b96db7 100644 --- a/tests/lib/ServerTest.php +++ b/tests/lib/ServerTest.php @@ -91,7 +91,6 @@ class ServerTest extends \Test\TestCase { ['Hasher', '\OC\Security\Hasher'], ['Hasher', '\OCP\Security\IHasher'], - ['HTTPHelper', '\OC\HTTPHelper'], ['HttpClientService', '\OC\Http\Client\ClientService'], ['HttpClientService', '\OCP\Http\Client\IClientService'], diff --git a/tests/lib/Share/ShareTest.php b/tests/lib/Share/ShareTest.php index 18d1944f193..273482e1759 100644 --- a/tests/lib/Share/ShareTest.php +++ b/tests/lib/Share/ShareTest.php @@ -542,53 +542,6 @@ class ShareTest extends \Test\TestCase { ); } - public function dataRemoteShareUrlCalls() { - return [ - ['admin@localhost', 'localhost'], - ['admin@https://localhost', 'localhost'], - ['admin@http://localhost', 'localhost'], - ['admin@localhost/subFolder', 'localhost/subFolder'], - ]; - } - - /** - * @dataProvider dataRemoteShareUrlCalls - * - * @param string $shareWith - * @param string $urlHost - */ - public function testRemoteShareUrlCalls($shareWith, $urlHost) { - $httpHelperMock = $this->getMockBuilder('OC\HTTPHelper') - ->disableOriginalConstructor() - ->getMock(); - $this->overwriteService('HTTPHelper', $httpHelperMock); - - $httpHelperMock->expects($this->at(0)) - ->method('post') - ->with($this->stringStartsWith('https://' . $urlHost . '/ocs/v2.php/cloud/shares'), $this->anything()) - ->willReturn(['success' => false, 'result' => 'Exception']); - $httpHelperMock->expects($this->at(1)) - ->method('post') - ->with($this->stringStartsWith('http://' . $urlHost . '/ocs/v2.php/cloud/shares'), $this->anything()) - ->willReturn(['success' => true, 'result' => json_encode(['ocs' => ['meta' => ['statuscode' => 100]]])]); - - \OC\Share\Share::shareItem('test', 'test.txt', \OCP\Share::SHARE_TYPE_REMOTE, $shareWith, \OCP\Constants::PERMISSION_READ); - $shares = \OCP\Share::getItemShared('test', 'test.txt'); - $share = array_shift($shares); - - $httpHelperMock->expects($this->at(0)) - ->method('post') - ->with($this->stringStartsWith('https://' . $urlHost . '/ocs/v2.php/cloud/shares/' . $share['id'] . '/unshare'), $this->anything()) - ->willReturn(['success' => false, 'result' => 'Exception']); - $httpHelperMock->expects($this->at(1)) - ->method('post') - ->with($this->stringStartsWith('http://' . $urlHost . '/ocs/v2.php/cloud/shares/' . $share['id'] . '/unshare'), $this->anything()) - ->willReturn(['success' => true, 'result' => json_encode(['ocs' => ['meta' => ['statuscode' => 100]]])]); - - \OC\Share\Share::unshare('test', 'test.txt', \OCP\Share::SHARE_TYPE_REMOTE, $shareWith); - $this->restoreService('HTTPHelper'); - } - /** * @dataProvider dataProviderTestGroupItems * @param array $ungrouped @@ -667,41 +620,6 @@ class ShareTest extends \Test\TestCase { } /** - * Make sure that a user cannot have multiple identical shares to remote users - */ - public function testOnlyOneRemoteShare() { - $httpHelperMock = $this->getMockBuilder('OC\HTTPHelper') - ->disableOriginalConstructor() - ->getMock(); - $this->overwriteService('HTTPHelper', $httpHelperMock); - - $httpHelperMock->expects($this->at(0)) - ->method('post') - ->with($this->stringStartsWith('https://localhost/ocs/v2.php/cloud/shares'), $this->anything()) - ->willReturn(['success' => true, 'result' => json_encode(['ocs' => ['meta' => ['statuscode' => 100]]])]); - - \OC\Share\Share::shareItem('test', 'test.txt', \OCP\Share::SHARE_TYPE_REMOTE, 'foo@localhost', \OCP\Constants::PERMISSION_READ); - $shares = \OCP\Share::getItemShared('test', 'test.txt'); - $share = array_shift($shares); - - //Try share again - try { - \OC\Share\Share::shareItem('test', 'test.txt', \OCP\Share::SHARE_TYPE_REMOTE, 'foo@localhost', \OCP\Constants::PERMISSION_READ); - $this->fail('Identical remote shares are not allowed'); - } catch (\Exception $e) { - $this->assertEquals('Sharing test.txt failed, because this item is already shared with foo@localhost', $e->getMessage()); - } - - $httpHelperMock->expects($this->at(0)) - ->method('post') - ->with($this->stringStartsWith('https://localhost/ocs/v2.php/cloud/shares/' . $share['id'] . '/unshare'), $this->anything()) - ->willReturn(['success' => true, 'result' => json_encode(['ocs' => ['meta' => ['statuscode' => 100]]])]); - - \OC\Share\Share::unshare('test', 'test.txt', \OCP\Share::SHARE_TYPE_REMOTE, 'foo@localhost'); - $this->restoreService('HTTPHelper'); - } - - /** * Test case for #17560 */ public function testAccesToSharedSubFolder() { |