File tree 2 files changed +27
-0
lines changed
main/java/com/example/busan/auth
test/java/com/example/busan/auth
2 files changed +27
-0
lines changed Original file line number Diff line number Diff line change 1
1
package com .example .busan .auth ;
2
2
3
+ import com .example .busan .auth .domain .Authorized ;
3
4
import com .example .busan .auth .dto .AuthenticatePhoneRequest ;
4
5
import com .example .busan .auth .dto .Authentication ;
5
6
import com .example .busan .auth .dto .FindEmailRequest ;
@@ -61,4 +62,9 @@ public ResponseEntity<FindEmailResponse> findEmailByPhone(@RequestBody final Fin
61
62
final FindEmailResponse response = authService .findEmailByPhone (request .phone ());
62
63
return ResponseEntity .ok (response );
63
64
}
65
+
66
+ @ GetMapping
67
+ public ResponseEntity <Authentication > getMemberInfo (@ Authorized final Authentication authentication ) {
68
+ return ResponseEntity .ok (authentication );
69
+ }
64
70
}
Original file line number Diff line number Diff line change @@ -151,4 +151,25 @@ void findEmailByPhone() throws Exception {
151
151
//then
152
152
assertThat (response .getStatus ()).isEqualTo (HttpStatus .OK .value ());
153
153
}
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
+ }
154
175
}
You can’t perform that action at this time.
0 commit comments