aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoryemkareems <yemkareems@gmail.com>2024-10-28 15:04:11 +0530
committeryemkareems <yemkareems@gmail.com>2024-10-28 15:04:11 +0530
commita74ef8237da49b75a930ca335713eef0347c9d51 (patch)
tree8f406854b99fd06b3f4a9568e72b151c1eaca529
parent505dfd65fd3520aaf95add30ef680723ddcd4dbd (diff)
downloadnextcloud-server-a74ef8237da49b75a930ca335713eef0347c9d51.tar.gz
nextcloud-server-a74ef8237da49b75a930ca335713eef0347c9d51.zip
fix: crypto type made not nullable and tests run using ICrypto
Signed-off-by: yemkareems <yemkareems@gmail.com>
-rw-r--r--lib/private/Authentication/LoginCredentials/Store.php6
-rw-r--r--lib/private/Server.php2
-rw-r--r--tests/lib/Authentication/LoginCredentials/StoreTest.php9
3 files changed, 8 insertions, 9 deletions
diff --git a/lib/private/Authentication/LoginCredentials/Store.php b/lib/private/Authentication/LoginCredentials/Store.php
index 8e31d7e23ca..210d1cc6463 100644
--- a/lib/private/Authentication/LoginCredentials/Store.php
+++ b/lib/private/Authentication/LoginCredentials/Store.php
@@ -30,13 +30,13 @@ class Store implements IStore {
/** @var IProvider|null */
private $tokenProvider;
- /** @var Crypto|null */
+ /** @var Crypto */
private $crypto;
public function __construct(ISession $session,
LoggerInterface $logger,
- ?IProvider $tokenProvider = null,
- ?Crypto $crypto = null) {
+ Crypto $crypto,
+ ?IProvider $tokenProvider = null) {
$this->session = $session;
$this->logger = $logger;
$this->tokenProvider = $tokenProvider;
diff --git a/lib/private/Server.php b/lib/private/Server.php
index be3f0bb9823..fb8c0aa7eda 100644
--- a/lib/private/Server.php
+++ b/lib/private/Server.php
@@ -452,7 +452,7 @@ class Server extends ServerContainer implements IServerContainer {
}
$logger = $c->get(LoggerInterface::class);
$crypto = $c->get(Crypto::class);
- return new Store($session, $logger, $tokenProvider, $crypto);
+ return new Store($session, $logger, $crypto, $tokenProvider);
});
$this->registerAlias(IStore::class, Store::class);
$this->registerAlias(IProvider::class, Authentication\Token\Manager::class);
diff --git a/tests/lib/Authentication/LoginCredentials/StoreTest.php b/tests/lib/Authentication/LoginCredentials/StoreTest.php
index 0a9a133746e..c58bb09faaa 100644
--- a/tests/lib/Authentication/LoginCredentials/StoreTest.php
+++ b/tests/lib/Authentication/LoginCredentials/StoreTest.php
@@ -13,7 +13,6 @@ use OC\Authentication\LoginCredentials\Credentials;
use OC\Authentication\LoginCredentials\Store;
use OC\Authentication\Token\IProvider;
use OC\Authentication\Token\IToken;
-use OC\Security\Crypto;
use OCP\Authentication\Exceptions\CredentialsUnavailableException;
use OCP\ISession;
use OCP\Security\ICrypto;
@@ -43,9 +42,9 @@ 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(Crypto::class);
+ $this->crypto = $this->createMock(ICrypto::class);
- $this->store = new Store($this->session, $this->logger, $this->tokenProvider, $this->crypto);
+ $this->store = new Store($this->session, $this->logger, $this->crypto, $this->tokenProvider);
}
public function testAuthenticate(): void {
@@ -60,7 +59,7 @@ class StoreTest extends TestCase {
->with($this->equalTo('login_credentials'), $this->equalTo(json_encode($params)));
$this->crypto->expects($this->once())
->method('encrypt')
- ->willReturn($params['password']);
+ ->willReturn('123456');
$this->store->authenticate($params);
}
@@ -73,7 +72,7 @@ class StoreTest extends TestCase {
}
public function testGetLoginCredentialsNoTokenProvider(): void {
- $this->store = new Store($this->session, $this->logger, null, $this->crypto);
+ $this->store = new Store($this->session, $this->logger, $this->crypto, null);
$this->expectException(CredentialsUnavailableException::class);