refactor(security): add typed authentication-success event
Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
@@ -12,6 +12,7 @@ use KTXC\Models\Firewall\FirewallLogObject;
|
||||
use KTXC\Models\Tenant\TenantConfiguration;
|
||||
use KTXC\Security\Event\AccessDeniedEvent;
|
||||
use KTXC\Security\Event\AuthenticationFailedEvent;
|
||||
use KTXC\Security\Event\AuthenticationSucceededEvent;
|
||||
use KTXC\Security\Event\BruteForceDetectedEvent;
|
||||
use KTXC\Security\Event\RateLimitExceededEvent;
|
||||
use KTXC\Security\Event\SuspiciousActivityEvent;
|
||||
@@ -307,6 +308,26 @@ class FirewallServiceTest extends TestCase
|
||||
$this->service->logSecurityEvent($event);
|
||||
}
|
||||
|
||||
#[TestDox('Successful authentication maps to an allowed access log')]
|
||||
public function testAuthenticationSuccessAudit(): void
|
||||
{
|
||||
$this->store->expects($this->once())
|
||||
->method('createLog')
|
||||
->with(self::callback(static function (FirewallLogObject $log): bool {
|
||||
return $log->getEventType() === FirewallLogObject::EVENT_ACCESS_CHECK
|
||||
&& $log->getResult() === FirewallLogObject::RESULT_ALLOWED
|
||||
&& $log->getIpAddress() === '203.0.113.10'
|
||||
&& $log->getIdentityId() === 'user-a';
|
||||
}))
|
||||
->willReturnArgument(0);
|
||||
|
||||
$this->service->logSecurityEvent(new AuthenticationSucceededEvent(
|
||||
'203.0.113.10',
|
||||
'user-a',
|
||||
'tenant-a',
|
||||
));
|
||||
}
|
||||
|
||||
#[TestDox('Suspicious-activity events retain request and detection metadata')]
|
||||
public function testSuspiciousActivityAudit(): void
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user