How to prevent Spring Security from throwing AuthenticationCredentialsNotFoundException in my unit tests? I'd like the user not to be authenticated, or to be authenticated anonymously.
I tried to do it like this:
SecurityContext ctx = SecurityContextHolder.createEmptyContext();
SecurityContextHolder.setContext(ctx);
// ctx.setAuthentication();
but I don't know where to get that anonymous authentication object from.