use of com.iplanet.dpro.session.SessionID in project OpenAM by OpenRock.
the class StatelessSessionFactoryTest method shouldReturnNullIfNoJWTInSessionID.
@Test
public void shouldReturnNullIfNoJWTInSessionID() {
SessionID id = mock(SessionID.class);
given(id.getTail()).willReturn(null);
assertThat(StatelessSessionFactory.getJWTFromSessionID(id, true)).isNull();
}
use of com.iplanet.dpro.session.SessionID in project OpenAM by OpenRock.
the class LoginAuthenticatorTest method shouldGetLoginProcessForInitialRequestWithAuthIndexTypeLevelWithSessionUpgradeButNotRequired.
@Test
public void shouldGetLoginProcessForInitialRequestWithAuthIndexTypeLevelWithSessionUpgradeButNotRequired() throws AuthException, AuthLoginException, SSOException, RestAuthException {
//Given
LoginConfiguration loginConfiguration = new LoginConfiguration();
HttpServletRequest request = mock(HttpServletRequest.class);
String sessionId = null;
AuthIndexType authIndexType = AuthIndexType.LEVEL;
String authIndexValue = "5";
String ssoTokenId = "SSO_TOKEN_ID";
AuthContextLocalWrapper authContextLocalWrapper = mock(AuthContextLocalWrapper.class);
SSOToken ssoToken = mock(SSOToken.class);
loginConfiguration.httpRequest(request).sessionId(sessionId).indexType(authIndexType).indexValue(authIndexValue).sessionUpgrade(ssoTokenId);
given(ssoToken.getProperty("AuthLevel")).willReturn("10");
given(coreServicesWrapper.getDomainNameByRequest(request)).willReturn("ORG_DN");
given(coreServicesWrapper.getAuthContext(eq(request), eq((HttpServletResponse) null), (SessionID) anyObject(), eq(false), eq(false))).willReturn(authContextLocalWrapper);
given(coreServicesWrapper.getExistingValidSSOToken(eq(new SessionID("SSO_TOKEN_ID")))).willReturn(ssoToken);
given(coreServicesWrapper.isNewRequest(authContextLocalWrapper)).willReturn(true);
given(coreServicesWrapper.doesValueContainKey(anyString(), anyString())).willReturn(false);
given(coreServicesWrapper.doesValueContainKey("INDEX_VALUE", "INDEX_VALUE")).willReturn(true);
//When
LoginProcess loginProcess = loginAuthenticator.getLoginProcess(loginConfiguration);
//Then
assertThat(loginProcess.isSuccessful()).isTrue();
verify(authContextLocalWrapper, never()).login();
assertNotNull(loginProcess);
}
use of com.iplanet.dpro.session.SessionID in project OpenAM by OpenRock.
the class LoginAuthenticatorTest method shouldGetLoginProcessForInitialRequestWithAuthIndexTypeServiceWithSessionUpgrade.
@Test
public void shouldGetLoginProcessForInitialRequestWithAuthIndexTypeServiceWithSessionUpgrade() throws AuthException, AuthLoginException, SSOException, RestAuthException {
//Given
LoginConfiguration loginConfiguration = new LoginConfiguration();
HttpServletRequest request = mock(HttpServletRequest.class);
String sessionId = null;
AuthIndexType authIndexType = AuthIndexType.SERVICE;
String authIndexValue = "INDEX_VALUE_NEW";
String ssoTokenId = "SSO_TOKEN_ID";
AuthContextLocalWrapper authContextLocalWrapper = mock(AuthContextLocalWrapper.class);
SSOToken ssoToken = mock(SSOToken.class);
loginConfiguration.httpRequest(request).sessionId(sessionId).indexType(authIndexType).indexValue(authIndexValue).sessionUpgrade(ssoTokenId);
given(ssoToken.getProperty("Service")).willReturn("INDEX_VALUE");
given(coreServicesWrapper.getDomainNameByRequest(request)).willReturn("ORG_DN");
given(coreServicesWrapper.getAuthContext(eq(request), eq((HttpServletResponse) null), (SessionID) anyObject(), eq(true), eq(false))).willReturn(authContextLocalWrapper);
given(coreServicesWrapper.getExistingValidSSOToken(eq(new SessionID("SSO_TOKEN_ID")))).willReturn(ssoToken);
given(coreServicesWrapper.isNewRequest(authContextLocalWrapper)).willReturn(true);
given(coreServicesWrapper.doesValueContainKey(anyString(), anyString())).willReturn(false);
given(coreServicesWrapper.doesValueContainKey("INDEX_VALUE", "INDEX_VALUE")).willReturn(true);
given(authContextLocalWrapper.isSessionUpgrade()).willReturn(true);
//When
LoginProcess loginProcess = loginAuthenticator.getLoginProcess(loginConfiguration);
//Then
verify(authContextLocalWrapper).login(AuthContext.IndexType.SERVICE, "INDEX_VALUE_NEW");
assertNotNull(loginProcess);
}
use of com.iplanet.dpro.session.SessionID in project OpenAM by OpenRock.
the class LoginAuthenticatorTest method shouldGetLoginProcessForInitialRequestWithAuthIndexTypeUserWithSessionUpgradeButNotRequired.
@Test
public void shouldGetLoginProcessForInitialRequestWithAuthIndexTypeUserWithSessionUpgradeButNotRequired() throws AuthException, AuthLoginException, SSOException, RestAuthException {
//Given
LoginConfiguration loginConfiguration = new LoginConfiguration();
HttpServletRequest request = mock(HttpServletRequest.class);
String sessionId = null;
AuthIndexType authIndexType = AuthIndexType.USER;
String authIndexValue = "INDEX_VALUE";
String ssoTokenId = "SSO_TOKEN_ID";
AuthContextLocalWrapper authContextLocalWrapper = mock(AuthContextLocalWrapper.class);
SSOToken ssoToken = mock(SSOToken.class);
loginConfiguration.httpRequest(request).sessionId(sessionId).indexType(authIndexType).indexValue(authIndexValue).sessionUpgrade(ssoTokenId);
given(ssoToken.getProperty("UserToken")).willReturn("INDEX_VALUE");
given(coreServicesWrapper.getDomainNameByRequest(request)).willReturn("ORG_DN");
given(coreServicesWrapper.getAuthContext(eq(request), eq((HttpServletResponse) null), (SessionID) anyObject(), eq(false), eq(false))).willReturn(authContextLocalWrapper);
given(coreServicesWrapper.getExistingValidSSOToken(eq(new SessionID("SSO_TOKEN_ID")))).willReturn(ssoToken);
given(coreServicesWrapper.isNewRequest(authContextLocalWrapper)).willReturn(true);
//When
LoginProcess loginProcess = loginAuthenticator.getLoginProcess(loginConfiguration);
//Then
assertThat(loginProcess.isSuccessful()).isTrue();
verify(authContextLocalWrapper, never()).login();
assertNotNull(loginProcess);
}
use of com.iplanet.dpro.session.SessionID in project OpenAM by OpenRock.
the class LoginAuthenticatorTest method shouldGetLoginProcessForInitialRequestWithAuthIndexTypeModuleWithSessionUpgrade.
@Test
public void shouldGetLoginProcessForInitialRequestWithAuthIndexTypeModuleWithSessionUpgrade() throws AuthException, AuthLoginException, SSOException, RestAuthException {
//Given
LoginConfiguration loginConfiguration = new LoginConfiguration();
HttpServletRequest request = mock(HttpServletRequest.class);
String sessionId = null;
AuthIndexType authIndexType = AuthIndexType.MODULE;
String authIndexValue = "INDEX_VALUE_NEW";
String ssoTokenId = "SSO_TOKEN_ID";
AuthContextLocalWrapper authContextLocalWrapper = mock(AuthContextLocalWrapper.class);
SSOToken ssoToken = mock(SSOToken.class);
loginConfiguration.httpRequest(request).sessionId(sessionId).indexType(authIndexType).indexValue(authIndexValue).sessionUpgrade(ssoTokenId);
given(ssoToken.getProperty("AuthType")).willReturn("INDEX_VALUE");
given(coreServicesWrapper.getDomainNameByRequest(request)).willReturn("ORG_DN");
given(coreServicesWrapper.getAuthContext(eq(request), eq((HttpServletResponse) null), (SessionID) anyObject(), eq(true), eq(false))).willReturn(authContextLocalWrapper);
given(coreServicesWrapper.getExistingValidSSOToken(eq(new SessionID("SSO_TOKEN_ID")))).willReturn(ssoToken);
given(coreServicesWrapper.isNewRequest(authContextLocalWrapper)).willReturn(true);
given(coreServicesWrapper.doesValueContainKey(anyString(), anyString())).willReturn(false);
given(coreServicesWrapper.doesValueContainKey("INDEX_VALUE", "INDEX_VALUE")).willReturn(true);
given(authContextLocalWrapper.isSessionUpgrade()).willReturn(true);
//When
LoginProcess loginProcess = loginAuthenticator.getLoginProcess(loginConfiguration);
//Then
verify(authContextLocalWrapper).login(AuthContext.IndexType.MODULE_INSTANCE, "INDEX_VALUE_NEW");
assertNotNull(loginProcess);
}
Aggregations