FedAuthTest.php 977 B

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. /**
  3. * SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors
  4. * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
  5. * SPDX-License-Identifier: AGPL-3.0-only
  6. */
  7. namespace OCA\Federation\Tests\DAV;
  8. use OCA\Federation\DAV\FedAuth;
  9. use OCA\Federation\DbHandler;
  10. use Test\TestCase;
  11. class FedAuthTest extends TestCase {
  12. /**
  13. * @dataProvider providesUser
  14. *
  15. * @param array $expected
  16. * @param string $user
  17. * @param string $password
  18. */
  19. public function testFedAuth($expected, $user, $password) {
  20. /** @var DbHandler | \PHPUnit\Framework\MockObject\MockObject $db */
  21. $db = $this->getMockBuilder('OCA\Federation\DbHandler')->disableOriginalConstructor()->getMock();
  22. $db->method('auth')->willReturn(true);
  23. $auth = new FedAuth($db);
  24. $result = $this->invokePrivate($auth, 'validateUserPass', [$user, $password]);
  25. $this->assertEquals($expected, $result);
  26. }
  27. public function providesUser() {
  28. return [
  29. [true, 'system', '123456']
  30. ];
  31. }
  32. }