use of org.springframework.security.messaging.context.SecurityContextChannelInterceptor in project spring-security by spring-projects.
the class AbstractSecurityWebSocketMessageBrokerConfigurerTests method securityContextChannelInterceptorDefinedByBean.
@Test
public void securityContextChannelInterceptorDefinedByBean() {
loadConfig(SockJsProxylessSecurityConfig.class);
MessageChannel messageChannel = clientInboundChannel();
SecurityContextChannelInterceptor securityContextChannelInterceptor = this.context.getBean(SecurityContextChannelInterceptor.class);
assertThat(((AbstractMessageChannel) messageChannel).getInterceptors()).contains(securityContextChannelInterceptor);
}
use of org.springframework.security.messaging.context.SecurityContextChannelInterceptor in project spring-security by spring-projects.
the class SecurityContextChannelInterceptorTests method preSendCustomHeader.
@Test
public void preSendCustomHeader() throws Exception {
String headerName = "header";
interceptor = new SecurityContextChannelInterceptor(headerName);
messageBuilder.setHeader(headerName, authentication);
interceptor.preSend(messageBuilder.build(), channel);
assertThat(SecurityContextHolder.getContext().getAuthentication()).isSameAs(authentication);
}
Aggregations