jonnybarnes.uk/tests/Feature/CorsHeadersTest.php

35 lines
745 B
PHP
Raw Normal View History

<?php
2021-03-17 18:38:18 +00:00
declare(strict_types=1);
namespace Tests\Feature;
use Tests\TestCase;
use Tests\TestToken;
class CorsHeadersTest extends TestCase
{
use TestToken;
/** @test */
2021-03-17 18:38:18 +00:00
public function checkCorsHeadersOnMediaEndpoint(): void
{
$response = $this->call(
'OPTIONS',
'/api/media',
[],
[],
[],
['HTTP_Authorization' => 'Bearer ' . $this->getToken()]
);
$response->assertHeader('Access-Control-Allow-Origin', '*');
}
/** @test */
2021-03-17 18:38:18 +00:00
public function checkForNoCorsHeaderOnNonMediaEndpointLinks(): void
{
2021-03-17 18:38:18 +00:00
$response = $this->get('/blog');
$response->assertHeaderMissing('Access-Control-Allow-Origin');
}
}