Search in sources :

Example 16 with SSOTokenID

use of com.iplanet.sso.SSOTokenID in project OpenAM by OpenRock.

the class SessionResourceTest method shouldUsePAPLogoutRedirectUrlWhenSet.

@Test
public void shouldUsePAPLogoutRedirectUrlWhenSet() throws Exception {
    // Given
    final String sessionId = "SSO_TOKEN_ID";
    final String logoutUrl = "http://forgerock.com/about";
    final ActionRequest request = mock(ActionRequest.class);
    final HttpServletRequest httpServletRequest = mock(HttpServletRequest.class);
    final AttributesContext context = new AttributesContext(new AdviceContext(realmContext, Collections.<String>emptyList()));
    final SSOTokenID tokenId = mock(SSOTokenID.class);
    context.getAttributes().put(HttpServletRequest.class.getName(), httpServletRequest);
    given(request.getAction()).willReturn(LOGOUT_ACTION_ID);
    given(ssoTokenManager.createSSOToken(sessionId)).willReturn(ssoToken);
    given(ssoToken.getTokenID()).willReturn(tokenId);
    given(tokenId.toString()).willReturn(sessionId);
    given(authUtilsWrapper.logout(eq(sessionId), eq(httpServletRequest), any(HttpServletResponse.class))).willReturn(true);
    given(authUtilsWrapper.getPostProcessLogoutURL(httpServletRequest)).willReturn(logoutUrl);
    // When
    ActionResponse response = sessionResource.actionInstance(context, sessionId, request).getOrThrowUninterruptibly();
    // Then
    assertThat(response).isNotNull().withContent().stringAt("goto").isEqualTo(logoutUrl);
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) SSOTokenID(com.iplanet.sso.SSOTokenID) AttributesContext(org.forgerock.services.context.AttributesContext) HttpServletResponse(javax.servlet.http.HttpServletResponse) Test(org.testng.annotations.Test)

Aggregations

SSOTokenID (com.iplanet.sso.SSOTokenID)16 Test (org.testng.annotations.Test)11 SSOToken (com.iplanet.sso.SSOToken)9 HttpServletRequest (javax.servlet.http.HttpServletRequest)7 HttpServletResponse (javax.servlet.http.HttpServletResponse)7 Map (java.util.Map)5 SSOException (com.iplanet.sso.SSOException)4 HashMap (java.util.HashMap)4 Principal (java.security.Principal)3 MessageInfo (javax.security.auth.message.MessageInfo)3 JsonValue (org.forgerock.json.JsonValue)3 LoginProcess (org.forgerock.openam.core.rest.authn.core.LoginProcess)3 AuthContextLocalWrapper (org.forgerock.openam.core.rest.authn.core.wrappers.AuthContextLocalWrapper)3 AttributesContext (org.forgerock.services.context.AttributesContext)3 Context (org.forgerock.services.context.Context)3 RootContext (org.forgerock.services.context.RootContext)3 SecurityContext (org.forgerock.services.context.SecurityContext)3 SessionID (com.iplanet.dpro.session.SessionID)2 SMSException (com.sun.identity.sm.SMSException)2 Iterator (java.util.Iterator)2