fix(backend): 后台注册限流配置优先并保留注入兜底
This commit is contained in:
1 parent
903e7db085
commit
35d92c0148
4 files changed
+23
-8
No files matched your search
+4
-3
@@ -26,6 +26,7 @@ import com.fruitshorts.user.vo.TokenRespVO;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.time.LocalDateTime;
|
||||
@@ -193,9 +194,9 @@ class AppAuthServiceTest {
|
||||
|
||||
@Test
|
||||
void should_fallback_to_default_limit_when_config_is_not_numeric() {
|
||||
setRegisterLimits(5, 3);
|
||||
given(configService.get("app.register.max-per-ip-per-day", "5")).willReturn("invalid");
|
||||
given(userMapper.selectCount(any())).willReturn(5L);
|
||||
ReflectionTestUtils.setField(authService, "maxRegisterPerIpPerDay", 2);
|
||||
given(configService.get("app.register.max-per-ip-per-day", "2")).willReturn("invalid");
|
||||
given(userMapper.selectCount(any())).willReturn(2L);
|
||||
|
||||
assertThatThrownBy(() -> authService.register(emailRegister("abcd1234", null), "203.0.113.8"))
|
||||
.isInstanceOf(ServiceException.class)
|
||||
|
||||
Reference in new issue
Block a user