2016-04-01 11:35:37 -04:00
|
|
|
<?php
|
2024-05-28 06:34:11 -04:00
|
|
|
|
2016-05-26 13:56:05 -04:00
|
|
|
/**
|
2024-05-28 06:34:11 -04:00
|
|
|
* SPDX-FileCopyrightText: 2022-2024 Nextcloud GmbH and Nextcloud contributors
|
|
|
|
|
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
|
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
2016-05-26 13:56:05 -04:00
|
|
|
*/
|
2016-05-25 10:04:15 -04:00
|
|
|
namespace OCA\DAV\Tests\unit\Connector;
|
2016-04-01 11:35:37 -04:00
|
|
|
|
2024-10-10 06:40:31 -04:00
|
|
|
use OCA\DAV\Connector\Sabre\PublicAuth;
|
2016-04-01 11:35:37 -04:00
|
|
|
use OCP\IRequest;
|
|
|
|
|
use OCP\ISession;
|
2023-08-28 09:50:45 -04:00
|
|
|
use OCP\Security\Bruteforce\IThrottler;
|
2016-04-01 11:35:37 -04:00
|
|
|
use OCP\Share\Exceptions\ShareNotFound;
|
|
|
|
|
use OCP\Share\IManager;
|
2017-10-24 18:03:28 -04:00
|
|
|
use OCP\Share\IShare;
|
2022-10-28 09:05:07 -04:00
|
|
|
use Psr\Log\LoggerInterface;
|
2016-04-01 11:35:37 -04:00
|
|
|
|
2016-04-21 07:36:52 -04:00
|
|
|
/**
|
2016-05-25 10:04:15 -04:00
|
|
|
* Class PublicAuthTest
|
2016-04-21 07:36:52 -04:00
|
|
|
*
|
|
|
|
|
* @group DB
|
2017-05-04 05:20:20 -04:00
|
|
|
*
|
2016-05-25 10:04:15 -04:00
|
|
|
* @package OCA\DAV\Tests\unit\Connector
|
2016-04-21 07:36:52 -04:00
|
|
|
*/
|
2016-05-25 10:04:15 -04:00
|
|
|
class PublicAuthTest extends \Test\TestCase {
|
2016-04-01 11:35:37 -04:00
|
|
|
|
2022-10-28 09:05:07 -04:00
|
|
|
/** @var ISession|MockObject */
|
2016-04-01 11:35:37 -04:00
|
|
|
private $session;
|
2022-10-28 09:05:07 -04:00
|
|
|
/** @var IRequest|MockObject */
|
2016-04-01 11:35:37 -04:00
|
|
|
private $request;
|
2022-10-28 09:05:07 -04:00
|
|
|
/** @var IManager|MockObject */
|
2016-04-01 11:35:37 -04:00
|
|
|
private $shareManager;
|
2022-10-28 09:05:07 -04:00
|
|
|
/** @var PublicAuth */
|
2016-04-01 11:35:37 -04:00
|
|
|
private $auth;
|
2022-10-28 09:05:07 -04:00
|
|
|
/** @var IThrottler|MockObject */
|
2021-06-22 13:54:13 -04:00
|
|
|
private $throttler;
|
2022-10-28 09:05:07 -04:00
|
|
|
/** @var LoggerInterface|MockObject */
|
|
|
|
|
private $logger;
|
2016-04-01 11:35:37 -04:00
|
|
|
|
|
|
|
|
/** @var string */
|
|
|
|
|
private $oldUser;
|
|
|
|
|
|
2019-11-21 10:40:38 -05:00
|
|
|
protected function setUp(): void {
|
2016-04-01 11:35:37 -04:00
|
|
|
parent::setUp();
|
|
|
|
|
|
2023-12-29 03:58:11 -05:00
|
|
|
$this->session = $this->createMock(ISession::class);
|
|
|
|
|
$this->request = $this->createMock(IRequest::class);
|
|
|
|
|
$this->shareManager = $this->createMock(IManager::class);
|
|
|
|
|
$this->throttler = $this->createMock(IThrottler::class);
|
2022-10-28 09:05:07 -04:00
|
|
|
$this->logger = $this->createMock(LoggerInterface::class);
|
2016-04-01 11:35:37 -04:00
|
|
|
|
2024-10-10 06:40:31 -04:00
|
|
|
$this->auth = new PublicAuth(
|
2016-04-01 11:35:37 -04:00
|
|
|
$this->request,
|
|
|
|
|
$this->shareManager,
|
2021-06-22 13:54:13 -04:00
|
|
|
$this->session,
|
2022-10-28 09:05:07 -04:00
|
|
|
$this->throttler,
|
|
|
|
|
$this->logger,
|
2016-04-01 11:35:37 -04:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// Store current user
|
|
|
|
|
$this->oldUser = \OC_User::getUser();
|
|
|
|
|
}
|
|
|
|
|
|
2019-11-21 10:40:38 -05:00
|
|
|
protected function tearDown(): void {
|
2016-04-01 11:35:37 -04:00
|
|
|
\OC_User::setIncognitoMode(false);
|
|
|
|
|
|
|
|
|
|
// Set old user
|
|
|
|
|
\OC_User::setUserId($this->oldUser);
|
|
|
|
|
\OC_Util::setupFS($this->oldUser);
|
|
|
|
|
|
|
|
|
|
parent::tearDown();
|
|
|
|
|
}
|
|
|
|
|
|
2022-10-28 09:05:07 -04:00
|
|
|
public function testGetToken(): void {
|
|
|
|
|
$this->request->method('getPathInfo')
|
|
|
|
|
->willReturn('/dav/files/GX9HSGQrGE');
|
|
|
|
|
|
|
|
|
|
$result = $this->invokePrivate($this->auth, 'getToken');
|
|
|
|
|
|
|
|
|
|
$this->assertSame('GX9HSGQrGE', $result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testGetTokenInvalid(): void {
|
|
|
|
|
$this->request->method('getPathInfo')
|
|
|
|
|
->willReturn('/dav/files');
|
|
|
|
|
|
|
|
|
|
$this->expectException(\Sabre\DAV\Exception\NotFound::class);
|
|
|
|
|
$this->invokePrivate($this->auth, 'getToken');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testCheckTokenValidShare(): void {
|
|
|
|
|
$this->request->method('getPathInfo')
|
|
|
|
|
->willReturn('/dav/files/GX9HSGQrGE');
|
|
|
|
|
|
|
|
|
|
$share = $this->getMockBuilder(IShare::class)
|
|
|
|
|
->disableOriginalConstructor()
|
|
|
|
|
->getMock();
|
|
|
|
|
$share->method('getPassword')->willReturn(null);
|
|
|
|
|
|
|
|
|
|
$this->shareManager->expects($this->once())
|
|
|
|
|
->method('getShareByToken')
|
|
|
|
|
->with('GX9HSGQrGE')
|
|
|
|
|
->willReturn($share);
|
|
|
|
|
|
|
|
|
|
$result = $this->invokePrivate($this->auth, 'checkToken');
|
|
|
|
|
$this->assertSame([true, 'principals/GX9HSGQrGE'], $result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testCheckTokenInvalidShare(): void {
|
|
|
|
|
$this->request->method('getPathInfo')
|
|
|
|
|
->willReturn('/dav/files/GX9HSGQrGE');
|
|
|
|
|
|
|
|
|
|
$this->shareManager
|
|
|
|
|
->expects($this->once())
|
|
|
|
|
->method('getShareByToken')
|
|
|
|
|
->with('GX9HSGQrGE')
|
|
|
|
|
->will($this->throwException(new ShareNotFound()));
|
|
|
|
|
|
|
|
|
|
$this->expectException(\Sabre\DAV\Exception\NotFound::class);
|
|
|
|
|
$this->invokePrivate($this->auth, 'checkToken');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testCheckTokenAlreadyAuthenticated(): void {
|
|
|
|
|
$this->request->method('getPathInfo')
|
|
|
|
|
->willReturn('/dav/files/GX9HSGQrGE');
|
|
|
|
|
|
|
|
|
|
$share = $this->getMockBuilder(IShare::class)
|
|
|
|
|
->disableOriginalConstructor()
|
|
|
|
|
->getMock();
|
|
|
|
|
$share->method('getShareType')->willReturn(42);
|
|
|
|
|
|
|
|
|
|
$this->shareManager->expects($this->once())
|
|
|
|
|
->method('getShareByToken')
|
|
|
|
|
->with('GX9HSGQrGE')
|
|
|
|
|
->willReturn($share);
|
|
|
|
|
|
|
|
|
|
$this->session->method('exists')->with('public_link_authenticated')->willReturn(true);
|
|
|
|
|
$this->session->method('get')->with('public_link_authenticated')->willReturn('42');
|
|
|
|
|
|
|
|
|
|
$result = $this->invokePrivate($this->auth, 'checkToken');
|
|
|
|
|
$this->assertSame([true, 'principals/GX9HSGQrGE'], $result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testCheckTokenPasswordNotAuthenticated(): void {
|
|
|
|
|
$this->request->method('getPathInfo')
|
|
|
|
|
->willReturn('/dav/files/GX9HSGQrGE');
|
|
|
|
|
|
|
|
|
|
$share = $this->getMockBuilder(IShare::class)
|
|
|
|
|
->disableOriginalConstructor()
|
|
|
|
|
->getMock();
|
|
|
|
|
$share->method('getPassword')->willReturn('password');
|
|
|
|
|
$share->method('getShareType')->willReturn(42);
|
|
|
|
|
|
|
|
|
|
$this->shareManager->expects($this->once())
|
|
|
|
|
->method('getShareByToken')
|
|
|
|
|
->with('GX9HSGQrGE')
|
|
|
|
|
->willReturn($share);
|
|
|
|
|
|
|
|
|
|
$this->session->method('exists')->with('public_link_authenticated')->willReturn(false);
|
|
|
|
|
|
|
|
|
|
$this->expectException(\Sabre\DAV\Exception\NotAuthenticated::class);
|
|
|
|
|
$this->invokePrivate($this->auth, 'checkToken');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testCheckTokenPasswordAuthenticatedWrongShare(): void {
|
|
|
|
|
$this->request->method('getPathInfo')
|
|
|
|
|
->willReturn('/dav/files/GX9HSGQrGE');
|
|
|
|
|
|
|
|
|
|
$share = $this->getMockBuilder(IShare::class)
|
|
|
|
|
->disableOriginalConstructor()
|
|
|
|
|
->getMock();
|
|
|
|
|
$share->method('getPassword')->willReturn('password');
|
|
|
|
|
$share->method('getShareType')->willReturn(42);
|
|
|
|
|
|
|
|
|
|
$this->shareManager->expects($this->once())
|
|
|
|
|
->method('getShareByToken')
|
|
|
|
|
->with('GX9HSGQrGE')
|
|
|
|
|
->willReturn($share);
|
|
|
|
|
|
|
|
|
|
$this->session->method('exists')->with('public_link_authenticated')->willReturn(false);
|
|
|
|
|
$this->session->method('get')->with('public_link_authenticated')->willReturn('43');
|
|
|
|
|
|
|
|
|
|
$this->expectException(\Sabre\DAV\Exception\NotAuthenticated::class);
|
|
|
|
|
$this->invokePrivate($this->auth, 'checkToken');
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-20 02:38:43 -05:00
|
|
|
public function testNoShare(): void {
|
2022-10-28 09:05:07 -04:00
|
|
|
$this->request->method('getPathInfo')
|
|
|
|
|
->willReturn('/dav/files/GX9HSGQrGE');
|
|
|
|
|
|
2016-04-01 11:35:37 -04:00
|
|
|
$this->shareManager->expects($this->once())
|
|
|
|
|
->method('getShareByToken')
|
2022-10-28 09:05:07 -04:00
|
|
|
->with('GX9HSGQrGE')
|
2016-04-01 11:35:37 -04:00
|
|
|
->willThrowException(new ShareNotFound());
|
|
|
|
|
|
|
|
|
|
$result = $this->invokePrivate($this->auth, 'validateUserPass', ['username', 'password']);
|
|
|
|
|
|
|
|
|
|
$this->assertFalse($result);
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-20 02:38:43 -05:00
|
|
|
public function testShareNoPassword(): void {
|
2022-10-28 09:05:07 -04:00
|
|
|
$this->request->method('getPathInfo')
|
|
|
|
|
->willReturn('/dav/files/GX9HSGQrGE');
|
|
|
|
|
|
2017-10-24 18:03:28 -04:00
|
|
|
$share = $this->getMockBuilder(IShare::class)
|
2016-07-15 03:52:46 -04:00
|
|
|
->disableOriginalConstructor()
|
|
|
|
|
->getMock();
|
2016-04-01 11:35:37 -04:00
|
|
|
$share->method('getPassword')->willReturn(null);
|
|
|
|
|
|
|
|
|
|
$this->shareManager->expects($this->once())
|
|
|
|
|
->method('getShareByToken')
|
2022-10-28 09:05:07 -04:00
|
|
|
->with('GX9HSGQrGE')
|
2016-04-01 11:35:37 -04:00
|
|
|
->willReturn($share);
|
|
|
|
|
|
|
|
|
|
$result = $this->invokePrivate($this->auth, 'validateUserPass', ['username', 'password']);
|
|
|
|
|
|
|
|
|
|
$this->assertTrue($result);
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-20 02:38:43 -05:00
|
|
|
public function testSharePasswordFancyShareType(): void {
|
2022-10-28 09:05:07 -04:00
|
|
|
$this->request->method('getPathInfo')
|
|
|
|
|
->willReturn('/dav/files/GX9HSGQrGE');
|
|
|
|
|
|
2017-10-24 18:03:28 -04:00
|
|
|
$share = $this->getMockBuilder(IShare::class)
|
2016-07-15 03:52:46 -04:00
|
|
|
->disableOriginalConstructor()
|
|
|
|
|
->getMock();
|
2016-04-01 11:35:37 -04:00
|
|
|
$share->method('getPassword')->willReturn('password');
|
|
|
|
|
$share->method('getShareType')->willReturn(42);
|
|
|
|
|
|
|
|
|
|
$this->shareManager->expects($this->once())
|
|
|
|
|
->method('getShareByToken')
|
2022-10-28 09:05:07 -04:00
|
|
|
->with('GX9HSGQrGE')
|
2016-04-01 11:35:37 -04:00
|
|
|
->willReturn($share);
|
|
|
|
|
|
|
|
|
|
$result = $this->invokePrivate($this->auth, 'validateUserPass', ['username', 'password']);
|
|
|
|
|
|
|
|
|
|
$this->assertFalse($result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2023-01-20 02:38:43 -05:00
|
|
|
public function testSharePasswordRemote(): void {
|
2022-10-28 09:05:07 -04:00
|
|
|
$this->request->method('getPathInfo')
|
|
|
|
|
->willReturn('/dav/files/GX9HSGQrGE');
|
|
|
|
|
|
2017-10-24 18:03:28 -04:00
|
|
|
$share = $this->getMockBuilder(IShare::class)
|
2016-07-15 03:52:46 -04:00
|
|
|
->disableOriginalConstructor()
|
|
|
|
|
->getMock();
|
2016-04-01 11:35:37 -04:00
|
|
|
$share->method('getPassword')->willReturn('password');
|
2020-06-24 10:49:16 -04:00
|
|
|
$share->method('getShareType')->willReturn(IShare::TYPE_REMOTE);
|
2016-04-01 11:35:37 -04:00
|
|
|
|
|
|
|
|
$this->shareManager->expects($this->once())
|
|
|
|
|
->method('getShareByToken')
|
2022-10-28 09:05:07 -04:00
|
|
|
->with('GX9HSGQrGE')
|
2016-04-01 11:35:37 -04:00
|
|
|
->willReturn($share);
|
|
|
|
|
|
|
|
|
|
$result = $this->invokePrivate($this->auth, 'validateUserPass', ['username', 'password']);
|
|
|
|
|
|
|
|
|
|
$this->assertTrue($result);
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-20 02:38:43 -05:00
|
|
|
public function testSharePasswordLinkValidPassword(): void {
|
2022-10-28 09:05:07 -04:00
|
|
|
$this->request->method('getPathInfo')
|
|
|
|
|
->willReturn('/dav/files/GX9HSGQrGE');
|
|
|
|
|
|
2017-10-24 18:03:28 -04:00
|
|
|
$share = $this->getMockBuilder(IShare::class)
|
2016-07-15 03:52:46 -04:00
|
|
|
->disableOriginalConstructor()
|
|
|
|
|
->getMock();
|
2016-04-01 11:35:37 -04:00
|
|
|
$share->method('getPassword')->willReturn('password');
|
2020-06-24 10:49:16 -04:00
|
|
|
$share->method('getShareType')->willReturn(IShare::TYPE_LINK);
|
2016-04-01 11:35:37 -04:00
|
|
|
|
|
|
|
|
$this->shareManager->expects($this->once())
|
|
|
|
|
->method('getShareByToken')
|
2022-10-28 09:05:07 -04:00
|
|
|
->with('GX9HSGQrGE')
|
2016-04-01 11:35:37 -04:00
|
|
|
->willReturn($share);
|
|
|
|
|
|
|
|
|
|
$this->shareManager->expects($this->once())
|
|
|
|
|
->method('checkPassword')->with(
|
|
|
|
|
$this->equalTo($share),
|
|
|
|
|
$this->equalTo('password')
|
|
|
|
|
)->willReturn(true);
|
|
|
|
|
|
|
|
|
|
$result = $this->invokePrivate($this->auth, 'validateUserPass', ['username', 'password']);
|
|
|
|
|
|
|
|
|
|
$this->assertTrue($result);
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-20 02:38:43 -05:00
|
|
|
public function testSharePasswordMailValidPassword(): void {
|
2022-10-28 09:05:07 -04:00
|
|
|
$this->request->method('getPathInfo')
|
|
|
|
|
->willReturn('/dav/files/GX9HSGQrGE');
|
|
|
|
|
|
2017-10-24 18:03:28 -04:00
|
|
|
$share = $this->getMockBuilder(IShare::class)
|
2017-05-04 05:20:20 -04:00
|
|
|
->disableOriginalConstructor()
|
|
|
|
|
->getMock();
|
|
|
|
|
$share->method('getPassword')->willReturn('password');
|
2020-06-24 10:49:16 -04:00
|
|
|
$share->method('getShareType')->willReturn(IShare::TYPE_EMAIL);
|
2017-05-04 05:20:20 -04:00
|
|
|
|
|
|
|
|
$this->shareManager->expects($this->once())
|
|
|
|
|
->method('getShareByToken')
|
2022-10-28 09:05:07 -04:00
|
|
|
->with('GX9HSGQrGE')
|
2017-05-04 05:20:20 -04:00
|
|
|
->willReturn($share);
|
|
|
|
|
|
|
|
|
|
$this->shareManager->expects($this->once())
|
|
|
|
|
->method('checkPassword')->with(
|
|
|
|
|
$this->equalTo($share),
|
|
|
|
|
$this->equalTo('password')
|
|
|
|
|
)->willReturn(true);
|
|
|
|
|
|
|
|
|
|
$result = $this->invokePrivate($this->auth, 'validateUserPass', ['username', 'password']);
|
|
|
|
|
|
|
|
|
|
$this->assertTrue($result);
|
|
|
|
|
}
|
|
|
|
|
|
2022-10-28 09:05:07 -04:00
|
|
|
public function testInvalidSharePasswordLinkValidSession(): void {
|
|
|
|
|
$this->request->method('getPathInfo')
|
|
|
|
|
->willReturn('/dav/files/GX9HSGQrGE');
|
|
|
|
|
|
2017-10-24 18:03:28 -04:00
|
|
|
$share = $this->getMockBuilder(IShare::class)
|
2016-07-15 03:52:46 -04:00
|
|
|
->disableOriginalConstructor()
|
|
|
|
|
->getMock();
|
2016-04-01 11:35:37 -04:00
|
|
|
$share->method('getPassword')->willReturn('password');
|
2020-06-24 10:49:16 -04:00
|
|
|
$share->method('getShareType')->willReturn(IShare::TYPE_LINK);
|
2016-04-01 11:35:37 -04:00
|
|
|
$share->method('getId')->willReturn('42');
|
|
|
|
|
|
|
|
|
|
$this->shareManager->expects($this->once())
|
|
|
|
|
->method('getShareByToken')
|
2022-10-28 09:05:07 -04:00
|
|
|
->with('GX9HSGQrGE')
|
2016-04-01 11:35:37 -04:00
|
|
|
->willReturn($share);
|
|
|
|
|
|
2022-10-28 09:05:07 -04:00
|
|
|
$this->shareManager->expects($this->once())
|
|
|
|
|
->method('checkPassword')
|
2016-04-01 11:35:37 -04:00
|
|
|
->with(
|
|
|
|
|
$this->equalTo($share),
|
|
|
|
|
$this->equalTo('password')
|
|
|
|
|
)->willReturn(false);
|
|
|
|
|
|
|
|
|
|
$this->session->method('exists')->with('public_link_authenticated')->willReturn(true);
|
|
|
|
|
$this->session->method('get')->with('public_link_authenticated')->willReturn('42');
|
|
|
|
|
|
|
|
|
|
$result = $this->invokePrivate($this->auth, 'validateUserPass', ['username', 'password']);
|
|
|
|
|
|
|
|
|
|
$this->assertTrue($result);
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-20 02:38:43 -05:00
|
|
|
public function testSharePasswordLinkInvalidSession(): void {
|
2022-10-28 09:05:07 -04:00
|
|
|
$this->request->method('getPathInfo')
|
|
|
|
|
->willReturn('/dav/files/GX9HSGQrGE');
|
|
|
|
|
|
2017-10-24 18:03:28 -04:00
|
|
|
$share = $this->getMockBuilder(IShare::class)
|
2016-07-15 03:52:46 -04:00
|
|
|
->disableOriginalConstructor()
|
|
|
|
|
->getMock();
|
2016-04-01 11:35:37 -04:00
|
|
|
$share->method('getPassword')->willReturn('password');
|
2020-06-24 10:49:16 -04:00
|
|
|
$share->method('getShareType')->willReturn(IShare::TYPE_LINK);
|
2016-04-01 11:35:37 -04:00
|
|
|
$share->method('getId')->willReturn('42');
|
|
|
|
|
|
|
|
|
|
$this->shareManager->expects($this->once())
|
|
|
|
|
->method('getShareByToken')
|
2022-10-28 09:05:07 -04:00
|
|
|
->with('GX9HSGQrGE')
|
2016-04-01 11:35:37 -04:00
|
|
|
->willReturn($share);
|
|
|
|
|
|
2022-10-28 09:05:07 -04:00
|
|
|
$this->shareManager->expects($this->once())
|
|
|
|
|
->method('checkPassword')
|
2016-04-01 11:35:37 -04:00
|
|
|
->with(
|
|
|
|
|
$this->equalTo($share),
|
|
|
|
|
$this->equalTo('password')
|
|
|
|
|
)->willReturn(false);
|
|
|
|
|
|
|
|
|
|
$this->session->method('exists')->with('public_link_authenticated')->willReturn(true);
|
|
|
|
|
$this->session->method('get')->with('public_link_authenticated')->willReturn('43');
|
|
|
|
|
|
|
|
|
|
$result = $this->invokePrivate($this->auth, 'validateUserPass', ['username', 'password']);
|
|
|
|
|
|
|
|
|
|
$this->assertFalse($result);
|
|
|
|
|
}
|
2017-05-04 05:20:20 -04:00
|
|
|
|
|
|
|
|
|
2023-01-20 02:38:43 -05:00
|
|
|
public function testSharePasswordMailInvalidSession(): void {
|
2022-10-28 09:05:07 -04:00
|
|
|
$this->request->method('getPathInfo')
|
|
|
|
|
->willReturn('/dav/files/GX9HSGQrGE');
|
|
|
|
|
|
2017-10-24 18:03:28 -04:00
|
|
|
$share = $this->getMockBuilder(IShare::class)
|
2017-05-04 05:20:20 -04:00
|
|
|
->disableOriginalConstructor()
|
|
|
|
|
->getMock();
|
|
|
|
|
$share->method('getPassword')->willReturn('password');
|
2020-06-24 10:49:16 -04:00
|
|
|
$share->method('getShareType')->willReturn(IShare::TYPE_EMAIL);
|
2017-05-04 05:20:20 -04:00
|
|
|
$share->method('getId')->willReturn('42');
|
|
|
|
|
|
|
|
|
|
$this->shareManager->expects($this->once())
|
|
|
|
|
->method('getShareByToken')
|
2022-10-28 09:05:07 -04:00
|
|
|
->with('GX9HSGQrGE')
|
2017-05-04 05:20:20 -04:00
|
|
|
->willReturn($share);
|
|
|
|
|
|
2022-10-28 09:05:07 -04:00
|
|
|
$this->shareManager->expects($this->once())
|
|
|
|
|
->method('checkPassword')
|
2017-05-04 05:20:20 -04:00
|
|
|
->with(
|
|
|
|
|
$this->equalTo($share),
|
|
|
|
|
$this->equalTo('password')
|
|
|
|
|
)->willReturn(false);
|
|
|
|
|
|
|
|
|
|
$this->session->method('exists')->with('public_link_authenticated')->willReturn(true);
|
|
|
|
|
$this->session->method('get')->with('public_link_authenticated')->willReturn('43');
|
|
|
|
|
|
|
|
|
|
$result = $this->invokePrivate($this->auth, 'validateUserPass', ['username', 'password']);
|
|
|
|
|
|
|
|
|
|
$this->assertFalse($result);
|
|
|
|
|
}
|
2016-04-01 11:35:37 -04:00
|
|
|
}
|