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());
}
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());
}
Aggregations