|
@@ -40,7 +40,7 @@ discard block |
|
|
block discarded – undo |
|
40
|
40
|
public function testServiceConfig() |
|
41
|
41
|
{ |
|
42
|
42
|
// service config max_age is less than zero |
|
43
|
|
- $this->assertThrows(\InvalidArgumentException::class, function () { |
|
|
43
|
+ $this->assertThrows(\InvalidArgumentException::class, function() { |
|
44
|
44
|
new CorsService(['max_age' => -1]); |
|
45
|
45
|
}); |
|
46
|
46
|
} |
|
@@ -55,7 +55,7 @@ discard block |
|
|
block discarded – undo |
|
55
|
55
|
|
|
56
|
56
|
$this->request = new Request; |
|
57
|
57
|
|
|
58
|
|
- $this->specify('200 response when origin, method and headers are allowed', function () { |
|
|
58
|
+ $this->specify('200 response when origin, method and headers are allowed', function() { |
|
59
|
59
|
$this->request->headers->set('Origin', 'http://foo.com'); |
|
60
|
60
|
$this->request->headers->set('Access-Control-Request-Method', 'POST'); |
|
61
|
61
|
$this->request->headers->set('Access-Control-Request-Headers', 'accept, authorization, content-type'); |
|
@@ -73,7 +73,7 @@ discard block |
|
|
block discarded – undo |
|
73
|
73
|
|
|
74
|
74
|
$this->request = new Request; |
|
75
|
75
|
|
|
76
|
|
- $this->specify('response headers are set', function () { |
|
|
76
|
+ $this->specify('response headers are set', function() { |
|
77
|
77
|
$this->request->headers->set('Origin', 'http://foo.com'); |
|
78
|
78
|
$this->request->headers->set('Access-Control-Request-Method', 'POST'); |
|
79
|
79
|
$this->request->headers->set('Access-Control-Request-Headers', 'accept, authorization, content-type'); |
|
@@ -95,7 +95,7 @@ discard block |
|
|
block discarded – undo |
|
95
|
95
|
|
|
96
|
96
|
$this->request = new Request; |
|
97
|
97
|
|
|
98
|
|
- $this->specify('regression test for issue #31', function () { |
|
|
98
|
+ $this->specify('regression test for issue #31', function() { |
|
99
|
99
|
$this->request->headers->set('Origin', 'http://foo.com'); |
|
100
|
100
|
$this->request->headers->set('Access-Control-Request-Method', 'POST'); |
|
101
|
101
|
$this->request->headers->set('Access-Control-Request-Headers', 'accept,authorization, content-type'); |
|
@@ -118,7 +118,7 @@ discard block |
|
|
block discarded – undo |
|
118
|
118
|
|
|
119
|
119
|
$this->request = new Request; |
|
120
|
120
|
|
|
121
|
|
- $this->specify('response credentials header is set', function () { |
|
|
121
|
+ $this->specify('response credentials header is set', function() { |
|
122
|
122
|
$this->request->headers->set('Origin', 'http://foo.com'); |
|
123
|
123
|
$this->request->headers->set('Access-Control-Request-Method', 'POST'); |
|
124
|
124
|
$this->request->headers->set('Access-Control-Request-Headers', 'accept, authorization, content-type'); |
|
@@ -137,7 +137,7 @@ discard block |
|
|
block discarded – undo |
|
137
|
137
|
|
|
138
|
138
|
$this->request = new Request; |
|
139
|
139
|
|
|
140
|
|
- $this->specify('response max-age header is set', function () { |
|
|
140
|
+ $this->specify('response max-age header is set', function() { |
|
141
|
141
|
$this->request->headers->set('Origin', 'http://foo.com'); |
|
142
|
142
|
$this->request->headers->set('Access-Control-Request-Method', 'POST'); |
|
143
|
143
|
$this->request->headers->set('Access-Control-Request-Headers', 'accept, authorization, content-type'); |
|
@@ -158,7 +158,7 @@ discard block |
|
|
block discarded – undo |
|
158
|
158
|
'allow_origins' => ['*'], |
|
159
|
159
|
]); |
|
160
|
160
|
|
|
161
|
|
- $this->specify('response origin header is set', function () { |
|
|
161
|
+ $this->specify('response origin header is set', function() { |
|
162
|
162
|
$this->request->headers->set('Origin', 'http://foo.com'); |
|
163
|
163
|
|
|
164
|
164
|
$response = $this->service->handleRequest($this->request, new Response()); |
|
@@ -170,7 +170,7 @@ discard block |
|
|
block discarded – undo |
|
170
|
170
|
'allow_origins' => ['*'], |
|
171
|
171
|
]); |
|
172
|
172
|
|
|
173
|
|
- $this->specify('response vary header is not set when all origins are allowed', function () { |
|
|
173
|
+ $this->specify('response vary header is not set when all origins are allowed', function() { |
|
174
|
174
|
$this->request->headers->set('Origin', 'http://foo.com'); |
|
175
|
175
|
|
|
176
|
176
|
$response = new Response(); |
|
@@ -184,7 +184,7 @@ discard block |
|
|
block discarded – undo |
|
184
|
184
|
'allow_origins' => ['http://foo.com'], |
|
185
|
185
|
]); |
|
186
|
186
|
|
|
187
|
|
- $this->specify('response vary header is set', function () { |
|
|
187
|
+ $this->specify('response vary header is set', function() { |
|
188
|
188
|
$this->request->headers->set('Origin', 'http://foo.com'); |
|
189
|
189
|
$this->request->headers->set('Vary', 'Accept-Encoding'); |
|
190
|
190
|
|
|
@@ -200,7 +200,7 @@ discard block |
|
|
block discarded – undo |
|
200
|
200
|
'allow_credentials' => true, |
|
201
|
201
|
]); |
|
202
|
202
|
|
|
203
|
|
- $this->specify('response credentials header is set', function () { |
|
|
203
|
+ $this->specify('response credentials header is set', function() { |
|
204
|
204
|
$this->request->headers->set('Origin', 'http://foo.com'); |
|
205
|
205
|
|
|
206
|
206
|
$response = $this->service->handleRequest($this->request, new Response()); |
|
@@ -215,7 +215,7 @@ discard block |
|
|
block discarded – undo |
|
215
|
215
|
'expose_headers' => ['Accept', 'Authorization', 'Content-Type'], |
|
216
|
216
|
]); |
|
217
|
217
|
|
|
218
|
|
- $this->specify('response expose headers header is set', function () { |
|
|
218
|
+ $this->specify('response expose headers header is set', function() { |
|
219
|
219
|
$this->request->headers->set('Origin', 'http://foo.com'); |
|
220
|
220
|
|
|
221
|
221
|
$response = $this->service->handleRequest($this->request, new Response()); |
|
@@ -227,7 +227,7 @@ discard block |
|
|
block discarded – undo |
|
227
|
227
|
'allow_origins' => ['http://foo.com', 'http://notbar.com'], |
|
228
|
228
|
]); |
|
229
|
229
|
|
|
230
|
|
- $this->specify('response origin header is not set when origin is not allowed', function () { |
|
|
230
|
+ $this->specify('response origin header is not set when origin is not allowed', function() { |
|
231
|
231
|
$this->request->headers->set('Origin', 'http://bar.com'); |
|
232
|
232
|
|
|
233
|
233
|
$response = $this->service->handleRequest($this->request, new Response()); |
|
@@ -243,7 +243,7 @@ discard block |
|
|
block discarded – undo |
|
243
|
243
|
|
|
244
|
244
|
$this->request = new Request; |
|
245
|
245
|
|
|
246
|
|
- $this->specify('cors request is recognized', function () { |
|
|
246
|
+ $this->specify('cors request is recognized', function() { |
|
247
|
247
|
verify($this->service->isCorsRequest($this->request))->false(); |
|
248
|
248
|
|
|
249
|
249
|
$this->request->headers->set('Origin', 'http://foo.com'); |
|
@@ -258,7 +258,7 @@ discard block |
|
|
block discarded – undo |
|
258
|
258
|
|
|
259
|
259
|
$this->request = new Request; |
|
260
|
260
|
|
|
261
|
|
- $this->specify('preflight request is recognized', function () { |
|
|
261
|
+ $this->specify('preflight request is recognized', function() { |
|
262
|
262
|
verify($this->service->isPreflightRequest($this->request))->false(); |
|
263
|
263
|
|
|
264
|
264
|
$this->request->setMethod('OPTIONS'); |
|
@@ -285,7 +285,7 @@ discard block |
|
|
block discarded – undo |
|
285
|
285
|
'allow_origins' => ['http://*.foo.com', 'http://notbar.com'], |
|
286
|
286
|
]); |
|
287
|
287
|
|
|
288
|
|
- $this->specify('response origin header is set when origin is match to a pattern', function () { |
|
|
288
|
+ $this->specify('response origin header is set when origin is match to a pattern', function() { |
|
289
|
289
|
$this->request->headers->set('Origin', 'http://bar.foo.com'); |
|
290
|
290
|
|
|
291
|
291
|
$response = $this->service->handleRequest($this->request, new Response()); |
|
@@ -305,7 +305,7 @@ discard block |
|
|
block discarded – undo |
|
305
|
305
|
'allow_origins' => ['http://*.foo.com', 'http://notbar.com'], |
|
306
|
306
|
]); |
|
307
|
307
|
|
|
308
|
|
- $this->specify('response origin header is not set when origin is not a match to a pattern', function () { |
|
|
308
|
+ $this->specify('response origin header is not set when origin is not a match to a pattern', function() { |
|
309
|
309
|
$this->request->headers->set('Origin', 'http://bar.com'); |
|
310
|
310
|
|
|
311
|
311
|
$response = $this->service->handleRequest($this->request, new Response()); |