@@ -51,6 +51,25 @@ class EmailAuthServiceTest extends UnitTestSupport {
5151 verify (emailSendService ).sendTemplatedEmail (eq (EmailTemplate .AUTH_CODE ), eq (email ), any ());
5252 }
5353
54+ @ Test
55+ void 인증번호_재설정_시_Rate_Limit이_적용되어_있지_않다면_정상_발송된다 () {
56+ // given
57+ String email = "test@example.com" ;
58+
59+ given (redisTemplate .hasKey (anyString ())).willReturn (false );
60+ given (redisTemplate .opsForValue ()).willReturn (valueOperations );
61+
62+ // when
63+ emailAuthService .sendAuthCode (EmailTemplate .PIN_RESET , email );
64+
65+ // then
66+ // 1. Rate Limit 키가 설정되었는지 검증 (3분)
67+ verify (valueOperations ).set (eq ("email:rate_limit:" + email ), eq ("1" ), eq (Duration .ofMinutes (3 )));
68+ // 2. 이메일 발송이 호출되었는지 검증
69+ verify (emailSendService ).sendTemplatedEmail (eq (EmailTemplate .PIN_RESET ), eq (email ), any ());
70+ }
71+
72+
5473 @ Test
5574 void _3분_내에_재요청_시_RateLimitException이_발생한다 () {
5675 // given
@@ -69,19 +88,19 @@ class EmailAuthServiceTest extends UnitTestSupport {
6988 }
7089
7190 @ Test
72- void PIN_재설정_메일은_Rate_Limit_영향을_받지_않는다 () {
91+ void 리마인더_메일은_Rate_Limit_영향을_받지_않는다 () {
7392 // given
7493 String email = "test@example.com" ;
7594 given (redisTemplate .opsForValue ()).willReturn (valueOperations );
7695
7796 // when
78- emailAuthService .sendAuthCode (EmailTemplate .PIN_RESET , email );
97+ emailAuthService .sendAuthCode (EmailTemplate .REMIND_APPLY , email );
7998
8099 // then
81100 // Rate Limit 체크(hasKey)를 하지 않아야 함
82101 verify (redisTemplate , never ()).hasKey (anyString ());
83102
84103 // 이메일 발송은 정상 호출
85- verify (emailSendService ).sendTemplatedEmail (eq (EmailTemplate .PIN_RESET ), eq (email ), any ());
104+ verify (emailSendService ).sendTemplatedEmail (eq (EmailTemplate .REMIND_APPLY ), eq (email ), any ());
86105 }
87106}
0 commit comments