I have following method in my Spring application
public static String getCurrentUserStudentId() {
return ((LdapPerson) SecurityContextHolder.getContext().getAuthentication().getPrincipal()).getID();
}
This works on the application run, but when I run a test calling this method, it gives
org.springframework.security.web.authentication.preauth.PreAuthenticatedAuthenticationToken cannot be cast to fi.utu.security.ldap.userdetails.LdapPerson
I'm not that familiar with Spring Security to give all the files this could be related, but ask me. I hope someone can tell what to do with this.