Skip to content

Commit

Permalink
Merge branch 'main' into feat/detect-jwt-expiration
Browse files Browse the repository at this point in the history
Signed-off-by: Trae Yelovich <trae.yelovich@broadcom.com>
  • Loading branch information
traeok committed Oct 14, 2024
2 parents 6d9c2e4 + e816257 commit d95b238
Show file tree
Hide file tree
Showing 55 changed files with 760 additions and 576 deletions.
3 changes: 3 additions & 0 deletions .github/dco.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
allowRemediationCommits:
individual: true
thirdParty: true
2 changes: 1 addition & 1 deletion .github/workflows/deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
- name: Use Node.js LTS
uses: actions/setup-node@v4
with:
node-version: '18.x'
node-version: '20.x'

# use pnpm version 8 until Octorelease supports pnpm@9
- name: Install pnpm and Lerna
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- name: Use Node.js LTS
uses: actions/setup-node@v4
with:
node-version: 18
node-version: lts/*

- run: |
npm install -g pnpm@8
Expand Down
2 changes: 2 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,8 @@ All notable changes to the "eslint-plugin-zowe-explorer" package will be documen

### Bug fixes

## `3.0.1`

## `3.0.0`

### New features and enhancements
Expand Down
6 changes: 6 additions & 0 deletions packages/zowe-explorer-api/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ All notable changes to the "zowe-explorer-api" extension will be documented in t

### Bug fixes

## `3.0.1`

### Bug fixes

- Updated the `ZoweTreeNode.setProfileToChoice` function so that it propagates profile changes to its child nodes. [#3150](https://github.com/zowe/zowe-explorer-vscode/issues/3150)

## `3.0.0`

### New features and enhancements
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ describe("ZoweTreeNode", () => {

it("setProfileToChoice should update profile for associated FSProvider entry", () => {
const node = makeNode("test", vscode.TreeItemCollapsibleState.None, undefined);
node.resourceUri = vscode.Uri.file(__dirname);
const fsEntry = {
metadata: {
profile: { name: "oldProfile" },
Expand All @@ -108,4 +109,23 @@ describe("ZoweTreeNode", () => {
expect(node.getProfileName()).toBe("newProfile");
expect(fsEntry.metadata.profile.name).toBe("newProfile");
});

it("setProfileToChoice should update child nodes with the new profile", () => {
const node = makeNode("test", vscode.TreeItemCollapsibleState.Expanded, undefined);
const nodeChild = makeNode("child", vscode.TreeItemCollapsibleState.None, undefined);
node.children = [nodeChild as any];
const setProfileToChoiceChildMock = jest.spyOn(nodeChild, "setProfileToChoice").mockImplementation();
const fsEntry = {
metadata: {
profile: { name: "oldProfile" },
},
};
const mockNewProfile = { name: "newProfile" } as unknown as imperative.IProfileLoaded;
const mockProvider = {
lookup: jest.fn().mockReturnValue(fsEntry),
} as unknown as BaseProvider;
node.setProfileToChoice(mockNewProfile, mockProvider);
expect(node.getProfileName()).toBe("newProfile");
expect(setProfileToChoiceChildMock).toHaveBeenCalledWith(mockNewProfile, mockProvider);
});
});
1 change: 0 additions & 1 deletion packages/zowe-explorer-api/src/fs/types/abstract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ export type ConflictData = {
export interface IFileSystemEntry extends vscode.FileStat {
name: string;
metadata: EntryMetadata;
type: vscode.FileType;
wasAccessed: boolean;
data?: Uint8Array;
}
Expand Down
10 changes: 10 additions & 0 deletions packages/zowe-explorer-api/src/tree/IZoweTreeNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,11 @@ export interface IZoweDatasetTreeNode extends IZoweTreeNode {
*/
encoding?: string;

/**
* Use Dataset-specific tree node for children.
*/
children?: IZoweDatasetTreeNode[];

/**
* Retrieves child nodes of this IZoweDatasetTreeNode
*
Expand Down Expand Up @@ -296,6 +301,11 @@ export interface IZoweUSSTreeNode extends IZoweTreeNode {
*/
onUpdateEmitter?: vscode.EventEmitter<IZoweUSSTreeNode>;

/**
* Use USS-specific tree node for children.
*/
children?: IZoweUSSTreeNode[];

/**
* Event that fires whenever an existing node is updated.
*/
Expand Down
11 changes: 8 additions & 3 deletions packages/zowe-explorer-api/src/tree/ZoweTreeNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,14 @@ export class ZoweTreeNode extends vscode.TreeItem {
// Don't reassign profile, we want to keep object reference shared across nodes
this.profile.profile = aProfile.profile;
}
const fsEntry = fsProvider?.lookup(this.resourceUri, true);
if (fsEntry != null) {
fsEntry.metadata.profile = aProfile;
if (this.resourceUri != null) {
const fsEntry = fsProvider?.lookup(this.resourceUri, true);
if (fsEntry != null) {
fsEntry.metadata.profile = aProfile;
}
}
for (const child of this.children) {
(child as unknown as ZoweTreeNode).setProfileToChoice(aProfile, fsProvider);
}
}
/**
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.1`

### Bug fixes

- Fixed bug where the `getContents` MVS and USS APIs failed to return whenever a local file path was provided. [#3199](https://github.com/zowe/zowe-explorer-vscode/issues/3199)

## `3.0.0`

### New features and enhancements
Expand Down
13 changes: 13 additions & 0 deletions packages/zowe-explorer-ftp-extension/__mocks__/mockUtils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/**
* This program and the accompanying materials are made available under the terms of the
* Eclipse Public License v2.0 which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-v20.html
*
* SPDX-License-Identifier: EPL-2.0
*
* Copyright Contributors to the Zowe Project.
*
*/

// Idea is borrowed from: https://github.com/kulshekhar/ts-jest/blob/master/src/util/testing.ts
export const mocked = <T extends (..._args: any[]) => any>(fn: T): jest.Mock<ReturnType<T>> => fn as any;
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import * as tmp from "tmp";
import { Gui, imperative } from "@zowe/zowe-explorer-api";
import * as globals from "../../../src/globals";
import { ZoweFtpExtensionError } from "../../../src/ZoweFtpExtensionError";
import { mocked } from "../../../__mocks__/mockUtils";

// two methods to mock modules: create a __mocks__ file for zowe-explorer-api.ts and direct mock for extension.ts
jest.mock("../../../__mocks__/@zowe/zowe-explorer-api.ts");
Expand Down Expand Up @@ -93,6 +94,7 @@ describe("FtpMvsApi", () => {

expect(result.apiResponse.etag).toHaveLength(64);
expect(DataSetUtils.downloadDataSet).toHaveBeenCalledTimes(1);
expect(mocked(DataSetUtils.downloadDataSet).mock.calls[0][2].localFile).toBe(localFile);
expect(MvsApi.releaseConnection).toHaveBeenCalled();

expect((response._readableState.buffer.head?.data ?? response._readableState.buffer).toString()).toContain("Hello world");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import * as globals from "../../../src/globals";
import { ZoweFtpExtensionError } from "../../../src/ZoweFtpExtensionError";
import * as tmp from "tmp";
import { imperative } from "@zowe/zowe-explorer-api";
import { mocked } from "../../../__mocks__/mockUtils";

// two methods to mock modules: create a __mocks__ file for zowe-explorer-api.ts and direct mock for extension.ts
jest.mock("../../../__mocks__/@zowe/zowe-explorer-api.ts");
Expand Down Expand Up @@ -78,6 +79,7 @@ describe("FtpUssApi", () => {

expect(result.apiResponse.etag).toHaveLength(64);
expect(UssUtils.downloadFile).toHaveBeenCalledTimes(1);
expect(mocked(UssUtils.downloadFile).mock.calls[0][2].localFile).toBe(localFile);
expect(UssApi.releaseConnection).toHaveBeenCalled();

expect((response._readableState.buffer.head?.data ?? response._readableState.buffer).toString()).toContain("Hello world");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export class FtpMvsApi extends AbstractFtpApi implements MainframeInteraction.IM
const result = this.getDefaultResponse();
const transferOptions = {
encoding: options.encoding,
localFile: undefined,
localFile: options.file,
transferType: CoreUtils.getBinaryTransferModeOrDefault(options.binary),
};
const fileOrStreamSpecified = options.file != null || options.stream != null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export class FtpUssApi extends AbstractFtpApi implements MainframeInteraction.IU
const result = this.getDefaultResponse();
const transferOptions = {
transferType: CoreUtils.getBinaryTransferModeOrDefault(options.binary),
localFile: undefined,
localFile: options.file,
size: 1,
};
const fileOrStreamSpecified = options.file != null || options.stream != null;
Expand Down
12 changes: 10 additions & 2 deletions packages/zowe-explorer/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,19 @@ All notable changes to the "vscode-extension-for-zowe" extension will be documen

### Bug fixes

## `3.0.1`

### Bug fixes

- Fixed an issue where opening sequential data sets within favorited searches resulted in an error. [#3163](https://github.com/zowe/zowe-explorer-vscode/pull/3163)
- Fixed an issue where automatic file extension detection identified file types incorrectly. [#3181](https://github.com/zowe/zowe-explorer-vscode/pull/3181)
- Fixed an issue where Zowe Explorer displayed a "No Zowe client configurations" prompt when a project user configuration existed but no global configuration was present. [#3168](https://github.com/zowe/zowe-explorer-vscode/issues/3168)
- Fixed an issue where the `ProfilesUtils.getProfileInfo` function returned a new `ProfileInfo` instance that ignored the `ZOWE_CLI_HOME` environment variable and workspace paths. [#3168](https://github.com/zowe/zowe-explorer-vscode/issues/3168)
- Fixed an issue where the location prompt for the `Create Directory` and `Create File` USS features would appear even when a path is already set for the profile or parent folder. [#3183](https://github.com/zowe/zowe-explorer-vscode/pull/3183)
- Fixed an issue where the `Create Directory` and `Create File` features would continue processing when the first prompt was dismissed, causing an incorrect URI to be generated. [#3183](https://github.com/zowe/zowe-explorer-vscode/pull/3183)
- Fixed an issue where the `Create Directory` and `Create File` features would incorrectly handle user-specified locations with trailing slashes. [#3183](https://github.com/zowe/zowe-explorer-vscode/pull/3183)
- Fixed an issue where a 401 error could occur when opening PDS members after updating credentials within the same user session. [#3150](https://github.com/zowe/zowe-explorer-vscode/issues/3150)
- Fixed the "Edit Profile" operation to open the correct files when both global and project team configs are present. [#3125](https://github.com/zowe/zowe-explorer-vscode/issues/3125)

## `3.0.0`

Expand Down Expand Up @@ -92,8 +102,6 @@ All notable changes to the "vscode-extension-for-zowe" extension will be documen
- Fixed issue where obsolete credentials persisted for PDS member nodes in Data Sets tree. [#3112](https://github.com/zowe/zowe-explorer-vscode/issues/3112)
- Fixed issue where Search operation did not prompt for credentials if profile contains expired token. [#2259](https://github.com/zowe/zowe-explorer-vscode/issues/2259)
- Fixed issue where inactive status was not displayed for profiles loaded from Global Config. [#3134](https://github.com/zowe/zowe-explorer-vscode/issues/3134)
- Fixed issue where switching from token-based authentication to user/password would cause an error for nested profiles. [#3142](https://github.com/zowe/zowe-explorer-vscode/issues/3142)
- Fixed the "Edit Profile" operation to open the correct files when both global and project team configs are present. [#3125](https://github.com/zowe/zowe-explorer-vscode/issues/3125)

## `3.0.0-next.202409132122`

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ import * as os from "os";
import * as path from "path";
const log4js = require("log4js");

export class EventProcessor {
public emitZoweEvent(eventName: string): void {}
}

export enum ProfLocType {
OLD_PROFILE = 0, // an old-school profile
TEAM_CONFIG = 1, // a team configuration
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,8 @@ export function createJobInfoNode(session: any, profile: imperative.IProfileLoad
collapsibleState: vscode.TreeItemCollapsibleState.None,
parentNode: session.getSessionNode(),
profile,
contextOverride: Constants.INFORMATION_CONTEXT,
});
jobNode.contextValue = Constants.INFORMATION_CONTEXT;
return jobNode;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ describe("Tree Provider unit tests, function getTreeItem", () => {
});
});

describe("Tree Provider unit tests, function getTreeItem", () => {
describe("Tree Provider unit tests, function flipState", () => {
it("Testing that expand tree is executed successfully", async () => {
const globalMocks = await createGlobalMocks();
const spy = jest.spyOn(ZoweLogger, "trace");
Expand All @@ -288,14 +288,17 @@ describe("Tree Provider unit tests, function getTreeItem", () => {
session: globalMocks.testSession,
});
folder.contextValue = Constants.USS_DIR_CONTEXT;
folder.dirty = false;

// Testing flipState to open
await globalMocks.testUSSTree.flipState(folder, true);
expect(JSON.stringify(folder.iconPath)).toContain("folder-open.svg");
expect(folder.dirty).toBe(false);

// Testing flipState to closed
await globalMocks.testUSSTree.flipState(folder, false);
expect(JSON.stringify(folder.iconPath)).toContain("folder-closed.svg");
expect(folder.dirty).toBe(true);
expect(spy).toHaveBeenCalled();
spy.mockClear();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -871,57 +871,6 @@ describe("Dataset Actions Unit Tests - Function deleteDataset", () => {
});
});

describe("Dataset Actions Unit Tests - Function enterPattern", () => {
afterAll(() => jest.restoreAllMocks());

it("Checking common dataset filter action", async () => {
createGlobalMocks();
const blockMocks = createBlockMocksShared();
const node = new ZoweDatasetNode({
label: "node",
collapsibleState: vscode.TreeItemCollapsibleState.None,
parentNode: blockMocks.datasetSessionNode,
});
node.pattern = "TEST";
node.contextValue = Constants.DS_SESSION_CONTEXT;

const mySpy = mocked(vscode.window.showInputBox).mockResolvedValue("test");
await DatasetActions.enterPattern(node, blockMocks.testDatasetTree);

expect(mySpy).toHaveBeenCalledWith(
expect.objectContaining({
prompt: "Search Data Sets: use a comma to separate multiple patterns",
value: node.pattern,
})
);
expect(mocked(Gui.showMessage)).not.toHaveBeenCalled();
});
it("Checking common dataset filter failed attempt", async () => {
createGlobalMocks();
const blockMocks = createBlockMocksShared();
const node = new ZoweDatasetNode({
label: "node",
collapsibleState: vscode.TreeItemCollapsibleState.None,
parentNode: blockMocks.datasetSessionNode,
});
node.pattern = "TEST";
node.contextValue = Constants.DS_SESSION_CONTEXT;

mocked(vscode.window.showInputBox).mockResolvedValueOnce("");
await DatasetActions.enterPattern(node, blockMocks.testDatasetTree);

expect(mocked(Gui.showMessage)).toHaveBeenCalledWith("You must enter a pattern.");
});
it("Checking favorite dataset filter action", async () => {
createGlobalMocks();
const blockMocks = createBlockMocksShared();
const favoriteSample = new ZoweDatasetNode({ label: "[sestest]: HLQ.TEST", collapsibleState: vscode.TreeItemCollapsibleState.None });

await DatasetActions.enterPattern(favoriteSample, blockMocks.testDatasetTree);
expect(blockMocks.testDatasetTree.addSession).toHaveBeenCalledWith({ sessionName: "sestest" });
});
});

describe("Dataset Actions Unit Tests - Function showAttributes", () => {
function createBlockMocks() {
const session = createISession();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -550,30 +550,6 @@ describe("Dataset Tree Unit Tests - Function getChildren", () => {

expect(loadProfilesForFavoritesSpy).toHaveBeenCalledWith(log, favProfileNode);
});

it("returns 'No data sets found' if there are no children", async () => {
createGlobalMocks();
const blockMocks = createBlockMocks();

mocked(Profiles.getInstance).mockReturnValue(blockMocks.profile);
mocked(vscode.window.createTreeView).mockReturnValueOnce(blockMocks.treeView);
const testTree = new DatasetTree();
testTree.mSessionNodes.push(blockMocks.datasetSessionNode);
const parent = new ZoweDatasetNode({
label: "BRTVS99.PUBLIC",
collapsibleState: vscode.TreeItemCollapsibleState.Collapsed,
parentNode: testTree.mSessionNodes[1],
});
parent.dirty = true;
jest.spyOn(parent, "getChildren").mockResolvedValueOnce([]);

const children = await testTree.getChildren(parent);

// This function should never return undefined.
expect(children).toBeDefined();
expect(children).toHaveLength(1);
expect(children[0].label).toBe("No data sets found");
});
});
describe("Dataset Tree Unit Tests - Function loadProfilesForFavorites", () => {
function createBlockMocks() {
Expand Down Expand Up @@ -3340,7 +3316,6 @@ describe("Dataset Tree Unit Tests - Function applyPatternsToChildren", () => {
const withProfileMock = jest.spyOn(SharedContext, "withProfile").mockImplementation((child) => String(child.contextValue));
testTree.applyPatternsToChildren(fakeChildren as any[], [{ dsn: "HLQ.PROD.PDS", member: "A*" }], fakeSessionNode as any);
expect(SharedContext.isFilterFolder(fakeChildren[0])).toBe(true);
expect(fakeSessionNode.dirty).toBe(true);
withProfileMock.mockRestore();
});
it("applies a closed filter folder icon to the PDS if collapsed", () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ describe("Dataset utils unit tests - function getExtension", () => {
}
});
it("returns null if no language was detected", () => {
expect(DatasetUtils.getExtension("TEST.DS")).toBe(null);
expect(DatasetUtils.getExtension("TEST.DS.X")).toBe(null);
});
});
Loading

0 comments on commit d95b238

Please sign in to comment.