mirror of
https://github.com/nextcloud/server.git
synced 2026-04-21 06:08:46 -04:00
fix: crypto type made not nullable and tests run using ICrypto
Signed-off-by: yemkareems <yemkareems@gmail.com>
This commit is contained in:
parent
505dfd65fd
commit
a74ef8237d
3 changed files with 8 additions and 9 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue