From 49ff48fcd3f07c229a0439748cb1469e5d11c504 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 12 Oct 2020 17:14:25 +0200 Subject: [PATCH] Use PSR logger in authentication Signed-off-by: Joas Schilling --- .../Listeners/RemoteWipeActivityListener.php | 11 +++++----- .../Listeners/RemoteWipeEmailListener.php | 16 +++++++------- .../UserDeletedTokenCleanupListener.php | 11 +++++----- .../Login/LoggedInCheckCommand.php | 10 ++++----- .../Login/UserDisabledCheckCommand.php | 6 +++--- .../Authentication/LoginCredentials/Store.php | 13 +++++------- .../Token/DefaultTokenProvider.php | 6 +++--- .../Token/PublicKeyTokenProvider.php | 8 +++---- .../Authentication/Token/RemoteWipe.php | 6 +++--- .../Authentication/TwoFactorAuth/Manager.php | 21 +++++++++++-------- .../Authentication/WebAuthn/Manager.php | 6 +++--- lib/private/Server.php | 2 +- .../RemoteWipeActivityListenerTest.php | 6 +++--- .../Listeners/RemoteWipeEmailListenerTest.php | 10 ++++----- .../UserDeletedTokenCleanupListenerTest.php | 13 ++++++------ .../Login/LoggedInCheckCommandTest.php | 6 +++--- .../Login/UserDisabledCheckCommandTest.php | 6 +++--- .../LoginCredentials/StoreTest.php | 6 +++--- .../Token/DefaultTokenProviderTest.php | 6 +++--- .../Token/PublicKeyTokenProviderTest.php | 6 +++--- .../Authentication/Token/RemoteWipeTest.php | 6 +++--- .../TwoFactorAuth/ManagerTest.php | 6 +++--- 22 files changed, 90 insertions(+), 97 deletions(-) diff --git a/lib/private/Authentication/Listeners/RemoteWipeActivityListener.php b/lib/private/Authentication/Listeners/RemoteWipeActivityListener.php index 0ab2dcf4837..b841f81555b 100644 --- a/lib/private/Authentication/Listeners/RemoteWipeActivityListener.php +++ b/lib/private/Authentication/Listeners/RemoteWipeActivityListener.php @@ -33,18 +33,18 @@ use OC\Authentication\Token\IToken; use OCP\Activity\IManager as IActvityManager; use OCP\EventDispatcher\Event; use OCP\EventDispatcher\IEventListener; -use OCP\ILogger; +use Psr\Log\LoggerInterface; class RemoteWipeActivityListener implements IEventListener { /** @var IActvityManager */ private $activityManager; - /** @var ILogger */ + /** @var LoggerInterface */ private $logger; public function __construct(IActvityManager $activityManager, - ILogger $logger) { + LoggerInterface $logger) { $this->activityManager = $activityManager; $this->logger = $logger; } @@ -69,10 +69,9 @@ class RemoteWipeActivityListener implements IEventListener { try { $this->activityManager->publish($activity); } catch (BadMethodCallException $e) { - $this->logger->logException($e, [ + $this->logger->warning('could not publish activity', [ 'app' => 'core', - 'level' => ILogger::WARN, - 'message' => 'could not publish activity', + 'exception' => $e, ]); } } diff --git a/lib/private/Authentication/Listeners/RemoteWipeEmailListener.php b/lib/private/Authentication/Listeners/RemoteWipeEmailListener.php index 799c4ea4cf5..52698855bd5 100644 --- a/lib/private/Authentication/Listeners/RemoteWipeEmailListener.php +++ b/lib/private/Authentication/Listeners/RemoteWipeEmailListener.php @@ -32,12 +32,12 @@ use OC\Authentication\Events\RemoteWipeStarted; use OCP\EventDispatcher\Event; use OCP\EventDispatcher\IEventListener; use OCP\IL10N; -use OCP\ILogger; use OCP\IUser; use OCP\IUserManager; use OCP\L10N\IFactory as IL10nFactory; use OCP\Mail\IMailer; use OCP\Mail\IMessage; +use Psr\Log\LoggerInterface; use function substr; class RemoteWipeEmailListener implements IEventListener { @@ -51,13 +51,13 @@ class RemoteWipeEmailListener implements IEventListener { /** @var IL10N */ private $l10n; - /** @var ILogger */ + /** @var LoggerInterface */ private $logger; public function __construct(IMailer $mailer, IUserManager $userManager, IL10nFactory $l10nFactory, - ILogger $logger) { + LoggerInterface $logger) { $this->mailer = $mailer; $this->userManager = $userManager; $this->l10n = $l10nFactory->get('core'); @@ -85,9 +85,8 @@ class RemoteWipeEmailListener implements IEventListener { $this->getWipingStartedMessage($event, $user) ); } catch (Exception $e) { - $this->logger->logException($e, [ - 'message' => "Could not send remote wipe started email to <$uid>", - 'level' => ILogger::ERROR, + $this->logger->error("Could not send remote wipe started email to <$uid>", [ + 'exception' => $e, ]); } } elseif ($event instanceof RemoteWipeFinished) { @@ -107,9 +106,8 @@ class RemoteWipeEmailListener implements IEventListener { $this->getWipingFinishedMessage($event, $user) ); } catch (Exception $e) { - $this->logger->logException($e, [ - 'message' => "Could not send remote wipe finished email to <$uid>", - 'level' => ILogger::ERROR, + $this->logger->error("Could not send remote wipe finished email to <$uid>", [ + 'exception' => $e, ]); } } diff --git a/lib/private/Authentication/Listeners/UserDeletedTokenCleanupListener.php b/lib/private/Authentication/Listeners/UserDeletedTokenCleanupListener.php index 3b362336675..e1199814da5 100644 --- a/lib/private/Authentication/Listeners/UserDeletedTokenCleanupListener.php +++ b/lib/private/Authentication/Listeners/UserDeletedTokenCleanupListener.php @@ -29,8 +29,8 @@ namespace OC\Authentication\Listeners; use OC\Authentication\Token\Manager; use OCP\EventDispatcher\Event; use OCP\EventDispatcher\IEventListener; -use OCP\ILogger; use OCP\User\Events\UserDeletedEvent; +use Psr\Log\LoggerInterface; use Throwable; class UserDeletedTokenCleanupListener implements IEventListener { @@ -38,11 +38,11 @@ class UserDeletedTokenCleanupListener implements IEventListener { /** @var Manager */ private $manager; - /** @var ILogger */ + /** @var LoggerInterface */ private $logger; public function __construct(Manager $manager, - ILogger $logger) { + LoggerInterface $logger) { $this->manager = $manager; $this->logger = $logger; } @@ -64,9 +64,8 @@ class UserDeletedTokenCleanupListener implements IEventListener { $this->manager->invalidateTokenById($uid, $token->getId()); } } catch (Throwable $e) { - $this->logger->logException($e, [ - 'message' => 'Could not clean up auth tokens after user deletion: ' . $e->getMessage(), - 'error' => ILogger::ERROR, + $this->logger->error('Could not clean up auth tokens after user deletion: ' . $e->getMessage(), [ + 'exception' => $e, ]); } } diff --git a/lib/private/Authentication/Login/LoggedInCheckCommand.php b/lib/private/Authentication/Login/LoggedInCheckCommand.php index d2546a62d16..1848c5db09e 100644 --- a/lib/private/Authentication/Login/LoggedInCheckCommand.php +++ b/lib/private/Authentication/Login/LoggedInCheckCommand.php @@ -29,19 +29,17 @@ namespace OC\Authentication\Login; use OC\Authentication\Events\LoginFailed; use OC\Core\Controller\LoginController; use OCP\EventDispatcher\IEventDispatcher; -use OCP\ILogger; -use OCP\IUserManager; +use Psr\Log\LoggerInterface; class LoggedInCheckCommand extends ALoginCommand { - /** @var ILogger */ + /** @var LoggerInterface */ private $logger; /** @var IEventDispatcher */ private $dispatcher; - /** @var IUserManager */ - private $userManager; - public function __construct(ILogger $logger, IEventDispatcher $dispatcher) { + public function __construct(LoggerInterface $logger, + IEventDispatcher $dispatcher) { $this->logger = $logger; $this->dispatcher = $dispatcher; } diff --git a/lib/private/Authentication/Login/UserDisabledCheckCommand.php b/lib/private/Authentication/Login/UserDisabledCheckCommand.php index e33853ef5bd..49762546bc4 100644 --- a/lib/private/Authentication/Login/UserDisabledCheckCommand.php +++ b/lib/private/Authentication/Login/UserDisabledCheckCommand.php @@ -26,19 +26,19 @@ declare(strict_types=1); namespace OC\Authentication\Login; use OC\Core\Controller\LoginController; -use OCP\ILogger; use OCP\IUserManager; +use Psr\Log\LoggerInterface; class UserDisabledCheckCommand extends ALoginCommand { /** @var IUserManager */ private $userManager; - /** @var ILogger */ + /** @var LoggerInterface */ private $logger; public function __construct(IUserManager $userManager, - ILogger $logger) { + LoggerInterface $logger) { $this->userManager = $userManager; $this->logger = $logger; } diff --git a/lib/private/Authentication/LoginCredentials/Store.php b/lib/private/Authentication/LoginCredentials/Store.php index 29bc4f6a2e1..89992dc2117 100644 --- a/lib/private/Authentication/LoginCredentials/Store.php +++ b/lib/private/Authentication/LoginCredentials/Store.php @@ -33,28 +33,25 @@ use OC\Authentication\Token\IProvider; use OCP\Authentication\Exceptions\CredentialsUnavailableException; use OCP\Authentication\LoginCredentials\ICredentials; use OCP\Authentication\LoginCredentials\IStore; -use OCP\ILogger; use OCP\ISession; use OCP\Session\Exceptions\SessionNotAvailableException; use OCP\Util; +use Psr\Log\LoggerInterface; class Store implements IStore { /** @var ISession */ private $session; - /** @var ILogger */ + /** @var LoggerInterface */ private $logger; /** @var IProvider|null */ private $tokenProvider; - /** - * @param ISession $session - * @param ILogger $logger - * @param IProvider $tokenProvider - */ - public function __construct(ISession $session, ILogger $logger, IProvider $tokenProvider = null) { + public function __construct(ISession $session, + LoggerInterface $logger, + IProvider $tokenProvider = null) { $this->session = $session; $this->logger = $logger; $this->tokenProvider = $tokenProvider; diff --git a/lib/private/Authentication/Token/DefaultTokenProvider.php b/lib/private/Authentication/Token/DefaultTokenProvider.php index ee8a28d3cb0..a6a1af5a97a 100644 --- a/lib/private/Authentication/Token/DefaultTokenProvider.php +++ b/lib/private/Authentication/Token/DefaultTokenProvider.php @@ -39,8 +39,8 @@ use OC\Authentication\Exceptions\PasswordlessTokenException; use OCP\AppFramework\Db\DoesNotExistException; use OCP\AppFramework\Utility\ITimeFactory; use OCP\IConfig; -use OCP\ILogger; use OCP\Security\ICrypto; +use Psr\Log\LoggerInterface; class DefaultTokenProvider implements IProvider { @@ -53,7 +53,7 @@ class DefaultTokenProvider implements IProvider { /** @var IConfig */ private $config; - /** @var ILogger */ + /** @var LoggerInterface */ private $logger; /** @var ITimeFactory */ @@ -62,7 +62,7 @@ class DefaultTokenProvider implements IProvider { public function __construct(DefaultTokenMapper $mapper, ICrypto $crypto, IConfig $config, - ILogger $logger, + LoggerInterface $logger, ITimeFactory $time) { $this->mapper = $mapper; $this->crypto = $crypto; diff --git a/lib/private/Authentication/Token/PublicKeyTokenProvider.php b/lib/private/Authentication/Token/PublicKeyTokenProvider.php index df50da2f03a..38551e63b87 100644 --- a/lib/private/Authentication/Token/PublicKeyTokenProvider.php +++ b/lib/private/Authentication/Token/PublicKeyTokenProvider.php @@ -39,8 +39,8 @@ use OC\Cache\CappedMemoryCache; use OCP\AppFramework\Db\DoesNotExistException; use OCP\AppFramework\Utility\ITimeFactory; use OCP\IConfig; -use OCP\ILogger; use OCP\Security\ICrypto; +use Psr\Log\LoggerInterface; class PublicKeyTokenProvider implements IProvider { /** @var PublicKeyTokenMapper */ @@ -52,10 +52,10 @@ class PublicKeyTokenProvider implements IProvider { /** @var IConfig */ private $config; - /** @var ILogger $logger */ + /** @var LoggerInterface */ private $logger; - /** @var ITimeFactory $time */ + /** @var ITimeFactory */ private $time; /** @var CappedMemoryCache */ @@ -64,7 +64,7 @@ class PublicKeyTokenProvider implements IProvider { public function __construct(PublicKeyTokenMapper $mapper, ICrypto $crypto, IConfig $config, - ILogger $logger, + LoggerInterface $logger, ITimeFactory $time) { $this->mapper = $mapper; $this->crypto = $crypto; diff --git a/lib/private/Authentication/Token/RemoteWipe.php b/lib/private/Authentication/Token/RemoteWipe.php index cab68357a01..b762073a8bc 100644 --- a/lib/private/Authentication/Token/RemoteWipe.php +++ b/lib/private/Authentication/Token/RemoteWipe.php @@ -28,13 +28,13 @@ declare(strict_types=1); namespace OC\Authentication\Token; +use Psr\Log\LoggerInterface; use function array_filter; use OC\Authentication\Events\RemoteWipeFinished; use OC\Authentication\Events\RemoteWipeStarted; use OC\Authentication\Exceptions\InvalidTokenException; use OC\Authentication\Exceptions\WipeTokenException; use OCP\EventDispatcher\IEventDispatcher; -use OCP\ILogger; use OCP\IUser; class RemoteWipe { @@ -45,12 +45,12 @@ class RemoteWipe { /** @var IEventDispatcher */ private $eventDispatcher; - /** @var ILogger */ + /** @var LoggerInterface */ private $logger; public function __construct(IProvider $tokenProvider, IEventDispatcher $eventDispatcher, - ILogger $logger) { + LoggerInterface $logger) { $this->tokenProvider = $tokenProvider; $this->eventDispatcher = $eventDispatcher; $this->logger = $logger; diff --git a/lib/private/Authentication/TwoFactorAuth/Manager.php b/lib/private/Authentication/TwoFactorAuth/Manager.php index 07e61175361..8e529ccbda8 100644 --- a/lib/private/Authentication/TwoFactorAuth/Manager.php +++ b/lib/private/Authentication/TwoFactorAuth/Manager.php @@ -27,8 +27,6 @@ declare(strict_types=1); namespace OC\Authentication\TwoFactorAuth; -use function array_diff; -use function array_filter; use BadMethodCallException; use Exception; use OC\Authentication\Exceptions\InvalidTokenException; @@ -39,11 +37,13 @@ use OCP\Authentication\TwoFactorAuth\IActivatableAtLogin; use OCP\Authentication\TwoFactorAuth\IProvider; use OCP\Authentication\TwoFactorAuth\IRegistry; use OCP\IConfig; -use OCP\ILogger; use OCP\ISession; use OCP\IUser; +use Psr\Log\LoggerInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\EventDispatcher\GenericEvent; +use function array_diff; +use function array_filter; class Manager { public const SESSION_UID_KEY = 'two_factor_auth_uid'; @@ -69,7 +69,7 @@ class Manager { /** @var IManager */ private $activityManager; - /** @var ILogger */ + /** @var LoggerInterface */ private $logger; /** @var TokenProvider */ @@ -84,9 +84,13 @@ class Manager { public function __construct(ProviderLoader $providerLoader, IRegistry $providerRegistry, MandatoryTwoFactor $mandatoryTwoFactor, - ISession $session, IConfig $config, - IManager $activityManager, ILogger $logger, TokenProvider $tokenProvider, - ITimeFactory $timeFactory, EventDispatcherInterface $eventDispatcher) { + ISession $session, + IConfig $config, + IManager $activityManager, + LoggerInterface $logger, + TokenProvider $tokenProvider, + ITimeFactory $timeFactory, + EventDispatcherInterface $eventDispatcher) { $this->providerLoader = $providerLoader; $this->providerRegistry = $providerRegistry; $this->mandatoryTwoFactor = $mandatoryTwoFactor; @@ -295,8 +299,7 @@ class Manager { try { $this->activityManager->publish($activity); } catch (BadMethodCallException $e) { - $this->logger->warning('could not publish activity', ['app' => 'core']); - $this->logger->logException($e, ['app' => 'core']); + $this->logger->warning('could not publish activity', ['app' => 'core', 'exception' => $e]); } } diff --git a/lib/private/Authentication/WebAuthn/Manager.php b/lib/private/Authentication/WebAuthn/Manager.php index 4415badc9b0..ce70c54bf11 100644 --- a/lib/private/Authentication/WebAuthn/Manager.php +++ b/lib/private/Authentication/WebAuthn/Manager.php @@ -35,8 +35,8 @@ use OC\Authentication\WebAuthn\Db\PublicKeyCredentialEntity; use OC\Authentication\WebAuthn\Db\PublicKeyCredentialMapper; use OCP\AppFramework\Db\DoesNotExistException; use OCP\IConfig; -use OCP\ILogger; use OCP\IUser; +use Psr\Log\LoggerInterface; use Webauthn\AttestationStatement\AttestationObjectLoader; use Webauthn\AttestationStatement\AttestationStatementSupportManager; use Webauthn\AttestationStatement\NoneAttestationStatementSupport; @@ -63,7 +63,7 @@ class Manager { /** @var PublicKeyCredentialMapper */ private $credentialMapper; - /** @var ILogger */ + /** @var LoggerInterface */ private $logger; /** @var IConfig */ @@ -72,7 +72,7 @@ class Manager { public function __construct( CredentialRepository $repository, PublicKeyCredentialMapper $credentialMapper, - ILogger $logger, + LoggerInterface $logger, IConfig $config ) { $this->repository = $repository; diff --git a/lib/private/Server.php b/lib/private/Server.php index c38965000f2..5de7808523e 100644 --- a/lib/private/Server.php +++ b/lib/private/Server.php @@ -498,7 +498,7 @@ class Server extends ServerContainer implements IServerContainer { } else { $tokenProvider = null; } - $logger = $c->get(ILogger::class); + $logger = $c->get(LoggerInterface::class); return new Store($session, $logger, $tokenProvider); }); $this->registerAlias(IStore::class, Store::class); diff --git a/tests/lib/Authentication/Listeners/RemoteWipeActivityListenerTest.php b/tests/lib/Authentication/Listeners/RemoteWipeActivityListenerTest.php index 05d38380026..6409ff2dc35 100644 --- a/tests/lib/Authentication/Listeners/RemoteWipeActivityListenerTest.php +++ b/tests/lib/Authentication/Listeners/RemoteWipeActivityListenerTest.php @@ -33,8 +33,8 @@ use OC\Authentication\Token\IToken; use OCP\Activity\IManager as IActivityManager; use OCP\EventDispatcher\Event; use OCP\EventDispatcher\IEventListener; -use OCP\ILogger; use PHPUnit\Framework\MockObject\MockObject; +use Psr\Log\LoggerInterface; use Test\TestCase; class RemoteWipeActivityListenerTests extends TestCase { @@ -42,7 +42,7 @@ class RemoteWipeActivityListenerTests extends TestCase { /** @var IActivityManager|MockObject */ private $activityManager; - /** @var ILogger|MockObject */ + /** @var LoggerInterface|MockObject */ private $logger; /** @var IEventListener */ @@ -52,7 +52,7 @@ class RemoteWipeActivityListenerTests extends TestCase { parent::setUp(); $this->activityManager = $this->createMock(IActivityManager::class); - $this->logger = $this->createMock(ILogger::class); + $this->logger = $this->createMock(LoggerInterface::class); $this->listener = new RemoteWipeActivityListener( $this->activityManager, diff --git a/tests/lib/Authentication/Listeners/RemoteWipeEmailListenerTest.php b/tests/lib/Authentication/Listeners/RemoteWipeEmailListenerTest.php index 9d2319fb9cc..932097d875f 100644 --- a/tests/lib/Authentication/Listeners/RemoteWipeEmailListenerTest.php +++ b/tests/lib/Authentication/Listeners/RemoteWipeEmailListenerTest.php @@ -33,13 +33,13 @@ use OC\Authentication\Token\IToken; use OCP\EventDispatcher\Event; use OCP\EventDispatcher\IEventListener; use OCP\IL10N; -use OCP\ILogger; use OCP\IUser; use OCP\IUserManager; use OCP\L10N\IFactory; use OCP\Mail\IMailer; use OCP\Mail\IMessage; use PHPUnit\Framework\MockObject\MockObject; +use Psr\Log\LoggerInterface; use Test\TestCase; class RemoteWipeEmailListenerTest extends TestCase { @@ -56,7 +56,7 @@ class RemoteWipeEmailListenerTest extends TestCase { /** @var IL10N|MockObject */ private $l10n; - /** @var ILogger|MockObject */ + /** @var LoggerInterface|MockObject */ private $logger; /** @var IEventListener */ @@ -69,7 +69,7 @@ class RemoteWipeEmailListenerTest extends TestCase { $this->userManager = $this->createMock(IUserManager::class); $this->l10nFactory = $this->createMock(IFactory::class); $this->l10n = $this->createMock(IL10N::class); - $this->logger = $this->createMock(ILogger::class); + $this->logger = $this->createMock(LoggerInterface::class); $this->l10nFactory->method('get')->with('core')->willReturn($this->l10n); $this->l10n->method('t')->willReturnArgument(0); @@ -135,7 +135,7 @@ class RemoteWipeEmailListenerTest extends TestCase { ->method('send') ->willThrowException(new Exception()); $this->logger->expects($this->once()) - ->method('logException'); + ->method('error'); $this->listener->handle($event); } @@ -210,7 +210,7 @@ class RemoteWipeEmailListenerTest extends TestCase { ->method('send') ->willThrowException(new Exception()); $this->logger->expects($this->once()) - ->method('logException'); + ->method('error'); $this->listener->handle($event); } diff --git a/tests/lib/Authentication/Listeners/UserDeletedTokenCleanupListenerTest.php b/tests/lib/Authentication/Listeners/UserDeletedTokenCleanupListenerTest.php index 672a044ce01..bf8405a4422 100644 --- a/tests/lib/Authentication/Listeners/UserDeletedTokenCleanupListenerTest.php +++ b/tests/lib/Authentication/Listeners/UserDeletedTokenCleanupListenerTest.php @@ -30,10 +30,10 @@ use OC\Authentication\Listeners\UserDeletedTokenCleanupListener; use OC\Authentication\Token\IToken; use OC\Authentication\Token\Manager; use OCP\EventDispatcher\Event; -use OCP\ILogger; use OCP\IUser; use OCP\User\Events\UserDeletedEvent; use PHPUnit\Framework\MockObject\MockObject; +use Psr\Log\LoggerInterface; use Test\TestCase; class UserDeletedTokenCleanupListenerTest extends TestCase { @@ -42,7 +42,7 @@ class UserDeletedTokenCleanupListenerTest extends TestCase { /** @var Manager|MockObject */ private $manager; - /** @var ILogger|MockObject */ + /** @var LoggerInterface|MockObject */ private $logger; /** @var UserDeletedTokenCleanupListener */ @@ -52,7 +52,7 @@ class UserDeletedTokenCleanupListenerTest extends TestCase { parent::setUp(); $this->manager = $this->createMock(Manager::class); - $this->logger = $this->createMock(ILogger::class); + $this->logger = $this->createMock(LoggerInterface::class); $this->listener = new UserDeletedTokenCleanupListener( $this->manager, @@ -63,7 +63,7 @@ class UserDeletedTokenCleanupListenerTest extends TestCase { public function testHandleUnrelated(): void { $event = new Event(); $this->manager->expects($this->never())->method('getTokenByUser'); - $this->logger->expects($this->never())->method('logException'); + $this->logger->expects($this->never())->method('error'); $this->listener->handle($event); } @@ -78,8 +78,7 @@ class UserDeletedTokenCleanupListenerTest extends TestCase { ->with('user123') ->willThrowException($exception); $this->logger->expects($this->once()) - ->method('logException') - ->with($exception, $this->anything()); + ->method('error'); $this->listener->handle($event); } @@ -110,7 +109,7 @@ class UserDeletedTokenCleanupListenerTest extends TestCase { ['user123', 3] ); $this->logger->expects($this->never()) - ->method('logException'); + ->method('error'); $this->listener->handle($event); } diff --git a/tests/lib/Authentication/Login/LoggedInCheckCommandTest.php b/tests/lib/Authentication/Login/LoggedInCheckCommandTest.php index 18f4a4938e8..4762c601bb8 100644 --- a/tests/lib/Authentication/Login/LoggedInCheckCommandTest.php +++ b/tests/lib/Authentication/Login/LoggedInCheckCommandTest.php @@ -28,12 +28,12 @@ namespace lib\Authentication\Login; use OC\Authentication\Login\LoggedInCheckCommand; use OC\Core\Controller\LoginController; use OCP\EventDispatcher\IEventDispatcher; -use OCP\ILogger; use PHPUnit\Framework\MockObject\MockObject; +use Psr\Log\LoggerInterface; class LoggedInCheckCommandTest extends ALoginCommandTest { - /** @var ILogger|MockObject */ + /** @var LoggerInterface|MockObject */ private $logger; /** @var IEventDispatcher|MockObject */ @@ -42,7 +42,7 @@ class LoggedInCheckCommandTest extends ALoginCommandTest { protected function setUp(): void { parent::setUp(); - $this->logger = $this->createMock(ILogger::class); + $this->logger = $this->createMock(LoggerInterface::class); $this->dispatcher = $this->createMock(IEventDispatcher::class); $this->cmd = new LoggedInCheckCommand( diff --git a/tests/lib/Authentication/Login/UserDisabledCheckCommandTest.php b/tests/lib/Authentication/Login/UserDisabledCheckCommandTest.php index e6f619aac0f..8c15ebe6c8f 100644 --- a/tests/lib/Authentication/Login/UserDisabledCheckCommandTest.php +++ b/tests/lib/Authentication/Login/UserDisabledCheckCommandTest.php @@ -27,23 +27,23 @@ namespace lib\Authentication\Login; use OC\Authentication\Login\UserDisabledCheckCommand; use OC\Core\Controller\LoginController; -use OCP\ILogger; use OCP\IUserManager; use PHPUnit\Framework\MockObject\MockObject; +use Psr\Log\LoggerInterface; class UserDisabledCheckCommandTest extends ALoginCommandTest { /** @var IUserManager|MockObject */ private $userManager; - /** @var ILogger|MockObject */ + /** @var LoggerInterface|MockObject */ private $logger; protected function setUp(): void { parent::setUp(); $this->userManager = $this->createMock(IUserManager::class); - $this->logger = $this->createMock(ILogger::class); + $this->logger = $this->createMock(LoggerInterface::class); $this->cmd = new UserDisabledCheckCommand( $this->userManager, diff --git a/tests/lib/Authentication/LoginCredentials/StoreTest.php b/tests/lib/Authentication/LoginCredentials/StoreTest.php index ad8a074660c..797dbc08da9 100644 --- a/tests/lib/Authentication/LoginCredentials/StoreTest.php +++ b/tests/lib/Authentication/LoginCredentials/StoreTest.php @@ -31,9 +31,9 @@ use OC\Authentication\LoginCredentials\Store; use OC\Authentication\Token\IProvider; use OC\Authentication\Token\IToken; use OCP\Authentication\Exceptions\CredentialsUnavailableException; -use OCP\ILogger; use OCP\ISession; use OCP\Session\Exceptions\SessionNotAvailableException; +use Psr\Log\LoggerInterface; use Test\TestCase; use function json_encode; @@ -45,7 +45,7 @@ class StoreTest extends TestCase { /** @var IProvider|\PHPUnit\Framework\MockObject\MockObject */ private $tokenProvider; - /** @var ILogger|\PHPUnit\Framework\MockObject\MockObject */ + /** @var LoggerInterface|\PHPUnit\Framework\MockObject\MockObject */ private $logger; /** @var Store */ @@ -56,7 +56,7 @@ class StoreTest extends TestCase { $this->session = $this->createMock(ISession::class); $this->tokenProvider = $this->createMock(IProvider::class); - $this->logger = $this->createMock(ILogger::class); + $this->logger = $this->createMock(LoggerInterface::class); $this->store = new Store($this->session, $this->logger, $this->tokenProvider); } diff --git a/tests/lib/Authentication/Token/DefaultTokenProviderTest.php b/tests/lib/Authentication/Token/DefaultTokenProviderTest.php index 00b7f0dee03..7a8915a7c14 100644 --- a/tests/lib/Authentication/Token/DefaultTokenProviderTest.php +++ b/tests/lib/Authentication/Token/DefaultTokenProviderTest.php @@ -32,8 +32,8 @@ use OC\Authentication\Token\PublicKeyToken; use OCP\AppFramework\Db\DoesNotExistException; use OCP\AppFramework\Utility\ITimeFactory; use OCP\IConfig; -use OCP\ILogger; use OCP\Security\ICrypto; +use Psr\Log\LoggerInterface; use Test\TestCase; class DefaultTokenProviderTest extends TestCase { @@ -46,7 +46,7 @@ class DefaultTokenProviderTest extends TestCase { private $crypto; /** @var IConfig|\PHPUnit\Framework\MockObject\MockObject */ private $config; - /** @var ILogger|\PHPUnit\Framework\MockObject\MockObject */ + /** @var LoggerInterface|\PHPUnit\Framework\MockObject\MockObject */ private $logger; /** @var ITimeFactory|\PHPUnit\Framework\MockObject\MockObject */ private $timeFactory; @@ -59,7 +59,7 @@ class DefaultTokenProviderTest extends TestCase { $this->mapper = $this->createMock(DefaultTokenMapper::class); $this->crypto = $this->createMock(ICrypto::class); $this->config = $this->createMock(IConfig::class); - $this->logger = $this->createMock(ILogger::class); + $this->logger = $this->createMock(LoggerInterface::class); $this->timeFactory = $this->createMock(ITimeFactory::class); $this->time = 1313131; $this->timeFactory->expects($this->any()) diff --git a/tests/lib/Authentication/Token/PublicKeyTokenProviderTest.php b/tests/lib/Authentication/Token/PublicKeyTokenProviderTest.php index a815025a509..04e0fdb527e 100644 --- a/tests/lib/Authentication/Token/PublicKeyTokenProviderTest.php +++ b/tests/lib/Authentication/Token/PublicKeyTokenProviderTest.php @@ -33,8 +33,8 @@ use OC\Authentication\Token\PublicKeyTokenProvider; use OCP\AppFramework\Db\DoesNotExistException; use OCP\AppFramework\Utility\ITimeFactory; use OCP\IConfig; -use OCP\ILogger; use OCP\Security\ICrypto; +use Psr\Log\LoggerInterface; use Test\TestCase; class PublicKeyTokenProviderTest extends TestCase { @@ -47,7 +47,7 @@ class PublicKeyTokenProviderTest extends TestCase { private $crypto; /** @var IConfig|\PHPUnit\Framework\MockObject\MockObject */ private $config; - /** @var ILogger|\PHPUnit\Framework\MockObject\MockObject */ + /** @var LoggerInterface|\PHPUnit\Framework\MockObject\MockObject */ private $logger; /** @var ITimeFactory|\PHPUnit\Framework\MockObject\MockObject */ private $timeFactory; @@ -67,7 +67,7 @@ class PublicKeyTokenProviderTest extends TestCase { ['secret', '', '1f4h9s'], ['openssl', [], []], ]); - $this->logger = $this->createMock(ILogger::class); + $this->logger = $this->createMock(LoggerInterface::class); $this->timeFactory = $this->createMock(ITimeFactory::class); $this->time = 1313131; $this->timeFactory->method('getTime') diff --git a/tests/lib/Authentication/Token/RemoteWipeTest.php b/tests/lib/Authentication/Token/RemoteWipeTest.php index 1338931ac72..e2506562dd4 100644 --- a/tests/lib/Authentication/Token/RemoteWipeTest.php +++ b/tests/lib/Authentication/Token/RemoteWipeTest.php @@ -34,9 +34,9 @@ use OC\Authentication\Token\IToken; use OC\Authentication\Token\IWipeableToken; use OC\Authentication\Token\RemoteWipe; use OCP\EventDispatcher\IEventDispatcher; -use OCP\ILogger; use OCP\IUser; use PHPUnit\Framework\MockObject\MockObject; +use Psr\Log\LoggerInterface; use Test\TestCase; class RemoteWipeTest extends TestCase { @@ -47,7 +47,7 @@ class RemoteWipeTest extends TestCase { /** @var IEventDispatcher|MockObject */ private $eventDispatcher; - /** @var ILogger|MockObject */ + /** @var LoggerInterface|MockObject */ private $logger; /** @var RemoteWipe */ @@ -58,7 +58,7 @@ class RemoteWipeTest extends TestCase { $this->tokenProvider = $this->createMock(IProvider::class); $this->eventDispatcher = $this->createMock(IEventDispatcher::class); - $this->logger = $this->createMock(ILogger::class); + $this->logger = $this->createMock(LoggerInterface::class); $this->remoteWipe = new RemoteWipe( $this->tokenProvider, diff --git a/tests/lib/Authentication/TwoFactorAuth/ManagerTest.php b/tests/lib/Authentication/TwoFactorAuth/ManagerTest.php index 051f2936ad7..c93b625f61a 100644 --- a/tests/lib/Authentication/TwoFactorAuth/ManagerTest.php +++ b/tests/lib/Authentication/TwoFactorAuth/ManagerTest.php @@ -34,10 +34,10 @@ use OCP\Authentication\TwoFactorAuth\IActivatableAtLogin; use OCP\Authentication\TwoFactorAuth\IProvider; use OCP\Authentication\TwoFactorAuth\IRegistry; use OCP\IConfig; -use OCP\ILogger; use OCP\ISession; use OCP\IUser; use PHPUnit\Framework\MockObject\MockObject; +use Psr\Log\LoggerInterface; use function reset; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Test\TestCase; @@ -68,7 +68,7 @@ class ManagerTest extends TestCase { /** @var IManager|MockObject */ private $activityManager; - /** @var ILogger|MockObject */ + /** @var LoggerInterface|MockObject */ private $logger; /** @var IProvider|MockObject */ @@ -96,7 +96,7 @@ class ManagerTest extends TestCase { $this->session = $this->createMock(ISession::class); $this->config = $this->createMock(IConfig::class); $this->activityManager = $this->createMock(IManager::class); - $this->logger = $this->createMock(ILogger::class); + $this->logger = $this->createMock(LoggerInterface::class); $this->tokenProvider = $this->createMock(TokenProvider::class); $this->timeFactory = $this->createMock(ITimeFactory::class); $this->eventDispatcher = $this->createMock(EventDispatcherInterface::class); -- 2.39.5