diff options
author | yemkareems <yemkareems@gmail.com> | 2024-10-28 15:04:11 +0530 |
---|---|---|
committer | backportbot[bot] <backportbot[bot]@users.noreply.github.com> | 2024-10-28 12:29:20 +0000 |
commit | 051cc83854d7092387eed18715b26a8190c6100b (patch) | |
tree | b1f8a8b770b55c0f3ba0b96405886b851dfbbfeb | |
parent | b7e4138886f7462d0ac3e6ecab64556d0e4e6557 (diff) | |
download | nextcloud-server-051cc83854d7092387eed18715b26a8190c6100b.tar.gz nextcloud-server-051cc83854d7092387eed18715b26a8190c6100b.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.php | 6 | ||||
-rw-r--r-- | lib/private/Server.php | 2 | ||||
-rw-r--r-- | tests/lib/Authentication/LoginCredentials/StoreTest.php | 7 |
3 files changed, 7 insertions, 8 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 4e55bddcb36..51f856c4d71 100644 --- a/lib/private/Server.php +++ b/lib/private/Server.php @@ -482,7 +482,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 c91cb8c7853..136bae6476e 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() { @@ -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); } |