Skip to content

Conversation

@brandonpage
Copy link
Contributor

@brandonpage brandonpage commented Nov 26, 2025

This PR adds a new appConfigForLoginHost lambda to SalesforceSDKManager that allows the app to supply a consumer key, redirect and scopes per login server. This functionality is also utilized by the newly wired up "Override Boot Config" section of the debug LoginOptionsActivity.

Apologies that this PR has become enormous, but the vast majority of it is test code.

@github-actions
Copy link

1 Warning
⚠️ Big PR, try to keep changes smaller if you can.

Generated by 🚫 Danger


// Choose front door bridge use by verifying intent data and such that only front door bridge URLs with matching consumer keys are used.
val uiBridgeApiParametersFrontDoorBridgeUrlMismatchedConsumerKey = uiBridgeApiParametersConsumerKey != null && uiBridgeApiParametersConsumerKey != viewModel.bootConfig.remoteAccessConsumerKey
val uiBridgeApiParametersFrontDoorBridgeUrlMismatchedConsumerKey = uiBridgeApiParametersConsumerKey != null && uiBridgeApiParametersConsumerKey != viewModel.oAuthConfig.redirectUri
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't understand the meaning of uiBridgeApiParametersConsumerKey != viewModel.oAuthConfig.redirectUri

* Asynchronously retrieves the app config for the specified login host. If not set the values
* found in the BootConfig file will be used for all servers.
*/
var appConfigForLoginHost: suspend (server: String) -> OAuthConfig = {
Copy link
Contributor

Choose a reason for hiding this comment

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

On iOS, if the block is not set OR returns nil, then the default config is being used.
See comment here and code here

Copy link
Contributor

Choose a reason for hiding this comment

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

For instance, if SApp goes to some end point and decides it should not override the default consumer key it doesn't have to figure out how to return the default config, it can simply return nil and let MSDK uses the default.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I had considered that, which is why I made the OAuthConfig bootconfig constructor public for them to fall back to. But I suppose allowing null is easier so it can update to allow that.

disabledContentColor = colorScheme.surfaceVariant,
),
enabled = validInput,
onClick = {
Copy link
Contributor

Choose a reason for hiding this comment

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

On iOS, the view does not interact with SalesforceSDKManager (or anything else) directly. Instead it is passed a onUseConfig at initialization and uses it when the button is clicked. See here.

Copy link
Contributor

Choose a reason for hiding this comment

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

So on iOS, we create two boot config editors, one for static and one for dynamic.
The onUseConfig of the first one is wired to a handleStaticConfig method (see this and that) and the dynamic one goes to a handleDynamicConfig method (see this and that).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I could extract out the SalesforceSDKManager but I don't really see the point. If it was used more than once it would make sense to extract it out, but the BootConfig class is not dynamic on Android.

I really do no like the idea of modifying the BootConfig class to change dynamically at runtime when it's purpose is represent a file that we do not write to. I also do not see the point in modifying BootConfig is is far simpler code-wise (and easier to understand IMO) to have a debug runtime config that takes president.

Copy link
Contributor

Choose a reason for hiding this comment

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

From Login Options, are you exclusively using debugOverrideAppConfig?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes.

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm, so it's not really exercising (testing) the code path that internal app will use?

Copy link
Contributor Author

@brandonpage brandonpage Dec 4, 2025

Choose a reason for hiding this comment

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

There is only one path. From getAuthorizationUrl:

oAuthConfig = if (isDebugBuild && debugOverrideAppConfig != null) {
    debugOverrideAppConfig!!
} else {
    appConfigForLoginHost(server) ?: OAuthConfig(bootConfig)
}

debugOverrideAppConfig and appConfigForLoginHost are only ever used in this one place. oAuthConfig is the single source of truth.

@github-actions
Copy link

github-actions bot commented Dec 2, 2025

1 Warning
⚠️ libs/SalesforceSDK/AndroidManifest.xml#L0 - The project references RTL attributes, but does not explicitly enable or disable RTL support with android:supportsRtl in the manifest

Generated by 🚫 Danger

@codecov
Copy link

codecov bot commented Dec 3, 2025

Codecov Report

❌ Patch coverage is 84.03361% with 19 lines in your changes missing coverage. Please review.
✅ Project coverage is 62.10%. Comparing base (324e73c) to head (612c8e3).
⚠️ Report is 13 commits behind head on dev.

Files with missing lines Patch % Lines
...m/salesforce/androidsdk/ui/LoginOptionsActivity.kt 86.66% 0 Missing and 6 partials ⚠️
...src/com/salesforce/androidsdk/ui/LoginViewModel.kt 84.84% 1 Missing and 4 partials ⚠️
.../salesforce/androidsdk/app/SalesforceSDKManager.kt 60.00% 1 Missing and 1 partial ⚠️
...rc/com/salesforce/androidsdk/config/OAuthConfig.kt 88.88% 0 Missing and 2 partials ⚠️
...rce/androidsdk/developer/support/DevSupportInfo.kt 0.00% 0 Missing and 2 partials ⚠️
.../src/com/salesforce/androidsdk/ui/LoginActivity.kt 50.00% 1 Missing ⚠️
...m/salesforce/androidsdk/ui/components/LoginView.kt 91.66% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##                dev    #2808       +/-   ##
=============================================
+ Coverage     43.68%   62.10%   +18.42%     
- Complexity     2061     2791      +730     
=============================================
  Files           214      215        +1     
  Lines         16931    16993       +62     
  Branches       2453     2474       +21     
=============================================
+ Hits           7396    10554     +3158     
+ Misses         8629     5264     -3365     
- Partials        906     1175      +269     
Components Coverage Δ
Analytics 47.92% <ø> (ø)
SalesforceSDK 54.18% <84.03%> (+16.53%) ⬆️
Hybrid 59.05% <ø> (+14.14%) ⬆️
SmartStore 78.20% <ø> (ø)
MobileSync 81.68% <ø> (+44.72%) ⬆️
React 52.36% <ø> (+16.11%) ⬆️
Files with missing lines Coverage Δ
...esforce/androidsdk/auth/AuthenticationUtilities.kt 28.31% <100.00%> (+6.88%) ⬆️
.../src/com/salesforce/androidsdk/ui/LoginActivity.kt 24.94% <50.00%> (+11.15%) ⬆️
...m/salesforce/androidsdk/ui/components/LoginView.kt 38.91% <91.66%> (+17.21%) ⬆️
.../salesforce/androidsdk/app/SalesforceSDKManager.kt 58.11% <60.00%> (+4.80%) ⬆️
...rc/com/salesforce/androidsdk/config/OAuthConfig.kt 88.88% <88.88%> (ø)
...rce/androidsdk/developer/support/DevSupportInfo.kt 87.25% <0.00%> (+0.98%) ⬆️
...src/com/salesforce/androidsdk/ui/LoginViewModel.kt 81.57% <84.84%> (+26.83%) ⬆️
...m/salesforce/androidsdk/ui/LoginOptionsActivity.kt 88.23% <86.66%> (+88.23%) ⬆️

... and 76 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@brandonpage brandonpage merged commit 347388f into forcedotcom:dev Dec 4, 2025
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants