Skip to content

Commit

Permalink
fix: crypto type made not nullable and tests run using ICrypto
Browse files Browse the repository at this point in the history
Signed-off-by: yemkareems <[email protected]>
  • Loading branch information
yemkareems committed Oct 28, 2024
1 parent 505dfd6 commit a74ef82
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
6 changes: 3 additions & 3 deletions lib/private/Authentication/LoginCredentials/Store.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion lib/private/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ public function __construct($webRoot, \OC\Config $config) {
}
$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);
Expand Down
9 changes: 4 additions & 5 deletions tests/lib/Authentication/LoginCredentials/StoreTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
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;
Expand Down Expand Up @@ -43,9 +42,9 @@ protected function setUp(): void {
$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 {
Expand All @@ -60,7 +59,7 @@ public function testAuthenticate(): void {
->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);
}
Expand All @@ -73,7 +72,7 @@ public function testSetSession(): void {
}

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);

Expand Down

0 comments on commit a74ef82

Please sign in to comment.