diff options
author | Arthur Schiwon <blizzz@arthur-schiwon.de> | 2023-04-06 11:12:52 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-06 11:12:52 +0200 |
commit | 1ac7a3f10730824c0c15671e3303ab57f12e217d (patch) | |
tree | 38f83e5863ef66e2364135ab89dbeec5d09a2145 /tests | |
parent | 6b4abd052235eaa5eac68fc0b2a578492fc57a15 (diff) | |
parent | a4032a38007a888c62ba9f72ac3037bc9a26031c (diff) | |
download | nextcloud-server-1ac7a3f10730824c0c15671e3303ab57f12e217d.tar.gz nextcloud-server-1ac7a3f10730824c0c15671e3303ab57f12e217d.zip |
Merge pull request #37595 from jtrees/add-some-tests-to-lost-controller
Add some tests for input trimming in LostController.php
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Core/Controller/LostControllerTest.php | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/Core/Controller/LostControllerTest.php b/tests/Core/Controller/LostControllerTest.php index e95c3fa1c51..1481a1e46d4 100644 --- a/tests/Core/Controller/LostControllerTest.php +++ b/tests/Core/Controller/LostControllerTest.php @@ -1,8 +1,10 @@ <?php /** * @author Lukas Reschke <lukas@owncloud.com> + * @author Joshua Trees <me@jtrees.io> * * @copyright Copyright (c) 2015, ownCloud, Inc. + * @copyright Copyright (c) 2023, Joshua Trees <me@jtrees.io> * @license AGPL-3.0 * * This code is free software: you can redistribute it and/or modify @@ -721,4 +723,38 @@ class LostControllerTest extends TestCase { $result = self::invokePrivate($this->lostController, 'findUserByIdOrMail', ['test@example.com']); $this->assertInstanceOf(IUser::class, $result); } + + public function testTrimEmailInput() { + $this->userManager + ->expects($this->once()) + ->method('getByEmail') + ->with('test@example.com') + ->willReturn([$this->existingUser]); + + $this->mailer + ->expects($this->once()) + ->method('send'); + + $response = $this->lostController->email(' test@example.com '); + $expectedResponse = new JSONResponse(['status' => 'success']); + $expectedResponse->throttle(); + $this->assertEquals($expectedResponse, $response); + } + + public function testUsernameInput() { + $this->userManager + ->expects($this->once()) + ->method('get') + ->with('ExistingUser') + ->willReturn($this->existingUser); + + $this->mailer + ->expects($this->once()) + ->method('send'); + + $response = $this->lostController->email(' ExistingUser '); + $expectedResponse = new JSONResponse(['status' => 'success']); + $expectedResponse->throttle(); + $this->assertEquals($expectedResponse, $response); + } } |