Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tillh-stripe committed Oct 7, 2022
1 parent 511c3d5 commit e37e132
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.stripe.android.payments.core.authentication

import android.app.Activity
import androidx.annotation.RestrictTo
import androidx.annotation.VisibleForTesting
import androidx.fragment.app.Fragment
import androidx.lifecycle.lifecycleScope
import androidx.lifecycle.whenResumed
Expand Down Expand Up @@ -38,7 +39,8 @@ abstract class PaymentAuthenticator<Authenticatable> : ActivityResultLauncherHos
}
}

protected abstract suspend fun performAuthentication(
@VisibleForTesting(otherwise = VisibleForTesting.PROTECTED)
abstract suspend fun performAuthentication(
host: AuthActivityStarterHost,
authenticatable: Authenticatable,
requestOptions: ApiRequest.Options
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,8 @@ import androidx.activity.ComponentActivity
import androidx.annotation.RestrictTo
import androidx.fragment.app.Fragment
import androidx.lifecycle.LifecycleOwner
import androidx.lifecycle.lifecycleScope
import androidx.lifecycle.whenResumed
import com.stripe.android.view.AuthActivityStarterHost.ActivityHost
import com.stripe.android.view.AuthActivityStarterHost.FragmentHost
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.launch

/**
* A representation of an Android component (i.e. [ComponentActivity] or [Fragment]) that can start
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import com.stripe.android.view.AuthActivityStarterHost
import com.stripe.android.view.PaymentRelayActivity
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.test.runTest
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.kotlin.KArgumentCaptor
Expand Down Expand Up @@ -55,7 +54,7 @@ class NoOpIntentAuthenticatorTest {
)
)

authenticator.authenticate(
authenticator.performAuthentication(
host,
PaymentIntentFixtures.PI_WITH_LAST_PAYMENT_ERROR,
REQUEST_OPTIONS
Expand All @@ -79,7 +78,7 @@ class NoOpIntentAuthenticatorTest {
host
)
)
authenticator.authenticate(
authenticator.performAuthentication(
host,
PaymentIntentFixtures.PI_WITH_LAST_PAYMENT_ERROR,
REQUEST_OPTIONS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class SourceAuthenticatorTest {
@Test
fun authenticate_withNoneFlowSource_shouldBypassAuth() =
runTest {
authenticator.authenticate(
authenticator.performAuthentication(
host = host,
authenticatable = SourceFixtures.SOURCE_WITH_SOURCE_ORDER.copy(
flow = Source.Flow.None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class Stripe3DS2AuthenticatorTest {
runTest {
val paymentIntent = PaymentIntentFixtures.PI_REQUIRES_MASTERCARD_3DS2

authenticator.authenticate(
authenticator.performAuthentication(
host,
paymentIntent,
REQUEST_OPTIONS
Expand All @@ -69,7 +69,7 @@ class Stripe3DS2AuthenticatorTest {
authenticator.stripe3ds2CompletionLauncher = mockLauncher

val paymentIntent = PaymentIntentFixtures.PI_REQUIRES_MASTERCARD_3DS2
authenticator.authenticate(
authenticator.performAuthentication(
host,
paymentIntent,
REQUEST_OPTIONS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class UnsupportedAuthenticatorTest {

@Test
fun verifyWeChat() = runTest {
authenticator.authenticate(
authenticator.performAuthentication(
mock(),
PaymentIntentFixtures.PI_REQUIRES_WECHAT_PAY_AUTHORIZE,
REQUEST_OPTIONS
Expand All @@ -70,7 +70,7 @@ class UnsupportedAuthenticatorTest {

@Test
fun verifyNullNextActionType() = runTest {
authenticator.authenticate(
authenticator.performAuthentication(
mock(),
PI_SUCCEEDED,
REQUEST_OPTIONS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ class WebIntentAuthenticatorTest {
expectedShouldCancelIntentOnUserNavigation: Boolean = true,
expectedAnalyticsEvent: PaymentAnalyticsEvent?
) = runTest {
authenticator.authenticate(
authenticator.performAuthentication(
host,
stripeIntent,
REQUEST_OPTIONS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import com.stripe.android.view.AuthActivityStarterHost
* [PaymentAuthenticator] implementation to authenticate through WeChatPay SDK.
*/
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
class WeChatPayAuthenticator : PaymentAuthenticator<StripeIntent> {
class WeChatPayAuthenticator : PaymentAuthenticator<StripeIntent>() {
/**
* [weChatPayAuthLauncher] is mutable and might be updated during
* through [onNewActivityResultCaller]
Expand Down

0 comments on commit e37e132

Please sign in to comment.