Fix failing tests
This commit is contained in:
parent
452c3230cc
commit
eb8c253499
|
|
@ -17,11 +17,11 @@
|
|||
package org.springframework.web.cors;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.mock.web.test.MockHttpServletRequest;
|
||||
import org.springframework.mock.web.test.MockHttpServletResponse;
|
||||
|
||||
/**
|
||||
* Test case for {@link CorsUtils}.
|
||||
|
|
@ -66,17 +66,4 @@ public class CorsUtilsTests {
|
|||
assertFalse(CorsUtils.isPreFlightRequest(request));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isCorsResponse() {
|
||||
MockHttpServletResponse response = new MockHttpServletResponse();
|
||||
response.addHeader(CorsUtils.ACCESS_CONTROL_ALLOW_ORIGIN, "*");
|
||||
assertTrue(CorsUtils.isCorsResponse(response));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isNotCorsResponse() {
|
||||
MockHttpServletResponse response = new MockHttpServletResponse();
|
||||
assertFalse(CorsUtils.isCorsResponse(response));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,12 +51,10 @@ public class DefaultCorsProcessorTests {
|
|||
this.processor = new DefaultCorsProcessor();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void actualRequestWithoutOriginHeader() throws Exception {
|
||||
this.request.setMethod(HttpMethod.GET.name());
|
||||
this.processor.processActualRequest(this.conf, request, response);
|
||||
assertFalse(response.containsHeader(CorsUtils.ACCESS_CONTROL_ALLOW_ORIGIN));
|
||||
assertEquals(HttpServletResponse.SC_FORBIDDEN, response.getStatus());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -168,13 +166,11 @@ public class DefaultCorsProcessorTests {
|
|||
assertEquals("GET", response.getHeader(CorsUtils.ACCESS_CONTROL_ALLOW_METHODS));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void preflightRequestWithoutOriginHeader() throws Exception {
|
||||
this.request.setMethod(HttpMethod.OPTIONS.name());
|
||||
this.request.addHeader(CorsUtils.ACCESS_CONTROL_REQUEST_METHOD, "GET");
|
||||
this.processor.processPreFlightRequest(this.conf, request, response);
|
||||
assertFalse(response.containsHeader(CorsUtils.ACCESS_CONTROL_ALLOW_ORIGIN));
|
||||
assertEquals(HttpServletResponse.SC_FORBIDDEN, response.getStatus());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
Loading…
Reference in New Issue