Skip to content

Commit

Permalink
Merge pull request #2692 from zowe/fix-token-support
Browse files Browse the repository at this point in the history
fix: Login and Logout with APIML Dynamic Token support
  • Loading branch information
traeok authored Feb 8, 2024
2 parents 669b37a + 74e5223 commit 04de484
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
2 changes: 2 additions & 0 deletions packages/zowe-explorer-api/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ All notable changes to the "zowe-explorer-api" extension will be documented in t

### Bug fixes

- Fix login and logout operations when APIML dynamic tokens are enabled. [#2692](https://github.com/zowe/vscode-extension-for-zowe/pull/2692)

## `2.14.0`

### New features and enhancements
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,10 +312,18 @@ describe("ZoweVsCodeExtension", () => {
delete testSession.ISession.password;
testSession.ISession.hostname = "service";
testSession.ISession.base64EncodedAuth = "dXNlcjpwYXNz";
testSession.ISession.tokenType = tempBaseProfile.profile.tokenType;

expect(loginSpy).toHaveBeenCalledWith(testSession);
expect(testSpy).toHaveBeenCalledWith(testCache, "service");
expect(testCache.updateBaseProfileFileLogin).toHaveBeenCalledWith(newServiceProfile, updProfile, true);
expect(testCache.updateBaseProfileFileLogin).toHaveBeenCalledWith(
newServiceProfile,
{
tokenType: tempBaseProfile.profile.tokenType,
tokenValue: "tokenValue",
},
true
);
});
it("should logout using the service profile given a simple profile name", async () => {
testCache.fetchBaseProfile.mockResolvedValue(baseProfile);
Expand Down
8 changes: 5 additions & 3 deletions packages/zowe-explorer-api/src/vscode/ZoweVsCodeExtension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,8 @@ export class ZoweVsCodeExtension {
if (typeof serviceProfile === "string") {
serviceProfile = await ZoweVsCodeExtension.getServiceProfileForAuthPurposes(cache, serviceProfile);
}
const tokenType = loginTokenType ?? serviceProfile.profile.tokenType ?? imperative.SessConstants.TOKEN_TYPE_APIML;
const tokenType =
serviceProfile.profile.tokenType ?? baseProfile.profile.tokenType ?? loginTokenType ?? imperative.SessConstants.TOKEN_TYPE_APIML;
const updSession = new imperative.Session({
hostname: serviceProfile.profile.host,
port: serviceProfile.profile.port,
Expand All @@ -195,7 +196,7 @@ export class ZoweVsCodeExtension {

const loginToken = await (zeRegister?.getCommonApi(serviceProfile).login ?? Login.apimlLogin)(updSession);
const updBaseProfile: imperative.IProfile = {
tokenType,
tokenType: updSession.ISession.tokenType ?? tokenType,
tokenValue: loginToken,
};

Expand Down Expand Up @@ -248,8 +249,9 @@ export class ZoweVsCodeExtension {
serviceProfile = await ZoweVsCodeExtension.getServiceProfileForAuthPurposes(cache, serviceProfile);
}
const tokenType =
zeRegister?.getCommonApi(serviceProfile).getTokenTypeName() ??
serviceProfile.profile.tokenType ??
baseProfile.profile.tokenType ??
zeRegister?.getCommonApi(serviceProfile).getTokenTypeName() ??
imperative.SessConstants.TOKEN_TYPE_APIML;
const updSession = new imperative.Session({
hostname: serviceProfile.profile.host,
Expand Down

0 comments on commit 04de484

Please sign in to comment.