From ea16717a5a03f113666ca041f4e55f26fdd32d06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Aur=C3=A9lio=20Deleu?= Date: Thu, 1 Oct 2020 12:28:00 +0200 Subject: [PATCH] Test nested wilcard (#501) --- tests/GlobalMiddlewareTest.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/GlobalMiddlewareTest.php b/tests/GlobalMiddlewareTest.php index 99fce42..996f157 100644 --- a/tests/GlobalMiddlewareTest.php +++ b/tests/GlobalMiddlewareTest.php @@ -70,6 +70,19 @@ public function testAllowAllOriginsWildcard() $this->assertEquals(204, $crawler->getStatusCode()); } + public function testOriginsWildcardIncludesNestedSubdomains() + { + $this->app['config']->set('cors.allowed_origins', ['*.laravel.com']); + + $crawler = $this->call('OPTIONS', 'api/ping', [], [], [], [ + 'HTTP_ORIGIN' => 'http://api.service.test.laravel.com', + 'HTTP_ACCESS_CONTROL_REQUEST_METHOD' => 'POST', + ]); + + $this->assertEquals('http://api.service.test.laravel.com', $crawler->headers->get('Access-Control-Allow-Origin')); + $this->assertEquals(204, $crawler->getStatusCode()); + } + public function testAllowAllOriginsWildcardNoMatch() { $this->app['config']->set('cors.allowed_origins', ['*.laravel.com']);