@@ -295,6 +295,100 @@ void verifyEmail_missingToken() throws Exception {
295295 .andExpect (jsonPath ("$.message" ).value ("잘못된 요청입니다." ));
296296 }
297297
298+ // ======================== 인증 메일 재발송 테스트 ========================
299+
300+ @ Test
301+ @ DisplayName ("인증 메일 재발송 성공 → 200 OK" )
302+ void resendVerificationEmail_success () throws Exception {
303+ // given: PENDING 상태 유저 생성
304+ User pending =
User .
createUser (
"resenduser" ,
"[email protected] " ,
305+ passwordEncoder .encode ("P@ssw0rd!" ));
306+ pending .setUserProfile (new UserProfile (pending , "재발송닉" , null , null , null , 0 ));
307+ pending .setUserStatus (UserStatus .PENDING );
308+ userRepository .save (pending );
309+
310+ String body = """
311+ {
312+ 313+ }
314+ """ ;
315+
316+ // when & then
317+ mvc .perform (post ("/api/auth/email-verification/resend" )
318+ .contentType (MediaType .APPLICATION_JSON )
319+ .content (body ))
320+ .andDo (print ())
321+ .andExpect (status ().isOk ())
322+ .andExpect (jsonPath ("$.success" ).value (true ))
323+ .andExpect (jsonPath ("$.code" ).value ("SUCCESS_200" ))
324+ .andExpect (jsonPath ("$.message" ).value ("인증 메일이 재발송되었습니다." ))
325+ .andExpect (jsonPath ("$.data" ).isEmpty ());
326+ }
327+
328+ @ Test
329+ @ DisplayName ("인증 메일 재발송 실패 - 존재하지 않는 사용자 → 404 Not Found" )
330+ void resendVerificationEmail_userNotFound () throws Exception {
331+ String body = """
332+ {
333+ 334+ }
335+ """ ;
336+
337+ mvc .perform (post ("/api/auth/email-verification/resend" )
338+ .contentType (MediaType .APPLICATION_JSON )
339+ .content (body ))
340+ .andDo (print ())
341+ .andExpect (status ().isNotFound ())
342+ .andExpect (jsonPath ("$.success" ).value (false ))
343+ .andExpect (jsonPath ("$.code" ).value ("USER_001" ))
344+ .andExpect (jsonPath ("$.message" ).value ("존재하지 않는 사용자입니다." ));
345+ }
346+
347+ @ Test
348+ @ DisplayName ("인증 메일 재발송 실패 - 이미 인증된 계정 → 409 Conflict" )
349+ void resendVerificationEmail_alreadyVerified () throws Exception {
350+ // given: ACTIVE 상태 유저 생성
351+ User active =
User .
createUser (
"activeuser2" ,
"[email protected] " ,
352+ passwordEncoder .encode ("P@ssw0rd!" ));
353+ active .setUserProfile (new UserProfile (active , "액티브닉" , null , null , null , 0 ));
354+ active .setUserStatus (UserStatus .ACTIVE );
355+ userRepository .save (active );
356+
357+ String body = """
358+ {
359+ 360+ }
361+ """ ;
362+
363+ mvc .perform (post ("/api/auth/email-verification/resend" )
364+ .contentType (MediaType .APPLICATION_JSON )
365+ .content (body ))
366+ .andDo (print ())
367+ .andExpect (status ().isConflict ())
368+ .andExpect (jsonPath ("$.success" ).value (false ))
369+ .andExpect (jsonPath ("$.code" ).value ("TOKEN_002" ))
370+ .andExpect (jsonPath ("$.message" ).value ("이미 인증된 계정입니다." ));
371+ }
372+
373+ @ Test
374+ @ DisplayName ("인증 메일 재발송 실패 - 이메일 필드 누락 → 400 Bad Request" )
375+ void resendVerificationEmail_missingField () throws Exception {
376+ // given: 잘못된 요청 (이메일 누락)
377+ String body = """
378+ {
379+ }
380+ """ ;
381+
382+ mvc .perform (post ("/api/auth/email-verification/resend" )
383+ .contentType (MediaType .APPLICATION_JSON )
384+ .content (body ))
385+ .andDo (print ())
386+ .andExpect (status ().isBadRequest ())
387+ .andExpect (jsonPath ("$.success" ).value (false ))
388+ .andExpect (jsonPath ("$.code" ).value ("COMMON_400" ))
389+ .andExpect (jsonPath ("$.message" ).value ("잘못된 요청입니다." ));
390+ }
391+
298392 // ======================== 로그인 테스트 ========================
299393
300394 @ Test
0 commit comments