use of org.springframework.security.providers.TestingAuthenticationToken in project gocd by gocd.
the class GoVelocityViewTest method shouldSetGroupAdministratorIfUserIsAPipelineGroupAdministrator.
@Test
public void shouldSetGroupAdministratorIfUserIsAPipelineGroupAdministrator() throws Exception {
securityContext.setAuthentication(new TestingAuthenticationToken("jez", "badger", new GrantedAuthority[] { new GrantedAuthorityImpl(GoAuthority.ROLE_GROUP_SUPERVISOR.toString()) }));
request.getSession().setAttribute(SPRING_SECURITY_CONTEXT_KEY, securityContext);
view.exposeHelpers(velocityContext, request);
assertThat(velocityContext.get(GoVelocityView.ADMINISTRATOR), is(nullValue()));
assertThat(velocityContext.get(GoVelocityView.GROUP_ADMINISTRATOR), is(true));
}
use of org.springframework.security.providers.TestingAuthenticationToken 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