Skip to content

Commit bf55108

Browse files
committed
feat: 현재 유저 정보 조회 API 추가
1 parent b6ad516 commit bf55108

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

src/main/java/com/example/busan/auth/AuthController.java

+6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.example.busan.auth;
22

3+
import com.example.busan.auth.domain.Authorized;
34
import com.example.busan.auth.dto.AuthenticatePhoneRequest;
45
import com.example.busan.auth.dto.Authentication;
56
import com.example.busan.auth.dto.FindEmailRequest;
@@ -61,4 +62,9 @@ public ResponseEntity<FindEmailResponse> findEmailByPhone(@RequestBody final Fin
6162
final FindEmailResponse response = authService.findEmailByPhone(request.phone());
6263
return ResponseEntity.ok(response);
6364
}
65+
66+
@GetMapping
67+
public ResponseEntity<Authentication> getMemberInfo(@Authorized final Authentication authentication) {
68+
return ResponseEntity.ok(authentication);
69+
}
6470
}

src/test/java/com/example/busan/auth/AuthControllerTest.java

+21
Original file line numberDiff line numberDiff line change
@@ -151,4 +151,25 @@ void findEmailByPhone() throws Exception {
151151
//then
152152
assertThat(response.getStatus()).isEqualTo(HttpStatus.OK.value());
153153
}
154+
155+
@Test
156+
@DisplayName("현재 로그인 유저 정보 얻기")
157+
void getMemberInfo() throws Exception {
158+
//given
159+
httpSession.setAttribute(AUTHORIZATION, new Authentication("[email protected]", Role.USER));
160+
161+
//when
162+
final MockHttpServletResponse response = mockMvc.perform(
163+
get("/auth").session(httpSession))
164+
.andDo(print())
165+
.andDo(document("현재 유저 정보 조회하기",
166+
responseFields(
167+
fieldWithPath("email").description("이메일"),
168+
fieldWithPath("role").description("계정 권한"))))
169+
.andReturn()
170+
.getResponse();
171+
172+
//then
173+
assertThat(response.getStatus()).isEqualTo(HttpStatus.OK.value());
174+
}
154175
}

0 commit comments

Comments
 (0)