Search in sources :

Example 1 with LogoutResponse

use of com.okta.oidc.net.response.web.LogoutResponse in project okta-oidc-android by okta.

the class AuthenticationResultHandlerTest method onActivityResultSignOutSuccess.

@Test
public void onActivityResultSignOutSuccess() throws InterruptedException {
    Intent intent = new Intent();
    intent.setData(Uri.parse("com.okta.test:/logout?state=" + CUSTOM_STATE));
    CountDownLatch latch = new CountDownLatch(1);
    final StateResult[] stateResult = new StateResult[1];
    final ResultType[] stateType = new ResultType[1];
    AuthenticationResultHandler.handler().setAuthenticationListener((result, type) -> {
        stateResult[0] = result;
        stateType[0] = type;
        latch.countDown();
    });
    AuthenticationResultHandler.handler().onActivityResult(REQUEST_CODE_SIGN_OUT, RESULT_OK, intent);
    latch.await();
    assertNotNull(stateResult[0]);
    LogoutResponse response = (LogoutResponse) stateResult[0].getAuthorizationResponse();
    assertNotNull(response);
    assertEquals(stateResult[0].getStatus(), LOGGED_OUT);
    assertEquals(response.getState(), CUSTOM_STATE);
    assertEquals(stateType[0], ResultType.SIGN_OUT);
    assertNull(AuthenticationResultHandler.handler().mCachedResult);
    assertNull(AuthenticationResultHandler.handler().mCachedResultType);
}
Also used : LogoutResponse(com.okta.oidc.net.response.web.LogoutResponse) StateResult(com.okta.oidc.AuthenticationResultHandler.StateResult) Intent(android.content.Intent) ResultType(com.okta.oidc.AuthenticationResultHandler.ResultType) CountDownLatch(java.util.concurrent.CountDownLatch) Test(org.junit.Test)

Aggregations

Intent (android.content.Intent)1 ResultType (com.okta.oidc.AuthenticationResultHandler.ResultType)1 StateResult (com.okta.oidc.AuthenticationResultHandler.StateResult)1 LogoutResponse (com.okta.oidc.net.response.web.LogoutResponse)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 Test (org.junit.Test)1