From 76b1dee499771c1b5327b4b7792e98fd41049096 Mon Sep 17 00:00:00 2001 From: Bjoern Schiessle Date: Wed, 2 Nov 2016 10:44:55 +0100 Subject: use https by default if no protocol is given. Only use unsecure connection if it is explicitely given Signed-off-by: Bjoern Schiessle --- .../tests/AddressHandlerTest.php | 20 ++++++++++++++++++++ .../federatedfilesharing/tests/NotificationsTest.php | 9 +++------ 2 files changed, 23 insertions(+), 6 deletions(-) (limited to 'apps/federatedfilesharing/tests') diff --git a/apps/federatedfilesharing/tests/AddressHandlerTest.php b/apps/federatedfilesharing/tests/AddressHandlerTest.php index c2e69fb2bd7..f62f3b62e03 100644 --- a/apps/federatedfilesharing/tests/AddressHandlerTest.php +++ b/apps/federatedfilesharing/tests/AddressHandlerTest.php @@ -177,6 +177,26 @@ class AddressHandlerTest extends \Test\TestCase { ]; } + /** + * @dataProvider dataTestUrlContainProtocol + * + * @param string $url + * @param bool $expectedResult + */ + public function testUrlContainProtocol($url, $expectedResult) { + $result = $this->addressHandler->urlContainProtocol($url); + $this->assertSame($expectedResult, $result); + } + + public function dataTestUrlContainProtocol() { + return [ + ['http://nextcloud.com', true], + ['https://nextcloud.com', true], + ['nextcloud.com', false], + ['httpserver.com', false], + ]; + } + /** * @dataProvider dataTestFixRemoteUrl * diff --git a/apps/federatedfilesharing/tests/NotificationsTest.php b/apps/federatedfilesharing/tests/NotificationsTest.php index dbcb1ef4e87..a5f5c6bc078 100644 --- a/apps/federatedfilesharing/tests/NotificationsTest.php +++ b/apps/federatedfilesharing/tests/NotificationsTest.php @@ -58,7 +58,7 @@ class NotificationsTest extends \Test\TestCase { /** * get instance of Notifications class - * + * * @param array $mockedMethods methods which should be mocked * @return Notifications | \PHPUnit_Framework_MockObject_MockObject */ @@ -81,7 +81,7 @@ class NotificationsTest extends \Test\TestCase { ] )->setMethods($mockedMethods)->getMock(); } - + return $instance; } @@ -94,7 +94,7 @@ class NotificationsTest extends \Test\TestCase { * @param bool $expected */ public function testSendUpdateToRemote($try, $httpRequestResult, $expected) { - $remote = 'remote'; + $remote = 'http://remote'; $id = 42; $timestamp = 63576; $token = 'token'; @@ -106,9 +106,6 @@ class NotificationsTest extends \Test\TestCase { ->with($remote, '/'.$id.'/unshare', ['token' => $token, 'data1Key' => 'data1Value']) ->willReturn($httpRequestResult); - $this->addressHandler->expects($this->once())->method('removeProtocolFromUrl') - ->with($remote)->willReturn($remote); - // only add background job on first try if ($try === 0 && $expected === false) { $this->jobList->expects($this->once())->method('add') -- cgit v1.2.3