woocommerce / google-listings-and-ads

Sync your store with Google to list products for free, run paid ads, and track performance straight from your store dashboard.
https://woo.com/products/google-listings-and-ads/
GNU General Public License v3.0
44 stars 21 forks source link

API Pull - Revoke access if plugin is deactivated #2430

Closed jorgemd24 closed 1 month ago

jorgemd24 commented 2 months ago

Changes proposed in this Pull Request:

Currently, if the plugin is deactivated, the WPCOM token is not revoked, allowing the partner to continue querying the API. This PR ensures that the WPCOM token is revoked when the plugin is deactivated.

Screenshots:

Detailed test instructions:

  1. Checkout this branch.
  2. In WooCommerce Connect Server, checkout this PR: https://github.com/Automattic/woocommerce-connect-server/pull/2485
  3. Add the following filter in GLA extension: add_filter( 'woocommerce_gla_notifications_enabled', '__return_true' );
  4. Go to Settings and Enable the API Pull mechanism: image
  5. The redirection of the OAuth flow will fail to redirect back to your site however the App will be connected in https://wordpress.com/me/security/connected-applications

image

  1. Once you confirmed that the app shows as connected go to Plugins->Installed Plugins and deactivate GLA
  2. Go to https://wordpress.com/me/security/connected-applications and that the App is not connected anymore.

Additional details:

Changelog entry

codecov[bot] commented 1 month ago

Codecov Report

Attention: Patch coverage is 62.50000% with 3 lines in your changes missing coverage. Please review.

Project coverage is 64.6%. Comparing base (e42f728) to head (e9313eb). Report is 5 commits behind head on feature/google-api-project.

:exclamation: Current head e9313eb differs from pull request most recent head 7ff8a9e

Please upload reports for the commit 7ff8a9e to get more accurate results.

Additional details and impacted files [![Impacted file tree graph](https://app.codecov.io/gh/woocommerce/google-listings-and-ads/pull/2430/graphs/tree.svg?width=650&height=150&src=pr&token=UROWUPF1LX&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=woocommerce)](https://app.codecov.io/gh/woocommerce/google-listings-and-ads/pull/2430?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=woocommerce) ```diff @@ Coverage Diff @@ ## feature/google-api-project #2430 +/- ## ============================================================== + Coverage 64.3% 64.6% +0.3% - Complexity 4549 4552 +3 ============================================================== Files 794 473 -321 Lines 22795 17757 -5038 Branches 1219 0 -1219 ============================================================== - Hits 14665 11478 -3187 + Misses 7963 6279 -1684 + Partials 167 0 -167 ``` | [Flag](https://app.codecov.io/gh/woocommerce/google-listings-and-ads/pull/2430/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=woocommerce) | Coverage Δ | | |---|---|---| | [js-unit-tests](https://app.codecov.io/gh/woocommerce/google-listings-and-ads/pull/2430/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=woocommerce) | `?` | | | [php-unit-tests](https://app.codecov.io/gh/woocommerce/google-listings-and-ads/pull/2430/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=woocommerce) | `64.6% <62.5%> (+0.1%)` | :arrow_up: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=woocommerce#carryforward-flags-in-the-pull-request-comment) to find out more. | [Files](https://app.codecov.io/gh/woocommerce/google-listings-and-ads/pull/2430?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=woocommerce) | Coverage Δ | | |---|---|---| | [...rc/API/Site/Controllers/RestAPI/AuthController.php](https://app.codecov.io/gh/woocommerce/google-listings-and-ads/pull/2430?src=pr&el=tree&filepath=src%2FAPI%2FSite%2FControllers%2FRestAPI%2FAuthController.php&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=woocommerce#diff-c3JjL0FQSS9TaXRlL0NvbnRyb2xsZXJzL1Jlc3RBUEkvQXV0aENvbnRyb2xsZXIucGhw) | `93.4% <ø> (+1.0%)` | :arrow_up: | | [src/API/WP/OAuthService.php](https://app.codecov.io/gh/woocommerce/google-listings-and-ads/pull/2430?src=pr&el=tree&filepath=src%2FAPI%2FWP%2FOAuthService.php&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=woocommerce#diff-c3JjL0FQSS9XUC9PQXV0aFNlcnZpY2UucGhw) | `96.1% <100.0%> (+29.4%)` | :arrow_up: | | [...rnal/DependencyManagement/ProxyServiceProvider.php](https://app.codecov.io/gh/woocommerce/google-listings-and-ads/pull/2430?src=pr&el=tree&filepath=src%2FInternal%2FDependencyManagement%2FProxyServiceProvider.php&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=woocommerce#diff-c3JjL0ludGVybmFsL0RlcGVuZGVuY3lNYW5hZ2VtZW50L1Byb3h5U2VydmljZVByb3ZpZGVyLnBocA==) | `0.0% <0.0%> (ø)` | | | [src/Proxies/Jetpack.php](https://app.codecov.io/gh/woocommerce/google-listings-and-ads/pull/2430?src=pr&el=tree&filepath=src%2FProxies%2FJetpack.php&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=woocommerce#diff-c3JjL1Byb3hpZXMvSmV0cGFjay5waHA=) | `0.0% <0.0%> (ø)` | | ... and [322 files with indirect coverage changes](https://app.codecov.io/gh/woocommerce/google-listings-and-ads/pull/2430/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=woocommerce)