use of com.microsoft.identity.common.internal.providers.oauth2.AuthorizationResult in project microsoft-authentication-library-common-for-android by AzureAD.
the class AzureActiveDirectoryAuthorizationResultFactoryTest method testUrlWithEmptyParams.
@Test
public void testUrlWithEmptyParams() {
Intent intent = new Intent();
Bundle bundle = new Bundle();
bundle.putString(AuthenticationConstants.Browser.RESPONSE_FINAL_URL, REDIRECT_URI);
intent.putExtras(bundle);
AuthorizationResult result = mAuthorizationResultFactory.createAuthorizationResult(AuthenticationConstants.UIResponse.BROWSER_CODE_COMPLETE, intent, getAADRequest());
assertNotNull(result);
assertNull(result.getAuthorizationResponse());
assertEquals(AuthorizationStatus.FAIL, result.getAuthorizationStatus());
AuthorizationErrorResponse errorResponse = result.getAuthorizationErrorResponse();
assertNotNull(errorResponse);
assertEquals(MicrosoftAuthorizationErrorResponse.AUTHORIZATION_FAILED, errorResponse.getError());
assertEquals(MicrosoftAuthorizationErrorResponse.AUTHORIZATION_SERVER_INVALID_RESPONSE, errorResponse.getErrorDescription());
}
use of com.microsoft.identity.common.internal.providers.oauth2.AuthorizationResult in project microsoft-authentication-library-common-for-android by AzureAD.
the class MicrosoftStsAuthorizationResultFactoryTest method testUrlWithInCorrectState.
@Test
public void testUrlWithInCorrectState() {
Intent intent = new Intent();
intent.putExtra(AUTHORIZATION_FINAL_URL, REDIRECT_URI + "?" + AUTH_CODE_AND_STATE);
intent.putExtra(MicrosoftAuthorizationResult.REQUEST_STATE_PARAMETER, "incorrect_state");
AuthorizationResult result = mAuthorizationResultFactory.createAuthorizationResult(AuthenticationConstants.UIResponse.BROWSER_CODE_COMPLETE, intent, getMstsAuthorizationRequest());
assertNotNull(result);
assertNotNull(result.getAuthorizationErrorResponse());
assertEquals(AuthorizationStatus.FAIL, result.getAuthorizationStatus());
AuthorizationErrorResponse errorResponse = result.getAuthorizationErrorResponse();
assertNotNull(errorResponse);
assertEquals(ErrorStrings.STATE_MISMATCH, errorResponse.getError());
assertEquals(MicrosoftAuthorizationErrorResponse.STATE_NOT_THE_SAME, errorResponse.getErrorDescription());
}
use of com.microsoft.identity.common.internal.providers.oauth2.AuthorizationResult in project microsoft-authentication-library-common-for-android by AzureAD.
the class MicrosoftStsAuthorizationResultFactoryTest method testUrlWithErrorInParams.
@Test
public void testUrlWithErrorInParams() {
Intent intent = new Intent();
String responseUrl = REDIRECT_URI + "?error=" + ERROR_MESSAGE + "&error_description=" + ERROR_DESCRIPTION;
intent.putExtra(AUTHORIZATION_FINAL_URL, responseUrl);
AuthorizationResult result = mAuthorizationResultFactory.createAuthorizationResult(AuthenticationConstants.UIResponse.BROWSER_CODE_COMPLETE, intent, getMstsAuthorizationRequest());
assertNotNull(result);
assertNull(result.getAuthorizationResponse());
assertEquals(AuthorizationStatus.FAIL, result.getAuthorizationStatus());
AuthorizationErrorResponse errorResponse = result.getAuthorizationErrorResponse();
assertNotNull(errorResponse);
assertEquals(errorResponse.getError(), ERROR_MESSAGE);
assertEquals(errorResponse.getErrorDescription(), ERROR_DESCRIPTION);
}
use of com.microsoft.identity.common.internal.providers.oauth2.AuthorizationResult in project microsoft-authentication-library-common-for-android by AzureAD.
the class MicrosoftStsAuthorizationResultFactoryTest method testUrlWithValidAuthCodeAndFragmentParas.
@Test
public void testUrlWithValidAuthCodeAndFragmentParas() {
Intent intent = new Intent();
MicrosoftStsAuthorizationRequest testRequest = getMstsAuthorizationRequest();
intent.putExtra(AUTHORIZATION_FINAL_URL, REDIRECT_URI + "?" + "code=authorization_code&state=" + testRequest.getState() + FRAGMENT_STRING);
AuthorizationResult result = mAuthorizationResultFactory.createAuthorizationResult(AuthenticationConstants.UIResponse.BROWSER_CODE_COMPLETE, intent, testRequest);
assertNotNull(result);
assertNotNull(result.getAuthorizationResponse());
assertEquals(AuthorizationStatus.SUCCESS, result.getAuthorizationStatus());
assertNotNull(result.getAuthorizationResponse().getCode());
}
use of com.microsoft.identity.common.internal.providers.oauth2.AuthorizationResult in project microsoft-authentication-library-common-for-android by AzureAD.
the class MicrosoftStsAuthorizationResultFactoryTest method testBrowserCodeCancel.
@Test
public void testBrowserCodeCancel() {
Intent intent = new Intent();
AuthorizationResult result = mAuthorizationResultFactory.createAuthorizationResult(AuthenticationConstants.UIResponse.BROWSER_CODE_CANCEL, intent, getMstsAuthorizationRequest());
assertNotNull(result);
assertNull(result.getAuthorizationResponse());
assertEquals(AuthorizationStatus.USER_CANCEL, result.getAuthorizationStatus());
AuthorizationErrorResponse errorResponse = result.getAuthorizationErrorResponse();
assertNotNull(errorResponse);
assertEquals(MicrosoftAuthorizationErrorResponse.USER_CANCEL, errorResponse.getError());
assertEquals(MicrosoftAuthorizationErrorResponse.USER_CANCELLED_FLOW, errorResponse.getErrorDescription());
}
Aggregations