commit compras3 2811
tests / ci (push) Waiting to run

This commit is contained in:
2026-11-28 18:16:04 +02:00
parent 060c119ba1
commit 1ddabbbdcc
41 changed files with 1341 additions and 138 deletions
@@ -157,3 +157,27 @@ test('private audit packages remain personal to their creator even within the sa
$this->withoutVite()->get('/auditoria/privada')->assertOk()->assertViewHas('page', fn (array $page) => $page['props']['exports']['data'] === []);
expect(PrivateAuditExport::query()->count())->toBe(1);
});
test('private audit detects a missing archive and accepts only the exact recovered private bytes without regenerating history', function () {
Storage::fake('audit_recovery');
$input = ['operation_key' => (string) Str::uuid(), 'families' => ['configuration']];
$service = app(PrivateAuditExporter::class);
$export = $service->generate($this->actor, $input);
$archive = Storage::disk('local')->get($export->path);
Storage::disk('audit_recovery')->put('original.zip', $archive);
$before = DB::table('private_audit_exports')->where('id', $export->id)->first();
$events = DB::table('audit_logs')->count();
// Remove only the known generated file in the disposable fake QA disk.
Storage::disk('local')->delete($export->path);
try {
$service->generate($this->actor, $input);
test()->fail('Missing historical packages must not be silently regenerated.');
} catch (HttpException $error) {
expect($error->getStatusCode())->toBe(409);
}
Storage::disk('local')->put($export->path, Storage::disk('audit_recovery')->get('original.zip'));
expect($service->generate($this->actor, $input)->id)->toBe($export->id)
->and(hash_file('sha256', $service->verifiedPath($this->actor, $export)))->toBe($export->sha256)
->and(DB::table('private_audit_exports')->where('id', $export->id)->first())->toEqual($before)
->and(DB::table('audit_logs')->count())->toBe($events);
});