SEC-2468: JdbcUserDetailsManager#createNewAuthentication uses null credentials

This commit is contained in:
Rob Winch
2014-02-14 16:51:54 -06:00
parent bf2df220ca
commit 65367e6547
2 changed files with 11 additions and 1 deletions

View File

@@ -2,6 +2,7 @@ package org.springframework.security.provisioning;
import static org.junit.Assert.*;
import static org.mockito.Mockito.*;
import static org.fest.assertions.Assertions.assertThat;
import java.util.Collections;
import java.util.HashMap;
@@ -302,6 +303,15 @@ public class JdbcUserDetailsManagerTests {
assertEquals(0, template.queryForList(SELECT_JOE_AUTHORITIES_SQL).size());
}
// SEC-2166
@Test
public void createNewAuthenticationUsesNullPasswordToKeepPassordsSave() {
insertJoe();
UsernamePasswordAuthenticationToken currentAuth = new UsernamePasswordAuthenticationToken("joe",null, AuthorityUtils.createAuthorityList("ROLE_USER"));
Authentication updatedAuth = manager.createNewAuthentication(currentAuth, "new");
assertThat(updatedAuth.getCredentials()).isNull();
}
private Authentication authenticateJoe() {
UsernamePasswordAuthenticationToken auth =
new UsernamePasswordAuthenticationToken("joe","password", joe.getAuthorities());