refactor(security): replace generic event with severity enum

Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
2026-08-05 23:59:49 -04:00
parent 3f9c2500d9
commit 84eb0e2c21
27 changed files with 80 additions and 247 deletions
-1
View File
@@ -23,7 +23,6 @@ use KTXC\Security\Event\FirewallRuleRemovedEvent;
use KTXC\Security\Event\FirewallSettingsUpdatedEvent; use KTXC\Security\Event\FirewallSettingsUpdatedEvent;
use KTXC\Security\Event\RateLimitExceededEvent; use KTXC\Security\Event\RateLimitExceededEvent;
use KTXC\Security\Event\SuspiciousActivityEvent; use KTXC\Security\Event\SuspiciousActivityEvent;
use KTXC\Security\Event\SecurityEvent;
use KTXF\Event\DeliveryMode; use KTXF\Event\DeliveryMode;
use KTXF\Event\EventListenerRegistrarInterface; use KTXF\Event\EventListenerRegistrarInterface;
use KTXF\Module\ModuleBrowserInterface; use KTXF\Module\ModuleBrowserInterface;
@@ -81,8 +81,8 @@ final class AccessDeniedEvent extends Event implements SecurityRequestEventInter
return $this->reason; return $this->reason;
} }
public function getSeverity(): int public function getSeverity(): SecurityEventSeverity
{ {
return SecurityEvent::SEVERITY_WARNING; return SecurityEventSeverity::WARNING;
} }
} }
@@ -32,8 +32,8 @@ final class AuthenticationFailedEvent extends Event implements SecurityEventInte
return $this->reason; return $this->reason;
} }
public function getSeverity(): int public function getSeverity(): SecurityEventSeverity
{ {
return SecurityEvent::SEVERITY_WARNING; return SecurityEventSeverity::WARNING;
} }
} }
@@ -63,8 +63,8 @@ final class AuthenticationSucceededEvent extends Event implements SecurityReques
return null; return null;
} }
public function getSeverity(): int public function getSeverity(): SecurityEventSeverity
{ {
return SecurityEvent::SEVERITY_INFO; return SecurityEventSeverity::INFO;
} }
} }
@@ -84,8 +84,8 @@ final class BruteForceDetectedEvent extends Event implements SecurityRequestEven
return $this->reason; return $this->reason;
} }
public function getSeverity(): int public function getSeverity(): SecurityEventSeverity
{ {
return SecurityEvent::SEVERITY_CRITICAL; return SecurityEventSeverity::CRITICAL;
} }
} }
@@ -59,8 +59,8 @@ final class DeviceBlockedEvent extends Event implements SecurityRequestEventInte
return $this->reason; return $this->reason;
} }
public function getSeverity(): int public function getSeverity(): SecurityEventSeverity
{ {
return SecurityEvent::SEVERITY_CRITICAL; return SecurityEventSeverity::CRITICAL;
} }
} }
+2 -2
View File
@@ -8,7 +8,7 @@ use KTXF\Event\Event;
abstract class FirewallIpEvent extends Event implements SecurityRequestEventInterface abstract class FirewallIpEvent extends Event implements SecurityRequestEventInterface
{ {
protected const SEVERITY = SecurityEvent::SEVERITY_INFO; protected const SecurityEventSeverity SEVERITY = SecurityEventSeverity::INFO;
final public function __construct( final public function __construct(
private readonly string $ipAddress, private readonly string $ipAddress,
@@ -61,7 +61,7 @@ abstract class FirewallIpEvent extends Event implements SecurityRequestEventInte
return $this->reason; return $this->reason;
} }
public function getSeverity(): int public function getSeverity(): SecurityEventSeverity
{ {
return static::SEVERITY; return static::SEVERITY;
} }
@@ -151,8 +151,8 @@ abstract class FirewallRuleEvent extends Event implements SecurityEventInterface
return $this->reason; return $this->reason;
} }
public function getSeverity(): int public function getSeverity(): SecurityEventSeverity
{ {
return SecurityEvent::SEVERITY_INFO; return SecurityEventSeverity::INFO;
} }
} }
@@ -69,8 +69,8 @@ final class FirewallSettingsUpdatedEvent extends Event implements SecurityEventI
return $this->changeReason; return $this->changeReason;
} }
public function getSeverity(): int public function getSeverity(): SecurityEventSeverity
{ {
return SecurityEvent::SEVERITY_INFO; return SecurityEventSeverity::INFO;
} }
} }
+1 -1
View File
@@ -6,5 +6,5 @@ namespace KTXC\Security\Event;
final class IpBlockedEvent extends FirewallIpEvent final class IpBlockedEvent extends FirewallIpEvent
{ {
protected const SEVERITY = SecurityEvent::SEVERITY_CRITICAL; protected const SecurityEventSeverity SEVERITY = SecurityEventSeverity::CRITICAL;
} }
@@ -97,8 +97,8 @@ final class RateLimitExceededEvent extends Event implements SecurityRequestEvent
return $this->reason; return $this->reason;
} }
public function getSeverity(): int public function getSeverity(): SecurityEventSeverity
{ {
return SecurityEvent::SEVERITY_ERROR; return SecurityEventSeverity::ERROR;
} }
} }
-141
View File
@@ -1,141 +0,0 @@
<?php
declare(strict_types=1);
namespace KTXC\Security\Event;
use KTXF\Event\Event;
/**
* Security-specific event for authentication and access control events
*/
final class SecurityEvent extends Event implements SecurityRequestEventInterface
{
// Event names
public const AUTH_LOGOUT = 'security.auth.logout';
public const TOKEN_REFRESH = 'security.token.refresh';
public const TOKEN_REVOKED = 'security.token.revoked';
public const ACCESS_GRANTED = 'security.access.granted';
// Severity levels
public const SEVERITY_DEBUG = 0;
public const SEVERITY_INFO = 1;
public const SEVERITY_WARNING = 2;
public const SEVERITY_ERROR = 3;
public const SEVERITY_CRITICAL = 4;
private readonly int $severity;
public function __construct(
string $name,
array $data = [],
?string $tenantId = null,
?string $identityId = null,
private readonly ?string $ipAddress = null,
private readonly ?string $deviceFingerprint = null,
private readonly ?string $userAgent = null,
private readonly ?string $requestPath = null,
private readonly ?string $requestMethod = null,
private readonly ?string $userId = null,
private readonly ?string $reason = null,
?int $severity = null,
) {
parent::__construct($name, $data, $tenantId, $identityId);
$this->severity = $severity ?? self::getSeverityForEvent($name);
}
/**
* Create a security event with common parameters
*/
public static function create(
string $name,
?string $ipAddress = null,
?string $deviceFingerprint = null,
array $data = [],
?string $tenantId = null,
?string $identityId = null,
?string $userAgent = null,
?string $requestPath = null,
?string $requestMethod = null,
?string $userId = null,
?string $reason = null,
?int $severity = null,
): self {
return new self(
$name,
$data,
$tenantId,
$identityId,
$ipAddress,
$deviceFingerprint,
$userAgent,
$requestPath,
$requestMethod,
$userId,
$reason,
$severity,
);
}
/**
* Get default severity for event types
*/
private static function getSeverityForEvent(string $eventName): int
{
return match ($eventName) {
self::ACCESS_GRANTED,
self::TOKEN_REFRESH => self::SEVERITY_INFO,
self::AUTH_LOGOUT,
self::TOKEN_REVOKED => self::SEVERITY_WARNING,
default => self::SEVERITY_INFO,
};
}
// Getters and setters
public function getIpAddress(): ?string
{
return $this->ipAddress;
}
public function getDeviceFingerprint(): ?string
{
return $this->deviceFingerprint;
}
public function getUserAgent(): ?string
{
return $this->userAgent;
}
public function getRequestPath(): ?string
{
return $this->requestPath;
}
public function getRequestMethod(): ?string
{
return $this->requestMethod;
}
public function getUserId(): ?string
{
return $this->userId;
}
public function getReason(): ?string
{
return $this->reason;
}
public function getSeverity(): int
{
return $this->severity;
}
}
@@ -22,5 +22,5 @@ interface SecurityEventInterface
public function getReason(): ?string; public function getReason(): ?string;
public function getSeverity(): int; public function getSeverity(): SecurityEventSeverity;
} }
@@ -0,0 +1,14 @@
<?php
declare(strict_types=1);
namespace KTXC\Security\Event;
enum SecurityEventSeverity: int
{
case DEBUG = 0;
case INFO = 1;
case WARNING = 2;
case ERROR = 3;
case CRITICAL = 4;
}
@@ -93,8 +93,8 @@ final class SuspiciousActivityEvent extends Event implements SecurityRequestEven
return $this->reason; return $this->reason;
} }
public function getSeverity(): int public function getSeverity(): SecurityEventSeverity
{ {
return SecurityEvent::SEVERITY_ERROR; return SecurityEventSeverity::ERROR;
} }
} }
+1 -3
View File
@@ -22,7 +22,6 @@ use KTXC\Security\Event\FirewallRuleRemovedEvent;
use KTXC\Security\Event\FirewallSettingsUpdatedEvent; use KTXC\Security\Event\FirewallSettingsUpdatedEvent;
use KTXC\Security\Event\RateLimitExceededEvent; use KTXC\Security\Event\RateLimitExceededEvent;
use KTXC\Security\Event\SuspiciousActivityEvent; use KTXC\Security\Event\SuspiciousActivityEvent;
use KTXC\Security\Event\SecurityEvent;
use KTXC\Security\Event\SecurityEventInterface; use KTXC\Security\Event\SecurityEventInterface;
use KTXC\Security\Event\SecurityRequestEventInterface; use KTXC\Security\Event\SecurityRequestEventInterface;
use KTXF\Event\EventDispatcherInterface; use KTXF\Event\EventDispatcherInterface;
@@ -311,8 +310,7 @@ class FirewallService
private function mapEventToResult(SecurityEventInterface $event): string private function mapEventToResult(SecurityEventInterface $event): string
{ {
return match ($event->getName()) { return match ($event->getName()) {
AuthenticationSucceededEvent::class, AuthenticationSucceededEvent::class => FirewallLogObject::RESULT_ALLOWED,
SecurityEvent::ACCESS_GRANTED => FirewallLogObject::RESULT_ALLOWED,
FirewallRuleCreatedEvent::class, FirewallRuleCreatedEvent::class,
FirewallRuleExtendedEvent::class, FirewallRuleExtendedEvent::class,
FirewallRuleEnabledEvent::class, FirewallRuleEnabledEvent::class,
@@ -6,7 +6,7 @@ namespace KTXT\Unit\Event;
use KTXC\Models\Firewall\FirewallRuleObject; use KTXC\Models\Firewall\FirewallRuleObject;
use KTXC\Security\Event\AccessDeniedEvent; use KTXC\Security\Event\AccessDeniedEvent;
use KTXC\Security\Event\SecurityEvent; use KTXC\Security\Event\SecurityEventSeverity;
use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\Attributes\TestDox; use PHPUnit\Framework\Attributes\TestDox;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
@@ -35,7 +35,7 @@ final class AccessDeniedEventTest extends TestCase
self::assertSame('Blocked by policy', $event->getReason()); self::assertSame('Blocked by policy', $event->getReason());
self::assertSame('tenant-a', $event->getTenantId()); self::assertSame('tenant-a', $event->getTenantId());
self::assertSame('identity-a', $event->getIdentityId()); self::assertSame('identity-a', $event->getIdentityId());
self::assertSame(SecurityEvent::SEVERITY_WARNING, $event->getSeverity()); self::assertSame(SecurityEventSeverity::WARNING, $event->getSeverity());
} }
#[Test] #[Test]
@@ -5,7 +5,7 @@ declare(strict_types=1);
namespace KTXT\Unit\Event; namespace KTXT\Unit\Event;
use KTXC\Security\Event\AuthenticationFailedEvent; use KTXC\Security\Event\AuthenticationFailedEvent;
use KTXC\Security\Event\SecurityEvent; use KTXC\Security\Event\SecurityEventSeverity;
use KTXC\Security\Event\SecurityRequestEventInterface; use KTXC\Security\Event\SecurityRequestEventInterface;
use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\Attributes\TestDox; use PHPUnit\Framework\Attributes\TestDox;
@@ -29,7 +29,7 @@ final class AuthenticationFailedEventTest extends TestCase
self::assertSame('Invalid credentials', $event->getReason()); self::assertSame('Invalid credentials', $event->getReason());
self::assertSame('tenant-a', $event->getTenantId()); self::assertSame('tenant-a', $event->getTenantId());
self::assertSame('identity-a', $event->getIdentityId()); self::assertSame('identity-a', $event->getIdentityId());
self::assertSame(SecurityEvent::SEVERITY_WARNING, $event->getSeverity()); self::assertSame(SecurityEventSeverity::WARNING, $event->getSeverity());
self::assertNotInstanceOf(SecurityRequestEventInterface::class, $event); self::assertNotInstanceOf(SecurityRequestEventInterface::class, $event);
} }
} }
@@ -5,7 +5,7 @@ declare(strict_types=1);
namespace KTXT\Unit\Event; namespace KTXT\Unit\Event;
use KTXC\Security\Event\AuthenticationSucceededEvent; use KTXC\Security\Event\AuthenticationSucceededEvent;
use KTXC\Security\Event\SecurityEvent; use KTXC\Security\Event\SecurityEventSeverity;
use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\Attributes\TestDox; use PHPUnit\Framework\Attributes\TestDox;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
@@ -29,7 +29,7 @@ final class AuthenticationSucceededEventTest extends TestCase
self::assertSame('tenant-a', $event->getTenantId()); self::assertSame('tenant-a', $event->getTenantId());
self::assertSame('device-a', $event->getDeviceFingerprint()); self::assertSame('device-a', $event->getDeviceFingerprint());
self::assertSame(['userId' => 'user-a'], $event->getData()); self::assertSame(['userId' => 'user-a'], $event->getData());
self::assertSame(SecurityEvent::SEVERITY_INFO, $event->getSeverity()); self::assertSame(SecurityEventSeverity::INFO, $event->getSeverity());
} }
#[Test] #[Test]
@@ -5,7 +5,7 @@ declare(strict_types=1);
namespace KTXT\Unit\Event; namespace KTXT\Unit\Event;
use KTXC\Security\Event\BruteForceDetectedEvent; use KTXC\Security\Event\BruteForceDetectedEvent;
use KTXC\Security\Event\SecurityEvent; use KTXC\Security\Event\SecurityEventSeverity;
use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\Attributes\TestDox; use PHPUnit\Framework\Attributes\TestDox;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
@@ -33,7 +33,7 @@ final class BruteForceDetectedEventTest extends TestCase
['failureCount' => 5, 'windowSeconds' => 300], ['failureCount' => 5, 'windowSeconds' => 300],
$event->getData(), $event->getData(),
); );
self::assertSame(SecurityEvent::SEVERITY_CRITICAL, $event->getSeverity()); self::assertSame(SecurityEventSeverity::CRITICAL, $event->getSeverity());
} }
#[Test] #[Test]
@@ -8,7 +8,7 @@ use KTXC\Security\Event\DeviceBlockedEvent;
use KTXC\Security\Event\FirewallSettingsUpdatedEvent; use KTXC\Security\Event\FirewallSettingsUpdatedEvent;
use KTXC\Security\Event\IpAllowedEvent; use KTXC\Security\Event\IpAllowedEvent;
use KTXC\Security\Event\IpBlockedEvent; use KTXC\Security\Event\IpBlockedEvent;
use KTXC\Security\Event\SecurityEvent; use KTXC\Security\Event\SecurityEventSeverity;
use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\Attributes\TestDox; use PHPUnit\Framework\Attributes\TestDox;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
@@ -26,13 +26,13 @@ final class FirewallPolicyEventTest extends TestCase
self::assertSame(IpBlockedEvent::class, $blocked->getName()); self::assertSame(IpBlockedEvent::class, $blocked->getName());
self::assertSame('203.0.113.10', $blocked->getIpAddress()); self::assertSame('203.0.113.10', $blocked->getIpAddress());
self::assertSame('Repeated abuse', $blocked->getReason()); self::assertSame('Repeated abuse', $blocked->getReason());
self::assertSame(SecurityEvent::SEVERITY_CRITICAL, $blocked->getSeverity()); self::assertSame(SecurityEventSeverity::CRITICAL, $blocked->getSeverity());
self::assertSame(IpAllowedEvent::class, $allowed->getName()); self::assertSame(IpAllowedEvent::class, $allowed->getName());
self::assertSame('203.0.113.11', $allowed->getIpAddress()); self::assertSame('203.0.113.11', $allowed->getIpAddress());
self::assertSame(SecurityEvent::SEVERITY_INFO, $allowed->getSeverity()); self::assertSame(SecurityEventSeverity::INFO, $allowed->getSeverity());
self::assertSame(DeviceBlockedEvent::class, $device->getName()); self::assertSame(DeviceBlockedEvent::class, $device->getName());
self::assertSame('device-a', $device->getDeviceFingerprint()); self::assertSame('device-a', $device->getDeviceFingerprint());
self::assertSame(SecurityEvent::SEVERITY_CRITICAL, $device->getSeverity()); self::assertSame(SecurityEventSeverity::CRITICAL, $device->getSeverity());
} }
#[Test] #[Test]
@@ -54,7 +54,7 @@ final class FirewallPolicyEventTest extends TestCase
self::assertSame('tenant-a', $event->getTenantId()); self::assertSame('tenant-a', $event->getTenantId());
self::assertSame('operator-a', $event->getIdentityId()); self::assertSame('operator-a', $event->getIdentityId());
self::assertSame('manual', $event->getChangeOrigin()); self::assertSame('manual', $event->getChangeOrigin());
self::assertSame(SecurityEvent::SEVERITY_INFO, $event->getSeverity()); self::assertSame(SecurityEventSeverity::INFO, $event->getSeverity());
} }
#[Test] #[Test]
@@ -10,7 +10,7 @@ use KTXC\Security\Event\FirewallRuleDisabledEvent;
use KTXC\Security\Event\FirewallRuleEnabledEvent; use KTXC\Security\Event\FirewallRuleEnabledEvent;
use KTXC\Security\Event\FirewallRuleExtendedEvent; use KTXC\Security\Event\FirewallRuleExtendedEvent;
use KTXC\Security\Event\FirewallRuleRemovedEvent; use KTXC\Security\Event\FirewallRuleRemovedEvent;
use KTXC\Security\Event\SecurityEvent; use KTXC\Security\Event\SecurityEventSeverity;
use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\Attributes\TestDox; use PHPUnit\Framework\Attributes\TestDox;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
@@ -54,7 +54,7 @@ final class FirewallRuleEventTest extends TestCase
self::assertSame('operator-a', $event->getIdentityId()); self::assertSame('operator-a', $event->getIdentityId());
self::assertSame(5, $event->get('failureCount')); self::assertSame(5, $event->get('failureCount'));
self::assertSame('Continue monitoring', $event->get('changeReason')); self::assertSame('Continue monitoring', $event->get('changeReason'));
self::assertSame(SecurityEvent::SEVERITY_INFO, $event->getSeverity()); self::assertSame(SecurityEventSeverity::INFO, $event->getSeverity());
} }
#[Test] #[Test]
@@ -5,7 +5,7 @@ declare(strict_types=1);
namespace KTXT\Unit\Event; namespace KTXT\Unit\Event;
use KTXC\Security\Event\RateLimitExceededEvent; use KTXC\Security\Event\RateLimitExceededEvent;
use KTXC\Security\Event\SecurityEvent; use KTXC\Security\Event\SecurityEventSeverity;
use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\Attributes\TestDox; use PHPUnit\Framework\Attributes\TestDox;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
@@ -32,7 +32,7 @@ final class RateLimitExceededEventTest extends TestCase
self::assertSame('/login', $event->getRequestPath()); self::assertSame('/login', $event->getRequestPath());
self::assertSame('tenant-a', $event->getTenantId()); self::assertSame('tenant-a', $event->getTenantId());
self::assertSame('101 requests in 60 seconds', $event->getReason()); self::assertSame('101 requests in 60 seconds', $event->getReason());
self::assertSame(SecurityEvent::SEVERITY_ERROR, $event->getSeverity()); self::assertSame(SecurityEventSeverity::ERROR, $event->getSeverity());
} }
#[Test] #[Test]
@@ -0,0 +1,24 @@
<?php
declare(strict_types=1);
namespace KTXT\Unit\Event;
use KTXC\Security\Event\SecurityEventSeverity;
use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\Attributes\TestDox;
use PHPUnit\Framework\TestCase;
final class SecurityEventSeverityTest extends TestCase
{
#[Test]
#[TestDox('Security severity levels expose stable numeric values')]
public function exposesStableNumericValues(): void
{
self::assertSame(0, SecurityEventSeverity::DEBUG->value);
self::assertSame(1, SecurityEventSeverity::INFO->value);
self::assertSame(2, SecurityEventSeverity::WARNING->value);
self::assertSame(3, SecurityEventSeverity::ERROR->value);
self::assertSame(4, SecurityEventSeverity::CRITICAL->value);
}
}
@@ -1,60 +0,0 @@
<?php
declare(strict_types=1);
namespace KTXT\Unit\Event;
use KTXC\Security\Event\SecurityEvent;
use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\Attributes\TestDox;
use PHPUnit\Framework\TestCase;
final class SecurityEventTest extends TestCase
{
#[Test]
#[TestDox('Direct construction applies the event type default severity')]
public function appliesDefaultSeverityDuringConstruction(): void
{
self::assertSame(
SecurityEvent::SEVERITY_WARNING,
(new SecurityEvent(SecurityEvent::AUTH_LOGOUT))->getSeverity(),
);
self::assertSame(
SecurityEvent::SEVERITY_INFO,
(new SecurityEvent(SecurityEvent::ACCESS_GRANTED))->getSeverity(),
);
}
#[Test]
#[TestDox('Construction can override the event type default severity')]
public function allowsSeverityOverride(): void
{
$event = new SecurityEvent(
SecurityEvent::AUTH_LOGOUT,
severity: SecurityEvent::SEVERITY_CRITICAL,
);
self::assertSame(SecurityEvent::SEVERITY_CRITICAL, $event->getSeverity());
}
#[Test]
#[TestDox('Event state exposes no mutation methods')]
public function exposesNoMutationMethods(): void
{
foreach ([
'set',
'setTenantId',
'setIdentityId',
'setIpAddress',
'setDeviceFingerprint',
'setUserAgent',
'setRequestPath',
'setRequestMethod',
'setUserId',
'setReason',
'setSeverity',
] as $method) {
self::assertFalse(method_exists(SecurityEvent::class, $method));
}
}
}
@@ -4,7 +4,7 @@ declare(strict_types=1);
namespace KTXT\Unit\Event; namespace KTXT\Unit\Event;
use KTXC\Security\Event\SecurityEvent; use KTXC\Security\Event\SecurityEventSeverity;
use KTXC\Security\Event\SuspiciousActivityEvent; use KTXC\Security\Event\SuspiciousActivityEvent;
use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\Attributes\TestDox; use PHPUnit\Framework\Attributes\TestDox;
@@ -43,7 +43,7 @@ final class SuspiciousActivityEventTest extends TestCase
self::assertSame('POST', $event->getRequestMethod()); self::assertSame('POST', $event->getRequestMethod());
self::assertSame('user-a', $event->getUserId()); self::assertSame('user-a', $event->getUserId());
self::assertSame('Matched a blocked payload signature', $event->getReason()); self::assertSame('Matched a blocked payload signature', $event->getReason());
self::assertSame(SecurityEvent::SEVERITY_ERROR, $event->getSeverity()); self::assertSame(SecurityEventSeverity::ERROR, $event->getSeverity());
} }
#[Test] #[Test]
-1
View File
@@ -28,7 +28,6 @@ use KTXC\Security\Event\FirewallRuleRemovedEvent;
use KTXC\Security\Event\FirewallSettingsUpdatedEvent; use KTXC\Security\Event\FirewallSettingsUpdatedEvent;
use KTXC\Security\Event\RateLimitExceededEvent; use KTXC\Security\Event\RateLimitExceededEvent;
use KTXC\Security\Event\SuspiciousActivityEvent; use KTXC\Security\Event\SuspiciousActivityEvent;
use KTXC\Security\Event\SecurityEvent;
use KTXF\Event\DeliveryMode; use KTXF\Event\DeliveryMode;
use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\Attributes\TestDox; use PHPUnit\Framework\Attributes\TestDox;