48 lines
1.5 KiB
PHP
48 lines
1.5 KiB
PHP
<?php
|
|
|
|
use Illuminate\Support\Facades\File;
|
|
|
|
it('returns either public build metadata or a non-disclosing not-found response', function (): void {
|
|
$response = $this->getJson('/build-info.json');
|
|
|
|
if (File::exists(base_path('build-info.json'))) {
|
|
$response->assertOk();
|
|
expect(array_keys($response->json()))->toBe(['environment', 'commit', 'built_at', 'release']);
|
|
} else {
|
|
$response->assertNotFound()
|
|
->assertJson(['error' => 'Build info unavailable']);
|
|
}
|
|
});
|
|
|
|
it('exposes only the public release provenance fields', function (): void {
|
|
$path = base_path('build-info.json');
|
|
$hadOriginal = File::exists($path);
|
|
$original = $hadOriginal ? File::get($path) : null;
|
|
|
|
File::put($path, json_encode([
|
|
'git_sha' => 'abc1234',
|
|
'release_id' => '20260830-b37-abc1234',
|
|
'deployed_at_utc' => '2026-08-30T09:30:00Z',
|
|
'git_branch' => 'develop',
|
|
'git_dirty' => 0,
|
|
'remote_folder' => '/opt/www/virtual/SkinbaseNova',
|
|
], JSON_THROW_ON_ERROR));
|
|
|
|
try {
|
|
$this->getJson('/build-info.json')
|
|
->assertOk()
|
|
->assertExactJson([
|
|
'environment' => app()->environment(),
|
|
'commit' => 'abc1234',
|
|
'built_at' => '2026-08-30T09:30:00Z',
|
|
'release' => '20260830-b37-abc1234',
|
|
]);
|
|
} finally {
|
|
if ($hadOriginal) {
|
|
File::put($path, $original);
|
|
} else {
|
|
File::delete($path);
|
|
}
|
|
}
|
|
});
|