forcedotcom / SalesforceMobileSDK-Android

Android SDK for Salesforce
Other
341 stars 388 forks source link

Saving more fields from token end point in user account - simplified data passing auth / user account / account manager #2616

Closed wmathurin closed 1 month ago

wmathurin commented 1 month ago

New token end point fields captured

Capturing a few extra fields from token end point (cookie client src, cookie sid client and sid cookie name). Saving them to the user account. We will need them when we change SalesforceDroidGapActivity from using front-door to using sessions returned by hybrid login and refresh flows.

Simplified data passing auth / user account / account manager

Class diagram highlighting new or modified methods/fields

classDiagram
    class UserAccount {
        +cookieClientSrc
        +cookieSidClient
        +sidCookieName
    }

    class UserAccountBuilder {
        +cookieClientSrc
        +cookieSidClient
        +sidCookieName
        +allowUnset: Boolean
        +populateFromIdServiceResponse()
        +populateFromTokenEndpointResponse()
        +populateFromUserAccount()
    }

    class UserAccountManager {
        -buildAuthBundle()
        +createAccount()
        +updateAccount()
    }

    class OAuthWebviewHelper {
    }

    class BaseFinishAuthFlowTask {
        +onPostExecute()
    }

    class ClientManager {
        +createNewAccount()
        +peekRestClient()
    }

    class AccMgrAuthTokenProvider {
        +getNewAuthToken()
        -refreshStaleToken()
    }

    class AuthenticationService {
        +getAuthToken()
    }

    UserAccount <-- UserAccountBuilder : builds
    UserAccountManager --> UserAccount : manages
    OAuthWebviewHelper --> BaseFinishAuthFlowTask: has
    BaseFinishAuthFlowTask --> UserAccountBuilder : uses
    ClientManager --> UserAccountManager : uses
    ClientManager --> AccMgrAuthTokenProvider: has
    AccMgrAuthTokenProvider --> UserAccountBuilder: uses
    ClientManager --> UserAccountBuilder : uses
    OAuthWebviewHelper --> UserAccountManager : uses
    AuthenticationService --> UserAccountManager : uses
    AuthenticationService --> UserAccountBuilder : uses

UserAccount

UserAccountBuilder

Converted to kotlin

New fields (and accompanying setters) mentioned above

New method: populateFromIdServiceResponse

UserAccountManager

New method: buildAuthBundle

OAuthWebviewHelper

ClientManager

Added / updated tests

mobilesdk-bot commented 1 month ago
1 Warning
:warning: Big PR, try to keep changes smaller if you can.

Generated by :no_entry_sign: Danger

mobilesdk-bot commented 1 month ago
1 Warning
:warning: No Lint Results.

Tests results for SalesforceSDK

Generated by :no_entry_sign: Danger

mobilesdk-bot commented 1 month ago
1 Warning
:warning: No Lint Results.

Tests results for SmartStore

Generated by :no_entry_sign: Danger

mobilesdk-bot commented 1 month ago
1 Warning
:warning: No Lint Results.

Tests results for SalesforceHybrid

Generated by :no_entry_sign: Danger

mobilesdk-bot commented 1 month ago
1 Warning
:warning: No Lint Results.

Tests results for MobileSync

Generated by :no_entry_sign: Danger

mobilesdk-bot commented 1 month ago
1 Error
:no_entry_sign: Tests have failed, see below for more information.
1 Warning
:warning: No Lint Results.

Tests:

Name Classname Time
test[testCleanResyncGhosts] com.salesforce.androidsdk.reactnative.ReactMobileSyncTest 132.43

Tests results for SalesforceReact

Generated by :no_entry_sign: Danger

codecov-commenter commented 1 month ago

Codecov Report

Attention: Patch coverage is 67.81915% with 121 lines in your changes missing coverage. Please review.

Project coverage is 58.98%. Comparing base (6e20c51) to head (801ceaa). Report is 1 commits behind head on dev.

Files with missing lines Patch % Lines
.../com/salesforce/androidsdk/rest/ClientManager.java 17.64% 38 Missing and 4 partials :warning:
...lesforce/androidsdk/accounts/UserAccountBuilder.kt 70.17% 2 Missing and 32 partials :warning:
...lesforce/androidsdk/auth/AuthenticatorService.java 0.00% 15 Missing :warning:
...sforce/androidsdk/accounts/UserAccountManager.java 92.91% 5 Missing and 4 partials :warning:
...com/salesforce/androidsdk/ui/OAuthWebviewHelper.kt 0.00% 9 Missing :warning:
...SDK/src/com/salesforce/androidsdk/auth/OAuth2.java 66.66% 4 Missing and 2 partials :warning:
...om/salesforce/androidsdk/accounts/UserAccount.java 92.30% 3 Missing :warning:
.../salesforce/androidsdk/app/SalesforceSDKManager.kt 0.00% 0 Missing and 2 partials :warning:
...m/salesforce/androidsdk/ui/SalesforceActivity.java 0.00% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## dev #2616 +/- ## ============================================ + Coverage 51.03% 58.98% +7.95% - Complexity 1776 2428 +652 ============================================ Files 146 187 +41 Lines 12102 14798 +2696 Branches 1720 1976 +256 ============================================ + Hits 6176 8729 +2553 + Misses 5227 5152 -75 - Partials 699 917 +218 ``` | [Flag](https://app.codecov.io/gh/forcedotcom/SalesforceMobileSDK-Android/pull/2616/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=forcedotcom) | Coverage Δ | | |---|---|---| | [MobileSync](https://app.codecov.io/gh/forcedotcom/SalesforceMobileSDK-Android/pull/2616/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=forcedotcom) | `81.68% <ø> (?)` | | | [SalesforceHybrid](https://app.codecov.io/gh/forcedotcom/SalesforceMobileSDK-Android/pull/2616/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=forcedotcom) | `55.56% <ø> (ø)` | | | [SalesforceReact](https://app.codecov.io/gh/forcedotcom/SalesforceMobileSDK-Android/pull/2616/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=forcedotcom) | `51.38% <ø> (-0.98%)` | :arrow_down: | | [SalesforceSDK](https://app.codecov.io/gh/forcedotcom/SalesforceMobileSDK-Android/pull/2616/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=forcedotcom) | `45.54% <67.81%> (+3.13%)` | :arrow_up: | | [SmartStore](https://app.codecov.io/gh/forcedotcom/SalesforceMobileSDK-Android/pull/2616/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=forcedotcom) | `78.30% <ø> (ø)` | | 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=forcedotcom#carryforward-flags-in-the-pull-request-comment) to find out more. | [Files with missing lines](https://app.codecov.io/gh/forcedotcom/SalesforceMobileSDK-Android/pull/2616?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=forcedotcom) | Coverage Δ | | |---|---|---| | [...src/com/salesforce/androidsdk/rest/RestClient.java](https://app.codecov.io/gh/forcedotcom/SalesforceMobileSDK-Android/pull/2616?src=pr&el=tree&filepath=libs%2FSalesforceSDK%2Fsrc%2Fcom%2Fsalesforce%2Fandroidsdk%2Frest%2FRestClient.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=forcedotcom#diff-bGlicy9TYWxlc2ZvcmNlU0RLL3NyYy9jb20vc2FsZXNmb3JjZS9hbmRyb2lkc2RrL3Jlc3QvUmVzdENsaWVudC5qYXZh) | `56.31% <ø> (ø)` | | | [...m/salesforce/androidsdk/ui/SalesforceActivity.java](https://app.codecov.io/gh/forcedotcom/SalesforceMobileSDK-Android/pull/2616?src=pr&el=tree&filepath=libs%2FSalesforceSDK%2Fsrc%2Fcom%2Fsalesforce%2Fandroidsdk%2Fui%2FSalesforceActivity.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=forcedotcom#diff-bGlicy9TYWxlc2ZvcmNlU0RLL3NyYy9jb20vc2FsZXNmb3JjZS9hbmRyb2lkc2RrL3VpL1NhbGVzZm9yY2VBY3Rpdml0eS5qYXZh) | `0.00% <0.00%> (ø)` | | | [.../salesforce/androidsdk/app/SalesforceSDKManager.kt](https://app.codecov.io/gh/forcedotcom/SalesforceMobileSDK-Android/pull/2616?src=pr&el=tree&filepath=libs%2FSalesforceSDK%2Fsrc%2Fcom%2Fsalesforce%2Fandroidsdk%2Fapp%2FSalesforceSDKManager.kt&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=forcedotcom#diff-bGlicy9TYWxlc2ZvcmNlU0RLL3NyYy9jb20vc2FsZXNmb3JjZS9hbmRyb2lkc2RrL2FwcC9TYWxlc2ZvcmNlU0RLTWFuYWdlci5rdA==) | `52.12% <0.00%> (-0.89%)` | :arrow_down: | | [...om/salesforce/androidsdk/accounts/UserAccount.java](https://app.codecov.io/gh/forcedotcom/SalesforceMobileSDK-Android/pull/2616?src=pr&el=tree&filepath=libs%2FSalesforceSDK%2Fsrc%2Fcom%2Fsalesforce%2Fandroidsdk%2Faccounts%2FUserAccount.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=forcedotcom#diff-bGlicy9TYWxlc2ZvcmNlU0RLL3NyYy9jb20vc2FsZXNmb3JjZS9hbmRyb2lkc2RrL2FjY291bnRzL1VzZXJBY2NvdW50LmphdmE=) | `75.83% <92.30%> (+11.86%)` | :arrow_up: | | [...SDK/src/com/salesforce/androidsdk/auth/OAuth2.java](https://app.codecov.io/gh/forcedotcom/SalesforceMobileSDK-Android/pull/2616?src=pr&el=tree&filepath=libs%2FSalesforceSDK%2Fsrc%2Fcom%2Fsalesforce%2Fandroidsdk%2Fauth%2FOAuth2.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=forcedotcom#diff-bGlicy9TYWxlc2ZvcmNlU0RLL3NyYy9jb20vc2FsZXNmb3JjZS9hbmRyb2lkc2RrL2F1dGgvT0F1dGgyLmphdmE=) | `62.89% <66.66%> (+9.27%)` | :arrow_up: | | [...sforce/androidsdk/accounts/UserAccountManager.java](https://app.codecov.io/gh/forcedotcom/SalesforceMobileSDK-Android/pull/2616?src=pr&el=tree&filepath=libs%2FSalesforceSDK%2Fsrc%2Fcom%2Fsalesforce%2Fandroidsdk%2Faccounts%2FUserAccountManager.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=forcedotcom#diff-bGlicy9TYWxlc2ZvcmNlU0RLL3NyYy9jb20vc2FsZXNmb3JjZS9hbmRyb2lkc2RrL2FjY291bnRzL1VzZXJBY2NvdW50TWFuYWdlci5qYXZh) | `68.91% <92.91%> (+10.85%)` | :arrow_up: | | [...com/salesforce/androidsdk/ui/OAuthWebviewHelper.kt](https://app.codecov.io/gh/forcedotcom/SalesforceMobileSDK-Android/pull/2616?src=pr&el=tree&filepath=libs%2FSalesforceSDK%2Fsrc%2Fcom%2Fsalesforce%2Fandroidsdk%2Fui%2FOAuthWebviewHelper.kt&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=forcedotcom#diff-bGlicy9TYWxlc2ZvcmNlU0RLL3NyYy9jb20vc2FsZXNmb3JjZS9hbmRyb2lkc2RrL3VpL09BdXRoV2Vidmlld0hlbHBlci5rdA==) | `14.37% <0.00%> (+3.96%)` | :arrow_up: | | [...lesforce/androidsdk/auth/AuthenticatorService.java](https://app.codecov.io/gh/forcedotcom/SalesforceMobileSDK-Android/pull/2616?src=pr&el=tree&filepath=libs%2FSalesforceSDK%2Fsrc%2Fcom%2Fsalesforce%2Fandroidsdk%2Fauth%2FAuthenticatorService.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=forcedotcom#diff-bGlicy9TYWxlc2ZvcmNlU0RLL3NyYy9jb20vc2FsZXNmb3JjZS9hbmRyb2lkc2RrL2F1dGgvQXV0aGVudGljYXRvclNlcnZpY2UuamF2YQ==) | `14.81% <0.00%> (+14.81%)` | :arrow_up: | | [...lesforce/androidsdk/accounts/UserAccountBuilder.kt](https://app.codecov.io/gh/forcedotcom/SalesforceMobileSDK-Android/pull/2616?src=pr&el=tree&filepath=libs%2FSalesforceSDK%2Fsrc%2Fcom%2Fsalesforce%2Fandroidsdk%2Faccounts%2FUserAccountBuilder.kt&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=forcedotcom#diff-bGlicy9TYWxlc2ZvcmNlU0RLL3NyYy9jb20vc2FsZXNmb3JjZS9hbmRyb2lkc2RrL2FjY291bnRzL1VzZXJBY2NvdW50QnVpbGRlci5rdA==) | `70.17% <70.17%> (ø)` | | | [.../com/salesforce/androidsdk/rest/ClientManager.java](https://app.codecov.io/gh/forcedotcom/SalesforceMobileSDK-Android/pull/2616?src=pr&el=tree&filepath=libs%2FSalesforceSDK%2Fsrc%2Fcom%2Fsalesforce%2Fandroidsdk%2Frest%2FClientManager.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=forcedotcom#diff-bGlicy9TYWxlc2ZvcmNlU0RLL3NyYy9jb20vc2FsZXNmb3JjZS9hbmRyb2lkc2RrL3Jlc3QvQ2xpZW50TWFuYWdlci5qYXZh) | `45.41% <17.64%> (-3.49%)` | :arrow_down: | ... and [47 files with indirect coverage changes](https://app.codecov.io/gh/forcedotcom/SalesforceMobileSDK-Android/pull/2616/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=forcedotcom)
wmathurin commented 1 month ago

@brandonpage I merged too quickly, I'll address your comments in the next PR

brandonpage commented 1 month ago

@brandonpage I merged too quickly, I'll address your comments in the next PR

No worries, pretty much everything was NIT or feedback for future releases.