Files
fotospiel-app/tests/Feature/Api/Event/BrandingAssetTest.php
2025-12-09 20:29:32 +01:00

53 lines
1.4 KiB
PHP

<?php
namespace Tests\Feature\Api\Event;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Facades\URL;
use Tests\TestCase;
class BrandingAssetTest extends TestCase
{
use RefreshDatabase;
public function test_branding_asset_serves_signed_file(): void
{
Config::set('filesystems.default', 'public');
Storage::fake('public');
$path = 'branding/logo.png';
Storage::disk('public')->put($path, 'branding-content');
$url = URL::temporarySignedRoute(
'api.v1.branding.asset',
now()->addMinutes(5),
['path' => $path]
);
$response = $this->get($url);
$response->assertOk();
$this->assertSame('branding-content', $response->streamedContent());
$this->assertStringContainsString('max-age=3600', $response->headers->get('Cache-Control'));
$this->assertStringContainsString('private', $response->headers->get('Cache-Control'));
}
public function test_branding_asset_rejects_invalid_path(): void
{
Config::set('filesystems.default', 'public');
Storage::fake('public');
$url = URL::temporarySignedRoute(
'api.v1.branding.asset',
now()->addMinutes(5),
['path' => '../.env']
);
$response = $this->get($url);
$response->assertStatus(404);
}
}