Skip to content

Commit

Permalink
Fix psalm
Browse files Browse the repository at this point in the history
Signed-off-by: sagargurung1001@gmail.com <sagargurung1001@gmail.com>
  • Loading branch information
SagarGi committed Jun 21, 2024
1 parent 23c7858 commit 2e6fd3c
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/Controller/ConfigController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
4 changes: 3 additions & 1 deletion lib/Service/OpenProjectAPIService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
}
}
}
Expand All @@ -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;
}
}
Expand Down
2 changes: 2 additions & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
<referencedClass name="Helmich\JsonAssert\JsonAssertions" />
<!-- these classes belong to the event app, which isn't compulsory, so might not exist while running psalm -->
<referencedClass name="OCP\App\Events\AppEnableEvent" />
<referencedClass name="OCA\AdminAudit\AuditLogger" />

</errorLevel>
</UndefinedClass>
<TooFewArguments>
Expand Down
11 changes: 8 additions & 3 deletions tests/lib/Service/OpenProjectAPIServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
);
}

Expand Down Expand Up @@ -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('', '', []);
Expand Down Expand Up @@ -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('', '', []);
Expand Down

0 comments on commit 2e6fd3c

Please sign in to comment.