Search in sources :

Example 1 with AuthenticationSwitchUserEvent

use of org.springframework.security.web.authentication.switchuser.AuthenticationSwitchUserEvent in project spring-boot by spring-projects.

the class AuthenticationAuditListenerTests method testAuthenticationSwitch.

@Test
public void testAuthenticationSwitch() {
    AuditApplicationEvent event = handleAuthenticationEvent(new AuthenticationSwitchUserEvent(new UsernamePasswordAuthenticationToken("user", "password"), new User("user", "password", AuthorityUtils.commaSeparatedStringToAuthorityList("USER"))));
    assertThat(event.getAuditEvent().getType()).isEqualTo(AuthenticationAuditListener.AUTHENTICATION_SWITCH);
}
Also used : User(org.springframework.security.core.userdetails.User) AuditApplicationEvent(org.springframework.boot.actuate.audit.listener.AuditApplicationEvent) UsernamePasswordAuthenticationToken(org.springframework.security.authentication.UsernamePasswordAuthenticationToken) AuthenticationSwitchUserEvent(org.springframework.security.web.authentication.switchuser.AuthenticationSwitchUserEvent) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 AuditApplicationEvent (org.springframework.boot.actuate.audit.listener.AuditApplicationEvent)1 UsernamePasswordAuthenticationToken (org.springframework.security.authentication.UsernamePasswordAuthenticationToken)1 User (org.springframework.security.core.userdetails.User)1 AuthenticationSwitchUserEvent (org.springframework.security.web.authentication.switchuser.AuthenticationSwitchUserEvent)1