aboutsummaryrefslogtreecommitdiffstats
path: root/tests/lib/Authentication/TwoFactorAuth
diff options
context:
space:
mode:
Diffstat (limited to 'tests/lib/Authentication/TwoFactorAuth')
-rw-r--r--tests/lib/Authentication/TwoFactorAuth/Db/ProviderUserAssignmentDaoTest.php4
-rw-r--r--tests/lib/Authentication/TwoFactorAuth/ManagerTest.php29
-rw-r--r--tests/lib/Authentication/TwoFactorAuth/ProviderManagerTest.php5
-rw-r--r--tests/lib/Authentication/TwoFactorAuth/RegistryTest.php2
4 files changed, 21 insertions, 19 deletions
diff --git a/tests/lib/Authentication/TwoFactorAuth/Db/ProviderUserAssignmentDaoTest.php b/tests/lib/Authentication/TwoFactorAuth/Db/ProviderUserAssignmentDaoTest.php
index 7a1ea64ca9a..b59ef876ffd 100644
--- a/tests/lib/Authentication/TwoFactorAuth/Db/ProviderUserAssignmentDaoTest.php
+++ b/tests/lib/Authentication/TwoFactorAuth/Db/ProviderUserAssignmentDaoTest.php
@@ -9,9 +9,9 @@ declare(strict_types=1);
namespace Test\Authentication\TwoFactorAuth\Db;
-use OC;
use OC\Authentication\TwoFactorAuth\Db\ProviderUserAssignmentDao;
use OCP\IDBConnection;
+use OCP\Server;
use Test\TestCase;
/**
@@ -27,7 +27,7 @@ class ProviderUserAssignmentDaoTest extends TestCase {
protected function setUp(): void {
parent::setUp();
- $this->dbConn = OC::$server->getDatabaseConnection();
+ $this->dbConn = Server::get(IDBConnection::class);
$qb = $this->dbConn->getQueryBuilder();
$q = $qb->delete(ProviderUserAssignmentDao::TABLE_NAME);
$q->execute();
diff --git a/tests/lib/Authentication/TwoFactorAuth/ManagerTest.php b/tests/lib/Authentication/TwoFactorAuth/ManagerTest.php
index 75691627ce7..c68d1de60c5 100644
--- a/tests/lib/Authentication/TwoFactorAuth/ManagerTest.php
+++ b/tests/lib/Authentication/TwoFactorAuth/ManagerTest.php
@@ -8,8 +8,9 @@
namespace Test\Authentication\TwoFactorAuth;
-use OC;
+use OC\Authentication\Exceptions\InvalidTokenException;
use OC\Authentication\Token\IProvider as TokenProvider;
+use OC\Authentication\Token\IToken;
use OC\Authentication\TwoFactorAuth\Manager;
use OC\Authentication\TwoFactorAuth\MandatoryTwoFactor;
use OC\Authentication\TwoFactorAuth\ProviderLoader;
@@ -363,7 +364,7 @@ class ManagerTest extends TestCase {
];
$this->session->expects($this->exactly(2))
->method('remove')
- ->willReturnCallback(function () use (&$calls) {
+ ->willReturnCallback(function () use (&$calls): void {
$expected = array_shift($calls);
$this->assertEquals($expected, func_get_args());
});
@@ -404,7 +405,7 @@ class ManagerTest extends TestCase {
'provider' => 'Fake 2FA',
]))
->willReturnSelf();
- $token = $this->createMock(OC\Authentication\Token\IToken::class);
+ $token = $this->createMock(IToken::class);
$this->tokenProvider->method('getToken')
->with('mysessionid')
->willReturn($token);
@@ -496,7 +497,7 @@ class ManagerTest extends TestCase {
$this->session->method('getId')
->willReturn('mysessionid');
- $token = $this->createMock(OC\Authentication\Token\IToken::class);
+ $token = $this->createMock(IToken::class);
$this->tokenProvider->method('getToken')
->with('mysessionid')
->willReturn($token);
@@ -567,14 +568,14 @@ class ManagerTest extends TestCase {
];
$this->session->expects($this->exactly(2))
->method('set')
- ->willReturnCallback(function () use (&$calls) {
+ ->willReturnCallback(function () use (&$calls): void {
$expected = array_shift($calls);
$this->assertEquals($expected, func_get_args());
});
$this->session->method('getId')
->willReturn('mysessionid');
- $token = $this->createMock(OC\Authentication\Token\IToken::class);
+ $token = $this->createMock(IToken::class);
$this->tokenProvider->method('getToken')
->with('mysessionid')
->willReturn($token);
@@ -601,14 +602,14 @@ class ManagerTest extends TestCase {
];
$this->session->expects($this->exactly(2))
->method('set')
- ->willReturnCallback(function () use (&$calls) {
+ ->willReturnCallback(function () use (&$calls): void {
$expected = array_shift($calls);
$this->assertEquals($expected, func_get_args());
});
$this->session->method('getId')
->willReturn('mysessionid');
- $token = $this->createMock(OC\Authentication\Token\IToken::class);
+ $token = $this->createMock(IToken::class);
$this->tokenProvider->method('getToken')
->with('mysessionid')
->willReturn($token);
@@ -669,7 +670,7 @@ class ManagerTest extends TestCase {
$this->session->method('getId')
->willReturn('mysessionid');
- $token = $this->createMock(OC\Authentication\Token\IToken::class);
+ $token = $this->createMock(IToken::class);
$token->method('getId')
->willReturn(40);
@@ -704,7 +705,7 @@ class ManagerTest extends TestCase {
$this->tokenProvider->method('getToken')
->with('mysessionid')
- ->willThrowException(new OC\Authentication\Exceptions\InvalidTokenException());
+ ->willThrowException(new InvalidTokenException());
$this->config->method('getUserKeys')->willReturn([]);
@@ -736,7 +737,7 @@ class ManagerTest extends TestCase {
];
$this->config->expects($this->exactly(3))
->method('deleteUserValue')
- ->willReturnCallback(function () use (&$deleteUserValueCalls) {
+ ->willReturnCallback(function () use (&$deleteUserValueCalls): void {
$expected = array_shift($deleteUserValueCalls);
$this->assertEquals($expected, func_get_args());
});
@@ -748,7 +749,7 @@ class ManagerTest extends TestCase {
];
$this->tokenProvider->expects($this->exactly(3))
->method('invalidateTokenById')
- ->willReturnCallback(function () use (&$invalidateCalls) {
+ ->willReturnCallback(function () use (&$invalidateCalls): void {
$expected = array_shift($invalidateCalls);
$this->assertEquals($expected, func_get_args());
});
@@ -770,7 +771,7 @@ class ManagerTest extends TestCase {
];
$this->config->expects($this->exactly(3))
->method('deleteUserValue')
- ->willReturnCallback(function () use (&$deleteUserValueCalls) {
+ ->willReturnCallback(function () use (&$deleteUserValueCalls): void {
$expected = array_shift($deleteUserValueCalls);
$this->assertEquals($expected, func_get_args());
});
@@ -782,7 +783,7 @@ class ManagerTest extends TestCase {
];
$this->tokenProvider->expects($this->exactly(3))
->method('invalidateTokenById')
- ->willReturnCallback(function ($user, $tokenId) use (&$invalidateCalls) {
+ ->willReturnCallback(function ($user, $tokenId) use (&$invalidateCalls): void {
$expected = array_shift($invalidateCalls);
$this->assertEquals($expected, func_get_args());
if ($tokenId === 43) {
diff --git a/tests/lib/Authentication/TwoFactorAuth/ProviderManagerTest.php b/tests/lib/Authentication/TwoFactorAuth/ProviderManagerTest.php
index 34248f11f21..6004e67603b 100644
--- a/tests/lib/Authentication/TwoFactorAuth/ProviderManagerTest.php
+++ b/tests/lib/Authentication/TwoFactorAuth/ProviderManagerTest.php
@@ -9,6 +9,7 @@ declare(strict_types=1);
namespace lib\Authentication\TwoFactorAuth;
+use OC\Authentication\Exceptions\InvalidProviderException;
use OC\Authentication\TwoFactorAuth\ProviderLoader;
use OC\Authentication\TwoFactorAuth\ProviderManager;
use OCP\Authentication\TwoFactorAuth\IActivatableByAdmin;
@@ -43,7 +44,7 @@ class ProviderManagerTest extends TestCase {
public function testTryEnableInvalidProvider(): void {
- $this->expectException(\OC\Authentication\Exceptions\InvalidProviderException::class);
+ $this->expectException(InvalidProviderException::class);
$user = $this->createMock(IUser::class);
$this->providerManager->tryEnableProviderFor('none', $user);
@@ -89,7 +90,7 @@ class ProviderManagerTest extends TestCase {
public function testTryDisableInvalidProvider(): void {
- $this->expectException(\OC\Authentication\Exceptions\InvalidProviderException::class);
+ $this->expectException(InvalidProviderException::class);
$user = $this->createMock(IUser::class);
$this->providerManager->tryDisableProviderFor('none', $user);
diff --git a/tests/lib/Authentication/TwoFactorAuth/RegistryTest.php b/tests/lib/Authentication/TwoFactorAuth/RegistryTest.php
index 252b57e7983..2018dc1a634 100644
--- a/tests/lib/Authentication/TwoFactorAuth/RegistryTest.php
+++ b/tests/lib/Authentication/TwoFactorAuth/RegistryTest.php
@@ -126,7 +126,7 @@ class RegistryTest extends TestCase {
];
$this->dispatcher->expects($this->exactly(2))
->method('dispatchTyped')
- ->willReturnCallback(function () use (&$calls) {
+ ->willReturnCallback(function () use (&$calls): void {
$expected = array_shift($calls);
$this->assertEquals($expected, func_get_args());
});