diff --git a/src/test/java/yonseigolf/server/user/controller/UserControllerTest.java b/src/test/java/yonseigolf/server/user/controller/UserControllerTest.java index 9ab266b..7d85ea6 100644 --- a/src/test/java/yonseigolf/server/user/controller/UserControllerTest.java +++ b/src/test/java/yonseigolf/server/user/controller/UserControllerTest.java @@ -127,45 +127,6 @@ void yonseiGolfLoginTest() throws Exception { )); } - @Test - @DisplayName("회원이 아니라면 회원가입을 할 수 있다.") - void signUpTest() throws Exception { - // given - MockHttpSession session = new MockHttpSession(); - session.setAttribute("kakaoUser", 1L); - SignUpUserRequest request = SignUpUserRequest.builder() - .name("name") - .phoneNumber("phoneNumber") - .major("major") - .studentId(1) - .semester(10) - .build(); - // when - - // then - mockMvc.perform(post("/users/signUp") - .session(session) - .contentType(MediaType.APPLICATION_JSON) - .content(objectMapper.writeValueAsString(request))) - .andDo(print()) - .andExpect(status().isOk()) - .andDo(document("user-signUp-doc", - getDocumentRequest(), - getDocumentResponse(), - requestFields( - fieldWithPath("name").type(JsonFieldType.STRING) - .description("이름"), - fieldWithPath("phoneNumber").type(JsonFieldType.STRING) - .description("전화번호"), - fieldWithPath("major").type(JsonFieldType.STRING) - .description("전공"), - fieldWithPath("studentId").type(JsonFieldType.NUMBER) - .description("학번"), - fieldWithPath("semester").type(JsonFieldType.NUMBER) - .description("학기")) - )); - } - @Test @DisplayName("로그인된 상태라면 에러를 발생한다.") void loggedInErrorTest() throws Exception { diff --git a/src/test/java/yonseigolf/server/user/controller/UserIntegrateControllerTest.java b/src/test/java/yonseigolf/server/user/controller/UserIntegrateControllerTest.java deleted file mode 100644 index f226880..0000000 --- a/src/test/java/yonseigolf/server/user/controller/UserIntegrateControllerTest.java +++ /dev/null @@ -1,82 +0,0 @@ -package yonseigolf.server.user.controller; - -import com.fasterxml.jackson.databind.ObjectMapper; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Test; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.mock.web.MockHttpSession; -import org.springframework.test.web.servlet.MockMvc; -import org.springframework.test.web.servlet.setup.MockMvcBuilders; -import yonseigolf.server.user.dto.request.SignUpUserRequest; - -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; - -@SpringBootTest -class UserIntegrateControllerTest { - - private MockMvc mockMvc; - @Autowired - private UserController userController; - @Autowired - private UserExceptionController userExceptionController; - - @BeforeEach - void setUp() { - mockMvc = MockMvcBuilders - .standaloneSetup(userController) - .setControllerAdvice(userExceptionController) - .build(); - } - - @Test - @DisplayName("이미 로그인한 경우 401 에러가 발생한다.") - public void testAlreadyLoggedIn() throws Exception { - // given - MockHttpSession session = new MockHttpSession(); - session.setAttribute("user", "testUser"); - - SignUpUserRequest request = SignUpUserRequest.builder() - .name("testName") - .phoneNumber("010-1234-5678") - .studentId(12) - .major("testMajor") - .semester(1) - .build(); - - String requestBody = new ObjectMapper().writeValueAsString(request); - - // when & then - mockMvc.perform(post("/users/signUp") - .content(requestBody) - .contentType("application/json") - .session(session)) - .andExpect(status().isUnauthorized()); - } - - @Test - @DisplayName("로그인 하지 않았지만, 카카오 로그인을 하지 않은 경우 401 에러가 발생한다.") - void test() throws Exception { - // given - MockHttpSession session = new MockHttpSession(); - - SignUpUserRequest request = SignUpUserRequest.builder() - .name("testName") - .phoneNumber("010-1234-5678") - .studentId(12) - .major("testMajor") - .semester(1) - .build(); - - String requestBody = new ObjectMapper().writeValueAsString(request); - - // when & then - mockMvc.perform(post("/users/signUp") - .content(requestBody) - .contentType("application/json") - .session(session)) - .andExpect(status().isUnauthorized()); - } -} \ No newline at end of file