Search in sources :

Example 1 with CANCELED

use of com.okta.oidc.AuthenticationResultHandler.Status.CANCELED in project okta-oidc-android by okta.

the class AuthenticationResultHandlerTest method setAuthenticationListener.

@Test
public void setAuthenticationListener() throws InterruptedException {
    AuthenticationResultHandler.handler().mCachedResult = StateResult.canceled();
    AuthenticationResultHandler.handler().mCachedResultType = ResultType.SIGN_IN;
    final StateResult[] resultFromListener = new StateResult[1];
    final ResultType[] typeFromListener = new ResultType[1];
    CountDownLatch latch = new CountDownLatch(1);
    AuthResultListener listener = (result, type) -> {
        resultFromListener[0] = result;
        typeFromListener[0] = type;
        latch.countDown();
    };
    AuthenticationResultHandler.handler().setAuthenticationListener(listener);
    latch.await();
    assertEquals(resultFromListener[0].getStatus(), CANCELED);
    assertEquals(typeFromListener[0], ResultType.SIGN_IN);
    assertNull(AuthenticationResultHandler.handler().mCachedResult);
    assertNull(AuthenticationResultHandler.handler().mCachedResultType);
}
Also used : JSON_DESERIALIZATION_ERROR(com.okta.oidc.util.AuthorizationException.GeneralErrors.JSON_DESERIALIZATION_ERROR) AuthResultListener(com.okta.oidc.AuthenticationResultHandler.AuthResultListener) RESULT_OK(android.app.Activity.RESULT_OK) LOGGED_OUT(com.okta.oidc.AuthenticationResultHandler.Status.LOGGED_OUT) Uri(android.net.Uri) RunWith(org.junit.runner.RunWith) Config(org.robolectric.annotation.Config) Intent(android.content.Intent) TestValues(com.okta.oidc.util.TestValues) REQUEST_CODE_SIGN_IN(com.okta.oidc.OktaResultFragment.REQUEST_CODE_SIGN_IN) LogoutResponse(com.okta.oidc.net.response.web.LogoutResponse) AuthorizeResponse(com.okta.oidc.net.response.web.AuthorizeResponse) CUSTOM_STATE(com.okta.oidc.util.TestValues.CUSTOM_STATE) AuthorizationRequestErrors(com.okta.oidc.util.AuthorizationException.AuthorizationRequestErrors) RESULT_CANCELED(android.app.Activity.RESULT_CANCELED) ResultType(com.okta.oidc.AuthenticationResultHandler.ResultType) CANCELED(com.okta.oidc.AuthenticationResultHandler.Status.CANCELED) Assert.assertNotNull(org.junit.Assert.assertNotNull) EXTRA_EXCEPTION(com.okta.oidc.OktaAuthenticationActivity.EXTRA_EXCEPTION) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) AuthorizationException(com.okta.oidc.util.AuthorizationException) Status(com.okta.oidc.AuthenticationResultHandler.Status) RobolectricTestRunner(org.robolectric.RobolectricTestRunner) CountDownLatch(java.util.concurrent.CountDownLatch) StateResult(com.okta.oidc.AuthenticationResultHandler.StateResult) Assert.assertNull(org.junit.Assert.assertNull) REQUEST_CODE_SIGN_OUT(com.okta.oidc.OktaResultFragment.REQUEST_CODE_SIGN_OUT) CUSTOM_CODE(com.okta.oidc.util.TestValues.CUSTOM_CODE) Assert.assertEquals(org.junit.Assert.assertEquals) StateResult(com.okta.oidc.AuthenticationResultHandler.StateResult) AuthResultListener(com.okta.oidc.AuthenticationResultHandler.AuthResultListener) ResultType(com.okta.oidc.AuthenticationResultHandler.ResultType) CountDownLatch(java.util.concurrent.CountDownLatch) Test(org.junit.Test)

Aggregations

RESULT_CANCELED (android.app.Activity.RESULT_CANCELED)1 RESULT_OK (android.app.Activity.RESULT_OK)1 Intent (android.content.Intent)1 Uri (android.net.Uri)1 AuthResultListener (com.okta.oidc.AuthenticationResultHandler.AuthResultListener)1 ResultType (com.okta.oidc.AuthenticationResultHandler.ResultType)1 StateResult (com.okta.oidc.AuthenticationResultHandler.StateResult)1 Status (com.okta.oidc.AuthenticationResultHandler.Status)1 CANCELED (com.okta.oidc.AuthenticationResultHandler.Status.CANCELED)1 LOGGED_OUT (com.okta.oidc.AuthenticationResultHandler.Status.LOGGED_OUT)1 EXTRA_EXCEPTION (com.okta.oidc.OktaAuthenticationActivity.EXTRA_EXCEPTION)1 REQUEST_CODE_SIGN_IN (com.okta.oidc.OktaResultFragment.REQUEST_CODE_SIGN_IN)1 REQUEST_CODE_SIGN_OUT (com.okta.oidc.OktaResultFragment.REQUEST_CODE_SIGN_OUT)1 AuthorizeResponse (com.okta.oidc.net.response.web.AuthorizeResponse)1 LogoutResponse (com.okta.oidc.net.response.web.LogoutResponse)1 AuthorizationException (com.okta.oidc.util.AuthorizationException)1 AuthorizationRequestErrors (com.okta.oidc.util.AuthorizationException.AuthorizationRequestErrors)1 JSON_DESERIALIZATION_ERROR (com.okta.oidc.util.AuthorizationException.GeneralErrors.JSON_DESERIALIZATION_ERROR)1 TestValues (com.okta.oidc.util.TestValues)1 CUSTOM_CODE (com.okta.oidc.util.TestValues.CUSTOM_CODE)1