Search in sources :

Example 1 with AzureActiveDirectoryAuthorizationResult

use of com.microsoft.identity.common.internal.providers.microsoft.azureactivedirectory.AzureActiveDirectoryAuthorizationResult in project microsoft-authentication-library-common-for-android by AzureAD.

the class AzureActiveDirectoryAuthorizationResultFactoryTest method testUrlWithCorrectCodeAndState.

@Test
public void testUrlWithCorrectCodeAndState() {
    Intent intent = new Intent();
    Bundle bundle = new Bundle();
    String responseUrl = REDIRECT_URI + "?" + AUTH_CODE_AND_STATE + "&" + AuthenticationConstants.AAD.CORRELATION_ID + "=" + CORRELATION_ID;
    bundle.putString(AuthenticationConstants.Browser.RESPONSE_FINAL_URL, responseUrl);
    bundle.putString(AuthenticationConstants.AAD.CORRELATION_ID, CORRELATION_ID);
    intent.putExtras(bundle);
    intent.putExtra(MicrosoftAuthorizationResult.REQUEST_STATE_PARAMETER, STATE);
    AzureActiveDirectoryAuthorizationResult result = mAuthorizationResultFactory.createAuthorizationResult(AuthenticationConstants.UIResponse.BROWSER_CODE_COMPLETE, intent, getAADRequest());
    assertNotNull(result);
    assertNull(result.getAuthorizationErrorResponse());
    assertEquals(AuthorizationStatus.SUCCESS, result.getAuthorizationStatus());
    AzureActiveDirectoryAuthorizationResponse response = result.getAuthorizationResponse();
    assertNotNull(response);
    assertEquals(AUTH_CODE, response.getCode());
    assertEquals(STATE, response.getState());
    assertEquals(CORRELATION_ID, response.getCorrelationId());
}
Also used : AzureActiveDirectoryAuthorizationResult(com.microsoft.identity.common.internal.providers.microsoft.azureactivedirectory.AzureActiveDirectoryAuthorizationResult) Bundle(android.os.Bundle) AzureActiveDirectoryAuthorizationResponse(com.microsoft.identity.common.internal.providers.microsoft.azureactivedirectory.AzureActiveDirectoryAuthorizationResponse) Intent(android.content.Intent) Test(org.junit.Test)

Example 2 with AzureActiveDirectoryAuthorizationResult

use of com.microsoft.identity.common.internal.providers.microsoft.azureactivedirectory.AzureActiveDirectoryAuthorizationResult in project microsoft-authentication-library-common-for-android by AzureAD.

the class AzureActiveDirectoryAuthorizationResultFactoryTest method testUrlWithError.

@Test
public void testUrlWithError() {
    Intent intent = new Intent();
    Bundle bundle = new Bundle();
    String responseUrl = REDIRECT_URI + "?error=" + ERROR_MESSAGE + "&error_description=" + ERROR_DESCRIPTION + "&error_codes=" + ERROR_CODES;
    bundle.putString(AuthenticationConstants.Browser.RESPONSE_FINAL_URL, responseUrl);
    intent.putExtras(bundle);
    AzureActiveDirectoryAuthorizationResult result = mAuthorizationResultFactory.createAuthorizationResult(AuthenticationConstants.UIResponse.BROWSER_CODE_COMPLETE, intent, getAADRequest());
    assertNotNull(result);
    assertNull(result.getAuthorizationResponse());
    assertEquals(AuthorizationStatus.FAIL, result.getAuthorizationStatus());
    AzureActiveDirectoryAuthorizationErrorResponse errorResponse = result.getAuthorizationErrorResponse();
    assertNotNull(errorResponse);
    assertEquals(ERROR_MESSAGE, errorResponse.getError());
    assertEquals(ERROR_DESCRIPTION, errorResponse.getErrorDescription());
    assertEquals(ERROR_CODES, errorResponse.getErrorCodes());
}
Also used : AzureActiveDirectoryAuthorizationResult(com.microsoft.identity.common.internal.providers.microsoft.azureactivedirectory.AzureActiveDirectoryAuthorizationResult) AzureActiveDirectoryAuthorizationErrorResponse(com.microsoft.identity.common.internal.providers.microsoft.azureactivedirectory.AzureActiveDirectoryAuthorizationErrorResponse) Bundle(android.os.Bundle) Intent(android.content.Intent) Test(org.junit.Test)

Aggregations

Intent (android.content.Intent)2 Bundle (android.os.Bundle)2 AzureActiveDirectoryAuthorizationResult (com.microsoft.identity.common.internal.providers.microsoft.azureactivedirectory.AzureActiveDirectoryAuthorizationResult)2 Test (org.junit.Test)2 AzureActiveDirectoryAuthorizationErrorResponse (com.microsoft.identity.common.internal.providers.microsoft.azureactivedirectory.AzureActiveDirectoryAuthorizationErrorResponse)1 AzureActiveDirectoryAuthorizationResponse (com.microsoft.identity.common.internal.providers.microsoft.azureactivedirectory.AzureActiveDirectoryAuthorizationResponse)1