jonnybarnes.uk/tests/Feature/CorsHeadersTest.php

36 lines
788 B
PHP
Raw Normal View History

<?php
2021-03-17 18:38:18 +00:00
declare(strict_types=1);
namespace Tests\Feature;
2025-03-01 15:00:41 +00:00
use PHPUnit\Framework\Attributes\Test;
use Tests\TestCase;
use Tests\TestToken;
class CorsHeadersTest extends TestCase
{
use TestToken;
2025-03-01 15:00:41 +00:00
#[Test]
2025-04-06 17:25:06 +01:00
public function check_cors_headers_on_media_endpoint(): void
{
$response = $this->call(
'OPTIONS',
'/api/media',
[],
[],
[],
['HTTP_Authorization' => 'Bearer ' . $this->getToken()]
);
$response->assertHeader('Access-Control-Allow-Origin', '*');
}
2025-03-01 15:00:41 +00:00
#[Test]
2025-04-06 17:25:06 +01:00
public function check_for_no_cors_header_on_non_media_endpoint_links(): void
{
2021-03-17 18:38:18 +00:00
$response = $this->get('/blog');
$response->assertHeaderMissing('Access-Control-Allow-Origin');
}
}