@ -62,7 +62,7 @@ public class DefaultCorsProcessorTests {
@@ -62,7 +62,7 @@ public class DefaultCorsProcessorTests {
this . request . setMethod ( HttpMethod . GET . name ( ) ) ;
this . request . addHeader ( HttpHeaders . ORIGIN , "http://domain2.com/test.html" ) ;
this . processor . processActualRequest ( this . conf , request , response ) ;
assertFalse ( response . containsHeader ( CorsUtil s. ACCESS_CONTROL_ALLOW_ORIGIN ) ) ;
assertFalse ( response . containsHeader ( HttpHeader s. ACCESS_CONTROL_ALLOW_ORIGIN ) ) ;
assertEquals ( HttpServletResponse . SC_FORBIDDEN , response . getStatus ( ) ) ;
}
@ -72,10 +72,10 @@ public class DefaultCorsProcessorTests {
@@ -72,10 +72,10 @@ public class DefaultCorsProcessorTests {
this . request . addHeader ( HttpHeaders . ORIGIN , "http://domain2.com/test.html" ) ;
this . conf . addAllowedOrigin ( "*" ) ;
this . processor . processActualRequest ( this . conf , request , response ) ;
assertTrue ( response . containsHeader ( CorsUtil s. ACCESS_CONTROL_ALLOW_ORIGIN ) ) ;
assertEquals ( "*" , response . getHeader ( CorsUtil s. ACCESS_CONTROL_ALLOW_ORIGIN ) ) ;
assertFalse ( response . containsHeader ( CorsUtil s. ACCESS_CONTROL_MAX_AGE ) ) ;
assertFalse ( response . containsHeader ( CorsUtil s. ACCESS_CONTROL_EXPOSE_HEADERS ) ) ;
assertTrue ( response . containsHeader ( HttpHeader s. ACCESS_CONTROL_ALLOW_ORIGIN ) ) ;
assertEquals ( "*" , response . getHeader ( HttpHeader s. ACCESS_CONTROL_ALLOW_ORIGIN ) ) ;
assertFalse ( response . containsHeader ( HttpHeader s. ACCESS_CONTROL_MAX_AGE ) ) ;
assertFalse ( response . containsHeader ( HttpHeader s. ACCESS_CONTROL_EXPOSE_HEADERS ) ) ;
assertEquals ( HttpServletResponse . SC_OK , response . getStatus ( ) ) ;
}
@ -88,10 +88,10 @@ public class DefaultCorsProcessorTests {
@@ -88,10 +88,10 @@ public class DefaultCorsProcessorTests {
this . conf . addAllowedOrigin ( "http://domain2.com/logout.html" ) ;
this . conf . setAllowCredentials ( true ) ;
this . processor . processActualRequest ( this . conf , request , response ) ;
assertTrue ( response . containsHeader ( CorsUtil s. ACCESS_CONTROL_ALLOW_ORIGIN ) ) ;
assertEquals ( "http://domain2.com/test.html" , response . getHeader ( CorsUtil s. ACCESS_CONTROL_ALLOW_ORIGIN ) ) ;
assertTrue ( response . containsHeader ( CorsUtil s. ACCESS_CONTROL_ALLOW_CREDENTIALS ) ) ;
assertEquals ( "true" , response . getHeader ( CorsUtil s. ACCESS_CONTROL_ALLOW_CREDENTIALS ) ) ;
assertTrue ( response . containsHeader ( HttpHeader s. ACCESS_CONTROL_ALLOW_ORIGIN ) ) ;
assertEquals ( "http://domain2.com/test.html" , response . getHeader ( HttpHeader s. ACCESS_CONTROL_ALLOW_ORIGIN ) ) ;
assertTrue ( response . containsHeader ( HttpHeader s. ACCESS_CONTROL_ALLOW_CREDENTIALS ) ) ;
assertEquals ( "true" , response . getHeader ( HttpHeader s. ACCESS_CONTROL_ALLOW_CREDENTIALS ) ) ;
assertEquals ( HttpServletResponse . SC_OK , response . getStatus ( ) ) ;
}
@ -102,10 +102,10 @@ public class DefaultCorsProcessorTests {
@@ -102,10 +102,10 @@ public class DefaultCorsProcessorTests {
this . conf . addAllowedOrigin ( "*" ) ;
this . conf . setAllowCredentials ( true ) ;
this . processor . processActualRequest ( this . conf , request , response ) ;
assertTrue ( response . containsHeader ( CorsUtil s. ACCESS_CONTROL_ALLOW_ORIGIN ) ) ;
assertEquals ( "http://domain2.com/test.html" , response . getHeader ( CorsUtil s. ACCESS_CONTROL_ALLOW_ORIGIN ) ) ;
assertTrue ( response . containsHeader ( CorsUtil s. ACCESS_CONTROL_ALLOW_CREDENTIALS ) ) ;
assertEquals ( "true" , response . getHeader ( CorsUtil s. ACCESS_CONTROL_ALLOW_CREDENTIALS ) ) ;
assertTrue ( response . containsHeader ( HttpHeader s. ACCESS_CONTROL_ALLOW_ORIGIN ) ) ;
assertEquals ( "http://domain2.com/test.html" , response . getHeader ( HttpHeader s. ACCESS_CONTROL_ALLOW_ORIGIN ) ) ;
assertTrue ( response . containsHeader ( HttpHeader s. ACCESS_CONTROL_ALLOW_CREDENTIALS ) ) ;
assertEquals ( "true" , response . getHeader ( HttpHeader s. ACCESS_CONTROL_ALLOW_CREDENTIALS ) ) ;
assertEquals ( HttpServletResponse . SC_OK , response . getStatus ( ) ) ;
}
@ -115,7 +115,7 @@ public class DefaultCorsProcessorTests {
@@ -115,7 +115,7 @@ public class DefaultCorsProcessorTests {
this . request . addHeader ( HttpHeaders . ORIGIN , "http://domain2.com/test.html" ) ;
this . conf . addAllowedOrigin ( "http://domain2.com/TEST.html" ) ;
this . processor . processActualRequest ( this . conf , request , response ) ;
assertTrue ( response . containsHeader ( CorsUtil s. ACCESS_CONTROL_ALLOW_ORIGIN ) ) ;
assertTrue ( response . containsHeader ( HttpHeader s. ACCESS_CONTROL_ALLOW_ORIGIN ) ) ;
assertEquals ( HttpServletResponse . SC_OK , response . getStatus ( ) ) ;
}
@ -127,11 +127,11 @@ public class DefaultCorsProcessorTests {
@@ -127,11 +127,11 @@ public class DefaultCorsProcessorTests {
this . conf . addExposedHeader ( "header2" ) ;
this . conf . addAllowedOrigin ( "http://domain2.com/test.html" ) ;
this . processor . processActualRequest ( this . conf , request , response ) ;
assertTrue ( response . containsHeader ( CorsUtil s. ACCESS_CONTROL_ALLOW_ORIGIN ) ) ;
assertEquals ( "http://domain2.com/test.html" , response . getHeader ( CorsUtil s. ACCESS_CONTROL_ALLOW_ORIGIN ) ) ;
assertTrue ( response . containsHeader ( CorsUtil s. ACCESS_CONTROL_EXPOSE_HEADERS ) ) ;
assertTrue ( response . getHeader ( CorsUtil s. ACCESS_CONTROL_EXPOSE_HEADERS ) . contains ( "header1" ) ) ;
assertTrue ( response . getHeader ( CorsUtil s. ACCESS_CONTROL_EXPOSE_HEADERS ) . contains ( "header2" ) ) ;
assertTrue ( response . containsHeader ( HttpHeader s. ACCESS_CONTROL_ALLOW_ORIGIN ) ) ;
assertEquals ( "http://domain2.com/test.html" , response . getHeader ( HttpHeader s. ACCESS_CONTROL_ALLOW_ORIGIN ) ) ;
assertTrue ( response . containsHeader ( HttpHeader s. ACCESS_CONTROL_EXPOSE_HEADERS ) ) ;
assertTrue ( response . getHeader ( HttpHeader s. ACCESS_CONTROL_EXPOSE_HEADERS ) . contains ( "header1" ) ) ;
assertTrue ( response . getHeader ( HttpHeader s. ACCESS_CONTROL_EXPOSE_HEADERS ) . contains ( "header2" ) ) ;
assertEquals ( HttpServletResponse . SC_OK , response . getStatus ( ) ) ;
}
@ -139,7 +139,7 @@ public class DefaultCorsProcessorTests {
@@ -139,7 +139,7 @@ public class DefaultCorsProcessorTests {
public void preflightRequestAllOriginsAllowed ( ) throws Exception {
this . request . setMethod ( HttpMethod . OPTIONS . name ( ) ) ;
this . request . addHeader ( HttpHeaders . ORIGIN , "http://domain2.com/test.html" ) ;
this . request . addHeader ( CorsUtil s. ACCESS_CONTROL_REQUEST_METHOD , "GET" ) ;
this . request . addHeader ( HttpHeader s. ACCESS_CONTROL_REQUEST_METHOD , "GET" ) ;
this . conf . addAllowedOrigin ( "*" ) ;
this . processor . processPreFlightRequest ( this . conf , request , response ) ;
assertEquals ( HttpServletResponse . SC_OK , response . getStatus ( ) ) ;
@ -149,7 +149,7 @@ public class DefaultCorsProcessorTests {
@@ -149,7 +149,7 @@ public class DefaultCorsProcessorTests {
public void preflightRequestWrongAllowedMethod ( ) throws Exception {
this . request . setMethod ( HttpMethod . OPTIONS . name ( ) ) ;
this . request . addHeader ( HttpHeaders . ORIGIN , "http://domain2.com/test.html" ) ;
this . request . addHeader ( CorsUtil s. ACCESS_CONTROL_REQUEST_METHOD , "DELETE" ) ;
this . request . addHeader ( HttpHeader s. ACCESS_CONTROL_REQUEST_METHOD , "DELETE" ) ;
this . conf . addAllowedOrigin ( "*" ) ;
this . processor . processPreFlightRequest ( this . conf , request , response ) ;
assertEquals ( HttpServletResponse . SC_FORBIDDEN , response . getStatus ( ) ) ;
@ -159,17 +159,17 @@ public class DefaultCorsProcessorTests {
@@ -159,17 +159,17 @@ public class DefaultCorsProcessorTests {
public void preflightRequestMatchedAllowedMethod ( ) throws Exception {
this . request . setMethod ( HttpMethod . OPTIONS . name ( ) ) ;
this . request . addHeader ( HttpHeaders . ORIGIN , "http://domain2.com/test.html" ) ;
this . request . addHeader ( CorsUtil s. ACCESS_CONTROL_REQUEST_METHOD , "GET" ) ;
this . request . addHeader ( HttpHeader s. ACCESS_CONTROL_REQUEST_METHOD , "GET" ) ;
this . conf . addAllowedOrigin ( "*" ) ;
this . processor . processPreFlightRequest ( this . conf , request , response ) ;
assertEquals ( HttpServletResponse . SC_OK , response . getStatus ( ) ) ;
assertEquals ( "GET" , response . getHeader ( CorsUtil s. ACCESS_CONTROL_ALLOW_METHODS ) ) ;
assertEquals ( "GET" , response . getHeader ( HttpHeader s. ACCESS_CONTROL_ALLOW_METHODS ) ) ;
}
@Test ( expected = IllegalArgumentException . class )
public void preflightRequestWithoutOriginHeader ( ) throws Exception {
this . request . setMethod ( HttpMethod . OPTIONS . name ( ) ) ;
this . request . addHeader ( CorsUtil s. ACCESS_CONTROL_REQUEST_METHOD , "GET" ) ;
this . request . addHeader ( HttpHeader s. ACCESS_CONTROL_REQUEST_METHOD , "GET" ) ;
this . processor . processPreFlightRequest ( this . conf , request , response ) ;
}
@ -178,7 +178,7 @@ public class DefaultCorsProcessorTests {
@@ -178,7 +178,7 @@ public class DefaultCorsProcessorTests {
this . request . setMethod ( HttpMethod . OPTIONS . name ( ) ) ;
this . request . addHeader ( HttpHeaders . ORIGIN , "http://domain2.com/test.html" ) ;
this . processor . processPreFlightRequest ( this . conf , request , response ) ;
assertFalse ( response . containsHeader ( CorsUtil s. ACCESS_CONTROL_ALLOW_ORIGIN ) ) ;
assertFalse ( response . containsHeader ( HttpHeader s. ACCESS_CONTROL_ALLOW_ORIGIN ) ) ;
assertEquals ( HttpServletResponse . SC_FORBIDDEN , response . getStatus ( ) ) ;
}
@ -186,9 +186,9 @@ public class DefaultCorsProcessorTests {
@@ -186,9 +186,9 @@ public class DefaultCorsProcessorTests {
public void preflightRequestWithoutRequestMethod ( ) throws Exception {
this . request . setMethod ( HttpMethod . OPTIONS . name ( ) ) ;
this . request . addHeader ( HttpHeaders . ORIGIN , "http://domain2.com/test.html" ) ;
this . request . addHeader ( CorsUtil s. ACCESS_CONTROL_REQUEST_HEADERS , "Header1" ) ;
this . request . addHeader ( HttpHeader s. ACCESS_CONTROL_REQUEST_HEADERS , "Header1" ) ;
this . processor . processPreFlightRequest ( this . conf , request , response ) ;
assertFalse ( response . containsHeader ( CorsUtil s. ACCESS_CONTROL_ALLOW_ORIGIN ) ) ;
assertFalse ( response . containsHeader ( HttpHeader s. ACCESS_CONTROL_ALLOW_ORIGIN ) ) ;
assertEquals ( HttpServletResponse . SC_FORBIDDEN , response . getStatus ( ) ) ;
}
@ -196,10 +196,10 @@ public class DefaultCorsProcessorTests {
@@ -196,10 +196,10 @@ public class DefaultCorsProcessorTests {
public void preflightRequestWithRequestAndMethodHeaderButNoConfig ( ) throws Exception {
this . request . setMethod ( HttpMethod . OPTIONS . name ( ) ) ;
this . request . addHeader ( HttpHeaders . ORIGIN , "http://domain2.com/test.html" ) ;
this . request . addHeader ( CorsUtil s. ACCESS_CONTROL_REQUEST_HEADERS , "Header1" ) ;
this . request . addHeader ( CorsUtil s. ACCESS_CONTROL_REQUEST_METHOD , "GET" ) ;
this . request . addHeader ( HttpHeader s. ACCESS_CONTROL_REQUEST_HEADERS , "Header1" ) ;
this . request . addHeader ( HttpHeader s. ACCESS_CONTROL_REQUEST_METHOD , "GET" ) ;
this . processor . processPreFlightRequest ( this . conf , request , response ) ;
assertFalse ( response . containsHeader ( CorsUtil s. ACCESS_CONTROL_ALLOW_ORIGIN ) ) ;
assertFalse ( response . containsHeader ( HttpHeader s. ACCESS_CONTROL_ALLOW_ORIGIN ) ) ;
assertEquals ( HttpServletResponse . SC_FORBIDDEN , response . getStatus ( ) ) ;
}
@ -207,19 +207,19 @@ public class DefaultCorsProcessorTests {
@@ -207,19 +207,19 @@ public class DefaultCorsProcessorTests {
public void preflightRequestValidRequestAndConfig ( ) throws Exception {
this . request . setMethod ( HttpMethod . OPTIONS . name ( ) ) ;
this . request . addHeader ( HttpHeaders . ORIGIN , "http://domain2.com/test.html" ) ;
this . request . addHeader ( CorsUtil s. ACCESS_CONTROL_REQUEST_HEADERS , "Header1" ) ;
this . request . addHeader ( CorsUtil s. ACCESS_CONTROL_REQUEST_METHOD , "GET" ) ;
this . request . addHeader ( HttpHeader s. ACCESS_CONTROL_REQUEST_HEADERS , "Header1" ) ;
this . request . addHeader ( HttpHeader s. ACCESS_CONTROL_REQUEST_METHOD , "GET" ) ;
this . conf . addAllowedOrigin ( "*" ) ;
this . conf . addAllowedMethod ( "GET" ) ;
this . conf . addAllowedMethod ( "PUT" ) ;
this . conf . addAllowedHeader ( "header1" ) ;
this . conf . addAllowedHeader ( "header2" ) ;
this . processor . processPreFlightRequest ( this . conf , request , response ) ;
assertTrue ( response . containsHeader ( CorsUtil s. ACCESS_CONTROL_ALLOW_ORIGIN ) ) ;
assertEquals ( "*" , response . getHeader ( CorsUtil s. ACCESS_CONTROL_ALLOW_ORIGIN ) ) ;
assertTrue ( response . containsHeader ( CorsUtil s. ACCESS_CONTROL_ALLOW_METHODS ) ) ;
assertEquals ( "GET,PUT" , response . getHeader ( CorsUtil s. ACCESS_CONTROL_ALLOW_METHODS ) ) ;
assertFalse ( response . containsHeader ( CorsUtil s. ACCESS_CONTROL_MAX_AGE ) ) ;
assertTrue ( response . containsHeader ( HttpHeader s. ACCESS_CONTROL_ALLOW_ORIGIN ) ) ;
assertEquals ( "*" , response . getHeader ( HttpHeader s. ACCESS_CONTROL_ALLOW_ORIGIN ) ) ;
assertTrue ( response . containsHeader ( HttpHeader s. ACCESS_CONTROL_ALLOW_METHODS ) ) ;
assertEquals ( "GET,PUT" , response . getHeader ( HttpHeader s. ACCESS_CONTROL_ALLOW_METHODS ) ) ;
assertFalse ( response . containsHeader ( HttpHeader s. ACCESS_CONTROL_MAX_AGE ) ) ;
assertEquals ( HttpServletResponse . SC_OK , response . getStatus ( ) ) ;
}
@ -227,18 +227,18 @@ public class DefaultCorsProcessorTests {
@@ -227,18 +227,18 @@ public class DefaultCorsProcessorTests {
public void preflightRequestCrendentials ( ) throws Exception {
this . request . setMethod ( HttpMethod . OPTIONS . name ( ) ) ;
this . request . addHeader ( HttpHeaders . ORIGIN , "http://domain2.com/test.html" ) ;
this . request . addHeader ( CorsUtil s. ACCESS_CONTROL_REQUEST_HEADERS , "Header1" ) ;
this . request . addHeader ( CorsUtil s. ACCESS_CONTROL_REQUEST_METHOD , "GET" ) ;
this . request . addHeader ( HttpHeader s. ACCESS_CONTROL_REQUEST_HEADERS , "Header1" ) ;
this . request . addHeader ( HttpHeader s. ACCESS_CONTROL_REQUEST_METHOD , "GET" ) ;
this . conf . addAllowedOrigin ( "http://domain2.com/home.html" ) ;
this . conf . addAllowedOrigin ( "http://domain2.com/test.html" ) ;
this . conf . addAllowedOrigin ( "http://domain2.com/logout.html" ) ;
this . conf . addAllowedHeader ( "Header1" ) ;
this . conf . setAllowCredentials ( true ) ;
this . processor . processPreFlightRequest ( this . conf , request , response ) ;
assertTrue ( response . containsHeader ( CorsUtil s. ACCESS_CONTROL_ALLOW_ORIGIN ) ) ;
assertEquals ( "http://domain2.com/test.html" , response . getHeader ( CorsUtil s. ACCESS_CONTROL_ALLOW_ORIGIN ) ) ;
assertTrue ( response . containsHeader ( CorsUtil s. ACCESS_CONTROL_ALLOW_CREDENTIALS ) ) ;
assertEquals ( "true" , response . getHeader ( CorsUtil s. ACCESS_CONTROL_ALLOW_CREDENTIALS ) ) ;
assertTrue ( response . containsHeader ( HttpHeader s. ACCESS_CONTROL_ALLOW_ORIGIN ) ) ;
assertEquals ( "http://domain2.com/test.html" , response . getHeader ( HttpHeader s. ACCESS_CONTROL_ALLOW_ORIGIN ) ) ;
assertTrue ( response . containsHeader ( HttpHeader s. ACCESS_CONTROL_ALLOW_CREDENTIALS ) ) ;
assertEquals ( "true" , response . getHeader ( HttpHeader s. ACCESS_CONTROL_ALLOW_CREDENTIALS ) ) ;
assertEquals ( HttpServletResponse . SC_OK , response . getStatus ( ) ) ;
}
@ -246,16 +246,16 @@ public class DefaultCorsProcessorTests {
@@ -246,16 +246,16 @@ public class DefaultCorsProcessorTests {
public void preflightRequestCrendentialsWithOriginWildcard ( ) throws Exception {
this . request . setMethod ( HttpMethod . OPTIONS . name ( ) ) ;
this . request . addHeader ( HttpHeaders . ORIGIN , "http://domain2.com/test.html" ) ;
this . request . addHeader ( CorsUtil s. ACCESS_CONTROL_REQUEST_HEADERS , "Header1" ) ;
this . request . addHeader ( CorsUtil s. ACCESS_CONTROL_REQUEST_METHOD , "GET" ) ;
this . request . addHeader ( HttpHeader s. ACCESS_CONTROL_REQUEST_HEADERS , "Header1" ) ;
this . request . addHeader ( HttpHeader s. ACCESS_CONTROL_REQUEST_METHOD , "GET" ) ;
this . conf . addAllowedOrigin ( "http://domain2.com/home.html" ) ;
this . conf . addAllowedOrigin ( "*" ) ;
this . conf . addAllowedOrigin ( "http://domain2.com/logout.html" ) ;
this . conf . addAllowedHeader ( "Header1" ) ;
this . conf . setAllowCredentials ( true ) ;
this . processor . processPreFlightRequest ( this . conf , request , response ) ;
assertTrue ( response . containsHeader ( CorsUtil s. ACCESS_CONTROL_ALLOW_ORIGIN ) ) ;
assertEquals ( "http://domain2.com/test.html" , response . getHeader ( CorsUtil s. ACCESS_CONTROL_ALLOW_ORIGIN ) ) ;
assertTrue ( response . containsHeader ( HttpHeader s. ACCESS_CONTROL_ALLOW_ORIGIN ) ) ;
assertEquals ( "http://domain2.com/test.html" , response . getHeader ( HttpHeader s. ACCESS_CONTROL_ALLOW_ORIGIN ) ) ;
assertEquals ( HttpServletResponse . SC_OK , response . getStatus ( ) ) ;
}
@ -263,18 +263,18 @@ public class DefaultCorsProcessorTests {
@@ -263,18 +263,18 @@ public class DefaultCorsProcessorTests {
public void preflightRequestAllowedHeaders ( ) throws Exception {
this . request . setMethod ( HttpMethod . OPTIONS . name ( ) ) ;
this . request . addHeader ( HttpHeaders . ORIGIN , "http://domain2.com/test.html" ) ;
this . request . addHeader ( CorsUtil s. ACCESS_CONTROL_REQUEST_HEADERS , "Header1, Header2" ) ;
this . request . addHeader ( CorsUtil s. ACCESS_CONTROL_REQUEST_METHOD , "GET" ) ;
this . request . addHeader ( HttpHeader s. ACCESS_CONTROL_REQUEST_HEADERS , "Header1, Header2" ) ;
this . request . addHeader ( HttpHeader s. ACCESS_CONTROL_REQUEST_METHOD , "GET" ) ;
this . conf . addAllowedHeader ( "Header1" ) ;
this . conf . addAllowedHeader ( "Header2" ) ;
this . conf . addAllowedHeader ( "Header3" ) ;
this . conf . addAllowedOrigin ( "http://domain2.com/test.html" ) ;
this . processor . processPreFlightRequest ( this . conf , request , response ) ;
assertTrue ( response . containsHeader ( CorsUtil s. ACCESS_CONTROL_ALLOW_ORIGIN ) ) ;
assertTrue ( response . containsHeader ( CorsUtil s. ACCESS_CONTROL_ALLOW_HEADERS ) ) ;
assertTrue ( response . getHeader ( CorsUtil s. ACCESS_CONTROL_ALLOW_HEADERS ) . contains ( "Header1" ) ) ;
assertTrue ( response . getHeader ( CorsUtil s. ACCESS_CONTROL_ALLOW_HEADERS ) . contains ( "Header2" ) ) ;
assertFalse ( response . getHeader ( CorsUtil s. ACCESS_CONTROL_ALLOW_HEADERS ) . contains ( "Header3" ) ) ;
assertTrue ( response . containsHeader ( HttpHeader s. ACCESS_CONTROL_ALLOW_ORIGIN ) ) ;
assertTrue ( response . containsHeader ( HttpHeader s. ACCESS_CONTROL_ALLOW_HEADERS ) ) ;
assertTrue ( response . getHeader ( HttpHeader s. ACCESS_CONTROL_ALLOW_HEADERS ) . contains ( "Header1" ) ) ;
assertTrue ( response . getHeader ( HttpHeader s. ACCESS_CONTROL_ALLOW_HEADERS ) . contains ( "Header2" ) ) ;
assertFalse ( response . getHeader ( HttpHeader s. ACCESS_CONTROL_ALLOW_HEADERS ) . contains ( "Header3" ) ) ;
assertEquals ( HttpServletResponse . SC_OK , response . getStatus ( ) ) ;
}
@ -282,16 +282,16 @@ public class DefaultCorsProcessorTests {
@@ -282,16 +282,16 @@ public class DefaultCorsProcessorTests {
public void preflightRequestAllowsAllHeaders ( ) throws Exception {
this . request . setMethod ( HttpMethod . OPTIONS . name ( ) ) ;
this . request . addHeader ( HttpHeaders . ORIGIN , "http://domain2.com/test.html" ) ;
this . request . addHeader ( CorsUtil s. ACCESS_CONTROL_REQUEST_HEADERS , "Header1, Header2" ) ;
this . request . addHeader ( CorsUtil s. ACCESS_CONTROL_REQUEST_METHOD , "GET" ) ;
this . request . addHeader ( HttpHeader s. ACCESS_CONTROL_REQUEST_HEADERS , "Header1, Header2" ) ;
this . request . addHeader ( HttpHeader s. ACCESS_CONTROL_REQUEST_METHOD , "GET" ) ;
this . conf . addAllowedHeader ( "*" ) ;
this . conf . addAllowedOrigin ( "http://domain2.com/test.html" ) ;
this . processor . processPreFlightRequest ( this . conf , request , response ) ;
assertTrue ( response . containsHeader ( CorsUtil s. ACCESS_CONTROL_ALLOW_ORIGIN ) ) ;
assertTrue ( response . containsHeader ( CorsUtil s. ACCESS_CONTROL_ALLOW_HEADERS ) ) ;
assertTrue ( response . getHeader ( CorsUtil s. ACCESS_CONTROL_ALLOW_HEADERS ) . contains ( "Header1" ) ) ;
assertTrue ( response . getHeader ( CorsUtil s. ACCESS_CONTROL_ALLOW_HEADERS ) . contains ( "Header2" ) ) ;
assertFalse ( response . getHeader ( CorsUtil s. ACCESS_CONTROL_ALLOW_HEADERS ) . contains ( "*" ) ) ;
assertTrue ( response . containsHeader ( HttpHeader s. ACCESS_CONTROL_ALLOW_ORIGIN ) ) ;
assertTrue ( response . containsHeader ( HttpHeader s. ACCESS_CONTROL_ALLOW_HEADERS ) ) ;
assertTrue ( response . getHeader ( HttpHeader s. ACCESS_CONTROL_ALLOW_HEADERS ) . contains ( "Header1" ) ) ;
assertTrue ( response . getHeader ( HttpHeader s. ACCESS_CONTROL_ALLOW_HEADERS ) . contains ( "Header2" ) ) ;
assertFalse ( response . getHeader ( HttpHeader s. ACCESS_CONTROL_ALLOW_HEADERS ) . contains ( "*" ) ) ;
assertEquals ( HttpServletResponse . SC_OK , response . getStatus ( ) ) ;
}