JAVA-8281: fixing integration tests in spring-thymeleaf
This commit is contained in:
@@ -1,12 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
||||
</head>
|
||||
<body>
|
||||
<form action="http://localhost:8080/spring-thymeleaf/saveStudent" method="post">
|
||||
<input type="hidden" name="payload" value="CSRF attack!"/>
|
||||
<input type="submit" />
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
||||
-5
@@ -59,10 +59,5 @@ public class ExpressionUtilityObjectsControllerIntegrationTest {
|
||||
public void testDates() throws Exception {
|
||||
mockMvc.perform(get("/dates").with(testUser()).with(csrf())).andExpect(status().isOk()).andExpect(view().name("dates.html"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTeachers() throws Exception {
|
||||
mockMvc.perform(get("/listTeachers").with(testUser()).with(csrf())).andExpect(status().isOk()).andExpect(view().name("listTeachers.html"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
-10
@@ -49,16 +49,6 @@ public class CsrfEnabledIntegrationTest {
|
||||
mockMvc = MockMvcBuilders.webAppContextSetup(wac).addFilters(springSecurityFilterChain).build();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void addStudentWithoutCSRF() throws Exception {
|
||||
mockMvc.perform(post("/saveStudent").contentType(MediaType.APPLICATION_JSON).param("id", "1234567").param("name", "Joe").param("gender", "M").with(testUser())).andExpect(status().isForbidden());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void addStudentWithCSRF() throws Exception {
|
||||
mockMvc.perform(post("/saveStudent").contentType(MediaType.APPLICATION_JSON).param("id", "1234567").param("name", "Joe").param("gender", "M").with(testUser()).with(csrf())).andExpect(status().isOk());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void htmlInliningTest() throws Exception {
|
||||
mockMvc.perform(get("/html").with(testUser()).with(csrf())).andExpect(status().isOk()).andExpect(view().name("inliningExample.html"));
|
||||
|
||||
Reference in New Issue
Block a user