Search in sources :

Example 96 with MockMvc

use of org.springframework.test.web.servlet.MockMvc in project uplace.es by Uplace.

the class WebConfigurerTest method testCorsFilterDeactivated2.

@Test
public void testCorsFilterDeactivated2() throws Exception {
    props.getCors().setAllowedOrigins(new ArrayList<>());
    MockMvc mockMvc = MockMvcBuilders.standaloneSetup(new WebConfigurerTestController()).addFilters(webConfigurer.corsFilter()).build();
    mockMvc.perform(get("/api/test-cors").header(HttpHeaders.ORIGIN, "other.domain.com")).andExpect(status().isOk()).andExpect(header().doesNotExist(HttpHeaders.ACCESS_CONTROL_ALLOW_ORIGIN));
}
Also used : MockMvc(org.springframework.test.web.servlet.MockMvc) Test(org.junit.Test)

Example 97 with MockMvc

use of org.springframework.test.web.servlet.MockMvc in project uplace.es by Uplace.

the class WebConfigurerTest method testCorsFilterDeactivated.

@Test
public void testCorsFilterDeactivated() throws Exception {
    props.getCors().setAllowedOrigins(null);
    MockMvc mockMvc = MockMvcBuilders.standaloneSetup(new WebConfigurerTestController()).addFilters(webConfigurer.corsFilter()).build();
    mockMvc.perform(get("/api/test-cors").header(HttpHeaders.ORIGIN, "other.domain.com")).andExpect(status().isOk()).andExpect(header().doesNotExist(HttpHeaders.ACCESS_CONTROL_ALLOW_ORIGIN));
}
Also used : MockMvc(org.springframework.test.web.servlet.MockMvc) Test(org.junit.Test)

Aggregations

MockMvc (org.springframework.test.web.servlet.MockMvc)97 Test (org.junit.Test)91 AnnotationConfigWebApplicationContext (org.springframework.web.context.support.AnnotationConfigWebApplicationContext)25 Todo (org.springframework.sync.Todo)16 List (java.util.List)15 TodoRepository (org.springframework.sync.TodoRepository)15 Filter (javax.servlet.Filter)13 MockServletContext (org.springframework.mock.web.MockServletContext)13 AnnotationConfigApplicationContext (org.springframework.context.annotation.AnnotationConfigApplicationContext)12 OncePerRequestFilter (org.springframework.web.filter.OncePerRequestFilter)9 MvcResult (org.springframework.test.web.servlet.MvcResult)6 TestingAuthenticationToken (org.springframework.security.authentication.TestingAuthenticationToken)5 Ignore (org.junit.Ignore)3 FilterChainProxy (org.springframework.security.web.FilterChainProxy)3 WebConnection (com.gargoylesoftware.htmlunit.WebConnection)2 CountDownLatch (java.util.concurrent.CountDownLatch)2 HttpSession (javax.servlet.http.HttpSession)2 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)2 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)2 DirectFieldAccessor (org.springframework.beans.DirectFieldAccessor)2