Search in sources :

Example 1 with XmAuthenticationContextHolder

use of com.icthh.xm.commons.security.XmAuthenticationContextHolder in project xm-ms-entity by xm-online.

the class XmAuthContextHolderDefaultTestConfiguration method xmAuthenticationContextHolder.

@Bean
@Primary
public XmAuthenticationContextHolder xmAuthenticationContextHolder() {
    XmAuthenticationContext context = mock(XmAuthenticationContext.class);
    when(context.hasAuthentication()).thenReturn(true);
    when(context.getLogin()).thenReturn(Optional.of("testLogin"));
    when(context.getUserKey()).thenReturn(Optional.of("ACCOUNT.TEST"));
    XmAuthenticationContextHolder holder = mock(XmAuthenticationContextHolder.class);
    when(holder.getContext()).thenReturn(context);
    return holder;
}
Also used : XmAuthenticationContext(com.icthh.xm.commons.security.XmAuthenticationContext) XmAuthenticationContextHolder(com.icthh.xm.commons.security.XmAuthenticationContextHolder) Primary(org.springframework.context.annotation.Primary) Bean(org.springframework.context.annotation.Bean)

Example 2 with XmAuthenticationContextHolder

use of com.icthh.xm.commons.security.XmAuthenticationContextHolder in project xm-ms-entity by xm-online.

the class ProfileResourceIntTest method xmAuthenticationContextHolder.

@Bean
@Primary
public XmAuthenticationContextHolder xmAuthenticationContextHolder() {
    XmAuthenticationContext context = mock(XmAuthenticationContext.class);
    when(context.hasAuthentication()).thenReturn(true);
    when(context.isFullyAuthenticated()).thenReturn(true);
    when(context.getUserKey()).thenReturn(Optional.of(DEFAULT_USER_KEY));
    when(context.getRequiredUserKey()).thenReturn(DEFAULT_USER_KEY);
    XmAuthenticationContextHolder holder = mock(XmAuthenticationContextHolder.class);
    when(holder.getContext()).thenReturn(context);
    return holder;
}
Also used : XmAuthenticationContext(com.icthh.xm.commons.security.XmAuthenticationContext) XmAuthenticationContextHolder(com.icthh.xm.commons.security.XmAuthenticationContextHolder) Primary(org.springframework.context.annotation.Primary) Bean(org.springframework.context.annotation.Bean)

Example 3 with XmAuthenticationContextHolder

use of com.icthh.xm.commons.security.XmAuthenticationContextHolder in project xm-ms-entity by xm-online.

the class CommentResourceIntTest method xmAuthenticationContextHolder.

@Bean
@Primary
public XmAuthenticationContextHolder xmAuthenticationContextHolder() {
    XmAuthenticationContext context = mock(XmAuthenticationContext.class);
    when(context.hasAuthentication()).thenReturn(true);
    when(context.getLogin()).thenReturn(Optional.of("testLogin"));
    when(context.getUserKey()).thenReturn(Optional.of(DEFAULT_USER_KEY));
    XmAuthenticationContextHolder holder = mock(XmAuthenticationContextHolder.class);
    when(holder.getContext()).thenReturn(context);
    return holder;
}
Also used : XmAuthenticationContext(com.icthh.xm.commons.security.XmAuthenticationContext) XmAuthenticationContextHolder(com.icthh.xm.commons.security.XmAuthenticationContextHolder) Primary(org.springframework.context.annotation.Primary) Bean(org.springframework.context.annotation.Bean)

Aggregations

XmAuthenticationContext (com.icthh.xm.commons.security.XmAuthenticationContext)3 XmAuthenticationContextHolder (com.icthh.xm.commons.security.XmAuthenticationContextHolder)3 Bean (org.springframework.context.annotation.Bean)3 Primary (org.springframework.context.annotation.Primary)3