-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/login2' into develop
- Loading branch information
Showing
6 changed files
with
131 additions
and
8 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
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
64 changes: 64 additions & 0 deletions
64
backend/src/test/java/com/infp/ciat/config/security/LoginfilterTest.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package com.infp.ciat.config.security; | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import com.infp.ciat.user.controller.dto.request.SignupRequestDTO; | ||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.http.MediaType; | ||
import org.springframework.test.context.ActiveProfiles; | ||
import org.springframework.test.web.servlet.MockMvc; | ||
import static org.junit.jupiter.api.Assertions.*; | ||
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.status; | ||
|
||
@ActiveProfiles("test") | ||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) | ||
@AutoConfigureMockMvc | ||
class LoginfilterTest { | ||
@Autowired | ||
private MockMvc mockMvc; | ||
|
||
@Test | ||
@DisplayName("회원가입 후 로그인") | ||
public void SignUp() throws Exception { | ||
SignupRequestDTO signup_requestdto1 = create_signup_requestdto("[email protected]", "test1", "password"); | ||
|
||
mockMvc.perform( | ||
post("/signup") | ||
.contentType(MediaType.APPLICATION_JSON) | ||
.content(new ObjectMapper().writeValueAsString(signup_requestdto1)) | ||
) | ||
.andExpect(status().isCreated()) | ||
.andDo(print()); | ||
|
||
RequestLoginDTO requestLoginDTO1 = new RequestLoginDTO(signup_requestdto1.getEmail(), signup_requestdto1.getPassword()); | ||
|
||
mockMvc.perform( | ||
post("/signin") | ||
.contentType(MediaType.APPLICATION_JSON) | ||
.content(new ObjectMapper().writeValueAsString(requestLoginDTO1)) | ||
) | ||
.andExpect(status().isOk()) | ||
.andDo(print()); | ||
} | ||
|
||
/*** | ||
* 회원가입 요청 DTO 생성 | ||
* @param email | ||
* @param nickname | ||
* @param password | ||
* @return | ||
*/ | ||
private SignupRequestDTO create_signup_requestdto(String email, String nickname, String password) { | ||
SignupRequestDTO signupRequestDTO = new SignupRequestDTO(); | ||
signupRequestDTO.setEmail(email); | ||
signupRequestDTO.setNickname(nickname); | ||
signupRequestDTO.setPassword(password); | ||
|
||
return signupRequestDTO; | ||
} | ||
} |
55 changes: 55 additions & 0 deletions
55
backend/src/test/java/com/infp/ciat/user/controller/AccountControllerTest.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package com.infp.ciat.user.controller; | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import com.infp.ciat.user.controller.dto.request.SignupRequestDTO; | ||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.http.MediaType; | ||
import org.springframework.test.context.ActiveProfiles; | ||
import org.springframework.test.web.servlet.MockMvc; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
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.status; | ||
|
||
@ActiveProfiles("test") | ||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) | ||
@AutoConfigureMockMvc | ||
class AccountControllerTest { | ||
@Autowired | ||
private MockMvc mockMvc; | ||
|
||
@Test | ||
@DisplayName("회원가입") | ||
public void SignUp() throws Exception { | ||
SignupRequestDTO signup_requestdto1 = create_signup_requestdto("[email protected]", "test1", "password"); | ||
|
||
mockMvc.perform( | ||
post("/signup") | ||
.contentType(MediaType.APPLICATION_JSON) | ||
.content(new ObjectMapper().writeValueAsString(signup_requestdto1)) | ||
) | ||
.andExpect(status().isCreated()) | ||
.andDo(print()); | ||
} | ||
|
||
/*** | ||
* 회원가입 요청 DTO 생성 | ||
* @param email | ||
* @param nickname | ||
* @param password | ||
* @return | ||
*/ | ||
private SignupRequestDTO create_signup_requestdto(String email, String nickname, String password) { | ||
SignupRequestDTO signupRequestDTO = new SignupRequestDTO(); | ||
signupRequestDTO.setEmail(email); | ||
signupRequestDTO.setNickname(nickname); | ||
signupRequestDTO.setPassword(password); | ||
|
||
return signupRequestDTO; | ||
} | ||
} |
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