Skip to content

e2e example - Add runtime SDK configuration injection for e2e tests - #2838

Open
Robert-SD wants to merge 4 commits into
mainfrom
chore/example-app-config-injection
Open

e2e example - Add runtime SDK configuration injection for e2e tests#2838
Robert-SD wants to merge 4 commits into
mainfrom
chore/example-app-config-injection

Conversation

@Robert-SD

@Robert-SD Robert-SD commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add ExternalConfigurationReader.kt to read a Base64-encoded JSON config from the config intent extra at app launch
  • Extend KeyValueStorage with showCardholderName support (persisted via SharedPreferences)
  • Wire up MainActivity to read the intent extra and apply the external config before UI creation
  • Update CheckoutConfigurationProvider to apply the external showCardholderName value

This enables the e2e test framework to inject SDK configuration (e.g., showCardholderName: true) at launch time via adb shell am start --es config '<base64>', without rebuilding the app.

JSON Schema

{
  "CARD_CONFIGURATION": {
    "showCardholderName": true
  }
}

@AdyenAutomationBot AdyenAutomationBot added the Chore [PRs only] Indicates any task that does not need to be mentioned in the public release notes label Jun 23, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces an ExternalConfigurationReader to parse and apply external SDK configurations (such as showCardholderName) from a Base64-encoded JSON string passed via intent extras, storing them in KeyValueStorage for use by the CheckoutConfigurationProvider. Feedback focuses on replacing java.util.Base64 with android.util.Base64 to prevent crashes on devices below API level 26, resetting the persisted configuration when empty to avoid test pollution, and using Moshi's compile-time code generation instead of reflection to improve main-thread startup performance.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

@Robert-SD Robert-SD changed the title Add runtime SDK configuration injection for e2e tests e2e example - Add runtime SDK configuration injection for e2e tests Jun 23, 2026
@Robert-SD
Robert-SD force-pushed the chore/example-app-config-injection branch from ae3a012 to 249262b Compare June 23, 2026 14:24
Add ExternalConfigurationReader to read Base64-encoded JSON config from
intent extras (passed by Appium e2e tests via `--es config '<base64>'`).
The config is parsed and written to SharedPreferences so both old and
new Drop In card configurations pick up the values.

Supported fields:
- CARD_CONFIGURATION.showCardholderName (boolean)

Wiring:
- SharedPreferencesEntry: SHOW_CARDHOLDER_NAME entry
- KeyValueStorage: isShowCardholderName() / setShowCardholderName()
- CheckoutConfigurationProvider: setHolderNameRequired() in old card
  config + showCardholderName in new card config
- MainActivity: applies external config in onCreate()
…ce Moshi with org.json

- Replace java.util.Base64 with android.util.Base64 to support minSdk 23
- Reset showCardholderName to default when no config extra is passed (prevents test pollution)
- Replace Moshi reflection with built-in org.json.JSONObject (no extra dependencies)
…s pollution

Apply ExternalConfigurationReader in onNewIntent so that config resets
to defaults when the activity receives a new intent without restarting,
preventing test pollution from previous e2e runs.
@Robert-SD
Robert-SD force-pushed the chore/example-app-config-injection branch from a3237e9 to b79770c Compare July 16, 2026 08:21
@github-actions

Copy link
Copy Markdown
Contributor

✅ No public API changes

import javax.inject.Inject
import javax.inject.Singleton
import kotlin.io.encoding.Base64
import kotlin.io.encoding.ExperimentalEncodingApi

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I considered a few options for decoding the Base64 configuration string.

  • android.util.Base64 — works on all Android API levels, but it is Android-framework code that cannot be called from plain JVM unit tests. Using it would force this logic into instrumented or Robolectric tests, which is heavier and slower for a simple decoder.
  • java.util.Base64 — works on the JVM, but is only available from Android API 26 / Java 8. The project minSdk is 23 and core library desugaring is not enabled, so using it would crash on older devices.
  • Third-party Base64 library — possible, but adding a new dependency just to decode a Base64 string is overkill.

kotlin.io.encoding.Base64 is part of the Kotlin stdlib, works on all Android API levels, works in JVM unit tests, and requires no extra dependency. The @OptIn(ExperimentalEncodingApi::class) annotation is only an opt-in for a still-experimental API surface; the decode behavior itself is stable and fully functional.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's fine to use indeed. We use it internally as well

@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
0.0% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

@Robert-SD
Robert-SD marked this pull request as ready for review July 16, 2026 12:50
@Robert-SD
Robert-SD requested a review from a team as a code owner July 16, 2026 12:50
Comment on lines +69 to +70
fun isShowCardholderName(): Boolean
fun setShowCardholderName(showCardholderName: Boolean)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nits: What do you think if we rename this to isCardHolderNameShown, setCardholderNameShown to read more naturally. isShowCardholderName reads a bit off.

Comment on lines 277 to +278
internal const val RETURN_URL_EXTRA = "RETURN_URL_EXTRA"
internal const val CONFIG_EXTRA = "config"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nits: Could you keep these two values consistent, uppercase or lowercase?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Chore [PRs only] Indicates any task that does not need to be mentioned in the public release notes size:small

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants