summaryrefslogtreecommitdiffstats
path: root/tests/lib
diff options
context:
space:
mode:
Diffstat (limited to 'tests/lib')
-rw-r--r--tests/lib/Authentication/Token/PublicKeyTokenMapperTest.php15
-rw-r--r--tests/lib/Authentication/Token/PublicKeyTokenProviderTest.php14
2 files changed, 14 insertions, 15 deletions
diff --git a/tests/lib/Authentication/Token/PublicKeyTokenMapperTest.php b/tests/lib/Authentication/Token/PublicKeyTokenMapperTest.php
index 27646f19888..c02785bbe4b 100644
--- a/tests/lib/Authentication/Token/PublicKeyTokenMapperTest.php
+++ b/tests/lib/Authentication/Token/PublicKeyTokenMapperTest.php
@@ -227,7 +227,7 @@ class PublicKeyTokenMapperTest extends TestCase {
$this->assertCount(0, $this->mapper->getTokenByUser('user1000'));
}
- public function testDeleteById() {
+ public function testGetById() {
/** @var IUser|\PHPUnit\Framework\MockObject\MockObject $user */
$user = $this->createMock(IUser::class);
$qb = $this->dbConnection->getQueryBuilder();
@@ -237,17 +237,8 @@ class PublicKeyTokenMapperTest extends TestCase {
$result = $qb->execute();
$id = $result->fetch()['id'];
- $this->mapper->deleteById('user1', (int)$id);
- $this->assertEquals(3, $this->getNumberOfTokens());
- }
-
- public function testDeleteByIdWrongUser() {
- /** @var IUser|\PHPUnit\Framework\MockObject\MockObject $user */
- $user = $this->createMock(IUser::class);
- $id = 33;
-
- $this->mapper->deleteById('user1000', $id);
- $this->assertEquals(4, $this->getNumberOfTokens());
+ $token = $this->mapper->getTokenById((int)$id);
+ $this->assertEquals('user1', $token->getUID());
}
public function testDeleteByName() {
diff --git a/tests/lib/Authentication/Token/PublicKeyTokenProviderTest.php b/tests/lib/Authentication/Token/PublicKeyTokenProviderTest.php
index a614780a908..045725bfe95 100644
--- a/tests/lib/Authentication/Token/PublicKeyTokenProviderTest.php
+++ b/tests/lib/Authentication/Token/PublicKeyTokenProviderTest.php
@@ -26,6 +26,7 @@ declare(strict_types=1);
namespace Test\Authentication\Token;
+use OCP\Security\IHasher;
use OC\Authentication\Exceptions\ExpiredTokenException;
use OC\Authentication\Exceptions\InvalidTokenException;
use OC\Authentication\Exceptions\PasswordlessTokenException;
@@ -35,6 +36,7 @@ use OC\Authentication\Token\PublicKeyTokenMapper;
use OC\Authentication\Token\PublicKeyTokenProvider;
use OCP\AppFramework\Db\DoesNotExistException;
use OCP\AppFramework\Utility\ITimeFactory;
+use OCP\ICacheFactory;
use OCP\IConfig;
use OCP\IDBConnection;
use OCP\Security\ICrypto;
@@ -57,6 +59,10 @@ class PublicKeyTokenProviderTest extends TestCase {
private $logger;
/** @var ITimeFactory|\PHPUnit\Framework\MockObject\MockObject */
private $timeFactory;
+ /** @var IHasher|\PHPUnit\Framework\MockObject\MockObject */
+ private $hasher;
+ /** @var ICacheFactory|\PHPUnit\Framework\MockObject\MockObject */
+ private $cacheFactory;
/** @var int */
private $time;
@@ -87,6 +93,7 @@ class PublicKeyTokenProviderTest extends TestCase {
$this->time = 1313131;
$this->timeFactory->method('getTime')
->willReturn($this->time);
+ $this->cacheFactory = $this->createMock(ICacheFactory::class);
$this->tokenProvider = new PublicKeyTokenProvider(
$this->mapper,
@@ -96,6 +103,7 @@ class PublicKeyTokenProviderTest extends TestCase {
$this->logger,
$this->timeFactory,
$this->hasher,
+ $this->cacheFactory,
);
}
@@ -329,12 +337,12 @@ class PublicKeyTokenProviderTest extends TestCase {
$this->tokenProvider->invalidateToken('token7');
}
- public function testInvaildateTokenById() {
+ public function testInvalidateTokenById() {
$id = 123;
$this->mapper->expects($this->once())
- ->method('deleteById')
- ->with('uid', $id);
+ ->method('getTokenById')
+ ->with($id);
$this->tokenProvider->invalidateTokenById('uid', $id);
}