jonnybarnes.uk/tests/Feature/CorsHeadersTest.php
Jonny Barnes c52f0e17d7 Add CORS headers to the media endpoint
Squashed commit of the following:

commit 0a620148dfad998f7b00804cae1db8208b23cc02
Author: Jonny Barnes <jonny@jonnybarnes.uk>
Date:   Fri Mar 2 15:08:36 2018 +0000

    Add tests for the Cors Headers

commit dd8518d279cdf3857597fa7ee6150bf383203fe1
Author: Jonny Barnes <jonny@jonnybarnes.uk>
Date:   Fri Mar 2 15:08:20 2018 +0000

    Only add Cors Headers to requests to the media endpoint

commit 6c79ca5632581345ef406f211b1576a4b7f400fe
Author: Jonny Barnes <jonny@jonnybarnes.uk>
Date:   Fri Mar 2 15:07:53 2018 +0000

    Add CorsHeaders to middleware array

commit e12d48ca1e837b14b75bbd87d6197d59d60cf32e
Author: Jonny Barnes <jonny@jonnybarnes.uk>
Date:   Fri Mar 2 15:06:32 2018 +0000

    We need to send something to the OPTIONS request to the media endpoint

commit f11c638be464373bff09bf015d4a989e48e61f0c
Author: Jonny Barnes <jonny@jonnybarnes.uk>
Date:   Fri Mar 2 15:05:45 2018 +0000

    Change routes to allow for responses to an OPTIONS request to the media endpoint
2018-03-02 15:49:07 +00:00

34 lines
805 B
PHP

<?php
namespace Tests\Feature;
use Tests\TestCase;
use Tests\TestToken;
use Illuminate\Foundation\Testing\WithFaker;
use Illuminate\Foundation\Testing\RefreshDatabase;
class CorsHeadersTest extends TestCase
{
use TestToken;
/** @test */
public function check_cors_headers_on_media_endpoint_options_request()
{
$response = $this->call(
'OPTIONS',
'/api/media',
[],
[],
[],
['HTTP_Authorization' => 'Bearer ' . $this->getToken()]
);
$response->assertHeader('Access-Control-Allow-Origin', '*');
}
/** @test */
public function check_missing_on_other_route()
{
$response = $this->get('/');
$response->assertHeaderMissing('Access-Control-Allow-Origin');
}
}