From ea3bf08e19bb688a55bdc3be176d3b672653b4e8 Mon Sep 17 00:00:00 2001 From: jangrui Date: Sat, 16 May 2026 01:33:18 +0800 Subject: [PATCH] =?UTF-8?q?fix(tests):=20=E7=A7=BB=E9=99=A4=20LocalAuthSer?= =?UTF-8?q?viceTest=20=E4=B8=AD=E4=B8=8D=E5=BF=85=E8=A6=81=E7=9A=84=20ldap?= =?UTF-8?q?Properties=20stub?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 将 ldapProperties.isEnabled() 的默认 stub 从 setUp() 移到 login_withUnknownUsername_stillPerformsDummyPasswordCheck 中, 消除 7 个测试方法的 UnnecessaryStubbingException。 Signed-off-by: jangrui --- .../com/iflytek/skillhub/auth/local/LocalAuthServiceTest.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/server/skillhub-auth/src/test/java/com/iflytek/skillhub/auth/local/LocalAuthServiceTest.java b/server/skillhub-auth/src/test/java/com/iflytek/skillhub/auth/local/LocalAuthServiceTest.java index bd5ac1c8..ab5b87e7 100644 --- a/server/skillhub-auth/src/test/java/com/iflytek/skillhub/auth/local/LocalAuthServiceTest.java +++ b/server/skillhub-auth/src/test/java/com/iflytek/skillhub/auth/local/LocalAuthServiceTest.java @@ -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);