From 7785c3752fbfef792cd33dc5da2ee63e8263b9fa Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Tue, 13 Mar 2018 16:30:41 +0100 Subject: Remove deprecated HTTPHelper * Remove the HTTP Helper * Remove from Server Containter * Removed legacy share tests that use it Signed-off-by: Roeland Jago Douma --- tests/lib/Share/ShareTest.php | 82 ------------------------------------------- 1 file changed, 82 deletions(-) (limited to 'tests/lib/Share') 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 @@ -666,41 +619,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 */ -- cgit v1.2.3