Search in sources :

Example 1 with SingleSignOn

use of io.undertow.security.impl.SingleSignOn in project wildfly by wildfly.

the class DistributableSingleSignOnManagerTestCase method findSingleSignOnNotExists.

@Test
public void findSingleSignOnNotExists() {
    String id = "sso";
    Batcher<Batch> batcher = mock(Batcher.class);
    Batch batch = mock(Batch.class);
    when(this.manager.getBatcher()).thenReturn(batcher);
    when(batcher.createBatch()).thenReturn(batch);
    when(this.manager.findSSO(id)).thenReturn(null);
    SingleSignOn result = this.subject.findSingleSignOn(id);
    assertNull(result);
    verify(batch).close();
    verify(batcher, never()).suspendBatch();
}
Also used : Batch(org.wildfly.clustering.ee.Batch) SingleSignOn(io.undertow.security.impl.SingleSignOn) Test(org.junit.Test)

Example 2 with SingleSignOn

use of io.undertow.security.impl.SingleSignOn in project wildfly by wildfly.

the class DistributableSingleSignOnManagerTestCase method findSingleSignOnInvalidCharacters.

@Test
public void findSingleSignOnInvalidCharacters() {
    String id = "sso+";
    SingleSignOn result = this.subject.findSingleSignOn(id);
    assertNull(result);
    verifyZeroInteractions(this.manager);
}
Also used : SingleSignOn(io.undertow.security.impl.SingleSignOn) Test(org.junit.Test)

Example 3 with SingleSignOn

use of io.undertow.security.impl.SingleSignOn in project wildfly by wildfly.

the class DistributableSingleSignOnManagerTestCase method createSingleSignOn.

@Test
public void createSingleSignOn() {
    String id = "sso";
    Batcher<Batch> batcher = mock(Batcher.class);
    Batch batch = mock(Batch.class);
    Account account = mock(Account.class);
    String mechanism = HttpServletRequest.BASIC_AUTH;
    SSO<AuthenticatedSession, String, String, Void> sso = mock(SSO.class);
    ArgumentCaptor<AuthenticatedSession> authenticationCaptor = ArgumentCaptor.forClass(AuthenticatedSession.class);
    when(this.manager.createIdentifier()).thenReturn(id);
    when(this.manager.getBatcher()).thenReturn(batcher);
    when(batcher.createBatch()).thenReturn(batch);
    when(this.manager.createSSO(same(id), authenticationCaptor.capture())).thenReturn(sso);
    SingleSignOn result = this.subject.createSingleSignOn(account, mechanism);
    verify(batcher).suspendBatch();
    assertNotNull(result);
    AuthenticatedSession capturedAuthentication = authenticationCaptor.getValue();
    assertNotNull(capturedAuthentication);
    assertSame(capturedAuthentication.getAccount(), account);
    assertSame(capturedAuthentication.getMechanism(), mechanism);
}
Also used : Account(io.undertow.security.idm.Account) AuthenticatedSession(io.undertow.security.api.AuthenticatedSessionManager.AuthenticatedSession) Batch(org.wildfly.clustering.ee.Batch) SingleSignOn(io.undertow.security.impl.SingleSignOn) Test(org.junit.Test)

Example 4 with SingleSignOn

use of io.undertow.security.impl.SingleSignOn in project wildfly by wildfly.

the class DistributableSingleSignOnManagerTestCase method findSingleSignOn.

@Test
public void findSingleSignOn() {
    String id = "sso";
    Batcher<Batch> batcher = mock(Batcher.class);
    Batch batch = mock(Batch.class);
    SSO<AuthenticatedSession, String, String, Void> sso = mock(SSO.class);
    when(this.manager.getBatcher()).thenReturn(batcher);
    when(batcher.createBatch()).thenReturn(batch);
    when(this.manager.findSSO(id)).thenReturn(sso);
    SingleSignOn result = this.subject.findSingleSignOn(id);
    assertNotNull(result);
    verify(batcher).suspendBatch();
}
Also used : AuthenticatedSession(io.undertow.security.api.AuthenticatedSessionManager.AuthenticatedSession) Batch(org.wildfly.clustering.ee.Batch) SingleSignOn(io.undertow.security.impl.SingleSignOn) Test(org.junit.Test)

Aggregations

SingleSignOn (io.undertow.security.impl.SingleSignOn)4 Test (org.junit.Test)4 Batch (org.wildfly.clustering.ee.Batch)3 AuthenticatedSession (io.undertow.security.api.AuthenticatedSessionManager.AuthenticatedSession)2 Account (io.undertow.security.idm.Account)1