use of org.springframework.security.userdetails.User in project gocd by gocd.
the class RemoveAdminPermissionFilterIntegrationTest method setupAuthentication.
private Authentication setupAuthentication() {
GrantedAuthority[] authorities = {};
Authentication authentication = new TestingAuthenticationToken(new User("loser", "secret", true, true, true, true, authorities), null, authorities);
SecurityContextHolder.getContext().setAuthentication(authentication);
authentication.setAuthenticated(true);
return authentication;
}
use of org.springframework.security.userdetails.User in project gocd by gocd.
the class GoVelocityViewTest method principalIsTheUsernameWhenNothingElseAvailable.
@Test
public void principalIsTheUsernameWhenNothingElseAvailable() throws Exception {
request.getSession().setAttribute(SPRING_SECURITY_CONTEXT_KEY, securityContext);
securityContext.setAuthentication(new TestingAuthenticationToken(new User("Test User", "pwd", true, new GrantedAuthority[] { new GrantedAuthorityImpl("nowt") }), null, null));
view.exposeHelpers(velocityContext, request);
assertThat(velocityContext.get(GoVelocityView.PRINCIPAL), is("Test User"));
}
Aggregations