mirror of
https://github.com/st-tu-dresden-praktikum/swt23w23
synced 2024-07-19 21:04:36 +02:00
Add more username tests
These test validate, that no username validation will be performed, if the form has an error.
This commit is contained in:
parent
073600a92c
commit
de900d2eeb
|
@ -61,6 +61,8 @@ class UserControllerIntegrationTests {
|
|||
createTestUser("eva");
|
||||
createTestUser("sarah");
|
||||
createTestUser("paul");
|
||||
createTestUser("maria");
|
||||
createTestUser("adam");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -401,4 +403,45 @@ class UserControllerIntegrationTests {
|
|||
.andExpect(redirectedUrl("/"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@WithMockUser(username = "maria", password = "123")
|
||||
void alreadyExistingNameCheckWillNotBePerformedIfFormHasErrorProfile() throws Exception {
|
||||
assertTrue(userManagement.getUserByName("maria").isPresent());
|
||||
MockHttpServletRequestBuilder createMessage = post("/profile")
|
||||
.param("username", "admin")
|
||||
.param("password", "\0")
|
||||
.param("address", "Baum Straße");
|
||||
assertThat(mvc.perform(createMessage).andReturn().getResponse().getContentAsString())
|
||||
.contains("Ungültiges Passwort")
|
||||
.contains("Ungültiger Name")
|
||||
.doesNotContain("Ungültiger Nutzername");
|
||||
}
|
||||
|
||||
@Test
|
||||
@WithMockUser(username = "admin", password = "admin", roles = "ADMIN")
|
||||
void alreadyExistingNameCheckWillNotBePerformedIfFormHasErrorCustomer() throws Exception {
|
||||
assertThat(userManagement.getUsers().findAll())
|
||||
.extracting("username", "fullName", "address")
|
||||
.contains(tuple("adam", "Adam Klaus", "Baum Weg"));
|
||||
assertThat(mvc.perform(post("/customers/edit/" + userManagement.getUserByName("adam").get().getId())
|
||||
.param("username", "adam")
|
||||
.param("address", "Baum Straße"))
|
||||
.andReturn().getResponse().getContentAsString())
|
||||
.contains("Ungültiger Name")
|
||||
.doesNotContain("Ungültiger Nutzername");
|
||||
}
|
||||
|
||||
@Test
|
||||
@WithAnonymousUser
|
||||
void alreadyExistingNameCheckWillNotBePerformedIfFormHasErrorRegistration() throws Exception {
|
||||
MockHttpServletRequestBuilder createCustomer = post("/register")
|
||||
.param("username", "admin")
|
||||
.param("password", "\0")
|
||||
.param("fullName", "Tom Klaus")
|
||||
.param("address", "Baum Weg");
|
||||
assertThat(mvc.perform(createCustomer).andReturn().getResponse().getContentAsString())
|
||||
.contains("Ungültiges Passwort")
|
||||
.doesNotContain("Ungültiger Nutzername");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue