Skip to content

Commit

Permalink
Merge branch 'next' into fix/multi-apiml-logout
Browse files Browse the repository at this point in the history
  • Loading branch information
t1m0thyj committed Sep 16, 2024
2 parents b82f83e + 5dbb05d commit 2fb5f7a
Show file tree
Hide file tree
Showing 19 changed files with 241 additions and 104 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/auto-comment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ name: Zowe Explorer Auto Responder for New Issues
on:
issues:
types: labeled
permissions:
issues: write

jobs:
processLabelAction:
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/update-project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ env:
PR_STATUS_DRAFT: 'In Progress'
PR_STATUS_READY: 'Review/QA'

permissions:
pull-requests: write

jobs:
update-project:
name: Move project item
Expand Down
6 changes: 6 additions & 0 deletions packages/eslint-plugin-zowe-explorer/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ All notable changes to the "eslint-plugin-zowe-explorer" package will be documen

### Bug fixes

## `3.0.0-next.202409132122`

### New features and enhancements

### Bug fixes

## `3.0.0-next.202409091409`

## `3.0.0-next.202408301858`
Expand Down
11 changes: 10 additions & 1 deletion packages/zowe-explorer-api/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,16 @@ All notable changes to the "zowe-explorer-api" extension will be documented in t

- Fixed behavior of logout action when token is defined in both base profile and parent profile. [#3076](https://github.com/zowe/zowe-explorer-vscode/issues/3076)

## `3.0.0-next.202409132122`

### New features and enhancements

- Added optional `patternMatches` property to the `IZoweDatasetTreeNode` interface to cache pattern matches from an applied filter search. [#1164](https://github.com/zowe/zowe-explorer-vscode/issues/1164)

### Bug fixes

- Fix extender's ability to fetch profile information from ProfilesCache for SSH profile types.

## `3.0.0-next.202409091409`

### Bug fixes
Expand Down Expand Up @@ -123,7 +133,6 @@ All notable changes to the "zowe-explorer-api" extension will be documented in t
- **Breaking:** Removed the `MemberEntry` filesystem class, in favor of using the `DsEntry` class with `isMember` set to `true`.
- Changed `TableViewProvider.setTableView` function to be asynchronous for more optimized data updates.
- Updated `Table.Conditional` and `Table.Callback` types to support multi-row callbacks.
- Added optional `patternMatches` property to the `IZoweDatasetTreeNode` interface to cache pattern matches from an applied filter search. [#1164](https://github.com/zowe/zowe-explorer-vscode/issues/1164)

### Bug fixes

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,25 +257,23 @@ describe("ProfilesCache", () => {
});

describe("refresh", () => {
const mockLogError = jest.fn();
const profileTypes = ["zosmf", "zftp"];
const fakeApiRegister = {
registeredApiTypes: jest.fn().mockReturnValue(profileTypes),
};

it("should refresh profile data for multiple profile types", async () => {
const profCache = new ProfilesCache({ ...fakeLogger, error: mockLogError } as unknown as imperative.Logger);
const profCache = new ProfilesCache(fakeLogger as unknown as imperative.Logger);
jest.spyOn(profCache, "getProfileInfo").mockResolvedValue(createProfInfoMock([lpar1Profile, zftpProfile]));
await profCache.refresh(fakeApiRegister as unknown as Types.IApiRegisterClient);
expect(profCache.allProfiles.length).toEqual(2);
expect(profCache.allProfiles[0]).toMatchObject(lpar1Profile);
expect(profCache.allProfiles[1]).toMatchObject(zftpProfile);
expect(profCache.getAllTypes()).toEqual([...profileTypes, "base"]);
expect(mockLogError).not.toHaveBeenCalled();
expect(profCache.getAllTypes()).toEqual([...profileTypes, "ssh", "base"]);
});

it("should refresh profile data for and merge tokens with base profile", async () => {
const profCache = new ProfilesCache({ ...fakeLogger, error: mockLogError } as unknown as imperative.Logger);
const profCache = new ProfilesCache(fakeLogger as unknown as imperative.Logger);
jest.spyOn(profCache, "getProfileInfo").mockResolvedValue(
createProfInfoMock([lpar1ProfileWithToken, lpar2ProfileWithToken, baseProfileWithToken])
);
Expand All @@ -284,24 +282,22 @@ describe("ProfilesCache", () => {
expect(profCache.allProfiles[0]).toMatchObject(lpar1ProfileWithToken);
expect(profCache.allProfiles[1]).toMatchObject(lpar2Profile); // without token
expect(profCache.allProfiles[2]).toMatchObject(baseProfileWithToken);
expect(profCache.getAllTypes()).toEqual([...profileTypes, "base"]);
expect(mockLogError).not.toHaveBeenCalled();
expect(profCache.getAllTypes()).toEqual([...profileTypes, "ssh", "base"]);
});

it("should handle error when refreshing profile data", async () => {
const fakeError = "Profile IO Error";
const profCache = new ProfilesCache({ ...fakeLogger, error: mockLogError } as unknown as imperative.Logger);
const profCache = new ProfilesCache(fakeLogger as unknown as imperative.Logger);
jest.spyOn(profCache, "getProfileInfo").mockImplementation(() => {
throw fakeError;
});
await profCache.refresh(fakeApiRegister as unknown as Types.IApiRegisterClient);
await expect(profCache.refresh(fakeApiRegister as unknown as Types.IApiRegisterClient)).rejects.toBe(fakeError);
expect(profCache.allProfiles.length).toEqual(0);
expect(profCache.getAllTypes().length).toEqual(0);
expect(mockLogError).toHaveBeenCalledWith(fakeError);
});

it("should remove old types from profilesByType and defaultProfileByType maps when reloading profiles", async () => {
const profCache = new ProfilesCache({ ...fakeLogger, error: mockLogError } as unknown as imperative.Logger);
const profCache = new ProfilesCache(fakeLogger as unknown as imperative.Logger);
jest.spyOn(profCache, "getProfileInfo").mockResolvedValue(createProfInfoMock([]));
(profCache as any).profilesByType.set("base", { name: "someProf" as any });
(profCache as any).defaultProfileByType.set("base", { name: "someProf" as any });
Expand All @@ -312,8 +308,7 @@ describe("ProfilesCache", () => {
expect((profCache as any).profilesByType.size).toBe(0);
expect((profCache as any).defaultProfileByType.size).toBe(0);
expect((profCache as any).allProfiles.length).toBe(0);
expect((profCache as any).allTypes).toEqual(["base"]);
expect(mockLogError).not.toHaveBeenCalled();
expect((profCache as any).allTypes).toEqual(["ssh", "base"]);
});
});

Expand Down
71 changes: 34 additions & 37 deletions packages/zowe-explorer-api/src/profiles/ProfilesCache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,47 +145,44 @@ export class ProfilesCache {

public async refresh(apiRegister?: IRegisterClient): Promise<void> {
const allProfiles: imperative.IProfileLoaded[] = [];
try {
const mProfileInfo = await this.getProfileInfo();
if (!mProfileInfo.getTeamConfig().exists) {
return;
}
const allTypes = this.getAllProfileTypes(apiRegister?.registeredApiTypes() ?? []);
allTypes.push("base");
for (const type of allTypes) {
const tmpAllProfiles: imperative.IProfileLoaded[] = [];
// Step 1: Get all profiles for each registered type
const profilesForType = mProfileInfo.getAllProfiles(type).filter((temp) => temp.profLoc.osLoc?.length > 0);
if (profilesForType && profilesForType.length > 0) {
for (const prof of profilesForType) {
// Step 2: Merge args for each profile
const profAttr = this.getMergedAttrs(mProfileInfo, prof);
// Work-around. TODO: Discuss with imperative team
const profileFix = this.getProfileLoaded(prof.profName, prof.profType, profAttr);
// set default for type
if (prof.isDefaultProfile) {
this.defaultProfileByType.set(type, profileFix);
}

// Step 3: Update allProfiles list
tmpAllProfiles.push(profileFix);
const mProfileInfo = await this.getProfileInfo();
if (!mProfileInfo.getTeamConfig().exists) {
return;
}
const allTypes = this.getAllProfileTypes(apiRegister?.registeredApiTypes() ?? []);
allTypes.push("ssh");
allTypes.push("base");
for (const type of allTypes) {
const tmpAllProfiles: imperative.IProfileLoaded[] = [];
// Step 1: Get all profiles for each registered type
const profilesForType = mProfileInfo.getAllProfiles(type).filter((temp) => temp.profLoc.osLoc?.length > 0);
if (profilesForType && profilesForType.length > 0) {
for (const prof of profilesForType) {
// Step 2: Merge args for each profile
const profAttr = this.getMergedAttrs(mProfileInfo, prof);
// Work-around. TODO: Discuss with imperative team
const profileFix = this.getProfileLoaded(prof.profName, prof.profType, profAttr);
// set default for type
if (prof.isDefaultProfile) {
this.defaultProfileByType.set(type, profileFix);
}
allProfiles.push(...tmpAllProfiles);
this.profilesByType.set(type, tmpAllProfiles);

// Step 3: Update allProfiles list
tmpAllProfiles.push(profileFix);
}
allProfiles.push(...tmpAllProfiles);
this.profilesByType.set(type, tmpAllProfiles);
}
this.allProfiles = allProfiles;
this.allTypes = allTypes;
for (const oldType of [...this.profilesByType.keys()].filter((type) => !allProfiles.some((prof) => prof.type === type))) {
this.profilesByType.delete(oldType);
this.defaultProfileByType.delete(oldType);
}
// check for proper merging of apiml tokens
this.checkMergingConfigAllProfiles();
this.profilesForValidation = [];
} catch (error) {
this.log.error(error as string);
}
this.allProfiles = allProfiles;
this.allTypes = allTypes;
for (const oldType of [...this.profilesByType.keys()].filter((type) => !allProfiles.some((prof) => prof.type === type))) {
this.profilesByType.delete(oldType);
this.defaultProfileByType.delete(oldType);
}
// check for proper merging of apiml tokens
this.checkMergingConfigAllProfiles();
this.profilesForValidation = [];
}

public validateAndParseUrl(newUrl: string): Validation.IValidationUrl {
Expand Down
6 changes: 6 additions & 0 deletions packages/zowe-explorer-ftp-extension/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ All notable changes to the "zowe-explorer-ftp-extension" extension will be docum

### Bug fixes

## `3.0.0-next.202409132122`

### New features and enhancements

### Bug fixes

## `3.0.0-next.202409091409`

### New features and enhancements
Expand Down
13 changes: 11 additions & 2 deletions packages/zowe-explorer/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,17 @@ All notable changes to the "vscode-extension-for-zowe" extension will be documen

- Fixed behavior of logout action when token is defined in both base profile and parent profile. [#3076](https://github.com/zowe/zowe-explorer-vscode/issues/3076)

## `3.0.0-next.202409132122`

### New features and enhancements

- Implemented support for favoriting a data set search that contains member wildcards. [#1164](https://github.com/zowe/zowe-explorer-vscode/issues/1164)
- Resolved `TypeError: Cannot read properties of undefined (reading 'direction')` error for favorited items. [#3067](https://github.com/zowe/zowe-explorer-vscode/pull/3067)

### Bug fixes

- Fix issue with outdated SSH credentials stored securely in the SSH profile causing errors. [#2901](https://github.com/zowe/zowe-explorer-vscode/issues/2901)

## `3.0.0-next.202409091409`

### Bug fixes
Expand Down Expand Up @@ -64,8 +75,6 @@ All notable changes to the "vscode-extension-for-zowe" extension will be documen
- Implemented change detection in the Data Sets and USS filesystems, so that changes on the mainframe will be reflected in opened editors for Data Sets and USS files. [#3040](https://github.com/zowe/zowe-explorer-vscode/pull/3040)
- Implemented a "Show as Table" option for profile nodes in the Jobs tree, displaying lists of jobs in a tabular view. Jobs can be filtered and sorted within this view, and users can select jobs to cancel, delete or download. [#2258](https://github.com/zowe/zowe-explorer-vscode/issues/2258)
- Replaced `lodash` dependency with `es-toolkit` to reduce webview bundle size and add technical currency. [#3060](https://github.com/zowe/zowe-explorer-vscode/pull/3060)
- Implemented support for favoriting a data set search that contains member wildcards. [#1164](https://github.com/zowe/zowe-explorer-vscode/issues/1164)
- Resolved `TypeError: Cannot read properties of undefined (reading 'direction')` error for favorited items. [#3067](https://github.com/zowe/zowe-explorer-vscode/pull/3067)

### Bug fixes

Expand Down
2 changes: 2 additions & 0 deletions packages/zowe-explorer/__tests__/__mocks__/vscode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1679,3 +1679,5 @@ export namespace env {
},
};
}

export class Selection {}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*/

import * as vscode from "vscode";
import { ZoweTreeNode, imperative } from "@zowe/zowe-explorer-api";
import { ProfilesCache, ZoweTreeNode, imperative } from "@zowe/zowe-explorer-api";
import { createIProfile, createISession } from "../../__mocks__/mockCreators/shared";
import { ZoweCommandProvider } from "../../../src/commands/ZoweCommandProvider";
import { Profiles } from "../../../src/configuration/Profiles";
Expand Down Expand Up @@ -48,9 +48,10 @@ describe("ZoweCommandProvider Unit Tests - function checkCurrentProfile", () =>
testNode.setProfileToChoice(globalMocks.testProfile);
testNode.contextValue = "session server";

beforeEach(() => {
void Profiles.createInstance(imperative.Logger.getAppLogger());
Object.defineProperty(Profiles.getInstance(), "log", {
beforeEach(async () => {
jest.spyOn(ProfilesCache.prototype, "refresh").mockImplementation();
const profilesInstance = await Profiles.createInstance(undefined as any);
Object.defineProperty(profilesInstance, "log", {
value: {
error: jest.fn(),
},
Expand Down
Loading

0 comments on commit 2fb5f7a

Please sign in to comment.