fix(tests): 移除 LocalAuthServiceTest 中不必要的 ldapProperties stub

将 ldapProperties.isEnabled() 的默认 stub 从 setUp() 移到
login_withUnknownUsername_stillPerformsDummyPasswordCheck 中,
消除 7 个测试方法的 UnnecessaryStubbingException。

Signed-off-by: jangrui <admin@jangrui.com>
This commit is contained in:
jangrui 2026-05-16 01:33:18 +08:00
parent d09d6172c1
commit ea3bf08e19

View file

@ -65,9 +65,6 @@ class LocalAuthServiceTest {
@BeforeEach
void setUp() {
// 默认禁用 LDAP,确保原有测试不受影响
given(ldapProperties.isEnabled()).willReturn(false);
service = new LocalAuthService(
credentialRepository,
userAccountRepository,
@ -176,6 +173,7 @@ class LocalAuthServiceTest {
@Test
void login_withUnknownUsername_stillPerformsDummyPasswordCheck() {
given(credentialRepository.findByUsernameIgnoreCase("ghost")).willReturn(Optional.empty());
given(ldapProperties.isEnabled()).willReturn(false);
given(passwordEncoder.matches(eq("bad"), eq("$2a$12$8Q/2o2A0V.b18G2DutV4c.s5zZxH6MECM7tP8mYv6b6Q6x6o9v3vu")))
.willReturn(false);