SAMLAuthenticationToken token = new SAMLAuthenticationToken(context);
SAMLCredential result = new SAMLCredential(nameID, assertion, "IDP", "localSP");
expect(consumer.processAuthenticationResponse(context)).andReturn(result);
expect(assertion.getAuthnStatements()).andReturn(new LinkedList<AuthnStatement>());
User user = new User("test", "test", true, true, true, true, Arrays.asList(new SimpleGrantedAuthority("role1"), new SimpleGrantedAuthority("role2")));
expect(details.loadUserBySAML(result)).andReturn(user);
provider.setForcePrincipalAsString(false);
replayMock();
replay(details);
Authentication authentication = provider.authenticate(token);
assertEquals(user, authentication.getPrincipal());
assertEquals(user.getUsername(), authentication.getName());
assertNotNull(authentication.getDetails());
assertEquals(2, authentication.getAuthorities().size());
assertTrue(authentication.getAuthorities().contains(new SimpleGrantedAuthority("role1")));
assertTrue(authentication.getAuthorities().contains(new SimpleGrantedAuthority("role2")));
verify(details);