From 2e6fd3c9d1de02f2275cada91bc2afdbd3be6d67 Mon Sep 17 00:00:00 2001 From: "sagargurung1001@gmail.com" Date: Fri, 21 Jun 2024 11:52:17 +0545 Subject: [PATCH] Fix psalm Signed-off-by: sagargurung1001@gmail.com --- lib/Controller/ConfigController.php | 2 +- lib/Service/OpenProjectAPIService.php | 4 +++- psalm.xml | 2 ++ tests/lib/Service/OpenProjectAPIServiceTest.php | 11 ++++++++--- 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/lib/Controller/ConfigController.php b/lib/Controller/ConfigController.php index 79ae35a8d..63f468886 100755 --- a/lib/Controller/ConfigController.php +++ b/lib/Controller/ConfigController.php @@ -224,7 +224,7 @@ private function setIntegrationConfig(array $values): array { $appPassword = $this->openprojectAPIService->generateAppPasswordTokenForUser(); if($isAppPasswordBeingReplaced) { $this->openprojectAPIService->logToAuditFile( - "Application password for user 'OpenProject has been replaced' in application " . Application::APP_ID + "Application password for user 'OpenProject has been replaced' with new password in application " . Application::APP_ID ); } else { $this->openprojectAPIService->logToAuditFile( diff --git a/lib/Service/OpenProjectAPIService.php b/lib/Service/OpenProjectAPIService.php index e13ea282b..fac7c4156 100644 --- a/lib/Service/OpenProjectAPIService.php +++ b/lib/Service/OpenProjectAPIService.php @@ -1269,6 +1269,9 @@ public function deleteAppPassword(): void { foreach ($tokens as $token) { if ($token->getName() === Application::OPEN_PROJECT_ENTITIES_NAME) { $this->tokenProvider->invalidateTokenById(Application::OPEN_PROJECT_ENTITIES_NAME, $token->getId()); + $this->logToAuditFile( + "Application password for user 'OpenProject has been deleted' in application " . Application::APP_ID + ); } } } @@ -1283,7 +1286,6 @@ public function hasAppPassword(): bool { $tokens = $this->tokenProvider->getTokenByUser(Application::OPEN_PROJECT_ENTITIES_NAME); foreach ($tokens as $token) { if ($token->getName() === Application::OPEN_PROJECT_ENTITIES_NAME) { - $this->logger->info('Application password for user "OpenProject" has been deleted.', ['app' => $this->appName]); return true; } } diff --git a/psalm.xml b/psalm.xml index c1ebfc86c..926a320fc 100644 --- a/psalm.xml +++ b/psalm.xml @@ -38,6 +38,8 @@ + + diff --git a/tests/lib/Service/OpenProjectAPIServiceTest.php b/tests/lib/Service/OpenProjectAPIServiceTest.php index 108815a18..73e5cd9d5 100644 --- a/tests/lib/Service/OpenProjectAPIServiceTest.php +++ b/tests/lib/Service/OpenProjectAPIServiceTest.php @@ -44,6 +44,7 @@ use OCP\IURLGenerator; use OCP\IUser; use OCP\IUserManager; +use OCP\Log\ILogFactory; use OCP\Security\IRemoteHostValidator; use OCP\Security\ISecureRandom; use PhpPact\Consumer\InteractionBuilder; @@ -708,7 +709,8 @@ private function getOpenProjectAPIService( $this->createMock(ISecureRandom::class), $this->createMock(IEventDispatcher::class), $this->createMock(ISubAdmin::class), - $this->createMock(IDBConnection::class) + $this->createMock(IDBConnection::class), + $this->createMock(ILogFactory::class) ); } @@ -1926,7 +1928,9 @@ public function testRequestConnectException( $this->createMock(ISecureRandom::class), $this->createMock(IEventDispatcher::class), $this->createMock(ISubAdmin::class), - $this->createMock(IDBConnection::class) + $this->createMock(IDBConnection::class), + $this->createMock(ILogFactory::class) + ); $response = $service->request('', '', []); @@ -1995,7 +1999,8 @@ public function testRequestClientServerException( $this->createMock(ISecureRandom::class), $this->createMock(IEventDispatcher::class), $this->createMock(ISubAdmin::class), - $this->createMock(IDBConnection::class) + $this->createMock(IDBConnection::class), + $this->createMock(ILogFactory::class) ); $response = $service->request('', '', []);