@@ -222,7 +222,7 @@ |
||
| 222 | 222 | } |
| 223 | 223 | |
| 224 | 224 | if ($this->maxAge) { |
| 225 | - $response->headers->set('Access-Control-Max-Age', (string)$this->maxAge); |
|
| 225 | + $response->headers->set('Access-Control-Max-Age', (string) $this->maxAge); |
|
| 226 | 226 | } |
| 227 | 227 | |
| 228 | 228 | $allowMethods = $this->isAllMethodsAllowed() |
@@ -29,7 +29,7 @@ |
||
| 29 | 29 | protected function registerBindings() |
| 30 | 30 | { |
| 31 | 31 | // TODO: Change to bind the implementation to the interface instead. |
| 32 | - $this->app->bind(CorsService::class, function () { |
|
| 32 | + $this->app->bind(CorsService::class, function() { |
|
| 33 | 33 | return new CorsService(config(self::CONFIG_KEY)); |
| 34 | 34 | }); |
| 35 | 35 | |
@@ -33,8 +33,8 @@ discard block |
||
| 33 | 33 | */ |
| 34 | 34 | public function testAssertIsNotCorsRequest() |
| 35 | 35 | { |
| 36 | - $this->specify('verify middleware is not cors request', function () { |
|
| 37 | - verify($this->middleware->handle(new Request(), function () { |
|
| 36 | + $this->specify('verify middleware is not cors request', function() { |
|
| 37 | + verify($this->middleware->handle(new Request(), function() { |
|
| 38 | 38 | return true; |
| 39 | 39 | }))->equals(true); |
| 40 | 40 | }); |
@@ -45,10 +45,10 @@ discard block |
||
| 45 | 45 | */ |
| 46 | 46 | public function testAssertIsCorsRequest() |
| 47 | 47 | { |
| 48 | - $this->specify('verify middleware is cors request', function () { |
|
| 48 | + $this->specify('verify middleware is cors request', function() { |
|
| 49 | 49 | $req = new Request(); |
| 50 | 50 | $req->headers->set('Origin', 'http://example.com'); |
| 51 | - $res = $this->middleware->handle($req, function () { |
|
| 51 | + $res = $this->middleware->handle($req, function() { |
|
| 52 | 52 | return new JsonResponse(); |
| 53 | 53 | }); |
| 54 | 54 | |
@@ -60,10 +60,10 @@ discard block |
||
| 60 | 60 | 'allow_origins' => ['http://foo.com'], |
| 61 | 61 | ]); |
| 62 | 62 | $this->middleware = new CorsMiddleware($service); |
| 63 | - $this->specify('Closure is called even if origin is not allowed', function () { |
|
| 63 | + $this->specify('Closure is called even if origin is not allowed', function() { |
|
| 64 | 64 | $req = new Request(); |
| 65 | 65 | $req->headers->set('Origin', 'http://bar.com'); |
| 66 | - $res = $this->middleware->handle($req, function () { |
|
| 66 | + $res = $this->middleware->handle($req, function() { |
|
| 67 | 67 | $res = new JsonResponse(); |
| 68 | 68 | $res->headers->set('X-Closure-Called', 1); |
| 69 | 69 | return $res; |
@@ -78,13 +78,13 @@ discard block |
||
| 78 | 78 | */ |
| 79 | 79 | public function testAssertIsPreflightRequest() |
| 80 | 80 | { |
| 81 | - $this->specify('verify middleware is preflight request', function () { |
|
| 81 | + $this->specify('verify middleware is preflight request', function() { |
|
| 82 | 82 | $req = new Request(); |
| 83 | 83 | $req->setMethod('OPTIONS'); |
| 84 | 84 | $req->headers->set('Origin', 'http://example.com'); |
| 85 | 85 | $req->headers->set('Access-Control-Request-Method', 'GET'); |
| 86 | 86 | |
| 87 | - $res = $this->middleware->handle($req, function () { |
|
| 87 | + $res = $this->middleware->handle($req, function() { |
|
| 88 | 88 | return new JsonResponse(); |
| 89 | 89 | }); |
| 90 | 90 | |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | |
| 39 | 39 | public function testServiceConfig() |
| 40 | 40 | { |
| 41 | - $this->specify('service config max_age is less than zero', function () { |
|
| 41 | + $this->specify('service config max_age is less than zero', function() { |
|
| 42 | 42 | new CorsService(['max_age' => -1]); |
| 43 | 43 | }, ['throws' => 'InvalidArgumentException']); |
| 44 | 44 | } |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | |
| 50 | 50 | $this->request = new Request; |
| 51 | 51 | |
| 52 | - $this->specify('403 response if origin is not allowed', function () { |
|
| 52 | + $this->specify('403 response if origin is not allowed', function() { |
|
| 53 | 53 | $this->request->headers->set('Origin', 'http://foo.com'); |
| 54 | 54 | $this->request->headers->set('Access-Control-Request-Method', 'POST'); |
| 55 | 55 | $this->request->headers->set('Access-Control-Request-Headers', 'accept, authorization, content-type'); |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | |
| 66 | 66 | $this->request = new Request; |
| 67 | 67 | |
| 68 | - $this->specify('405 response if method is not allowed', function () { |
|
| 68 | + $this->specify('405 response if method is not allowed', function() { |
|
| 69 | 69 | $this->request->headers->set('Origin', 'http://foo.com'); |
| 70 | 70 | $this->request->headers->set('Access-Control-Request-Method', 'POST'); |
| 71 | 71 | $this->request->headers->set('Access-Control-Request-Headers', 'accept, authorization, content-type'); |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | |
| 83 | 83 | $this->request = new Request; |
| 84 | 84 | |
| 85 | - $this->specify('403 response if header is not allowed', function () { |
|
| 85 | + $this->specify('403 response if header is not allowed', function() { |
|
| 86 | 86 | $this->request->headers->set('Origin', 'http://foo.com'); |
| 87 | 87 | $this->request->headers->set('Access-Control-Request-Method', 'POST'); |
| 88 | 88 | $this->request->headers->set('Access-Control-Request-Headers', 'accept, authorization, content-type'); |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | |
| 99 | 99 | $this->request = new Request; |
| 100 | 100 | |
| 101 | - $this->specify('200 response when origin, method and headers are allowed', function () { |
|
| 101 | + $this->specify('200 response when origin, method and headers are allowed', function() { |
|
| 102 | 102 | $this->request->headers->set('Origin', 'http://foo.com'); |
| 103 | 103 | $this->request->headers->set('Access-Control-Request-Method', 'POST'); |
| 104 | 104 | $this->request->headers->set('Access-Control-Request-Headers', 'accept, authorization, content-type'); |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | |
| 115 | 115 | $this->request = new Request; |
| 116 | 116 | |
| 117 | - $this->specify('403 response when origin is not set', function () { |
|
| 117 | + $this->specify('403 response when origin is not set', function() { |
|
| 118 | 118 | $response = $this->service->handlePreflightRequest($this->request); |
| 119 | 119 | |
| 120 | 120 | verify($response->getStatusCode())->equals(403); |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | |
| 128 | 128 | $this->request = new Request; |
| 129 | 129 | |
| 130 | - $this->specify('403 response exception when header is not set', function () { |
|
| 130 | + $this->specify('403 response exception when header is not set', function() { |
|
| 131 | 131 | $this->request->headers->set('Origin', 'http://foo.com'); |
| 132 | 132 | $this->request->headers->set('Access-Control-Request-Headers', 'accept, '); |
| 133 | 133 | |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | |
| 145 | 145 | $this->request = new Request; |
| 146 | 146 | |
| 147 | - $this->specify('response headers are set', function () { |
|
| 147 | + $this->specify('response headers are set', function() { |
|
| 148 | 148 | $this->request->headers->set('Origin', 'http://foo.com'); |
| 149 | 149 | $this->request->headers->set('Access-Control-Request-Method', 'POST'); |
| 150 | 150 | $this->request->headers->set('Access-Control-Request-Headers', 'accept, authorization, content-type'); |
@@ -166,7 +166,7 @@ discard block |
||
| 166 | 166 | |
| 167 | 167 | $this->request = new Request; |
| 168 | 168 | |
| 169 | - $this->specify('regression test for issue #31', function () { |
|
| 169 | + $this->specify('regression test for issue #31', function() { |
|
| 170 | 170 | $this->request->headers->set('Origin', 'http://foo.com'); |
| 171 | 171 | $this->request->headers->set('Access-Control-Request-Method', 'POST'); |
| 172 | 172 | $this->request->headers->set('Access-Control-Request-Headers', 'accept,authorization, content-type'); |
@@ -189,7 +189,7 @@ discard block |
||
| 189 | 189 | |
| 190 | 190 | $this->request = new Request; |
| 191 | 191 | |
| 192 | - $this->specify('response credentials header is set', function () { |
|
| 192 | + $this->specify('response credentials header is set', function() { |
|
| 193 | 193 | $this->request->headers->set('Origin', 'http://foo.com'); |
| 194 | 194 | $this->request->headers->set('Access-Control-Request-Method', 'POST'); |
| 195 | 195 | $this->request->headers->set('Access-Control-Request-Headers', 'accept, authorization, content-type'); |
@@ -208,7 +208,7 @@ discard block |
||
| 208 | 208 | |
| 209 | 209 | $this->request = new Request; |
| 210 | 210 | |
| 211 | - $this->specify('response max-age header is set', function () { |
|
| 211 | + $this->specify('response max-age header is set', function() { |
|
| 212 | 212 | $this->request->headers->set('Origin', 'http://foo.com'); |
| 213 | 213 | $this->request->headers->set('Access-Control-Request-Method', 'POST'); |
| 214 | 214 | $this->request->headers->set('Access-Control-Request-Headers', 'accept, authorization, content-type'); |
@@ -220,14 +220,14 @@ discard block |
||
| 220 | 220 | |
| 221 | 221 | $this->service = new CorsService([ |
| 222 | 222 | 'allow_origins' => ['http://foo.com'], |
| 223 | - 'origin_not_allowed' => function () { |
|
| 223 | + 'origin_not_allowed' => function() { |
|
| 224 | 224 | return new Response('INVALID ORIGIN', 403); |
| 225 | 225 | }, |
| 226 | 226 | ]); |
| 227 | 227 | |
| 228 | 228 | $this->request = new Request; |
| 229 | 229 | |
| 230 | - $this->specify('response origin_not_allowed header is set', function () { |
|
| 230 | + $this->specify('response origin_not_allowed header is set', function() { |
|
| 231 | 231 | $this->request->headers->set('Origin', 'http://bar.com'); |
| 232 | 232 | |
| 233 | 233 | $response = $this->service->handlePreflightRequest($this->request); |
@@ -239,14 +239,14 @@ discard block |
||
| 239 | 239 | $this->service = new CorsService([ |
| 240 | 240 | 'allow_origins' => ['*'], |
| 241 | 241 | 'allow_methods' => ['GET'], |
| 242 | - 'method_not_allowed' => function () { |
|
| 242 | + 'method_not_allowed' => function() { |
|
| 243 | 243 | return new Response('INVALID METHOD', 403); |
| 244 | 244 | }, |
| 245 | 245 | ]); |
| 246 | 246 | |
| 247 | 247 | $this->request = new Request; |
| 248 | 248 | |
| 249 | - $this->specify('response method_not_allowed header is set', function () { |
|
| 249 | + $this->specify('response method_not_allowed header is set', function() { |
|
| 250 | 250 | $this->request->headers->set('Origin', 'http://foo.com'); |
| 251 | 251 | $this->request->headers->set('Access-Control-Request-Method', 'POST'); |
| 252 | 252 | |
@@ -259,14 +259,14 @@ discard block |
||
| 259 | 259 | $this->service = new CorsService([ |
| 260 | 260 | 'allow_origins' => ['*'], |
| 261 | 261 | 'allow_headers' => ['accept'], |
| 262 | - 'header_not_allowed' => function () { |
|
| 262 | + 'header_not_allowed' => function() { |
|
| 263 | 263 | return new Response('INVALID HEADER', 403); |
| 264 | 264 | }, |
| 265 | 265 | ]); |
| 266 | 266 | |
| 267 | 267 | $this->request = new Request; |
| 268 | 268 | |
| 269 | - $this->specify('response header_not_allowed header is set', function () { |
|
| 269 | + $this->specify('response header_not_allowed header is set', function() { |
|
| 270 | 270 | $this->request->headers->set('Origin', 'http://foo.com'); |
| 271 | 271 | $this->request->headers->set('Access-Control-Request-Headers', 'accept, authorization'); |
| 272 | 272 | |
@@ -283,7 +283,7 @@ discard block |
||
| 283 | 283 | |
| 284 | 284 | $this->response = new Response; |
| 285 | 285 | |
| 286 | - $this->closure = function () { |
|
| 286 | + $this->closure = function() { |
|
| 287 | 287 | return new Response; |
| 288 | 288 | }; |
| 289 | 289 | |
@@ -291,7 +291,7 @@ discard block |
||
| 291 | 291 | 'allow_origins' => ['*'], |
| 292 | 292 | ]); |
| 293 | 293 | |
| 294 | - $this->specify('response origin header is set', function () { |
|
| 294 | + $this->specify('response origin header is set', function() { |
|
| 295 | 295 | $this->request->headers->set('Origin', 'http://foo.com'); |
| 296 | 296 | |
| 297 | 297 | $response = $this->service->handleRequest($this->request, $this->closure); |
@@ -303,7 +303,7 @@ discard block |
||
| 303 | 303 | 'allow_origins' => ['*'], |
| 304 | 304 | ]); |
| 305 | 305 | |
| 306 | - $this->specify('response vary header is set', function () { |
|
| 306 | + $this->specify('response vary header is set', function() { |
|
| 307 | 307 | $this->request->headers->set('Origin', 'http://foo.com'); |
| 308 | 308 | $this->request->headers->set('Vary', 'Accept-Encoding'); |
| 309 | 309 | |
@@ -319,7 +319,7 @@ discard block |
||
| 319 | 319 | 'allow_credentials' => true, |
| 320 | 320 | ]); |
| 321 | 321 | |
| 322 | - $this->specify('response credentials header is set', function () { |
|
| 322 | + $this->specify('response credentials header is set', function() { |
|
| 323 | 323 | $this->request->headers->set('Origin', 'http://foo.com'); |
| 324 | 324 | |
| 325 | 325 | $response = $this->service->handleRequest($this->request, $this->closure); |
@@ -334,7 +334,7 @@ discard block |
||
| 334 | 334 | 'expose_headers' => ['Accept', 'Authorization', 'Content-Type'], |
| 335 | 335 | ]); |
| 336 | 336 | |
| 337 | - $this->specify('response expose headers header is set', function () { |
|
| 337 | + $this->specify('response expose headers header is set', function() { |
|
| 338 | 338 | $this->request->headers->set('Origin', 'http://foo.com'); |
| 339 | 339 | |
| 340 | 340 | $response = $this->service->handleRequest($this->request, $this->closure); |
@@ -346,7 +346,7 @@ discard block |
||
| 346 | 346 | 'allow_origins' => ['http://foo.com'], |
| 347 | 347 | ]); |
| 348 | 348 | |
| 349 | - $this->specify('response origin header is not set when origin is not allowed', function () { |
|
| 349 | + $this->specify('response origin header is not set when origin is not allowed', function() { |
|
| 350 | 350 | $this->request->headers->set('Origin', 'http://bar.com'); |
| 351 | 351 | |
| 352 | 352 | $response = $this->service->handleRequest($this->request, $this->closure); |
@@ -362,7 +362,7 @@ discard block |
||
| 362 | 362 | |
| 363 | 363 | $this->request = new Request; |
| 364 | 364 | |
| 365 | - $this->specify('cors request is recognized', function () { |
|
| 365 | + $this->specify('cors request is recognized', function() { |
|
| 366 | 366 | verify($this->service->isCorsRequest($this->request))->false(); |
| 367 | 367 | |
| 368 | 368 | $this->request->headers->set('Origin', 'http://foo.com'); |
@@ -377,7 +377,7 @@ discard block |
||
| 377 | 377 | |
| 378 | 378 | $this->request = new Request; |
| 379 | 379 | |
| 380 | - $this->specify('preflight request is recognized', function () { |
|
| 380 | + $this->specify('preflight request is recognized', function() { |
|
| 381 | 381 | verify($this->service->isPreflightRequest($this->request))->false(); |
| 382 | 382 | |
| 383 | 383 | $this->request->setMethod('OPTIONS'); |
@@ -28,7 +28,7 @@ |
||
| 28 | 28 | */ |
| 29 | 29 | public function testAssertCanBeRegistered() |
| 30 | 30 | { |
| 31 | - $this->specify('verify serviceProvider is registered', function () { |
|
| 31 | + $this->specify('verify serviceProvider is registered', function() { |
|
| 32 | 32 | $service = $this->app->make(CorsService::class); |
| 33 | 33 | verify($service)->isInstanceOf(CorsService::class); |
| 34 | 34 | }); |