diff options
author | Kate <26026535+provokateurin@users.noreply.github.com> | 2024-10-28 13:26:55 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-28 13:26:55 +0100 |
commit | d25a0a2896a2a981939cacb8ee0d555feef22b3b (patch) | |
tree | f7ac5dfd04420209273da58b8745031d912f01d5 /tests | |
parent | 8b5e1bac90288692cde05da3694cdb749272d533 (diff) | |
parent | 34b07ace9579db1ce04feebd1c15f626f5503ee3 (diff) | |
download | nextcloud-server-d25a0a2896a2a981939cacb8ee0d555feef22b3b.tar.gz nextcloud-server-d25a0a2896a2a981939cacb8ee0d555feef22b3b.zip |
Merge pull request #48915 from nextcloud/fix/encrypt-decrypt-password
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lib/Authentication/LoginCredentials/StoreTest.php | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/tests/lib/Authentication/LoginCredentials/StoreTest.php b/tests/lib/Authentication/LoginCredentials/StoreTest.php index 6f1e3a6d750..c58bb09faaa 100644 --- a/tests/lib/Authentication/LoginCredentials/StoreTest.php +++ b/tests/lib/Authentication/LoginCredentials/StoreTest.php @@ -15,6 +15,7 @@ use OC\Authentication\Token\IProvider; use OC\Authentication\Token\IToken; use OCP\Authentication\Exceptions\CredentialsUnavailableException; use OCP\ISession; +use OCP\Security\ICrypto; use OCP\Session\Exceptions\SessionNotAvailableException; use Psr\Log\LoggerInterface; use Test\TestCase; @@ -29,6 +30,8 @@ class StoreTest extends TestCase { /** @var LoggerInterface|\PHPUnit\Framework\MockObject\MockObject */ private $logger; + /** @var ICrypto|\PHPUnit\Framework\MockObject\MockObject */ + private $crypto; /** @var Store */ private $store; @@ -39,20 +42,24 @@ class StoreTest extends TestCase { $this->session = $this->createMock(ISession::class); $this->tokenProvider = $this->createMock(IProvider::class); $this->logger = $this->createMock(LoggerInterface::class); + $this->crypto = $this->createMock(ICrypto::class); - $this->store = new Store($this->session, $this->logger, $this->tokenProvider); + $this->store = new Store($this->session, $this->logger, $this->crypto, $this->tokenProvider); } public function testAuthenticate(): void { $params = [ 'run' => true, 'uid' => 'user123', - 'password' => 123456, + 'password' => '123456', ]; $this->session->expects($this->once()) ->method('set') ->with($this->equalTo('login_credentials'), $this->equalTo(json_encode($params))); + $this->crypto->expects($this->once()) + ->method('encrypt') + ->willReturn('123456'); $this->store->authenticate($params); } @@ -65,7 +72,7 @@ class StoreTest extends TestCase { } public function testGetLoginCredentialsNoTokenProvider(): void { - $this->store = new Store($this->session, $this->logger, null); + $this->store = new Store($this->session, $this->logger, $this->crypto, null); $this->expectException(CredentialsUnavailableException::class); @@ -139,6 +146,9 @@ class StoreTest extends TestCase { ->method('exists') ->with($this->equalTo('login_credentials')) ->willReturn(true); + $this->crypto->expects($this->once()) + ->method('decrypt') + ->willReturn($password); $this->session->expects($this->exactly(2)) ->method('get') ->willReturnMap([ @@ -176,6 +186,9 @@ class StoreTest extends TestCase { ->method('exists') ->with($this->equalTo('login_credentials')) ->willReturn(true); + $this->crypto->expects($this->once()) + ->method('decrypt') + ->willReturn($password); $this->session->expects($this->exactly(2)) ->method('get') ->willReturnMap([ @@ -214,6 +227,9 @@ class StoreTest extends TestCase { ->method('exists') ->with($this->equalTo('login_credentials')) ->willReturn(true); + $this->crypto->expects($this->once()) + ->method('decrypt') + ->willReturn($password); $this->session->expects($this->once()) ->method('get') ->with($this->equalTo('login_credentials')) |