From 777cd941dc1bf7009bbb8465afd907c75b4d2d7b Mon Sep 17 00:00:00 2001 From: Julius Knorr Date: Fri, 28 Feb 2025 11:59:10 +0100 Subject: fix: Do not build encrypted password if there is none Signed-off-by: Julius Knorr --- .../Authentication/LoginCredentials/StoreTest.php | 40 ++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'tests') diff --git a/tests/lib/Authentication/LoginCredentials/StoreTest.php b/tests/lib/Authentication/LoginCredentials/StoreTest.php index c58bb09faaa..072ec2ab571 100644 --- a/tests/lib/Authentication/LoginCredentials/StoreTest.php +++ b/tests/lib/Authentication/LoginCredentials/StoreTest.php @@ -253,4 +253,44 @@ class StoreTest extends TestCase { $this->store->getLoginCredentials(); } + + public function testAuthenticatePasswordlessToken(): void { + $user = 'user987'; + $password = null; + + $params = [ + 'run' => true, + 'loginName' => $user, + 'uid' => $user, + 'password' => $password, + ]; + + $this->session->expects($this->once()) + ->method('set') + ->with($this->equalTo('login_credentials'), $this->equalTo(json_encode($params))); + + + $this->session->expects($this->once()) + ->method('getId') + ->willReturn('sess2233'); + $this->tokenProvider->expects($this->once()) + ->method('getToken') + ->with('sess2233') + ->will($this->throwException(new PasswordlessTokenException())); + + $this->session->expects($this->once()) + ->method('exists') + ->with($this->equalTo('login_credentials')) + ->willReturn(true); + $this->session->expects($this->once()) + ->method('get') + ->with($this->equalTo('login_credentials')) + ->willReturn(json_encode($params)); + + $this->store->authenticate($params); + $actual = $this->store->getLoginCredentials(); + + $expected = new Credentials($user, $user, $password); + $this->assertEquals($expected, $actual); + } } -- cgit v1.2.3