diff options
author | John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com> | 2018-02-28 19:03:00 +0100 |
---|---|---|
committer | John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com> | 2018-02-28 19:03:00 +0100 |
commit | 7bcc82164221f5f6c807af4e1309220a1f852a0f (patch) | |
tree | 880dee2ae705d9ccdb9ba7f25490284226b514ce /apps/files_sharing | |
parent | 8c69d783e0f32394d1d37c059bd55e648dcbba93 (diff) | |
download | nextcloud-server-7bcc82164221f5f6c807af4e1309220a1f852a0f.tar.gz nextcloud-server-7bcc82164221f5f6c807af4e1309220a1f852a0f.zip |
fixup! Fixed tests
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Diffstat (limited to 'apps/files_sharing')
-rw-r--r-- | apps/files_sharing/tests/Controller/ShareControllerTest.php | 34 |
1 files changed, 32 insertions, 2 deletions
diff --git a/apps/files_sharing/tests/Controller/ShareControllerTest.php b/apps/files_sharing/tests/Controller/ShareControllerTest.php index 28f81395b9d..dc0c7709a77 100644 --- a/apps/files_sharing/tests/Controller/ShareControllerTest.php +++ b/apps/files_sharing/tests/Controller/ShareControllerTest.php @@ -254,6 +254,37 @@ class ShareControllerTest extends \Test\TestCase { $this->assertEquals($expectedResponse, $response); } + public function testAuthenticateValidPasswordAndDownload() { + $share = \OC::$server->getShareManager()->newShare(); + $share->setId(42); + + $this->shareManager + ->expects($this->once()) + ->method('getShareByToken') + ->with('token') + ->willReturn($share); + + $this->shareManager + ->expects($this->once()) + ->method('checkPassword') + ->with($share, 'validpassword') + ->willReturn(true); + + $this->session + ->expects($this->once()) + ->method('set') + ->with('public_link_authenticated', '42'); + + $this->urlGenerator->expects($this->once()) + ->method('linkToRoute') + ->with('files_sharing.sharecontroller.downloadShare', ['token'=>'token']) + ->willReturn('redirect'); + + $response = $this->shareController->authenticate('token', 'download', 'validpassword'); + $expectedResponse = new RedirectResponse('redirect'); + $this->assertEquals($expectedResponse, $response); + } + public function testAuthenticateInvalidPassword() { $share = \OC::$server->getShareManager()->newShare(); $share->setNodeId(100) @@ -510,7 +541,7 @@ class ShareControllerTest extends \Test\TestCase { // Test with a password protected share and no authentication $response = $this->shareController->downloadShare('validtoken'); - $expectedResponse = new RedirectResponse('redirect', ''); + $expectedResponse = new RedirectResponse('redirect'); $this->assertEquals($expectedResponse, $response); } @@ -533,5 +564,4 @@ class ShareControllerTest extends \Test\TestCase { $expectedResponse = new DataResponse('Share is read-only'); $this->assertEquals($expectedResponse, $response); } - } |