feat(helpdesk): enable oauth2 token flow and tenant-scoped cache

This commit is contained in:
2026-04-02 21:46:01 +02:00
parent a37486c0e3
commit 8de67fa882
9 changed files with 267 additions and 21 deletions

View File

@@ -2,7 +2,9 @@
namespace MintyPHP\Tests\Module\Helpdesk\Service;
use MintyPHP\Http\SessionStoreInterface;
use MintyPHP\Module\Helpdesk\Service\BcODataGateway;
use MintyPHP\Module\Helpdesk\Service\HelpdeskOAuthTokenService;
use MintyPHP\Module\Helpdesk\Service\HelpdeskSettingsGateway;
use PHPUnit\Framework\TestCase;
@@ -21,7 +23,13 @@ class BcODataGatewayTest extends TestCase
$settings->method('getBasicUser')->willReturn('testuser');
$settings->method('getBasicPassword')->willReturn('testpass');
return new BcODataGateway($settings);
$oauthTokenService = $this->createMock(HelpdeskOAuthTokenService::class);
$sessionStore = $this->createMock(SessionStoreInterface::class);
$sessionStore->method('all')->willReturn([
'current_tenant' => ['id' => 1],
]);
return new BcODataGateway($settings, $oauthTokenService, $sessionStore);
}
public function testSearchCustomersReturnsEmptyForEmptyQuery(): void

View File

@@ -55,4 +55,16 @@ class HelpdeskOAuthTokenServiceTest extends TestCase
$service = new HelpdeskOAuthTokenService($settings, $tokenRepo);
$service->getAccessToken(1);
}
public function testDoesNotQueryCacheForInvalidTenantId(): void
{
$settings = $this->createMock(HelpdeskSettingsGateway::class);
$settings->method('getAuthMode')->willReturn(HelpdeskSettingsGateway::AUTH_MODE_OAUTH2);
$tokenRepo = $this->createMock(HelpdeskTokenRepository::class);
$tokenRepo->expects($this->never())->method('findValidToken');
$service = new HelpdeskOAuthTokenService($settings, $tokenRepo);
$this->assertNull($service->getAccessToken(0));
}
}