Implement UserDetailsPasswordService in JdbcUserDetailsManager

Signed-off-by: Junhyeok Lee <jhl221123@naver.com>
This commit is contained in:
Junhyeok Lee
2025-05-08 01:41:22 +09:00
committed by Rob Winch
parent 817938fa49
commit 0722c2dc41
2 changed files with 46 additions and 1 deletions

View File

@@ -410,6 +410,23 @@ public class JdbcUserDetailsManagerTests {
verify(mockMapper).mapRow(any(), anyInt());
}
@Test
void updatePasswordWhenDisabledReturnOriginalUser() {
insertJoe();
this.manager.updatePassword(joe, "new");
UserDetails newJoe = this.manager.loadUserByUsername("joe");
assertThat(newJoe.getPassword()).isEqualTo("password");
}
@Test
void updatePasswordWhenEnabledShouldUpdatePassword() {
insertJoe();
this.manager.setEnableUpdatePassword(true);
this.manager.updatePassword(joe, "new");
UserDetails newJoe = this.manager.loadUserByUsername("joe");
assertThat(newJoe.getPassword()).isEqualTo("new");
}
private Authentication authenticateJoe() {
UsernamePasswordAuthenticationToken auth = UsernamePasswordAuthenticationToken.authenticated("joe", "password",
joe.getAuthorities());