feat(backup): add dedicated .kmh archive reader with zero-storage file inspection and CLI command
This commit is contained in:
@@ -310,4 +310,60 @@ class BackupAndRestoreTest extends TestCase
|
||||
'target_name' => 'backup_dari_pc.kmh',
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_super_admin_can_inspect_server_kmh_backup(): void
|
||||
{
|
||||
$filename = $this->backupService->createKmhBackup(['users'], false, 'test_inspect_server.kmh');
|
||||
|
||||
$response = $this->actingAs($this->superAdmin)
|
||||
->getJson(route('admin.backups.inspect', $filename));
|
||||
|
||||
$response->assertStatus(200);
|
||||
$response->assertJson([
|
||||
'success' => true,
|
||||
'data' => [
|
||||
'filename' => $filename,
|
||||
'is_valid' => true,
|
||||
'encryption_cipher' => 'AES-256-CBC',
|
||||
],
|
||||
]);
|
||||
|
||||
$this->assertContains('users', $response->json('data.tables'));
|
||||
}
|
||||
|
||||
public function test_super_admin_can_inspect_uploaded_kmh_backup_with_zero_disk_retention(): void
|
||||
{
|
||||
$filename = $this->backupService->createKmhBackup(['users'], false, 'test_inspect_upload.kmh');
|
||||
$fullPath = $this->backupService->getBackupDirectory() . DIRECTORY_SEPARATOR . $filename;
|
||||
$kmhContent = file_get_contents($fullPath);
|
||||
|
||||
$uploadedFile = UploadedFile::fake()->createWithContent('arsip_lama_2bulan_lalu.kmh', $kmhContent);
|
||||
|
||||
$response = $this->actingAs($this->superAdmin)
|
||||
->postJson(route('admin.backups.inspect_upload'), [
|
||||
'backup_file' => $uploadedFile,
|
||||
]);
|
||||
|
||||
$response->assertStatus(200);
|
||||
$response->assertJson([
|
||||
'success' => true,
|
||||
'data' => [
|
||||
'filename' => 'arsip_lama_2bulan_lalu.kmh',
|
||||
'is_valid' => true,
|
||||
'encryption_cipher' => 'AES-256-CBC',
|
||||
],
|
||||
]);
|
||||
|
||||
$this->assertContains('users', $response->json('data.tables'));
|
||||
}
|
||||
|
||||
public function test_inspect_kmh_command_outputs_metadata(): void
|
||||
{
|
||||
$filename = $this->backupService->createKmhBackup(['users'], false, 'test_cli_inspect.kmh');
|
||||
|
||||
$this->artisan('kmh:inspect', ['file' => $filename])
|
||||
->expectsOutputToContain('HASIL INSPEKSI ARSIP KMH')
|
||||
->expectsOutputToContain('AES-256-CBC')
|
||||
->assertExitCode(0);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user