Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix logout to give base profile precedence over parent profile #3076

Merged
merged 16 commits into from
Sep 19, 2024

Conversation

t1m0thyj
Copy link
Member

@t1m0thyj t1m0thyj commented Aug 28, 2024

Proposed changes

Follow up to #3019 - fixes behavior of logout action when token is defined in both base profile and parent profile.

TODO:

  • Test APIML login/logout scenarios
    • Token already on base profile
    • Token already on parent profile
    • Token already on both base and parent profile
    • Token not stored yet

Release Notes

Milestone: V3

Changelog: TBD

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • Enhancement (non-breaking change which adds or improves functionality)
  • Breaking change (a change that would cause existing functionality to not work as expected)
  • Documentation (Markdown, README updates)
  • Other (please specify above in "Proposed changes" section)

Checklist

General

  • I have read the CONTRIBUTOR GUIDANCE wiki
  • All PR dependencies have been merged and published (if applicable)
  • A GIF or screenshot is included in the PR for visual changes
  • The pre-publish command has been executed:
    • v2 and below: yarn workspace vscode-extension-for-zowe vscode:prepublish
    • v3: pnpm --filter vscode-extension-for-zowe vscode:prepublish

Code coverage

  • There is coverage for the code that I have added
  • I have added new test cases and they are passing
  • I have manually tested the changes

Deployment

  • I have added developer documentation (if applicable)
  • Documentation should be added to Zowe Docs
    • If you're an outside contributor, please post in the #zowe-doc Slack channel to coordinate documentation.
    • Otherwise, please check with the rest of the squad about any needed documentation before merging.
  • These changes may need ported to the appropriate branches (list here):

Further comments

Signed-off-by: Timothy Johnson <timothy.johnson@broadcom.com>
Signed-off-by: Timothy Johnson <timothy.johnson@broadcom.com>
Copy link

codecov bot commented Aug 28, 2024

Codecov Report

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

Project coverage is 92.59%. Comparing base (c4c9478) to head (4fda88f).
Report is 17 commits behind head on next.

Files with missing lines Patch % Lines
...owe-explorer-api/src/vscode/ZoweVsCodeExtension.ts 93.75% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             next    #3076      +/-   ##
==========================================
+ Coverage   92.57%   92.59%   +0.02%     
==========================================
  Files         113      113              
  Lines       11638    11660      +22     
  Branches     2570     2488      -82     
==========================================
+ Hits        10774    10797      +23     
+ Misses        862      861       -1     
  Partials        2        2              

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

traeok
traeok previously approved these changes Aug 29, 2024
Copy link
Member

@traeok traeok left a comment

Choose a reason for hiding this comment

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

These changes LGTM, thanks @t1m0thyj for the fix!

Copy link
Member

@zFernand0 zFernand0 left a comment

Choose a reason for hiding this comment

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

Changes makes sense to me 😋

I left a comment, however this is all theoretical, so it might be nice to discuss offline (or during standup)

Signed-off-by: Trae Yelovich <trae.yelovich@broadcom.com>
@pull-request-size pull-request-size bot added size/M and removed size/S labels Aug 30, 2024
@t1m0thyj t1m0thyj marked this pull request as draft August 30, 2024 23:52
Signed-off-by: Timothy Johnson <timothy.johnson@broadcom.com>
Signed-off-by: Timothy Johnson <timothy.johnson@broadcom.com>
…nto fix/multi-apiml-logout

Signed-off-by: zFernand0 <37381190+zFernand0@users.noreply.github.com>
Signed-off-by: zFernand0 <37381190+zFernand0@users.noreply.github.com>
@zFernand0 zFernand0 dismissed their stale review September 6, 2024 15:02

Initial concerned was discussed and addressed in 4f24050

@zFernand0 zFernand0 mentioned this pull request Sep 6, 2024
15 tasks
…nto fix/multi-apiml-logout

Signed-off-by: zFernand0 <37381190+zFernand0@users.noreply.github.com>
Signed-off-by: zFernand0 <37381190+zFernand0@users.noreply.github.com>
…nto fix/multi-apiml-logout

Signed-off-by: zFernand0 <37381190+zFernand0@users.noreply.github.com>
Signed-off-by: zFernand0 <37381190+zFernand0@users.noreply.github.com>
…ined in the IProfile

Signed-off-by: zFernand0 <37381190+zFernand0@users.noreply.github.com>
Signed-off-by: Timothy Johnson <timothy.johnson@broadcom.com>
Signed-off-by: Timothy Johnson <timothy.johnson@broadcom.com>
@t1m0thyj t1m0thyj marked this pull request as ready for review September 16, 2024 21:05
Copy link

📅 Suggested merge-by date: 9/30/2024

@zFernand0 zFernand0 added this to the v3 pre-releases milestone Sep 17, 2024
zFernand0
zFernand0 previously approved these changes Sep 17, 2024
Copy link
Member

@zFernand0 zFernand0 left a comment

Choose a reason for hiding this comment

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

LGTM! 😋

Not sure if I should be approving as this is something that I was very closely watching (and at times "fixing" tests for)

// Note: It should be expected that nested profiles within this service profile will have their credentials updated.
const profIndex = cache.allProfiles.findIndex((profile) => profile.name === opts.serviceProfile.name);
cache.allProfiles[profIndex] = opts.serviceProfile;
cache.allProfiles[profIndex] = { ...cache.allProfiles[profIndex], profile: opts.serviceProfile.profile };
Copy link
Member

Choose a reason for hiding this comment

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

Thanks for fixing.
This seems to keep the name and type of serviceProfile in the cache, while updating the contents of the profiles (say with tokenType and tokenValue).

Comment on lines 507 to 510
// it("should prefer base profile when it exists and it has tokenValue in secure array", async () => {});
// it("should prefer base profile when it exists, it does not have tokenValue in its secure array, and service profile is flat", async () => {});
// it("should prefer parent profile when base profile does not exist and service profile is nested", () => {});
// it("should cancel the operation if the base profile does not exist and service profile is flat", () => {});
Copy link
Member

Choose a reason for hiding this comment

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

Thanks for adding this set of "e2e" tests 🙏🏽

this.log.error(error as string);
const mProfileInfo = await this.getProfileInfo();
if (!mProfileInfo.getTeamConfig().exists) {
return;
}
const allTypes = this.getAllProfileTypes(apiRegister?.registeredApiTypes() ?? []);
Copy link
Member

Choose a reason for hiding this comment

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

Seems like the workaround above was not being used after the merge from next?
either way, thanks for cleaning it up 🙏🏽

* If there is no API registered for the profile type, this method defaults the login behavior to that of the APIML.
* @param {BaseProfileAuthOptions} opts Object defining options for base profile authentication
*/
public static async ssoLogin(opts: BaseProfileAuthOptions): Promise<boolean> {
Copy link
Member

Choose a reason for hiding this comment

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

I completely missed that this would've been a breaking change to extenders.
Great catch! 🙏🏽

Thanks for deprecating the old login/-out function in favor of the new ssoLogin/-out 🥳

traeok
traeok previously approved these changes Sep 18, 2024
Copy link
Member

@traeok traeok left a comment

Choose a reason for hiding this comment

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

Changes LGTM, thanks @t1m0thyj and @zFernand0 😋

Signed-off-by: Timothy Johnson <timothy.johnson@broadcom.com>
@t1m0thyj t1m0thyj dismissed stale reviews from traeok and zFernand0 via 4fda88f September 19, 2024 13:43
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
15.4% Duplication on New Code (required ≤ 3%)

See analysis details on SonarCloud

Copy link
Member

@zFernand0 zFernand0 left a comment

Choose a reason for hiding this comment

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

LGTM! 🙏🏽

@t1m0thyj t1m0thyj merged commit a0c779f into next Sep 19, 2024
29 of 30 checks passed
@t1m0thyj t1m0thyj deleted the fix/multi-apiml-logout branch September 19, 2024 15:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Closed
Development

Successfully merging this pull request may close these issues.

3 participants