Skip to content
Snippets Groups Projects
Commit 8ec4597d authored by Dominika Zemanovičová's avatar Dominika Zemanovičová
Browse files

Test logout user

parent dea2bf8a
No related branches found
No related tags found
2 merge requests!14Language school user tests,!13Language school user
...@@ -174,7 +174,7 @@ class UserControllerTest { ...@@ -174,7 +174,7 @@ class UserControllerTest {
@Test @Test
void login() throws Exception { void login() throws Exception {
mockMvc.perform(get("/users/login") mockMvc.perform(post("/users/login")
.content(asJsonString(USER_TO_LOGIN)) .content(asJsonString(USER_TO_LOGIN))
.contentType(MediaType.APPLICATION_JSON)) .contentType(MediaType.APPLICATION_JSON))
.andExpect(status().isOk()); .andExpect(status().isOk());
...@@ -189,6 +189,19 @@ class UserControllerTest { ...@@ -189,6 +189,19 @@ class UserControllerTest {
.andExpect(status().is4xxClientError()); .andExpect(status().is4xxClientError());
} }
@Test
void logout() throws Exception {
String response = mockMvc.perform(post("/users")
.content(asJsonString(USER_TO_CREATE))
.contentType(MediaType.APPLICATION_JSON))
.andExpect(status().isOk()).andReturn().getResponse().getContentAsString();
String id = objectMapper.readValue(response, UserDto.class).getId();
mockMvc.perform(post("/users/logout/{id}", id))
.andExpect(status().isOk());
}
private static String asJsonString(final Object obj) throws JsonProcessingException { private static String asJsonString(final Object obj) throws JsonProcessingException {
return new ObjectMapper().writeValueAsString(obj); return new ObjectMapper().writeValueAsString(obj);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment