Skip to content

Commit

Permalink
Fix fingerprint-related tests
Browse files Browse the repository at this point in the history
  • Loading branch information
djoksimo committed May 6, 2024
1 parent 20466f3 commit 8fe4d9d
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,9 @@ import org.json.JSONObject

/**
* @property last4 The last 4 digits of the card number.
* @property fingerprint A unique hash based on the card PAN. The fingerprint is constant for a card PAN,
* no matter the `customerId`. Use the [fingerprint] to track card usage details for fraud prevention.
*/
interface Card {
val last4: String
val fingerprint: String
}

/**
Expand All @@ -22,7 +19,7 @@ interface Card {
*/
data class EbtCard(
override val last4: String,
override val fingerprint: String,
val fingerprint: String,
internal val token: String,
val usState: USState? = null
) : Card {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.joinforage.forage.android.mock

import com.joinforage.forage.android.ForageSDK
import com.joinforage.forage.android.core.telemetry.Log
import com.joinforage.forage.android.model.USState
import com.joinforage.forage.android.network.EncryptionKeyService
import com.joinforage.forage.android.network.MessageStatusService
import com.joinforage.forage.android.network.OkHttpClientBuilder
Expand Down Expand Up @@ -38,6 +39,8 @@ internal class MockServiceFactory(
// card tokenization
const val cardNumber: String = "5076801234567845"
const val customerId: String = "test-android-customer-id"
val cardUsState: USState = USState.PENNSYLVANIA
const val cardFingerprint: String = "470dda97b63f016a962de150cf53ad72a93aaea4c2a59de2541e0994f48e02ef"

// PIN-related interactions
const val paymentRef: String = "6ae6a45ff1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import com.joinforage.forage.android.fixtures.returnsPaymentMethodFailed
import com.joinforage.forage.android.fixtures.returnsPaymentMethodSuccessfully
import com.joinforage.forage.android.mock.MockServiceFactory
import com.joinforage.forage.android.mock.MockVaultSubmitter
import com.joinforage.forage.android.model.USState
import com.joinforage.forage.android.network.model.EbtCard
import com.joinforage.forage.android.network.model.ForageApiResponse
import com.joinforage.forage.android.network.model.ForageError
Expand Down Expand Up @@ -84,7 +83,8 @@ class TokenizeCardServiceTest : MockServerSuite() {
card = EbtCard(
last4 = "7845",
token = "tok_sandbox_sYiPe9Q249qQ5wQyUPP5f7",
usState = USState.PENNSYLVANIA
usState = testData.cardUsState,
fingerprint = testData.cardFingerprint
),
customerId = "test-android-customer-id",
reusable = true
Expand All @@ -109,7 +109,8 @@ class TokenizeCardServiceTest : MockServerSuite() {
card = EbtCard(
last4 = "7845",
token = "tok_sandbox_sYiPe9Q249qQ5wQyUPP5f7",
usState = USState.PENNSYLVANIA
usState = testData.cardUsState,
fingerprint = testData.cardFingerprint
),
reusable = true,
customerId = null
Expand All @@ -136,7 +137,8 @@ class TokenizeCardServiceTest : MockServerSuite() {
card = EbtCard(
last4 = "7845",
token = "tok_sandbox_sYiPe9Q249qQ5wQyUPP5f7",
usState = USState.PENNSYLVANIA
usState = testData.cardUsState,
fingerprint = testData.cardFingerprint
),
customerId = "test-android-customer-id",
reusable = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,8 @@ class ForageTerminalSDKTest : MockServerSuite() {
card = EbtCard(
last4 = "7845",
token = "tok_sandbox_sYiPe9Q249qQ5wQyUPP5f7",
usState = (response.card as EbtCard).usState
usState = (response.card as EbtCard).usState,
fingerprint = (response.card as EbtCard).fingerprint
),
reusable = true,
customerId = null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ class AbstractVaultSubmitterTest : MockServerSuite() {
balance = null,
card = EbtCard(
last4 = "7845",
token = "tok_sandbox_sYiPe9Q249qQ5wQyUPP5f7,basis-theory-token"
token = "tok_sandbox_sYiPe9Q249qQ5wQyUPP5f7,basis-theory-token",
fingerprint = "fingerprint"
),
customerId = "test-android-customer-id",
reusable = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"last_4": "7845",
"created": "2022-11-01T12:21:03.801119-07:00",
"token": "tok_sandbox_sYiPe9Q249qQ5wQyUPP5f7",
"state": "PA"
"state": "PA",
"fingerprint": "470dda97b63f016a962de150cf53ad72a93aaea4c2a59de2541e0994f48e02ef"
},
"customer_id": "test-android-customer-id"
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"last_4": "7845",
"created": "2022-11-01T12:21:03.801119-07:00",
"token": "tok_sandbox_sYiPe9Q249qQ5wQyUPP5f7",
"state": "PA"
"state": "PA",
"fingerprint": "470dda97b63f016a962de150cf53ad72a93aaea4c2a59de2541e0994f48e02ef"
},
"customer_id": "test-android-customer-id",
"reusable": false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"last_4": "7845",
"created": "2022-11-01T12:21:03.801119-07:00",
"token": "tok_sandbox_sYiPe9Q249qQ5wQyUPP5f7",
"state": "PA"
"state": "PA",
"fingerprint": "470dda97b63f016a962de150cf53ad72a93aaea4c2a59de2541e0994f48e02ef"
},
"customer_id": "test-android-customer-id",
"reusable": true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"last_4": "7845",
"created": "2022-11-01T12:21:03.801119-07:00",
"token": "tok_sandbox_sYiPe9Q249qQ5wQyUPP5f7",
"state": "PA"
"state": "PA",
"fingerprint": "470dda97b63f016a962de150cf53ad72a93aaea4c2a59de2541e0994f48e02ef"
},
"reusable": true
}

0 comments on commit 8fe4d9d

Please sign in to comment.