|
@@ -38,7 +38,7 @@ discard block |
|
|
block discarded – undo |
|
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
|
} |
|
@@ -53,7 +53,7 @@ discard block |
|
|
block discarded – undo |
|
53
|
53
|
|
|
54
|
54
|
$this->request = new Request; |
|
55
|
55
|
|
|
56
|
|
- $this->specify('200 response when origin, method and headers are allowed', function () { |
|
|
56
|
+ $this->specify('200 response when origin, method and headers are allowed', function() { |
|
57
|
57
|
$this->request->headers->set('Origin', 'http://foo.com'); |
|
58
|
58
|
$this->request->headers->set('Access-Control-Request-Method', 'POST'); |
|
59
|
59
|
$this->request->headers->set('Access-Control-Request-Headers', 'accept, authorization, content-type'); |
|
@@ -71,7 +71,7 @@ discard block |
|
|
block discarded – undo |
|
71
|
71
|
|
|
72
|
72
|
$this->request = new Request; |
|
73
|
73
|
|
|
74
|
|
- $this->specify('response headers are set', function () { |
|
|
74
|
+ $this->specify('response headers are set', function() { |
|
75
|
75
|
$this->request->headers->set('Origin', 'http://foo.com'); |
|
76
|
76
|
$this->request->headers->set('Access-Control-Request-Method', 'POST'); |
|
77
|
77
|
$this->request->headers->set('Access-Control-Request-Headers', 'accept, authorization, content-type'); |
|
@@ -93,7 +93,7 @@ discard block |
|
|
block discarded – undo |
|
93
|
93
|
|
|
94
|
94
|
$this->request = new Request; |
|
95
|
95
|
|
|
96
|
|
- $this->specify('regression test for issue #31', function () { |
|
|
96
|
+ $this->specify('regression test for issue #31', function() { |
|
97
|
97
|
$this->request->headers->set('Origin', 'http://foo.com'); |
|
98
|
98
|
$this->request->headers->set('Access-Control-Request-Method', 'POST'); |
|
99
|
99
|
$this->request->headers->set('Access-Control-Request-Headers', 'accept,authorization, content-type'); |
|
@@ -116,7 +116,7 @@ discard block |
|
|
block discarded – undo |
|
116
|
116
|
|
|
117
|
117
|
$this->request = new Request; |
|
118
|
118
|
|
|
119
|
|
- $this->specify('response credentials header is set', function () { |
|
|
119
|
+ $this->specify('response credentials header is set', function() { |
|
120
|
120
|
$this->request->headers->set('Origin', 'http://foo.com'); |
|
121
|
121
|
$this->request->headers->set('Access-Control-Request-Method', 'POST'); |
|
122
|
122
|
$this->request->headers->set('Access-Control-Request-Headers', 'accept, authorization, content-type'); |
|
@@ -135,7 +135,7 @@ discard block |
|
|
block discarded – undo |
|
135
|
135
|
|
|
136
|
136
|
$this->request = new Request; |
|
137
|
137
|
|
|
138
|
|
- $this->specify('response max-age header is set', function () { |
|
|
138
|
+ $this->specify('response max-age header is set', function() { |
|
139
|
139
|
$this->request->headers->set('Origin', 'http://foo.com'); |
|
140
|
140
|
$this->request->headers->set('Access-Control-Request-Method', 'POST'); |
|
141
|
141
|
$this->request->headers->set('Access-Control-Request-Headers', 'accept, authorization, content-type'); |
|
@@ -156,7 +156,7 @@ discard block |
|
|
block discarded – undo |
|
156
|
156
|
'allow_origins' => ['*'], |
|
157
|
157
|
]); |
|
158
|
158
|
|
|
159
|
|
- $this->specify('response origin header is set', function () { |
|
|
159
|
+ $this->specify('response origin header is set', function() { |
|
160
|
160
|
$this->request->headers->set('Origin', 'http://foo.com'); |
|
161
|
161
|
|
|
162
|
162
|
$response = $this->service->handleRequest($this->request, new Response()); |
|
@@ -168,7 +168,7 @@ discard block |
|
|
block discarded – undo |
|
168
|
168
|
'allow_origins' => ['*'], |
|
169
|
169
|
]); |
|
170
|
170
|
|
|
171
|
|
- $this->specify('response vary header is not set when all origins are allowed', function () { |
|
|
171
|
+ $this->specify('response vary header is not set when all origins are allowed', function() { |
|
172
|
172
|
$this->request->headers->set('Origin', 'http://foo.com'); |
|
173
|
173
|
|
|
174
|
174
|
$response = new Response(); |
|
@@ -182,7 +182,7 @@ discard block |
|
|
block discarded – undo |
|
182
|
182
|
'allow_origins' => ['http://foo.com'], |
|
183
|
183
|
]); |
|
184
|
184
|
|
|
185
|
|
- $this->specify('response vary header is set', function () { |
|
|
185
|
+ $this->specify('response vary header is set', function() { |
|
186
|
186
|
$this->request->headers->set('Origin', 'http://foo.com'); |
|
187
|
187
|
$this->request->headers->set('Vary', 'Accept-Encoding'); |
|
188
|
188
|
|
|
@@ -198,7 +198,7 @@ discard block |
|
|
block discarded – undo |
|
198
|
198
|
'allow_credentials' => true, |
|
199
|
199
|
]); |
|
200
|
200
|
|
|
201
|
|
- $this->specify('response credentials header is set', function () { |
|
|
201
|
+ $this->specify('response credentials header is set', function() { |
|
202
|
202
|
$this->request->headers->set('Origin', 'http://foo.com'); |
|
203
|
203
|
|
|
204
|
204
|
$response = $this->service->handleRequest($this->request, new Response()); |
|
@@ -213,7 +213,7 @@ discard block |
|
|
block discarded – undo |
|
213
|
213
|
'expose_headers' => ['Accept', 'Authorization', 'Content-Type'], |
|
214
|
214
|
]); |
|
215
|
215
|
|
|
216
|
|
- $this->specify('response expose headers header is set', function () { |
|
|
216
|
+ $this->specify('response expose headers header is set', function() { |
|
217
|
217
|
$this->request->headers->set('Origin', 'http://foo.com'); |
|
218
|
218
|
|
|
219
|
219
|
$response = $this->service->handleRequest($this->request, new Response()); |
|
@@ -225,7 +225,7 @@ discard block |
|
|
block discarded – undo |
|
225
|
225
|
'allow_origins' => ['http://foo.com', 'http://notbar.com'], |
|
226
|
226
|
]); |
|
227
|
227
|
|
|
228
|
|
- $this->specify('response origin header is not set when origin is not allowed', function () { |
|
|
228
|
+ $this->specify('response origin header is not set when origin is not allowed', function() { |
|
229
|
229
|
$this->request->headers->set('Origin', 'http://bar.com'); |
|
230
|
230
|
|
|
231
|
231
|
$response = $this->service->handleRequest($this->request, new Response()); |
|
@@ -241,7 +241,7 @@ discard block |
|
|
block discarded – undo |
|
241
|
241
|
|
|
242
|
242
|
$this->request = new Request; |
|
243
|
243
|
|
|
244
|
|
- $this->specify('cors request is recognized', function () { |
|
|
244
|
+ $this->specify('cors request is recognized', function() { |
|
245
|
245
|
verify($this->service->isCorsRequest($this->request))->false(); |
|
246
|
246
|
|
|
247
|
247
|
$this->request->headers->set('Origin', 'http://foo.com'); |
|
@@ -256,7 +256,7 @@ discard block |
|
|
block discarded – undo |
|
256
|
256
|
|
|
257
|
257
|
$this->request = new Request; |
|
258
|
258
|
|
|
259
|
|
- $this->specify('preflight request is recognized', function () { |
|
|
259
|
+ $this->specify('preflight request is recognized', function() { |
|
260
|
260
|
verify($this->service->isPreflightRequest($this->request))->false(); |
|
261
|
261
|
|
|
262
|
262
|
$this->request->setMethod('OPTIONS'); |
|
@@ -283,7 +283,7 @@ discard block |
|
|
block discarded – undo |
|
283
|
283
|
'allow_origins' => ['http://*.foo.com', 'http://notbar.com'], |
|
284
|
284
|
]); |
|
285
|
285
|
|
|
286
|
|
- $this->specify('response origin header is set when origin is match to a pattern', function () { |
|
|
286
|
+ $this->specify('response origin header is set when origin is match to a pattern', function() { |
|
287
|
287
|
$this->request->headers->set('Origin', 'http://bar.foo.com'); |
|
288
|
288
|
|
|
289
|
289
|
$response = $this->service->handleRequest($this->request, new Response()); |
|
@@ -303,7 +303,7 @@ discard block |
|
|
block discarded – undo |
|
303
|
303
|
'allow_origins' => ['http://*.foo.com', 'http://notbar.com'], |
|
304
|
304
|
]); |
|
305
|
305
|
|
|
306
|
|
- $this->specify('response origin header is not set when origin is not a match to a pattern', function () { |
|
|
306
|
+ $this->specify('response origin header is not set when origin is not a match to a pattern', function() { |
|
307
|
307
|
$this->request->headers->set('Origin', 'http://bar.com'); |
|
308
|
308
|
|
|
309
|
309
|
$response = $this->service->handleRequest($this->request, new Response()); |