first commit
This commit is contained in:
33
tests/Feature/Security/AuditLogTest.php
Normal file
33
tests/Feature/Security/AuditLogTest.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
use App\Facades\Audit;
|
||||
use App\Models\AuditLog;
|
||||
|
||||
it('подписывает записи журнала и подтверждает целостность (РСБ.3)', function () {
|
||||
Audit::log('pdn.viewed', 'read', 'PersonalData:1');
|
||||
Audit::log('pdn.updated', 'update', 'PersonalData:1');
|
||||
|
||||
expect(AuditLog::count())->toBe(2)
|
||||
->and(Audit::verifyIntegrity())->toBe([]);
|
||||
});
|
||||
|
||||
it('обнаруживает подделку записи журнала (РСБ.3)', function () {
|
||||
Audit::log('pdn.viewed', 'read', 'PersonalData:1');
|
||||
$entry = Audit::log('pdn.updated', 'update', 'PersonalData:1');
|
||||
|
||||
// Изменение записи в обход подписи.
|
||||
$entry->result = 'failure';
|
||||
$entry->saveQuietly();
|
||||
|
||||
expect(Audit::verifyIntegrity())->toContain($entry->id);
|
||||
});
|
||||
|
||||
it('обнаруживает разрыв хеш-цепочки при удалении записи (РСБ.3)', function () {
|
||||
Audit::log('e1', 'a', 'R:1');
|
||||
$second = Audit::log('e2', 'a', 'R:2');
|
||||
Audit::log('e3', 'a', 'R:3');
|
||||
|
||||
$second->delete();
|
||||
|
||||
expect(Audit::verifyIntegrity())->not->toBe([]);
|
||||
});
|
||||
Reference in New Issue
Block a user