Skip to content

Conversation

JohnsonEricAtSalesforce
Copy link
Contributor

@JohnsonEricAtSalesforce JohnsonEricAtSalesforce commented Oct 9, 2025

🎸 Ready For Review 🥁

This adds a new activity which may be used for debug app builds only to authenticate a user via test credentials in automated tests. The new activity will finish without any action for app release builds. This is controlled by Salesforce Mobile SDK's existing isDebugBuild property.

This new means of automating authentication for debug testing does not expose production builds to risk and also minimizes access since usernames and passwords are not used. The test credentials JSON provided by Salesforce Mobile SDK's REST Explorer sample app uses refresh tokens which can be remotely expired and cannot be used for privilege elevation beyond the public APIs.

From the shell, the new intent may be started using ADB.

$ adb shell
$ am start -n <App Package Namepace>/com.salesforce.androidsdk.util.test.TestAuthenticationActivity -e creds '<Credentials JSON>'

The "App Package Namespace" is the app's package namespace, which is usually declared in the app module's Gradle script via android { namespace.

The "Credentials JSON" can be obtained by running the existing Salesforce Mobile SDK REST Explorer sample app, logging in and then using the "Dev Menu" "Export Credentials To Clipboard" menu item.

Note that the shell invocation must preserve quotations and other potentially interpreted characters from the shell such that the Credentials JSON is received by the activity without alteration.

The new intent could also be launched by UIAutomator2.

intent.setComponent(ComponentName("<App Package Namespace>", "com.salesforce.androidsdk.util.test.TestAuthenticationActivity"))
intent.putExtra("creds", "<Credentials JSON>")
context.startActivity(intent)

Appium is another means of launching the new intent.

capabilities = {
       "platformName": "Android",
       "deviceName": "Android Emulator",
       "appPackage": "<App Package Namespace>",
       "appActivity": "com.salesforce.androidsdk.util.test.TestAuthenticationActivity",
       "appium:processArguments": {
           "args": ["creds", "<Credentials JSON>"]
       }
   }

@JohnsonEricAtSalesforce JohnsonEricAtSalesforce force-pushed the feature/w-19368406_msdk-local-dev-instant-login-android branch from 8409528 to 4b15565 Compare October 9, 2025 02:56
Copy link

github-actions bot commented Oct 9, 2025

Job Summary for Gradle

Pull Request :: test-android
Gradle Root Project Requested Tasks Gradle Version Build Outcome Build Scan®
SalesforceMobileSDK-Android libs:SalesforceSDK:lint 8.14.2 Build Scan not published
SalesforceMobileSDK-Android libs:SalesforceSDK:assembleAndroidTest 8.14.2 Build Scan not published
SalesforceMobileSDK-Android libs:SalesforceSDK:convertCodeCoverage 8.14.2 Build Scan not published

Copy link

github-actions bot commented Oct 9, 2025

Job Summary for Gradle

Pull Request :: test-android
Gradle Root Project Requested Tasks Gradle Version Build Outcome Build Scan®
SalesforceMobileSDK-Android libs:SalesforceSDK:lint 8.14.2 Build Scan not published
SalesforceMobileSDK-Android libs:SalesforceSDK:assembleAndroidTest 8.14.2 Build Scan not published
SalesforceMobileSDK-Android libs:SalesforceSDK:convertCodeCoverage 8.14.2 Build Scan not published


<application>

<!-- Debug-Only: Test Authentication Activity For Automated Testing -->
Copy link
Contributor

Choose a reason for hiding this comment

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

What's keeping it from being used in production? Should we check that we are in a debug build in the code?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We ought to be able to use the SalesforceSDKManager isDebugBuild check in the activity and simply finish without action for other build types.

Copy link

github-actions bot commented Oct 10, 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

Copy link

Job Summary for Gradle

Pull Request :: test-android
Gradle Root Project Requested Tasks Gradle Version Build Outcome Build Scan®
SalesforceMobileSDK-Android libs:SalesforceSDK:lint 8.14.2 Build Scan not published
SalesforceMobileSDK-Android libs:SalesforceSDK:assembleAndroidTest 8.14.2 Build Scan not published
SalesforceMobileSDK-Android libs:SalesforceSDK:convertCodeCoverage 8.14.2 Build Scan not published

@JohnsonEricAtSalesforce JohnsonEricAtSalesforce force-pushed the feature/w-19368406_msdk-local-dev-instant-login-android branch from b5dbee0 to 93ec5ff Compare October 10, 2025 19:02
@JohnsonEricAtSalesforce JohnsonEricAtSalesforce marked this pull request as ready for review October 10, 2025 22:38
@JohnsonEricAtSalesforce
Copy link
Contributor Author

Note the test failures I've observed are also present on dev. I verified this in an earlier commit here by temporarily disabling them. All tests passed in that case.

@Test
fun topAppBar_ChangeServerButton_OpensServerPicker() {
var showPicker: MutableState<Boolean>? = null
val showPicker = mutableStateOf(false)
Copy link
Contributor Author

@JohnsonEricAtSalesforce JohnsonEricAtSalesforce Oct 10, 2025

Choose a reason for hiding this comment

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

This subtle change resolves inspector warnings and should be acceptable for tests. I'd used the same style where dynamic background color is now used as well.

@JohnsonEricAtSalesforce JohnsonEricAtSalesforce merged commit 47550d1 into forcedotcom:dev Oct 14, 2025
4 of 6 checks passed
@JohnsonEricAtSalesforce JohnsonEricAtSalesforce deleted the feature/w-19368406_msdk-local-dev-instant-login-android branch October 14, 2025 21:03
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.

3 participants