2015-12-07 09:28:06 -05:00
|
|
|
<?php
|
2024-05-28 10:42:42 -04:00
|
|
|
|
2025-05-28 18:25:25 -04:00
|
|
|
declare(strict_types=1);
|
2015-12-07 09:28:06 -05:00
|
|
|
/**
|
2024-05-28 10:42:42 -04:00
|
|
|
* SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors
|
|
|
|
|
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
|
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
2015-12-07 09:28:06 -05:00
|
|
|
*/
|
|
|
|
|
namespace OCA\Federation\Tests\DAV;
|
|
|
|
|
|
|
|
|
|
use OCA\Federation\DAV\FedAuth;
|
|
|
|
|
use OCA\Federation\DbHandler;
|
2025-05-28 18:25:25 -04:00
|
|
|
use PHPUnit\Framework\MockObject\MockObject;
|
2015-12-07 09:28:06 -05:00
|
|
|
use Test\TestCase;
|
|
|
|
|
|
|
|
|
|
class FedAuthTest extends TestCase {
|
|
|
|
|
|
2025-06-30 10:56:59 -04:00
|
|
|
#[\PHPUnit\Framework\Attributes\DataProvider('providesUser')]
|
2025-05-28 18:25:25 -04:00
|
|
|
public function testFedAuth(bool $expected, string $user, string $password): void {
|
|
|
|
|
/** @var DbHandler&MockObject $db */
|
|
|
|
|
$db = $this->createMock(DbHandler::class);
|
2015-12-07 09:28:06 -05:00
|
|
|
$db->method('auth')->willReturn(true);
|
|
|
|
|
$auth = new FedAuth($db);
|
2025-05-28 18:25:25 -04:00
|
|
|
$result = self::invokePrivate($auth, 'validateUserPass', [$user, $password]);
|
2015-12-07 09:28:06 -05:00
|
|
|
$this->assertEquals($expected, $result);
|
|
|
|
|
}
|
|
|
|
|
|
2025-05-28 18:25:25 -04:00
|
|
|
public static function providesUser(): array {
|
2015-12-07 09:28:06 -05:00
|
|
|
return [
|
|
|
|
|
[true, 'system', '123456']
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
}
|