diff options
author | Côme Chilliet <91878298+come-nc@users.noreply.github.com> | 2025-03-04 18:21:57 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-03-04 18:21:57 +0100 |
commit | 2ef04bfb5d481b6401fcce77e28d4428d3057122 (patch) | |
tree | 8d903f08aa29dcf00fe10a4cd717dcad358ef04e /tests | |
parent | a1a35c070b78f80be75c8a1670e62a602a05f9de (diff) | |
parent | 3c4feff028ab87b57a29e5771cde8ba6c5b7e4b0 (diff) | |
download | nextcloud-server-2ef04bfb5d481b6401fcce77e28d4428d3057122.tar.gz nextcloud-server-2ef04bfb5d481b6401fcce77e28d4428d3057122.zip |
Merge pull request #47686 from nextcloud/fix/move-email-logic-local-user-backend
fix: Move login via email logic to local backend
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lib/Authentication/Login/EmailLoginCommandTest.php | 148 |
1 files changed, 0 insertions, 148 deletions
diff --git a/tests/lib/Authentication/Login/EmailLoginCommandTest.php b/tests/lib/Authentication/Login/EmailLoginCommandTest.php deleted file mode 100644 index b34d0d95f4f..00000000000 --- a/tests/lib/Authentication/Login/EmailLoginCommandTest.php +++ /dev/null @@ -1,148 +0,0 @@ -<?php - -/** - * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors - * SPDX-License-Identifier: AGPL-3.0-or-later - */ - -declare(strict_types=1); - -namespace Test\Authentication\Login; - -use OC\Authentication\Login\EmailLoginCommand; -use OCP\IUser; -use OCP\IUserManager; -use PHPUnit\Framework\MockObject\MockObject; - -class EmailLoginCommandTest extends ALoginCommandTest { - /** @var IUserManager|MockObject */ - private $userManager; - - protected function setUp(): void { - parent::setUp(); - - $this->userManager = $this->createMock(IUserManager::class); - - $this->cmd = new EmailLoginCommand( - $this->userManager - ); - } - - public function testProcessAlreadyLoggedIn(): void { - $data = $this->getLoggedInLoginData(); - - $result = $this->cmd->process($data); - - $this->assertTrue($result->isSuccess()); - } - - public function testProcessNotAnEmailLogin(): void { - $data = $this->getFailedLoginData(); - $this->userManager->expects($this->never()) - ->method('getByEmail') - ->with($this->username) - ->willReturn([]); - - $result = $this->cmd->process($data); - - $this->assertTrue($result->isSuccess()); - } - - public function testProcessDuplicateEmailLogin(): void { - $data = $this->getFailedLoginData(); - $data->setUsername('user@example.com'); - $this->userManager->expects($this->once()) - ->method('getByEmail') - ->with('user@example.com') - ->willReturn([ - $this->createMock(IUser::class), - $this->createMock(IUser::class), - ]); - - $result = $this->cmd->process($data); - - $this->assertTrue($result->isSuccess()); - } - - public function testProcessUidIsEmail(): void { - $email = 'user@domain.com'; - $data = $this->getFailedLoginData(); - $data->setUsername($email); - $emailUser = $this->createMock(IUser::class); - $emailUser->expects($this->any()) - ->method('getUID') - ->willReturn($email); - $this->userManager->expects($this->once()) - ->method('getByEmail') - ->with($email) - ->willReturn([ - $emailUser, - ]); - $this->userManager->expects($this->never()) - ->method('checkPassword'); - - $result = $this->cmd->process($data); - - $this->assertTrue($result->isSuccess()); - $this->assertFalse($data->getUser()); - $this->assertEquals($email, $data->getUsername()); - } - - public function testProcessWrongPassword(): void { - $email = 'user@domain.com'; - $data = $this->getFailedLoginData(); - $data->setUsername($email); - $emailUser = $this->createMock(IUser::class); - $emailUser->expects($this->any()) - ->method('getUID') - ->willReturn('user2'); - $this->userManager->expects($this->once()) - ->method('getByEmail') - ->with($email) - ->willReturn([ - $emailUser, - ]); - $this->userManager->expects($this->once()) - ->method('checkPassword') - ->with( - 'user2', - $this->password - ) - ->willReturn(false); - - $result = $this->cmd->process($data); - - $this->assertTrue($result->isSuccess()); - $this->assertFalse($data->getUser()); - $this->assertEquals($email, $data->getUsername()); - } - - public function testProcess(): void { - $email = 'user@domain.com'; - $data = $this->getFailedLoginData(); - $data->setUsername($email); - $emailUser = $this->createMock(IUser::class); - $emailUser->expects($this->any()) - ->method('getUID') - ->willReturn('user2'); - $this->userManager->expects($this->once()) - ->method('getByEmail') - ->with($email) - ->willReturn([ - $emailUser, - ]); - $this->userManager->expects($this->once()) - ->method('checkPassword') - ->with( - 'user2', - $this->password - ) - ->willReturn($emailUser); - - $result = $this->cmd->process($data); - - $this->assertTrue($result->isSuccess()); - $this->assertEquals($emailUser, $data->getUser()); - $this->assertEquals('user2', $data->getUsername()); - } -} |