use of org.springframework.security.core.context.SecurityContextImpl in project Asqatasun by Asqatasun.
the class AuditSetUpControllerTest method setUpMockAuthenticationContext.
private void setUpMockAuthenticationContext() {
// initialise the context with the user identified by the email
// "test1@test.com" seen as authenticated
Collection<GrantedAuthority> gac = new ArrayList<GrantedAuthority>();
TgolUserDetails tud = new TgolUserDetails("test1@test.com", "", true, false, true, true, gac, mockUser);
mockAuthentication = createMock(Authentication.class);
SecurityContextImpl securityContextImpl = new SecurityContextImpl();
securityContextImpl.setAuthentication(mockAuthentication);
SecurityContextHolder.setContext(securityContextImpl);
expect(mockAuthentication.getName()).andReturn("test1@test.com").anyTimes();
expect(mockAuthentication.getPrincipal()).andReturn(tud).anyTimes();
expect(mockAuthentication.getAuthorities()).andReturn(null).anyTimes();
replay(mockAuthentication);
mockAuthenticationDetails = createMock(AuthenticationDetails.class);
expect(mockAuthenticationDetails.getContext()).andReturn("test1@test.com").anyTimes();
replay(mockAuthenticationDetails);
}
use of org.springframework.security.core.context.SecurityContextImpl in project midpoint by Evolveum.
the class AbstractModelIntegrationTest method createSecurityContext.
protected void createSecurityContext(MidPointPrincipal principal) {
SecurityContext context = new SecurityContextImpl();
Authentication authentication = new UsernamePasswordAuthenticationToken(principal, null);
context.setAuthentication(authentication);
SecurityContextHolder.setContext(context);
}
use of org.springframework.security.core.context.SecurityContextImpl in project coffeenet-starter by coffeenet.
the class DevelopmentCoffeeNetCurrentUserServiceTest method providePrinciple.
private void providePrinciple(User principal) {
SecurityContextImpl context = new SecurityContextImpl();
context.setAuthentication(new UsernamePasswordAuthenticationToken(principal, null));
SecurityContextHolder.setContext(context);
}
use of org.springframework.security.core.context.SecurityContextImpl in project coffeenet-starter by coffeenet.
the class IntegrationCoffeeNetCurrentUserServiceTest method get.
@Test
public void get() {
CoffeeNetUserDetails principal = new HumanCoffeeNetUser("test", "test@synyx.de", new HashSet<>());
SecurityContextImpl context = new SecurityContextImpl();
context.setAuthentication(new UsernamePasswordAuthenticationToken(principal, null));
SecurityContextHolder.setContext(context);
CoffeeNetUserDetails result = sut.get().get();
assertThat(result, is(principal));
}
Aggregations