【发布时间】:2014-02-24 19:49:24
【问题描述】:
如何防止 Spring Security 在我的单元测试中抛出 AuthenticationCredentialsNotFoundException?我不希望用户通过身份验证或匿名身份验证。
我试着这样做:
SecurityContext ctx = SecurityContextHolder.createEmptyContext();
SecurityContextHolder.setContext(ctx);
// ctx.setAuthentication();
但我不知道从哪里获取匿名身份验证对象。
【问题讨论】:
标签: spring unit-testing spring-security