public void testAdditionalAuthenticationChecks() {
UserDetails user = userDetailService.loadUserByUsername(getTestUser().getUserId());
//remove authentication temporally
Authentication oriAuth = SecurityContextHolder.getContext().getAuthentication();
SecurityContextImpl context = new SecurityContextImpl();
SecurityContextHolder.setContext(context);
UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken("admin", null);
try {
provider.additionalAuthenticationChecks(user, token);
assertTrue(false);
} catch (BadCredentialsException e) {
assertTrue(true);
}
token = new UsernamePasswordAuthenticationToken("TEST_USER", "123");
provider.additionalAuthenticationChecks(user, token);
context.setAuthentication(oriAuth);
}