Files
laravel-gost-template/tests/Feature/Security/PdnEncryptionTest.php
2026-06-24 17:20:43 +09:00

31 lines
1.2 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
use App\Models\PersonalData;
use Illuminate\Support\Facades\DB;
it('хранит поля ПДн в зашифрованном виде (ЗНИ)', function () {
$pd = PersonalData::create([
'last_name' => 'Иванов',
'passport' => '1234 567890',
]);
// В приложении значение доступно в открытом виде.
expect($pd->fresh()->last_name)->toBe('Иванов');
// В БД хранится шифртекст, а не исходное значение.
$raw = DB::table('personal_data')->where('id', $pd->id)->value('last_name');
expect($raw)->not->toBe('Иванов')
->and(strlen((string) $raw))->toBeGreaterThan(20);
});
it('контролирует целостность записи ПДн (ОЦЛ.2)', function () {
$pd = PersonalData::create(['last_name' => 'Петров']);
expect($pd->integrityValid())->toBeTrue();
// Подмена шифртекста в обход приложения нарушает контрольную сумму.
DB::table('personal_data')->where('id', $pd->id)->update(['last_name' => 'tampered']);
expect(PersonalData::find($pd->id)->integrityValid())->toBeFalse();
});