Repository navigation
[PIMOB-5427]: Update Risk to 3.0.1 #306
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
adrian-orlowski-cko
merged 7 commits into
master
from
feature/PIMOB-5427_update_risk_sdk
Nov 16, 2026
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
745001f
[PIMOB-5427] Update Risk to 3.0.1 and require API 23
adrian-orlowski-cko ee32586
[PIMOB-5427] Share prefix validation across token and Risk endpoints
adrian-orlowski-cko 51888e9
[PIMOB-5427] Fix coroutine dispatcher race in token repository tests
adrian-orlowski-cko 702990d
[PIMOB-5427] Remove stale SDK compatibility claim
adrian-orlowski-cko 1bd30fa
[PIMOB-5427] Limit test fix to dispatcher injection
adrian-orlowski-cko 90689ca
[PIMOB-5427] Centralize baseUrlPrefix validation in the API factory
adrian-orlowski-cko b7dd93e
[PIMOB-5427] added KDoc
adrian-orlowski-cko File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,8 @@ | ||
| -keep class com.checkout.** { *; } | ||
| -keep class com.checkout.** { *; } | ||
|
|
||
| # Risk SDK leaves Fingerprint's optional device-location collection disabled. | ||
| -dontwarn com.google.android.gms.location.** | ||
| -dontwarn com.google.android.gms.tasks.CancellationToken | ||
| -dontwarn com.google.android.gms.tasks.OnFailureListener | ||
| -dontwarn com.google.android.gms.tasks.OnSuccessListener | ||
| -dontwarn com.google.android.gms.tasks.Task |
8 changes: 8 additions & 0 deletions
8
checkout/src/main/java/com/checkout/BaseUrlPrefixValidator.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| package com.checkout | ||
|
|
||
| internal object BaseUrlPrefixValidator { | ||
| fun validPrefixOrNull(baseUrlPrefix: String?): String? = | ||
| baseUrlPrefix?.takeIf { LABEL_REGEX.matches(it) } | ||
|
|
||
| private val LABEL_REGEX = Regex("^[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?$") | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 1 addition & 5 deletions
6
checkout/src/main/java/com/checkout/threedsecure/utils/WebResourcesExtension.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,14 +1,10 @@ | ||
| package com.checkout.threedsecure.utils | ||
|
|
||
| import android.os.Build | ||
| import android.webkit.WebResourceError | ||
| import android.webkit.WebResourceResponse | ||
| import com.checkout.threedsecure.error.ThreeDSError | ||
|
|
||
| internal fun WebResourceResponse.toThreeDSError() = ThreeDSError(this.statusCode.toString(), this.reasonPhrase) | ||
|
|
||
| internal fun WebResourceError.toThreeDSError() = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { | ||
| internal fun WebResourceError.toThreeDSError() = | ||
| ThreeDSError(this.errorCode.toString(), this.description.toString()) | ||
| } else { | ||
| null | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
checkout/src/test/java/com/checkout/tokenization/RiskInstanceProviderTest.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| package com.checkout.tokenization | ||
|
|
||
| import android.content.Context | ||
| import com.checkout.base.model.Environment | ||
| import com.checkout.risk.FramesOptions | ||
| import com.checkout.risk.Risk | ||
| import com.checkout.risk.RiskConfig | ||
| import com.checkout.risk.RiskEnvironment | ||
| import com.checkout.tokenization.usecase.RiskInstanceProvider | ||
| import io.mockk.coEvery | ||
| import io.mockk.mockk | ||
| import io.mockk.mockkObject | ||
| import io.mockk.unmockkObject | ||
| import kotlinx.coroutines.test.runTest | ||
| import org.junit.jupiter.api.AfterEach | ||
| import org.junit.jupiter.api.Assertions.assertEquals | ||
| import org.junit.jupiter.api.BeforeEach | ||
| import org.junit.jupiter.api.Test | ||
|
|
||
| internal class RiskInstanceProviderTest { | ||
| private val context: Context = mockk() | ||
| private val framesOptions = FramesOptions("1.0.0", "productIdentifier", "correlationId") | ||
| private val riskConfigs = mutableListOf<RiskConfig>() | ||
|
|
||
| @BeforeEach | ||
| fun setup() { | ||
| mockkObject(Risk.Companion) | ||
| coEvery { Risk.getInstance(context, capture(riskConfigs)) } returns null | ||
| } | ||
|
|
||
| @AfterEach | ||
| fun tearDown() { | ||
| unmockkObject(Risk.Companion) | ||
| } | ||
|
|
||
| @Test | ||
| fun `valid subdomain labels are forwarded to Risk in both environments`() = runTest { | ||
| listOf("a", "0", "Ab", "merchant-123", "a--b", "A" + "-".repeat(61) + "9").forEach { prefix -> | ||
| provideInBothEnvironments(prefix) | ||
| assertEquals(prefix, riskConfigs[riskConfigs.lastIndex - 1].mssd) | ||
| assertEquals(prefix, riskConfigs.last().mssd) | ||
| } | ||
| } | ||
|
|
||
| @Test | ||
| fun `null prefix is forwarded to Risk in both environments`() = runTest { | ||
| provideInBothEnvironments(null) | ||
| assertEquals(null, riskConfigs[riskConfigs.lastIndex - 1].mssd) | ||
| assertEquals(null, riskConfigs.last().mssd) | ||
| } | ||
|
|
||
| private suspend fun provideInBothEnvironments(prefix: String?) { | ||
| listOf(Environment.SANDBOX, Environment.PRODUCTION).forEach { environment -> | ||
| RiskInstanceProvider.provide(context, "publicKey", environment, framesOptions, prefix) | ||
| } | ||
| assertEquals(RiskEnvironment.SANDBOX, riskConfigs[riskConfigs.lastIndex - 1].environment) | ||
| assertEquals(RiskEnvironment.PRODUCTION, riskConfigs.last().environment) | ||
| assertEquals("publicKey", riskConfigs.last().publicKey) | ||
| assertEquals(framesOptions, riskConfigs.last().framesOptions) | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.