Search in sources :

Example 1 with SessionIDExtensions

use of com.iplanet.dpro.session.SessionIDExtensions in project OpenAM by OpenRock.

the class KeyConversionTest method shouldNotFailToEncryptKey.

@Test
public void shouldNotFailToEncryptKey() {
    // Given
    SessionID key = mock(SessionID.class);
    SessionIDExtensions extensions = mock(SessionIDExtensions.class);
    given(key.getExtension()).willReturn(extensions);
    given(extensions.getStorageKey()).willReturn("badger");
    KeyConversion conversion = new KeyConversion();
    // When
    String result = conversion.encryptKey(key);
    // Then
    assertNotNull(result);
}
Also used : SessionIDExtensions(com.iplanet.dpro.session.SessionIDExtensions) SessionID(com.iplanet.dpro.session.SessionID) Test(org.testng.annotations.Test)

Example 2 with SessionIDExtensions

use of com.iplanet.dpro.session.SessionIDExtensions in project OpenAM by OpenRock.

the class MultiServerClusterMonitorTest method canDeterministicallyEstablishFailoverHostServerIdForSessionIfHomeServerIsDown.

@Test
public void canDeterministicallyEstablishFailoverHostServerIdForSessionIfHomeServerIsDown() throws Exception {
    // Given
    // A site with 2x AM servers, if server "01" is presented a session that is homed
    // on server "02" which is down, then a deterministic routing algorithm should be
    // used to generate a sequence of alternative servers to try to re-home the session
    // to. The first of these alternate servers that is found to be up will become the
    // new home server for that session.
    given(mockServiceConfig.isSessionFailoverEnabled()).willReturn(true);
    given(mockServiceConfig.isUseInternalRequestRoutingEnabled()).willReturn(true);
    given(mockServerConfig.getServerIDsInLocalSite()).willReturn(CollectionUtils.asSet("01", "02"));
    given(mockServerConfig.getServerFromID("01")).willReturn("http://openam1.example.com:18080/openam");
    given(mockServerConfig.getServerFromID("02")).willReturn("http://openam2.example.com:28080/openam");
    // the 'site'
    given(mockServerConfig.getServerFromID("03")).willReturn("http://openam.example.com:8080/openam");
    given(mockServerConfig.getLocalServerID()).willReturn("02");
    given(mockServerConfig.getLocalServerSessionServiceURL()).willReturn(new URL("http://openam2.example.com:28080/openam/sessionservice"));
    given(mockServerConfig.getAllServerIDs()).willReturn(CollectionUtils.asList("02", "01"));
    given(mockServerConfig.isSite("02")).willReturn(false);
    given(mockServerConfig.isSite("01")).willReturn(false);
    given(mockServerConfig.isLocalServer("03")).willReturn(false);
    given(mockServerConfig.isPrimaryServer("03")).willReturn(true);
    ClusterStateService mockClusterService = mock(ClusterStateService.class);
    given(mockFactory.createClusterStateService(eq(mockSessionService), eq(mockServerConfig), eq(mockServiceConfig), any(Map.class), any(Map.class))).willReturn(mockClusterService);
    given(mockClusterService.isUp("01")).willReturn(true);
    given(mockClusterService.isUp("02")).willReturn(false);
    given(mockClusterService.getServerSelectionListSize()).willReturn(2);
    given(mockClusterService.getServerSelection(0)).willReturn("01");
    SessionID mockSessionID = mock(SessionID.class);
    SessionIDExtensions mockExtensions = mock(SessionIDExtensions.class);
    given(mockSessionID.getExtension()).willReturn(mockExtensions);
    given(mockExtensions.getPrimaryID()).willReturn("02");
    given(mockSessionID.getSessionServerID()).willReturn("03");
    given(mockExtensions.getStorageKey()).willReturn("4059025133086137527");
    // When
    MultiServerClusterMonitor clusterMonitor = new MultiServerClusterMonitor(mockSessionService, mockDebug, mockServiceConfig, mockServerConfig, mockFactory);
    String currentHostServer = clusterMonitor.getCurrentHostServer(mockSessionID);
    // Then
    assertThat(currentHostServer).isEqualTo("01");
}
Also used : SessionIDExtensions(com.iplanet.dpro.session.SessionIDExtensions) Map(java.util.Map) SessionID(com.iplanet.dpro.session.SessionID) URL(java.net.URL) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest)

Example 3 with SessionIDExtensions

use of com.iplanet.dpro.session.SessionIDExtensions in project OpenAM by OpenRock.

the class MultiServerClusterMonitorTest method canEstablishHostServerIdForSession.

@Test
public void canEstablishHostServerIdForSession() throws Exception {
    // Given
    given(mockServiceConfig.isSessionFailoverEnabled()).willReturn(true);
    given(mockServiceConfig.isUseInternalRequestRoutingEnabled()).willReturn(true);
    given(mockServerConfig.getServerIDsInLocalSite()).willReturn(CollectionUtils.asSet("01", "02"));
    given(mockServerConfig.getServerFromID("01")).willReturn("http://openam1.example.com:18080/openam");
    given(mockServerConfig.getServerFromID("02")).willReturn("http://openam2.example.com:28080/openam");
    // the 'site'
    given(mockServerConfig.getServerFromID("03")).willReturn("http://openam.example.com:8080/openam");
    given(mockServerConfig.getLocalServerID()).willReturn("01");
    given(mockServerConfig.getLocalServerSessionServiceURL()).willReturn(new URL("http://openam1.example.com:18080/openam/sessionservice"));
    given(mockServerConfig.getAllServerIDs()).willReturn(CollectionUtils.asList("02", "01"));
    given(mockServerConfig.isSite("02")).willReturn(false);
    given(mockServerConfig.isSite("01")).willReturn(false);
    given(mockServerConfig.isLocalServer("03")).willReturn(false);
    given(mockServerConfig.isPrimaryServer("03")).willReturn(true);
    ClusterStateService mockClusterService = mock(ClusterStateService.class);
    given(mockFactory.createClusterStateService(eq(mockSessionService), eq(mockServerConfig), eq(mockServiceConfig), any(Map.class), any(Map.class))).willReturn(mockClusterService);
    given(mockClusterService.isUp("01")).willReturn(true);
    SessionID mockSessionID = mock(SessionID.class);
    SessionIDExtensions mockExtensions = mock(SessionIDExtensions.class);
    given(mockSessionID.getExtension()).willReturn(mockExtensions);
    given(mockExtensions.getPrimaryID()).willReturn("01");
    given(mockSessionID.getSessionServerID()).willReturn("03");
    // When
    MultiServerClusterMonitor clusterMonitor = new MultiServerClusterMonitor(mockSessionService, mockDebug, mockServiceConfig, mockServerConfig, mockFactory);
    String currentHostServer = clusterMonitor.getCurrentHostServer(mockSessionID);
    // Then
    assertThat(currentHostServer).isEqualTo("01");
}
Also used : SessionIDExtensions(com.iplanet.dpro.session.SessionIDExtensions) Map(java.util.Map) SessionID(com.iplanet.dpro.session.SessionID) URL(java.net.URL) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest)

Aggregations

SessionID (com.iplanet.dpro.session.SessionID)3 SessionIDExtensions (com.iplanet.dpro.session.SessionIDExtensions)3 Test (org.testng.annotations.Test)3 URL (java.net.URL)2 Map (java.util.Map)2 BeforeTest (org.testng.annotations.BeforeTest)2