use of com.enonic.xp.security.IdProviders in project xp by enonic.
the class LoginHandlerTest method testLoginNoIdProviders.
@Test
public void testLoginNoIdProviders() {
final IdProviders idProviders = IdProviders.from(IdProvider.create().displayName("system").key(IdProviderKey.from("system")).build());
final AuthenticationInfo authInfo = TestDataFixtures.createAuthenticationInfo();
Mockito.when(this.securityService.authenticate(Mockito.any())).thenReturn(authInfo);
Mockito.when(this.securityService.getIdProviders()).thenReturn(idProviders);
runFunction("/test/login-test.js", "loginNoIdProvider");
final Session session = ContextAccessor.current().getLocalScope().getSession();
final AuthenticationInfo sessionAuthInfo = session.getAttribute(AuthenticationInfo.class);
assertEquals(authInfo, sessionAuthInfo);
}
use of com.enonic.xp.security.IdProviders in project xp by enonic.
the class LoginHandlerTest method testExamples.
@Test
public void testExamples() {
final AuthenticationInfo authInfo = TestDataFixtures.createAuthenticationInfo();
final IdProviders idProviders = IdProviders.from(IdProvider.create().displayName("system").key(IdProviderKey.from("system")).build());
Mockito.when(this.securityService.authenticate(Mockito.any())).thenReturn(authInfo);
Mockito.when(this.securityService.getIdProviders()).thenReturn(idProviders);
runScript("/lib/xp/examples/auth/login.js");
}
use of com.enonic.xp.security.IdProviders in project xp by enonic.
the class BasicAuthFilterTest method setup.
@BeforeEach
public void setup() {
this.request = Mockito.mock(HttpServletRequest.class);
this.response = Mockito.mock(HttpServletResponse.class);
this.chain = Mockito.mock(FilterChain.class);
this.securityService = Mockito.mock(SecurityService.class);
this.filter = new BasicAuthFilter();
this.filter.setSecurityService(this.securityService);
final IdProviderKey idProviderKey = IdProviderKey.from("store");
final IdProvider idProvider = IdProvider.create().key(idProviderKey).build();
final IdProviders idProviders = IdProviders.from(idProvider);
when(this.securityService.getIdProviders()).thenReturn(idProviders);
}
Aggregations