@@ -65,6 +65,7 @@ public void actualRequestWithOriginHeader() throws Exception {
65
65
66
66
this .processor .processRequest (this .conf , this .request , this .response );
67
67
assertFalse (this .response .containsHeader (HttpHeaders .ACCESS_CONTROL_ALLOW_ORIGIN ));
68
+ assertEquals (HttpHeaders .ORIGIN , this .response .getHeader (HttpHeaders .VARY ));
68
69
assertEquals (HttpServletResponse .SC_FORBIDDEN , this .response .getStatus ());
69
70
}
70
71
@@ -89,6 +90,7 @@ public void actualRequestWithOriginHeaderAndAllowedOrigin() throws Exception {
89
90
assertEquals ("*" , this .response .getHeader (HttpHeaders .ACCESS_CONTROL_ALLOW_ORIGIN ));
90
91
assertFalse (this .response .containsHeader (HttpHeaders .ACCESS_CONTROL_MAX_AGE ));
91
92
assertFalse (this .response .containsHeader (HttpHeaders .ACCESS_CONTROL_EXPOSE_HEADERS ));
93
+ assertEquals (HttpHeaders .ORIGIN , this .response .getHeader (HttpHeaders .VARY ));
92
94
assertEquals (HttpServletResponse .SC_OK , this .response .getStatus ());
93
95
}
94
96
@@ -106,6 +108,7 @@ public void actualRequestCredentials() throws Exception {
106
108
assertEquals ("http://domain2.com" , this .response .getHeader (HttpHeaders .ACCESS_CONTROL_ALLOW_ORIGIN ));
107
109
assertTrue (this .response .containsHeader (HttpHeaders .ACCESS_CONTROL_ALLOW_CREDENTIALS ));
108
110
assertEquals ("true" , this .response .getHeader (HttpHeaders .ACCESS_CONTROL_ALLOW_CREDENTIALS ));
111
+ assertEquals (HttpHeaders .ORIGIN , this .response .getHeader (HttpHeaders .VARY ));
109
112
assertEquals (HttpServletResponse .SC_OK , this .response .getStatus ());
110
113
}
111
114
@@ -121,6 +124,7 @@ public void actualRequestCredentialsWithOriginWildcard() throws Exception {
121
124
assertEquals ("http://domain2.com" , this .response .getHeader (HttpHeaders .ACCESS_CONTROL_ALLOW_ORIGIN ));
122
125
assertTrue (this .response .containsHeader (HttpHeaders .ACCESS_CONTROL_ALLOW_CREDENTIALS ));
123
126
assertEquals ("true" , this .response .getHeader (HttpHeaders .ACCESS_CONTROL_ALLOW_CREDENTIALS ));
127
+ assertEquals (HttpHeaders .ORIGIN , this .response .getHeader (HttpHeaders .VARY ));
124
128
assertEquals (HttpServletResponse .SC_OK , this .response .getStatus ());
125
129
}
126
130
@@ -132,6 +136,7 @@ public void actualRequestCaseInsensitiveOriginMatch() throws Exception {
132
136
133
137
this .processor .processRequest (this .conf , this .request , this .response );
134
138
assertTrue (this .response .containsHeader (HttpHeaders .ACCESS_CONTROL_ALLOW_ORIGIN ));
139
+ assertEquals (HttpHeaders .ORIGIN , this .response .getHeader (HttpHeaders .VARY ));
135
140
assertEquals (HttpServletResponse .SC_OK , this .response .getStatus ());
136
141
}
137
142
@@ -149,6 +154,7 @@ public void actualRequestExposedHeaders() throws Exception {
149
154
assertTrue (this .response .containsHeader (HttpHeaders .ACCESS_CONTROL_EXPOSE_HEADERS ));
150
155
assertTrue (this .response .getHeader (HttpHeaders .ACCESS_CONTROL_EXPOSE_HEADERS ).contains ("header1" ));
151
156
assertTrue (this .response .getHeader (HttpHeaders .ACCESS_CONTROL_EXPOSE_HEADERS ).contains ("header2" ));
157
+ assertEquals (HttpHeaders .ORIGIN , this .response .getHeader (HttpHeaders .VARY ));
152
158
assertEquals (HttpServletResponse .SC_OK , this .response .getStatus ());
153
159
}
154
160
@@ -160,6 +166,7 @@ public void preflightRequestAllOriginsAllowed() throws Exception {
160
166
this .conf .addAllowedOrigin ("*" );
161
167
162
168
this .processor .processRequest (this .conf , this .request , this .response );
169
+ assertEquals (HttpHeaders .ORIGIN , this .response .getHeader (HttpHeaders .VARY ));
163
170
assertEquals (HttpServletResponse .SC_OK , this .response .getStatus ());
164
171
}
165
172
@@ -171,6 +178,7 @@ public void preflightRequestWrongAllowedMethod() throws Exception {
171
178
this .conf .addAllowedOrigin ("*" );
172
179
173
180
this .processor .processRequest (this .conf , this .request , this .response );
181
+ assertEquals (HttpHeaders .ORIGIN , this .response .getHeader (HttpHeaders .VARY ));
174
182
assertEquals (HttpServletResponse .SC_FORBIDDEN , this .response .getStatus ());
175
183
}
176
184
@@ -184,6 +192,7 @@ public void preflightRequestMatchedAllowedMethod() throws Exception {
184
192
this .processor .processRequest (this .conf , this .request , this .response );
185
193
assertEquals (HttpServletResponse .SC_OK , this .response .getStatus ());
186
194
assertEquals ("GET,HEAD" , this .response .getHeader (HttpHeaders .ACCESS_CONTROL_ALLOW_METHODS ));
195
+ assertEquals (HttpHeaders .ORIGIN , this .response .getHeader (HttpHeaders .VARY ));
187
196
}
188
197
189
198
@ Test
@@ -193,6 +202,7 @@ public void preflightRequestTestWithOriginButWithoutOtherHeaders() throws Except
193
202
194
203
this .processor .processRequest (this .conf , this .request , this .response );
195
204
assertFalse (this .response .containsHeader (HttpHeaders .ACCESS_CONTROL_ALLOW_ORIGIN ));
205
+ assertEquals (HttpHeaders .ORIGIN , this .response .getHeader (HttpHeaders .VARY ));
196
206
assertEquals (HttpServletResponse .SC_FORBIDDEN , this .response .getStatus ());
197
207
}
198
208
@@ -204,6 +214,7 @@ public void preflightRequestWithoutRequestMethod() throws Exception {
204
214
205
215
this .processor .processRequest (this .conf , this .request , this .response );
206
216
assertFalse (this .response .containsHeader (HttpHeaders .ACCESS_CONTROL_ALLOW_ORIGIN ));
217
+ assertEquals (HttpHeaders .ORIGIN , this .response .getHeader (HttpHeaders .VARY ));
207
218
assertEquals (HttpServletResponse .SC_FORBIDDEN , this .response .getStatus ());
208
219
}
209
220
@@ -216,6 +227,7 @@ public void preflightRequestWithRequestAndMethodHeaderButNoConfig() throws Excep
216
227
217
228
this .processor .processRequest (this .conf , this .request , this .response );
218
229
assertFalse (this .response .containsHeader (HttpHeaders .ACCESS_CONTROL_ALLOW_ORIGIN ));
230
+ assertEquals (HttpHeaders .ORIGIN , this .response .getHeader (HttpHeaders .VARY ));
219
231
assertEquals (HttpServletResponse .SC_FORBIDDEN , this .response .getStatus ());
220
232
}
221
233
@@ -237,6 +249,7 @@ public void preflightRequestValidRequestAndConfig() throws Exception {
237
249
assertTrue (this .response .containsHeader (HttpHeaders .ACCESS_CONTROL_ALLOW_METHODS ));
238
250
assertEquals ("GET,PUT" , this .response .getHeader (HttpHeaders .ACCESS_CONTROL_ALLOW_METHODS ));
239
251
assertFalse (this .response .containsHeader (HttpHeaders .ACCESS_CONTROL_MAX_AGE ));
252
+ assertEquals (HttpHeaders .ORIGIN , this .response .getHeader (HttpHeaders .VARY ));
240
253
assertEquals (HttpServletResponse .SC_OK , this .response .getStatus ());
241
254
}
242
255
@@ -257,6 +270,7 @@ public void preflightRequestCredentials() throws Exception {
257
270
assertEquals ("http://domain2.com" , this .response .getHeader (HttpHeaders .ACCESS_CONTROL_ALLOW_ORIGIN ));
258
271
assertTrue (this .response .containsHeader (HttpHeaders .ACCESS_CONTROL_ALLOW_CREDENTIALS ));
259
272
assertEquals ("true" , this .response .getHeader (HttpHeaders .ACCESS_CONTROL_ALLOW_CREDENTIALS ));
273
+ assertEquals (HttpHeaders .ORIGIN , this .response .getHeader (HttpHeaders .VARY ));
260
274
assertEquals (HttpServletResponse .SC_OK , this .response .getStatus ());
261
275
}
262
276
@@ -275,6 +289,7 @@ public void preflightRequestCredentialsWithOriginWildcard() throws Exception {
275
289
this .processor .processRequest (this .conf , this .request , this .response );
276
290
assertTrue (this .response .containsHeader (HttpHeaders .ACCESS_CONTROL_ALLOW_ORIGIN ));
277
291
assertEquals ("http://domain2.com" , this .response .getHeader (HttpHeaders .ACCESS_CONTROL_ALLOW_ORIGIN ));
292
+ assertEquals (HttpHeaders .ORIGIN , this .response .getHeader (HttpHeaders .VARY ));
278
293
assertEquals (HttpServletResponse .SC_OK , this .response .getStatus ());
279
294
}
280
295
@@ -295,6 +310,7 @@ public void preflightRequestAllowedHeaders() throws Exception {
295
310
assertTrue (this .response .getHeader (HttpHeaders .ACCESS_CONTROL_ALLOW_HEADERS ).contains ("Header1" ));
296
311
assertTrue (this .response .getHeader (HttpHeaders .ACCESS_CONTROL_ALLOW_HEADERS ).contains ("Header2" ));
297
312
assertFalse (this .response .getHeader (HttpHeaders .ACCESS_CONTROL_ALLOW_HEADERS ).contains ("Header3" ));
313
+ assertEquals (HttpHeaders .ORIGIN , this .response .getHeader (HttpHeaders .VARY ));
298
314
assertEquals (HttpServletResponse .SC_OK , this .response .getStatus ());
299
315
}
300
316
@@ -313,6 +329,7 @@ public void preflightRequestAllowsAllHeaders() throws Exception {
313
329
assertTrue (this .response .getHeader (HttpHeaders .ACCESS_CONTROL_ALLOW_HEADERS ).contains ("Header1" ));
314
330
assertTrue (this .response .getHeader (HttpHeaders .ACCESS_CONTROL_ALLOW_HEADERS ).contains ("Header2" ));
315
331
assertFalse (this .response .getHeader (HttpHeaders .ACCESS_CONTROL_ALLOW_HEADERS ).contains ("*" ));
332
+ assertEquals (HttpHeaders .ORIGIN , this .response .getHeader (HttpHeaders .VARY ));
316
333
assertEquals (HttpServletResponse .SC_OK , this .response .getStatus ());
317
334
}
318
335
@@ -328,6 +345,7 @@ public void preflightRequestWithEmptyHeaders() throws Exception {
328
345
this .processor .processRequest (this .conf , this .request , this .response );
329
346
assertTrue (this .response .containsHeader (HttpHeaders .ACCESS_CONTROL_ALLOW_ORIGIN ));
330
347
assertFalse (this .response .containsHeader (HttpHeaders .ACCESS_CONTROL_ALLOW_HEADERS ));
348
+ assertEquals (HttpHeaders .ORIGIN , this .response .getHeader (HttpHeaders .VARY ));
331
349
assertEquals (HttpServletResponse .SC_OK , this .response .getStatus ());
332
350
}
333
351
0 commit comments