mirror of
https://github.com/st-tu-dresden-praktikum/swt23w23
synced 2024-07-19 21:04:36 +02:00
These action fail in browser
This commit is contained in:
parent
ff8bbdca15
commit
8974e933cd
|
@ -155,7 +155,7 @@ public class UserController {
|
|||
if (
|
||||
!result.hasErrors() &&
|
||||
!userManagement.getUserByName(form.getUsername()).isEmpty() &&
|
||||
!user.getUsername().equals(form.getUsername())
|
||||
(user.getUsername() != form.getUsername())
|
||||
) {
|
||||
result.rejectValue("username", "username already in use");
|
||||
}
|
||||
|
|
|
@ -59,6 +59,7 @@ class UserControllerIntegrationTests {
|
|||
createTestUser("paul");
|
||||
createTestUser("mark");
|
||||
createTestUser("eva");
|
||||
createTestUser("sarah");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -133,6 +134,8 @@ class UserControllerIntegrationTests {
|
|||
String streetPost = userManagement.getUserByName("tim").get().getAddress();
|
||||
|
||||
assertThat(streetPost).isNotEqualTo(streetPre);
|
||||
System.out.println(streetPre);
|
||||
System.out.println(streetPost);
|
||||
}
|
||||
|
||||
// This test is necessary, because the password in the profile form is not
|
||||
|
@ -353,4 +356,20 @@ class UserControllerIntegrationTests {
|
|||
).andExpect(content().string(containsString("Ungültiger Nutzername")));
|
||||
assertTrue(userAccountManagement.findByUsername("eva").isPresent());
|
||||
}
|
||||
|
||||
@Test
|
||||
@WithMockUser(username = "admin", password = "admin", roles = "ADMIN")
|
||||
void editCustomerDetailsExeptUsername() throws Exception {
|
||||
mvc.perform(post("/customers/edit/" + userManagement.getUserByName("sarah").get().getId())
|
||||
.param("username", "sarah")
|
||||
.param("fullName", "Moan Klaus")
|
||||
.param("address", "Baum Straße"))
|
||||
.andExpect(redirectedUrl("/customers"));
|
||||
assertThat(userManagement.getUsers().findAll())
|
||||
.extracting("username", "fullName", "address")
|
||||
.contains(tuple("sarah", "Moan Klaus", "Baum Straße"));
|
||||
mvc.perform(get("/customers/edit/" + userManagement.getUserByName("sarah").get().getId()))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(view().name("edit-customer"));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue