mirror of
https://github.com/spring-projects/spring-security.git
synced 2025-07-07 19:22:14 +00:00
Added test for non-String role.
This commit is contained in:
parent
49da801096
commit
aaf51c4bee
@ -20,6 +20,8 @@ import junit.framework.TestCase;
|
|||||||
import javax.naming.directory.BasicAttributes;
|
import javax.naming.directory.BasicAttributes;
|
||||||
import javax.naming.directory.BasicAttribute;
|
import javax.naming.directory.BasicAttribute;
|
||||||
|
|
||||||
|
import org.acegisecurity.GrantedAuthorityImpl;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests {@link LdapUserDetailsMapper}.
|
* Tests {@link LdapUserDetailsMapper}.
|
||||||
*
|
*
|
||||||
@ -64,4 +66,17 @@ public class LdapUserDetailsMapperTests extends TestCase {
|
|||||||
assertEquals(1, user.getGrantedAuthorities().length);
|
assertEquals(1, user.getGrantedAuthorities().length);
|
||||||
assertEquals("ROLE_X", user.getGrantedAuthorities()[0].getAuthority());
|
assertEquals("ROLE_X", user.getGrantedAuthorities()[0].getAuthority());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testNonStringRoleAttributeIsIgnoredByDefault() throws Exception {
|
||||||
|
LdapUserDetailsMapper mapper = new LdapUserDetailsMapper();
|
||||||
|
|
||||||
|
mapper.setRoleAttributes(new String[] {"userRole"});
|
||||||
|
|
||||||
|
BasicAttributes attrs = new BasicAttributes();
|
||||||
|
attrs.put(new BasicAttribute("userRole", new GrantedAuthorityImpl("X")));
|
||||||
|
|
||||||
|
LdapUserDetailsImpl.Essence user = (LdapUserDetailsImpl.Essence) mapper.mapAttributes("cn=someName", attrs);
|
||||||
|
|
||||||
|
assertEquals(0, user.getGrantedAuthorities().length);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user