Search in sources :

Example 21 with AuthorizationResult

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

the class MicrosoftStsAuthorizationResultFactoryTest method testUrlWithInvalidParams.

@Test
public void testUrlWithInvalidParams() {
    Intent intent = new Intent();
    intent.putExtra(AUTHORIZATION_FINAL_URL, REDIRECT_URI + "?some_random_error=accessdenied");
    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(MicrosoftAuthorizationErrorResponse.AUTHORIZATION_FAILED, errorResponse.getError());
    assertEquals(MicrosoftAuthorizationErrorResponse.AUTHORIZATION_SERVER_INVALID_RESPONSE, errorResponse.getErrorDescription());
}
Also used : AuthorizationErrorResponse(com.microsoft.identity.common.internal.providers.oauth2.AuthorizationErrorResponse) MicrosoftAuthorizationErrorResponse(com.microsoft.identity.common.internal.providers.microsoft.MicrosoftAuthorizationErrorResponse) Intent(android.content.Intent) AuthorizationResult(com.microsoft.identity.common.internal.providers.oauth2.AuthorizationResult) MicrosoftStsAuthorizationResult(com.microsoft.identity.common.internal.providers.microsoft.microsoftsts.MicrosoftStsAuthorizationResult) MicrosoftAuthorizationResult(com.microsoft.identity.common.internal.providers.microsoft.MicrosoftAuthorizationResult) Test(org.junit.Test)

Example 22 with AuthorizationResult

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

the class AzureActiveDirectoryAuthorizationResultFactoryTest method testNullUrl.

@Test
public void testNullUrl() {
    Intent intent = new Intent();
    intent.putExtras(new 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());
}
Also used : AuthorizationErrorResponse(com.microsoft.identity.common.internal.providers.oauth2.AuthorizationErrorResponse) AzureActiveDirectoryAuthorizationErrorResponse(com.microsoft.identity.common.internal.providers.microsoft.azureactivedirectory.AzureActiveDirectoryAuthorizationErrorResponse) MicrosoftAuthorizationErrorResponse(com.microsoft.identity.common.internal.providers.microsoft.MicrosoftAuthorizationErrorResponse) Bundle(android.os.Bundle) Intent(android.content.Intent) AuthorizationResult(com.microsoft.identity.common.internal.providers.oauth2.AuthorizationResult) AzureActiveDirectoryAuthorizationResult(com.microsoft.identity.common.internal.providers.microsoft.azureactivedirectory.AzureActiveDirectoryAuthorizationResult) MicrosoftAuthorizationResult(com.microsoft.identity.common.internal.providers.microsoft.MicrosoftAuthorizationResult) Test(org.junit.Test)

Example 23 with AuthorizationResult

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

the class AzureActiveDirectoryAuthorizationResultFactoryTest method testBrowserCodeError.

@Test
public void testBrowserCodeError() {
    Intent intent = new Intent();
    AuthorizationResult result = mAuthorizationResultFactory.createAuthorizationResult(AuthenticationConstants.UIResponse.BROWSER_CODE_ERROR, intent, getAADRequest());
    assertNotNull(result);
    assertNull(result.getAuthorizationResponse());
    assertEquals(AuthorizationStatus.FAIL, result.getAuthorizationStatus());
    assertNotNull(result.getAuthorizationErrorResponse());
}
Also used : Intent(android.content.Intent) AuthorizationResult(com.microsoft.identity.common.internal.providers.oauth2.AuthorizationResult) AzureActiveDirectoryAuthorizationResult(com.microsoft.identity.common.internal.providers.microsoft.azureactivedirectory.AzureActiveDirectoryAuthorizationResult) MicrosoftAuthorizationResult(com.microsoft.identity.common.internal.providers.microsoft.MicrosoftAuthorizationResult) Test(org.junit.Test)

Example 24 with AuthorizationResult

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

the class AzureActiveDirectoryAuthorizationResultFactoryTest method testBrowserCodeCancel.

@Test
public void testBrowserCodeCancel() {
    Intent intent = new Intent();
    intent.putExtras(new Bundle());
    AuthorizationResult result = mAuthorizationResultFactory.createAuthorizationResult(AuthenticationConstants.UIResponse.BROWSER_CODE_CANCEL, intent, getAADRequest());
    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());
}
Also used : AuthorizationErrorResponse(com.microsoft.identity.common.internal.providers.oauth2.AuthorizationErrorResponse) AzureActiveDirectoryAuthorizationErrorResponse(com.microsoft.identity.common.internal.providers.microsoft.azureactivedirectory.AzureActiveDirectoryAuthorizationErrorResponse) MicrosoftAuthorizationErrorResponse(com.microsoft.identity.common.internal.providers.microsoft.MicrosoftAuthorizationErrorResponse) Bundle(android.os.Bundle) Intent(android.content.Intent) AuthorizationResult(com.microsoft.identity.common.internal.providers.oauth2.AuthorizationResult) AzureActiveDirectoryAuthorizationResult(com.microsoft.identity.common.internal.providers.microsoft.azureactivedirectory.AzureActiveDirectoryAuthorizationResult) MicrosoftAuthorizationResult(com.microsoft.identity.common.internal.providers.microsoft.MicrosoftAuthorizationResult) Test(org.junit.Test)

Example 25 with AuthorizationResult

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

the class AzureActiveDirectoryAuthorizationResultFactoryTest method testNoMatchingResultCode.

@Test
public void testNoMatchingResultCode() {
    Intent intent = new Intent();
    intent.putExtras(new Bundle());
    AuthorizationResult result = mAuthorizationResultFactory.createAuthorizationResult(0, intent, getAADRequest());
    assertNotNull(result);
    assertNull(result.getAuthorizationResponse());
    assertEquals(AuthorizationStatus.FAIL, result.getAuthorizationStatus());
    AuthorizationErrorResponse errorResponse = result.getAuthorizationErrorResponse();
    assertNotNull(errorResponse);
    assertEquals(MicrosoftAuthorizationErrorResponse.UNKNOWN_ERROR, errorResponse.getError());
    assertNotNull(errorResponse.getErrorDescription());
}
Also used : AuthorizationErrorResponse(com.microsoft.identity.common.internal.providers.oauth2.AuthorizationErrorResponse) AzureActiveDirectoryAuthorizationErrorResponse(com.microsoft.identity.common.internal.providers.microsoft.azureactivedirectory.AzureActiveDirectoryAuthorizationErrorResponse) MicrosoftAuthorizationErrorResponse(com.microsoft.identity.common.internal.providers.microsoft.MicrosoftAuthorizationErrorResponse) Bundle(android.os.Bundle) Intent(android.content.Intent) AuthorizationResult(com.microsoft.identity.common.internal.providers.oauth2.AuthorizationResult) AzureActiveDirectoryAuthorizationResult(com.microsoft.identity.common.internal.providers.microsoft.azureactivedirectory.AzureActiveDirectoryAuthorizationResult) MicrosoftAuthorizationResult(com.microsoft.identity.common.internal.providers.microsoft.MicrosoftAuthorizationResult) Test(org.junit.Test)

Aggregations

AuthorizationResult (com.microsoft.identity.common.internal.providers.oauth2.AuthorizationResult)35 MicrosoftAuthorizationResult (com.microsoft.identity.common.internal.providers.microsoft.MicrosoftAuthorizationResult)22 Test (org.junit.Test)21 Intent (android.content.Intent)20 MicrosoftAuthorizationErrorResponse (com.microsoft.identity.common.internal.providers.microsoft.MicrosoftAuthorizationErrorResponse)20 AuthorizationErrorResponse (com.microsoft.identity.common.internal.providers.oauth2.AuthorizationErrorResponse)20 AzureActiveDirectoryAuthorizationResult (com.microsoft.identity.common.internal.providers.microsoft.azureactivedirectory.AzureActiveDirectoryAuthorizationResult)11 MicrosoftStsAuthorizationResult (com.microsoft.identity.common.internal.providers.microsoft.microsoftsts.MicrosoftStsAuthorizationResult)11 AzureActiveDirectoryAuthorizationErrorResponse (com.microsoft.identity.common.internal.providers.microsoft.azureactivedirectory.AzureActiveDirectoryAuthorizationErrorResponse)10 Bundle (android.os.Bundle)8 ClientException (com.microsoft.identity.common.exception.ClientException)5 OAuth2StrategyParameters (com.microsoft.identity.common.internal.providers.oauth2.OAuth2StrategyParameters)4 ServiceException (com.microsoft.identity.common.exception.ServiceException)3 OAuth2Strategy (com.microsoft.identity.common.internal.providers.oauth2.OAuth2Strategy)3 TokenResult (com.microsoft.identity.common.internal.providers.oauth2.TokenResult)3 AcquireTokenResult (com.microsoft.identity.common.internal.result.AcquireTokenResult)3 ResultFuture (com.microsoft.identity.common.internal.result.ResultFuture)3 ApiEndEvent (com.microsoft.identity.common.internal.telemetry.events.ApiEndEvent)3 ApiStartEvent (com.microsoft.identity.common.internal.telemetry.events.ApiStartEvent)3 ArgumentException (com.microsoft.identity.common.exception.ArgumentException)2