mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-07-01 14:04:30 +02:00
Use a enum for level in LogEntries
This commit is contained in:
parent
4a644d8712
commit
2da7463edf
18 changed files with 322 additions and 149 deletions
|
@ -42,6 +42,7 @@ declare(strict_types=1);
|
|||
namespace App\Tests\Services\LogSystem;
|
||||
|
||||
use App\Entity\LogSystem\AbstractLogEntry;
|
||||
use App\Entity\LogSystem\LogLevel;
|
||||
use App\Entity\LogSystem\UserLoginLogEntry;
|
||||
use App\Entity\LogSystem\UserLogoutLogEntry;
|
||||
use App\Services\LogSystem\EventLogger;
|
||||
|
@ -67,21 +68,21 @@ class EventLoggerTest extends WebTestCase
|
|||
{
|
||||
$event1 = new UserLoginLogEntry('127.0.0.1');
|
||||
$event2 = new UserLogoutLogEntry('127.0.0.1');
|
||||
$event2->setLevel(AbstractLogEntry::LEVEL_CRITICAL);
|
||||
$event2->setLevel(LogLevel::CRITICAL);
|
||||
|
||||
//Test without restrictions
|
||||
$this->assertTrue($this->service->shouldBeAdded($event1, 7, [], []));
|
||||
$this->assertTrue($this->service->shouldBeAdded($event1, LogLevel::DEBUG, [], []));
|
||||
|
||||
//Test minimum log level
|
||||
$this->assertFalse($this->service->shouldBeAdded($event1, 2, [], []));
|
||||
$this->assertTrue($this->service->shouldBeAdded($event2, 2, [], []));
|
||||
$this->assertFalse($this->service->shouldBeAdded($event1, LogLevel::CRITICAL, [], []));
|
||||
$this->assertTrue($this->service->shouldBeAdded($event2, LogLevel::CRITICAL, [], []));
|
||||
|
||||
//Test blacklist
|
||||
$this->assertFalse($this->service->shouldBeAdded($event1, 7, [UserLoginLogEntry::class], []));
|
||||
$this->assertTrue($this->service->shouldBeAdded($event2, 7, [UserLoginLogEntry::class], []));
|
||||
$this->assertFalse($this->service->shouldBeAdded($event1, LogLevel::DEBUG, [UserLoginLogEntry::class], []));
|
||||
$this->assertTrue($this->service->shouldBeAdded($event2, LogLevel::DEBUG, [UserLoginLogEntry::class], []));
|
||||
|
||||
//Test whitelist
|
||||
$this->assertFalse($this->service->shouldBeAdded($event1, 7, [], [UserLogoutLogEntry::class]));
|
||||
$this->assertTrue($this->service->shouldBeAdded($event2, 7, [], [UserLogoutLogEntry::class]));
|
||||
$this->assertFalse($this->service->shouldBeAdded($event1, LogLevel::DEBUG, [], [UserLogoutLogEntry::class]));
|
||||
$this->assertTrue($this->service->shouldBeAdded($event2, LogLevel::DEBUG, [], [UserLogoutLogEntry::class]));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue