Search in sources :

Example 1 with ResponseParsingException

use of com.paypal.android.sdk.onetouch.core.exception.ResponseParsingException in project braintree_android by braintree.

the class AuthorizationRequestUnitTest method parseBrowserSwitchResponse_returnsErrorWhenNoEncryptionKeyInPreferences.

@Test
public void parseBrowserSwitchResponse_returnsErrorWhenNoEncryptionKeyInPreferences() {
    Uri uri = Uri.parse("com.braintreepayments.demo.braintree://onetouch/v1/success?payload=eyJtc2dfR1VJRCI6Im1zZ19HVUlEIn0=&payloadEnc=encrypteddata");
    when(mContextInspector.getStringPreference("com.paypal.otc.msg_guid")).thenReturn("msg_GUID");
    when(mContextInspector.getStringPreference("com.paypal.otc.key")).thenReturn("");
    Result result = mRequest.parseBrowserResponse(mContextInspector, uri);
    assertEquals(ResultType.Error, result.getResultType());
    assertTrue(result.getError() instanceof ResponseParsingException);
    assertEquals("Response invalid", result.getError().getMessage());
}
Also used : ResponseParsingException(com.paypal.android.sdk.onetouch.core.exception.ResponseParsingException) Uri(android.net.Uri) Test(org.junit.Test)

Example 2 with ResponseParsingException

use of com.paypal.android.sdk.onetouch.core.exception.ResponseParsingException in project braintree_android by braintree.

the class AuthorizationRequestUnitTest method parseBrowserSwitchResponse_returnsErrorForInvalidJsonPayload.

@Test
public void parseBrowserSwitchResponse_returnsErrorForInvalidJsonPayload() {
    Uri uri = Uri.parse("com.braintreepayments.demo.braintree://onetouch/v1/success?payload=amFhZmpmamY=");
    Result result = mRequest.parseBrowserResponse(mContextInspector, uri);
    assertEquals(ResultType.Error, result.getResultType());
    assertTrue(result.getError() instanceof ResponseParsingException);
    assertEquals("Response incomplete", result.getError().getMessage());
}
Also used : ResponseParsingException(com.paypal.android.sdk.onetouch.core.exception.ResponseParsingException) Uri(android.net.Uri) Test(org.junit.Test)

Example 3 with ResponseParsingException

use of com.paypal.android.sdk.onetouch.core.exception.ResponseParsingException in project braintree_android by braintree.

the class AuthorizationRequestUnitTest method parseBrowserSwitchResponse_returnsErrorForMissingPayloadEnc.

@Test
public void parseBrowserSwitchResponse_returnsErrorForMissingPayloadEnc() {
    Uri uri = Uri.parse("com.braintreepayments.demo.braintree://onetouch/v1/success?payload=eyJtc2dfR1VJRCI6Im1zZ19HVUlEIn0=");
    Result result = mRequest.parseBrowserResponse(mContextInspector, uri);
    assertEquals(ResultType.Error, result.getResultType());
    assertTrue(result.getError() instanceof ResponseParsingException);
    assertEquals("Response invalid", result.getError().getMessage());
}
Also used : ResponseParsingException(com.paypal.android.sdk.onetouch.core.exception.ResponseParsingException) Uri(android.net.Uri) Test(org.junit.Test)

Example 4 with ResponseParsingException

use of com.paypal.android.sdk.onetouch.core.exception.ResponseParsingException in project braintree_android by braintree.

the class AuthorizationRequestUnitTest method parseBrowserSwitchResponse_returnsErrorForInvalidBase64PayloadInSuccessResponse.

@Test
public void parseBrowserSwitchResponse_returnsErrorForInvalidBase64PayloadInSuccessResponse() {
    Uri uri = Uri.parse("com.braintreepayments.demo.braintree://onetouch/v1/success?payload=afjfi");
    Result result = mRequest.parseBrowserResponse(mContextInspector, uri);
    assertEquals(ResultType.Error, result.getResultType());
    assertTrue(result.getError() instanceof ResponseParsingException);
    assertEquals("Response incomplete", result.getError().getMessage());
}
Also used : ResponseParsingException(com.paypal.android.sdk.onetouch.core.exception.ResponseParsingException) Uri(android.net.Uri) Test(org.junit.Test)

Example 5 with ResponseParsingException

use of com.paypal.android.sdk.onetouch.core.exception.ResponseParsingException in project braintree_android by braintree.

the class AuthorizationRequestUnitTest method parseBrowserSwitchResponse_returnsErrorWhenNoMsgGUIDInPreferences.

@Test
public void parseBrowserSwitchResponse_returnsErrorWhenNoMsgGUIDInPreferences() {
    Uri uri = Uri.parse("com.braintreepayments.demo.braintree://onetouch/v1/success?payload=eyJtc2dfR1VJRCI6Im1zZ19HVUlEIn0=&payloadEnc=encrypteddata");
    when(mContextInspector.getStringPreference("com.paypal.otc.msg_guid")).thenReturn("");
    when(mContextInspector.getStringPreference("com.paypal.otc.key")).thenReturn("key");
    Result result = mRequest.parseBrowserResponse(mContextInspector, uri);
    assertEquals(ResultType.Error, result.getResultType());
    assertTrue(result.getError() instanceof ResponseParsingException);
    assertEquals("Response invalid", result.getError().getMessage());
}
Also used : ResponseParsingException(com.paypal.android.sdk.onetouch.core.exception.ResponseParsingException) Uri(android.net.Uri) Test(org.junit.Test)

Aggregations

ResponseParsingException (com.paypal.android.sdk.onetouch.core.exception.ResponseParsingException)14 Test (org.junit.Test)11 Uri (android.net.Uri)10 JSONException (org.json.JSONException)3 JSONObject (org.json.JSONObject)3 Result (com.paypal.android.sdk.onetouch.core.Result)2 BrowserSwitchException (com.paypal.android.sdk.onetouch.core.exception.BrowserSwitchException)2 Context (android.content.Context)1 Intent (android.content.Intent)1 Bundle (android.os.Bundle)1 AuthorizationRequest (com.paypal.android.sdk.onetouch.core.AuthorizationRequest)1 CheckoutRequest (com.paypal.android.sdk.onetouch.core.CheckoutRequest)1 Request (com.paypal.android.sdk.onetouch.core.Request)1 ContextInspector (com.paypal.android.sdk.onetouch.core.base.ContextInspector)1 Protocol (com.paypal.android.sdk.onetouch.core.enums.Protocol)1 ResponseType (com.paypal.android.sdk.onetouch.core.enums.ResponseType)1 InvalidEncryptionDataException (com.paypal.android.sdk.onetouch.core.exception.InvalidEncryptionDataException)1 WalletSwitchException (com.paypal.android.sdk.onetouch.core.exception.WalletSwitchException)1 TestSetupHelper.getMockContextInspector (com.paypal.android.sdk.onetouch.core.test.TestSetupHelper.getMockContextInspector)1 InvalidAlgorithmParameterException (java.security.InvalidAlgorithmParameterException)1