Search in sources :

Example 1 with SessionExtenderResponse

use of org.wso2.carbon.identity.application.authentication.framework.session.extender.response.SessionExtenderResponse in project carbon-identity-framework by wso2.

the class SessionExtenderResponseFactoryTest method testCreate.

@Test
public void testCreate() {
    SessionExtenderResponse sessionExtenderResponse = mock(SessionExtenderResponse.class);
    when(sessionExtenderResponse.getTraceId()).thenReturn(TRACE_ID);
    HttpIdentityResponse.HttpIdentityResponseBuilder responseBuilder = sessionExtenderResponseFactory.create(sessionExtenderResponse);
    HttpIdentityResponse response = responseBuilder.build();
    assertNull(response.getBody());
    assertNotNull(response.getHeaders().get("Trace-ID"));
}
Also used : HttpIdentityResponse(org.wso2.carbon.identity.application.authentication.framework.inbound.HttpIdentityResponse) Test(org.testng.annotations.Test)

Example 2 with SessionExtenderResponse

use of org.wso2.carbon.identity.application.authentication.framework.session.extender.response.SessionExtenderResponse in project carbon-identity-framework by wso2.

the class SessionExtenderProcessorTest method testProcessWithSessionKey.

@Test(expectedExceptions = NullPointerException.class)
public void testProcessWithSessionKey() throws Exception {
    mockStatic(SessionContextCache.class);
    SessionExtenderRequest sessionExtenderRequest = mock(SessionExtenderRequest.class);
    SessionContextCache sessionContextCache = mock(SessionContextCache.class);
    SessionContextCacheKey sessionContextCacheKey = mock(SessionContextCacheKey.class);
    SessionContextCacheEntry sessionContextCacheEntry = mock(SessionContextCacheEntry.class);
    SessionContext sessionContext = mock(SessionContext.class);
    whenNew(SessionContextCacheKey.class).withArguments(anyString()).thenReturn(sessionContextCacheKey);
    when(sessionExtenderRequest.getTenantDomain()).thenReturn(TENANT_DOMAIN);
    when(sessionExtenderRequest.getSessionKey()).thenReturn(IDP_SESSION_KEY);
    when(SessionContextCache.getInstance()).thenReturn(sessionContextCache);
    when(sessionContextCache.getSessionContextCacheEntry(anyObject(), anyString())).thenReturn(sessionContextCacheEntry);
    when(sessionContextCacheEntry.getContext()).thenReturn(sessionContext);
    SessionExtenderResponse.SessionExtenderResponseBuilder responseBuilder = (SessionExtenderResponse.SessionExtenderResponseBuilder) sessionExtenderProcessor.process(sessionExtenderRequest);
    SessionExtenderResponse response = responseBuilder.build();
    assertNotNull(response.getTraceId(), "Error creating successful response.");
}
Also used : SessionExtenderResponse(org.wso2.carbon.identity.application.authentication.framework.session.extender.response.SessionExtenderResponse) SessionContextCacheEntry(org.wso2.carbon.identity.application.authentication.framework.cache.SessionContextCacheEntry) SessionContext(org.wso2.carbon.identity.application.authentication.framework.context.SessionContext) SessionContextCacheKey(org.wso2.carbon.identity.application.authentication.framework.cache.SessionContextCacheKey) SessionContextCache(org.wso2.carbon.identity.application.authentication.framework.cache.SessionContextCache) SessionExtenderRequest(org.wso2.carbon.identity.application.authentication.framework.session.extender.request.SessionExtenderRequest) Test(org.testng.annotations.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Aggregations

Test (org.testng.annotations.Test)2 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)1 SessionContextCache (org.wso2.carbon.identity.application.authentication.framework.cache.SessionContextCache)1 SessionContextCacheEntry (org.wso2.carbon.identity.application.authentication.framework.cache.SessionContextCacheEntry)1 SessionContextCacheKey (org.wso2.carbon.identity.application.authentication.framework.cache.SessionContextCacheKey)1 SessionContext (org.wso2.carbon.identity.application.authentication.framework.context.SessionContext)1 HttpIdentityResponse (org.wso2.carbon.identity.application.authentication.framework.inbound.HttpIdentityResponse)1 SessionExtenderRequest (org.wso2.carbon.identity.application.authentication.framework.session.extender.request.SessionExtenderRequest)1 SessionExtenderResponse (org.wso2.carbon.identity.application.authentication.framework.session.extender.response.SessionExtenderResponse)1