use of com.braintreepayments.api.models.Authorization in project braintree_android by braintree.
the class VenmoUnitTest method performAppSwitch_persistsIfVaultFalse.
@Test
public void performAppSwitch_persistsIfVaultFalse() throws InvalidArgumentException {
Configuration configuration = getConfigurationFromFixture();
Authorization clientToken = Authorization.fromString(stringFromFixture("base_64_client_token.txt"));
disableSignatureVerification();
BraintreeFragment fragment = new MockFragmentBuilder().context(VenmoInstalledContextFactory.venmoInstalledContext(true, RuntimeEnvironment.application)).configuration(configuration).authorization(clientToken).build();
Venmo.authorizeAccount(fragment, false);
SharedPreferences prefs = SharedPreferencesHelper.getSharedPreferences(fragment.getApplicationContext());
assertFalse(prefs.getBoolean("com.braintreepayments.api.Venmo.VAULT_VENMO_KEY", true));
}
use of com.braintreepayments.api.models.Authorization in project braintree_android by braintree.
the class VenmoUnitTest method onActivityResult_performsVaultRequestIfRequestPersisted.
@Test
public void onActivityResult_performsVaultRequestIfRequestPersisted() throws InvalidArgumentException, NoSuchAlgorithmException {
Configuration configuration = getConfigurationFromFixture();
Authorization clientToken = Authorization.fromString(stringFromFixture("base_64_client_token.txt"));
disableSignatureVerification();
BraintreeFragment fragment = new MockFragmentBuilder().context(VenmoInstalledContextFactory.venmoInstalledContext(true, RuntimeEnvironment.application)).configuration(configuration).authorization(clientToken).sessionId("session-id").build();
Venmo.authorizeAccount(fragment, true);
mockStatic(TokenizationClient.class);
Venmo.onActivityResult(fragment, Activity.RESULT_OK, new Intent());
verifyStatic();
TokenizationClient.tokenize(eq(fragment), any(VenmoAccountBuilder.class), any(PaymentMethodNonceCallback.class));
}
use of com.braintreepayments.api.models.Authorization in project braintree_android by braintree.
the class VenmoUnitTest method onActivityResult_withFailedVaultCall_sendsAnalyticsEvent.
@Test
public void onActivityResult_withFailedVaultCall_sendsAnalyticsEvent() throws InvalidArgumentException {
Configuration configuration = getConfigurationFromFixture();
Authorization clientToken = Authorization.fromString(stringFromFixture("base_64_client_token.txt"));
disableSignatureVerification();
BraintreeFragment fragment = new MockFragmentBuilder().context(VenmoInstalledContextFactory.venmoInstalledContext(true, RuntimeEnvironment.application)).configuration(configuration).authorization(clientToken).sessionId("session-id").errorResponse(new AuthorizationException("Bad fingerprint")).build();
Venmo.authorizeAccount(fragment, true);
Intent responseIntent = new Intent().putExtra(Venmo.EXTRA_PAYMENT_METHOD_NONCE, "nonce");
Venmo.onActivityResult(fragment, Activity.RESULT_OK, responseIntent);
verify(fragment).sendAnalyticsEvent(endsWith("pay-with-venmo.vault.failed"));
}
use of com.braintreepayments.api.models.Authorization in project braintree_android by braintree.
the class VenmoUnitTest method performAppSwitch_whenProfileIdIsSpecified_appSwitchesWithProfileIdAndAccessToken.
@Test
public void performAppSwitch_whenProfileIdIsSpecified_appSwitchesWithProfileIdAndAccessToken() throws InvalidArgumentException, JSONException {
Configuration configuration = getConfigurationFromFixture();
Authorization clientToken = Authorization.fromString(stringFromFixture("base_64_client_token.txt"));
disableSignatureVerification();
BraintreeFragment fragment = new MockFragmentBuilder().context(VenmoInstalledContextFactory.venmoInstalledContext(true, RuntimeEnvironment.application)).authorization(clientToken).configuration(configuration).build();
when(fragment.getSessionId()).thenReturn("a-session-id");
when(fragment.getIntegrationType()).thenReturn("custom");
Venmo.authorizeAccount(fragment, false, "second-pwv-profile-id");
ArgumentCaptor<Intent> captor = ArgumentCaptor.forClass(Intent.class);
verify(fragment).startActivityForResult(captor.capture(), eq(BraintreeRequestCodes.VENMO));
assertEquals("com.venmo/com.venmo.controller.SetupMerchantActivity", captor.getValue().getComponent().flattenToString());
Bundle extras = captor.getValue().getExtras();
assertEquals("second-pwv-profile-id", extras.getString(Venmo.EXTRA_MERCHANT_ID));
assertEquals("access-token", extras.getString(Venmo.EXTRA_ACCESS_TOKEN));
}
use of com.braintreepayments.api.models.Authorization in project braintree_android by braintree.
the class BraintreeFragmentTestUtils method setConfiguration.
public static void setConfiguration(String authorization, String configuration) throws InvalidArgumentException {
Authorization auth = Authorization.fromString(authorization);
writeMockConfiguration(getTargetContext(), auth.getConfigUrl(), auth.getBearer(), configuration);
}
Aggregations