Skip to content

Conversation

@hichamboushaba
Copy link
Member

@hichamboushaba hichamboushaba commented Sep 1, 2025

Closes WOOMOB-1220

Description

This PR adds the following changes:

  • Refactors the handling of app passwords configuration, so instead of just supplying the ApplicationClientId to the DI, we now supply an implementation of ApplicationPasswordsConfiguration, this allows us to control whether the feature is enabled or not from the app module.
  • Add a feature flag and use it to enable the feature. We'll replace this with a remote feature flag.
  • Move the WooExperimentalNetwork logic to WooNetwork, and update it to use the new property of ApplicationPasswordsConfiguration.
  • Improve the logging of failures (wip for now, I'll revisit this to see if we need further improvements).

Steps to reproduce

  1. Confirm the feature flag APP_PASSWORDS_FOR_JETPACK_SITES is enabled.
  2. Use a way to inspect app network requests.
  3. Open the app.
  4. Make sure you are signed in using WordPress.com account.
  5. Confirm the app is using app passwords (talking to the site directly using its URL, and authenticating using app passwords.
  6. Disable the feature flag APP_PASSWORDS_FOR_JETPACK_SITES.
  7. Re-open the app.
  8. Confirm the app is using Jetpack proxy.

Testing information

The above steps should be enough.

The tests that have been performed

The above.

  • I have considered if this change warrants release notes and have added them to RELEASE-NOTES.txt if necessary. Use the "[Internal]" label for non-user-facing changes.

@hichamboushaba hichamboushaba added type: task An internally driven task. category: performance Related to performance such as slow loading. labels Sep 1, 2025
@dangermattic
Copy link
Collaborator

dangermattic commented Sep 1, 2025

3 Warnings
⚠️ This PR is larger than 300 lines of changes. Please consider splitting it into smaller PRs for easier and faster reviews.
⚠️ Class WooWearApplicationPasswordsConfiguration is missing tests, but unit-tests-exemption label was set to ignore this.
⚠️ Class WooApplicationPasswordsConfiguration is missing tests, but unit-tests-exemption label was set to ignore this.

Generated by 🚫 Danger

@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Sep 1, 2025

📲 You can test the changes from this Pull Request in WooCommerce Android by scanning the QR code below to install the corresponding build.

App Name WooCommerce Android
Platform📱 Mobile
FlavorJalapeno
Build TypeDebug
Commit586a357
Direct Downloadwoocommerce-prototype-build-pr14544-586a357.apk

@hichamboushaba hichamboushaba force-pushed the issue/WOOMOB-1126-app-passwords-network branch from 0e380bc to 2792941 Compare September 1, 2025 18:34
Comment on lines +22 to +23
override fun isEnabledForDirectAccess(): Boolean = false
override suspend fun isEnabledForJetpackAccess(): Boolean = false
Copy link
Member Author

@hichamboushaba hichamboushaba Sep 1, 2025

Choose a reason for hiding this comment

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

The wear app didn't support Application Passwords before #12124, and we are keeping the same behavior.

@hichamboushaba hichamboushaba marked this pull request as ready for review September 1, 2025 18:56
* Returns true if the Application Passwords feature is enabled for Jetpack-mediated access.
* This applies when sites are accessed through Jetpack, even if they are self-hosted.
*/
suspend fun isEnabledForJetpackAccess(): Boolean
Copy link
Member Author

Choose a reason for hiding this comment

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

Having this a suspendable function will make using remote feature flags easier for us, given they require DB access.

@hichamboushaba hichamboushaba added this to the 23.2 milestone Sep 1, 2025
@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Sep 1, 2025

📲 You can test the changes from this Pull Request in WooCommerce-Wear Android by scanning the QR code below to install the corresponding build.
App Name WooCommerce-Wear Android
Platform⌚️ Wear OS
FlavorJalapeno
Build TypeDebug
Commit586a357
Direct Downloadwoocommerce-wear-prototype-build-pr14544-586a357.apk

@hichamboushaba hichamboushaba force-pushed the issue/WOOMOB-1126-app-passwords-network branch from ae981cd to b43d54c Compare September 1, 2025 19:53
@codecov-commenter
Copy link

codecov-commenter commented Sep 1, 2025

Codecov Report

❌ Patch coverage is 8.57143% with 96 lines in your changes missing coverage. Please review.
✅ Project coverage is 38.32%. Comparing base (c58946a) to head (586a357).
⚠️ Report is 25 commits behind head on trunk.

Files with missing lines Patch % Lines
.../android/fluxc/network/rest/wpcom/wc/WooNetwork.kt 0.00% 60 Missing ⚠️
.../org/wordpress/android/fluxc/store/WCOrderStore.kt 0.00% 12 Missing ⚠️
...uxc/network/rest/wpcom/wc/order/OrderRestClient.kt 14.28% 6 Missing ⚠️
...npasswords/WooApplicationPasswordsConfiguration.kt 0.00% 5 Missing ⚠️
...erce/android/wear/di/ApplicationPasswordsModule.kt 0.00% 4 Missing ⚠️
...rc/main/kotlin/com/woocommerce/android/AppPrefs.kt 0.00% 4 Missing ⚠️
.../android/ui/orders/list/OrderListItemDataSource.kt 0.00% 2 Missing ⚠️
...kotlin/com/woocommerce/android/util/FeatureFlag.kt 66.66% 1 Missing ⚠️
...tionpasswords/ApplicationPasswordsConfiguration.kt 0.00% 1 Missing ⚠️
.../applicationpasswords/ApplicationPasswordsStore.kt 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##              trunk   #14544      +/-   ##
============================================
+ Coverage     38.31%   38.32%   +0.01%     
+ Complexity     9645     9641       -4     
============================================
  Files          2051     2052       +1     
  Lines        114860   114813      -47     
  Branches      15240    15239       -1     
============================================
- Hits          44011    44005       -6     
+ Misses        66816    66776      -40     
+ Partials       4033     4032       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.


public boolean isUsingWpComRestApi() {
return isWPCom() || (isJetpackConnected() && getOrigin() == ORIGIN_WPCOM_REST);
return isWPCom() || getOrigin() == ORIGIN_WPCOM_REST;
Copy link
Member Author

Choose a reason for hiding this comment

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

When testing the app passwords feature with a Jetpack CP site, I found an issue, we always ignore the created password, and the cause was in this condition.
I checked the usages of this function, and I think we can safely remove the Jetpack connection condition here, as they apply also to Jetpack CP sites.

`isUsingWpComRestApi` was returning false for Jetpack CP sites, leading to always ignoring saved app passwords credentials, as for WPCom rest sites, `SiteModel#username` is always null.
@hichamboushaba hichamboushaba force-pushed the issue/WOOMOB-1126-app-passwords-network branch from 06cffda to 8ea3d7f Compare September 2, 2025 18:11
* The [SiteModel.ORIGIN_XMLRPC] support is kept for backward compatibility
*/
@Singleton
class WooNetwork @Inject constructor(
Copy link
Member Author

Choose a reason for hiding this comment

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

All the changes here are a copy of what we had before in WooExperimentalNetwork

@JorgeMucientes JorgeMucientes self-assigned this Sep 3, 2025
@hichamboushaba
Copy link
Member Author

@irfano since Jorge is AFK for two days, I'm removing his assignment for this PR.
Reviewing this is not urgent, but if you have some time you'll have something to review, and this is a base for my other PRs, so having it merged before them will make things easier for me.

Copy link
Contributor

@irfano irfano left a comment

Choose a reason for hiding this comment

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

It works expected. I also tested the Wear app, it works there as well. I'm approving but not merging in case you'd like to make changes based on these notes:

  • In WPAPIResponse, there's this comment: "This is used for tracking purposes, and used only with the Woo experimental networking mode." I believe this is no longer valid and can be removed.
  • I believe the fetchAppPasswordsSupportIfNeeded() function is no longer needed and can be removed.

Comment on lines 182 to 187
"Request failed using Application Passwords for Jetpack Site,\n" +
"site: ${siteUrl},\n" +
"path: ${requestContext.path},\n" +
"method: ${requestContext.method},\n" +
"error: HTTP status code ${error.volleyError.networkResponse?.statusCode}, " +
"error message: ${error.errorCode?.ifEmpty { null } ?: error.message}",
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice logging details, they’ll be helpful for debugging. 👍🏻

@irfano irfano modified the milestones: 23.2, 23.3 Sep 5, 2025
irfano and others added 4 commits September 5, 2025 16:34
…asswords-toggle

[Jetpack Performance] Add a preference toggle for enabling app passwords for Jetpack sites
# Conflicts:
#	WooCommerce/src/main/kotlin/com/woocommerce/android/AppPrefs.kt
@hichamboushaba
Copy link
Member Author

Thanks @irfano, both remarks are addressed, nice catch.

@hichamboushaba hichamboushaba merged commit adfdc06 into trunk Sep 5, 2025
17 checks passed
@hichamboushaba hichamboushaba deleted the issue/WOOMOB-1126-app-passwords-network branch September 5, 2025 22:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

category: performance Related to performance such as slow loading. type: task An internally driven task. unit-tests-exemption

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants