diff --git a/src/test/java/com/linkurlshorter/urlshortener/auth/AuthControllerIntegrationTest.java b/src/test/java/com/linkurlshorter/urlshortener/auth/AuthControllerIntegrationTest.java index 2ea568d..3333374 100644 --- a/src/test/java/com/linkurlshorter/urlshortener/auth/AuthControllerIntegrationTest.java +++ b/src/test/java/com/linkurlshorter/urlshortener/auth/AuthControllerIntegrationTest.java @@ -2,8 +2,6 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.linkurlshorter.urlshortener.auth.dto.AuthRequest; -import com.linkurlshorter.urlshortener.user.ChangeUserEmailRequest; -import com.linkurlshorter.urlshortener.user.ChangeUserPasswordRequest; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.params.ParameterizedTest; @@ -74,8 +72,7 @@ void loginFailedWhenUserDoesNotExistTest() throws Exception { .content(objectMapper.writeValueAsString(authRequest))) .andExpect(MockMvcResultMatchers.status().is4xxClientError()) .andExpect(MockMvcResultMatchers.jsonPath("$.statusCode").value(401)) - .andExpect(MockMvcResultMatchers.jsonPath("$.message").value("Authentication failed!")) - .andExpect(MockMvcResultMatchers.jsonPath("$.exceptionMessage").value("No user by provided email found")); + .andExpect(MockMvcResultMatchers.jsonPath("$.message").value("No user by provided email found")); } /** @@ -91,8 +88,7 @@ void loginFailedWhenPasswordDoesNotMatchTest() throws Exception { .content(objectMapper.writeValueAsString(authRequest))) .andExpect(MockMvcResultMatchers.status().is4xxClientError()) .andExpect(MockMvcResultMatchers.jsonPath("$.statusCode").value(401)) - .andExpect(MockMvcResultMatchers.jsonPath("$.message").value("Bad Credentials!")) - .andExpect(MockMvcResultMatchers.jsonPath("$.exceptionMessage").value("Bad credentials")); + .andExpect(MockMvcResultMatchers.jsonPath("$.message").value("Bad credentials")); } /** @@ -110,8 +106,7 @@ void loginFailedWhenInvalidPasswordGivenTest(String password) throws Exception { .content(objectMapper.writeValueAsString(authRequest))) .andExpect(status().is4xxClientError()) .andExpect(MockMvcResultMatchers.jsonPath("$.statusCode").value(400)) - .andExpect(MockMvcResultMatchers.jsonPath("$.message").value("Validation failed!")) - .andExpect(MockMvcResultMatchers.jsonPath("$.exceptionMessage").value("Password " + + .andExpect(MockMvcResultMatchers.jsonPath("$.message").value("Password " + "must be at least 8 characters long and contain at least one digit, one uppercase letter, " + "and one lowercase letter. No spaces are allowed.")); } @@ -136,9 +131,7 @@ void loginFailedWhenInvalidEmailGivenTest(String email) throws Exception { .content(objectMapper.writeValueAsString(authRequest))) .andExpect(status().is4xxClientError()) .andExpect(MockMvcResultMatchers.jsonPath("$.statusCode").value(400)) - .andExpect(MockMvcResultMatchers.jsonPath("$.message").value("Validation failed!")) - .andExpect(MockMvcResultMatchers.jsonPath("$.exceptionMessage") - .value("Email address entered incorrectly!")); + .andExpect(MockMvcResultMatchers.jsonPath("$.message").value("Email address entered incorrectly!")); } /** @@ -156,8 +149,7 @@ void registerFailedWhenInvalidPasswordGivenTest(String password) throws Exceptio .content(objectMapper.writeValueAsString(authRequest))) .andExpect(status().is4xxClientError()) .andExpect(MockMvcResultMatchers.jsonPath("$.statusCode").value(400)) - .andExpect(MockMvcResultMatchers.jsonPath("$.message").value("Validation failed!")) - .andExpect(MockMvcResultMatchers.jsonPath("$.exceptionMessage").value("Password " + + .andExpect(MockMvcResultMatchers.jsonPath("$.message").value("Password " + "must be at least 8 characters long and contain at least one digit, one uppercase letter, " + "and one lowercase letter. No spaces are allowed.")); } @@ -182,8 +174,6 @@ void registerFailedWhenInvalidEmailGivenTest(String email) throws Exception { .content(objectMapper.writeValueAsString(authRequest))) .andExpect(status().is4xxClientError()) .andExpect(MockMvcResultMatchers.jsonPath("$.statusCode").value(400)) - .andExpect(MockMvcResultMatchers.jsonPath("$.message").value("Validation failed!")) - .andExpect(MockMvcResultMatchers.jsonPath("$.exceptionMessage") - .value("Email address entered incorrectly!")); + .andExpect(MockMvcResultMatchers.jsonPath("$.message").value("Email address entered incorrectly!")); } } diff --git a/src/test/java/com/linkurlshorter/urlshortener/user/UserControllerIntegrationTest.java b/src/test/java/com/linkurlshorter/urlshortener/user/UserControllerIntegrationTest.java index 91b68ec..61f2539 100644 --- a/src/test/java/com/linkurlshorter/urlshortener/user/UserControllerIntegrationTest.java +++ b/src/test/java/com/linkurlshorter/urlshortener/user/UserControllerIntegrationTest.java @@ -23,8 +23,6 @@ import org.testcontainers.junit.jupiter.Container; import org.testcontainers.junit.jupiter.Testcontainers; - -import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.csrf; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; @@ -106,8 +104,7 @@ void changePasswordFailedWhenInvalidPasswordGivenTest(String password) throws Ex .content(objectMapper.writeValueAsString(request))) .andExpect(status().is4xxClientError()) .andExpect(MockMvcResultMatchers.jsonPath("$.statusCode").value(400)) - .andExpect(MockMvcResultMatchers.jsonPath("$.message").value("Validation failed!")) - .andExpect(MockMvcResultMatchers.jsonPath("$.exceptionMessage").value("Password " + + .andExpect(MockMvcResultMatchers.jsonPath("$.message").value("Password " + "must be at least 8 characters long and contain at least one digit, one uppercase letter, " + "and one lowercase letter. No spaces are allowed.")); } @@ -158,8 +155,7 @@ void changeEmailFailedWhenInvalidEmailGivenTest(String email) throws Exception { .content(objectMapper.writeValueAsString(request))) .andExpect(status().is4xxClientError()) .andExpect(MockMvcResultMatchers.jsonPath("$.statusCode").value(400)) - .andExpect(MockMvcResultMatchers.jsonPath("$.message").value("Validation failed!")) - .andExpect(MockMvcResultMatchers.jsonPath("$.exceptionMessage") + .andExpect(MockMvcResultMatchers.jsonPath("$.message") .value("Email address entered incorrectly!")); } }