-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #65 from nastiausenko/fix-errors
Fix errors
- Loading branch information
Showing
12 changed files
with
118 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...hortener/security/ForbiddenException.java → ...urlshortener/link/ForbiddenException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
src/main/java/com/linkurlshorter/urlshortener/link/LinkController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,7 +22,6 @@ | |
import org.testcontainers.junit.jupiter.Testcontainers; | ||
|
||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; | ||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; | ||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; | ||
|
||
/** | ||
|
@@ -59,9 +58,9 @@ void loginSuccessfulTest() throws Exception { | |
this.mockMvc.perform(MockMvcRequestBuilders.post(baseUrl + "login") | ||
.contentType(MediaType.APPLICATION_JSON) | ||
.content(objectMapper.writeValueAsString(authRequest))) | ||
.andExpect(status().isOk()) | ||
.andExpect(jsonPath("$.message").value("User logged in successfully!")) | ||
.andExpect(jsonPath("$.jwtToken").exists()); | ||
.andExpect(MockMvcResultMatchers.status().isOk()) | ||
.andExpect(MockMvcResultMatchers.jsonPath("$.message").value("User logged in successfully!")) | ||
.andExpect(MockMvcResultMatchers.jsonPath("$.jwtToken").exists()); | ||
} | ||
|
||
/** | ||
|
@@ -72,12 +71,12 @@ void loginSuccessfulTest() throws Exception { | |
@Test | ||
void loginFailedWhenUserDoesNotExistTest() throws Exception { | ||
authRequest = new AuthRequest("[email protected]", "Pass1234"); | ||
this.mockMvc.perform(post(baseUrl + "login") | ||
this.mockMvc.perform(MockMvcRequestBuilders.post(baseUrl + "login") | ||
.contentType(MediaType.APPLICATION_JSON) | ||
.content(objectMapper.writeValueAsString(authRequest))) | ||
.andExpect(status().is4xxClientError()) | ||
.andExpect(jsonPath("$.statusCode").value(401)) | ||
.andExpect(jsonPath("$.message").value("Authentication failed!")); | ||
.andExpect(MockMvcResultMatchers.status().is4xxClientError()) | ||
.andExpect(MockMvcResultMatchers.jsonPath("$.statusCode").value(401)) | ||
.andExpect(MockMvcResultMatchers.jsonPath("$.message").value("No user by provided email found")); | ||
} | ||
|
||
/** | ||
|
@@ -88,12 +87,12 @@ void loginFailedWhenUserDoesNotExistTest() throws Exception { | |
@Test | ||
void loginFailedWhenPasswordDoesNotMatchTest() throws Exception { | ||
authRequest = new AuthRequest("[email protected]", "Pass12345"); | ||
this.mockMvc.perform(post(baseUrl + "login") | ||
this.mockMvc.perform(MockMvcRequestBuilders.post(baseUrl + "login") | ||
.contentType(MediaType.APPLICATION_JSON) | ||
.content(objectMapper.writeValueAsString(authRequest))) | ||
.andExpect(MockMvcResultMatchers.status().is4xxClientError()) | ||
.andExpect(jsonPath("$.statusCode").value(401)) | ||
.andExpect(jsonPath("$.message").value("Bad Credentials!")); | ||
.andExpect(MockMvcResultMatchers.jsonPath("$.statusCode").value(401)) | ||
.andExpect(MockMvcResultMatchers.jsonPath("$.message").value("Bad credentials")); | ||
} | ||
|
||
/** | ||
|
@@ -110,8 +109,10 @@ void loginFailedWhenInvalidPasswordGivenTest(String password) throws Exception { | |
.contentType(MediaType.APPLICATION_JSON) | ||
.content(objectMapper.writeValueAsString(authRequest))) | ||
.andExpect(status().is4xxClientError()) | ||
.andExpect(jsonPath("$.statusCode").value(400)) | ||
.andExpect(jsonPath("$.message").value("Validation failed!")); | ||
.andExpect(MockMvcResultMatchers.jsonPath("$.statusCode").value(400)) | ||
.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.")); | ||
} | ||
|
||
/** | ||
|
@@ -133,8 +134,8 @@ void loginFailedWhenInvalidEmailGivenTest(String email) throws Exception { | |
.contentType(MediaType.APPLICATION_JSON) | ||
.content(objectMapper.writeValueAsString(authRequest))) | ||
.andExpect(status().is4xxClientError()) | ||
.andExpect(jsonPath("$.statusCode").value(400)) | ||
.andExpect(jsonPath("$.message").value("Validation failed!")); | ||
.andExpect(MockMvcResultMatchers.jsonPath("$.statusCode").value(400)) | ||
.andExpect(MockMvcResultMatchers.jsonPath("$.message").value("Email address entered incorrectly!")); | ||
} | ||
|
||
/** | ||
|
@@ -167,8 +168,10 @@ void registerFailedWhenInvalidPasswordGivenTest(String password) throws Exceptio | |
.contentType(MediaType.APPLICATION_JSON) | ||
.content(objectMapper.writeValueAsString(authRequest))) | ||
.andExpect(status().is4xxClientError()) | ||
.andExpect(jsonPath("$.statusCode").value(400)) | ||
.andExpect(jsonPath("$.message").value("Validation failed!")); | ||
.andExpect(MockMvcResultMatchers.jsonPath("$.statusCode").value(400)) | ||
.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.")); | ||
} | ||
|
||
/** | ||
|
@@ -190,7 +193,7 @@ void registerFailedWhenInvalidEmailGivenTest(String email) throws Exception { | |
.contentType(MediaType.APPLICATION_JSON) | ||
.content(objectMapper.writeValueAsString(authRequest))) | ||
.andExpect(status().is4xxClientError()) | ||
.andExpect(jsonPath("$.statusCode").value(400)) | ||
.andExpect(jsonPath("$.message").value("Validation failed!")); | ||
.andExpect(MockMvcResultMatchers.jsonPath("$.statusCode").value(400)) | ||
.andExpect(MockMvcResultMatchers.jsonPath("$.message").value("Email address entered incorrectly!")); | ||
} | ||
} | ||
} |
Oops, something went wrong.