Skip to content

Commit

Permalink
Merge branch 'main' into fix/secure-credentials-theia
Browse files Browse the repository at this point in the history
Signed-off-by: Timothy Johnson <timothy.johnson@broadcom.com>
  • Loading branch information
t1m0thyj committed Apr 17, 2023
2 parents 421bdaf + 5f8def3 commit 9a38388
Show file tree
Hide file tree
Showing 21 changed files with 185 additions and 138 deletions.
1 change: 1 addition & 0 deletions packages/zowe-explorer-api/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ All notable changes to the "zowe-explorer-api" extension will be documented in t
- Added `Gui.reportProgress` that can be used to notify users of action progress in conjunction with the `Gui.withProgress` call. [#2167](https://github.com/zowe/vscode-extension-for-zowe/issues/2167)
- Updated linter rules and addressed linter errors throughout the codebase. [#2184](https://github.com/zowe/vscode-extension-for-zowe/issues/2184)
- Added checks to verify that `@zowe/cli` dependency exists before building. [#2199](https://github.com/zowe/vscode-extension-for-zowe/issues/2199)
- Added `ZoweVsCodeExtension.customLoggingPath` that can be used to get custom logging path defined in VS Code settings. [#2186](https://github.com/zowe/vscode-extension-for-zowe/issues/2186)

### Bug fixes

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,16 @@ describe("ZoweVsCodeExtension", () => {
jest.clearAllMocks();
});

it("customLoggingPath should return value if defined in VS Code settings", () => {
const mockGetConfig = jest.fn().mockReturnValueOnce(__dirname);
jest.spyOn(vscode.workspace, "getConfiguration").mockReturnValue({
get: mockGetConfig,
} as unknown as vscode.WorkspaceConfiguration);
expect(ZoweVsCodeExtension.customLoggingPath).toBe(__dirname);
expect(ZoweVsCodeExtension.customLoggingPath).toBeUndefined();
expect(mockGetConfig).toHaveBeenCalledTimes(2);
});

describe("getZoweExplorerApi", () => {
it("should return client API", () => {
jest.spyOn(vscode.extensions, "getExtension").mockReturnValueOnce(fakeVsce);
Expand Down
7 changes: 7 additions & 0 deletions packages/zowe-explorer-api/src/vscode/ZoweVsCodeExtension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ export class ZoweVsCodeExtension {
return new ProfilesCache(imperative.Logger.getAppLogger(), vscode.workspace.workspaceFolders?.[0]?.uri.fsPath);
}

/**
* Get custom logging path if one is defined in VS Code settings.
*/
public static get customLoggingPath(): string | undefined {
return vscode.workspace.getConfiguration("zowe").get("files.logsFolder.path") || undefined;
}

/**
* @param {string} [requiredVersion] Optional semver string specifying the minimal required version
* of Zowe Explorer that needs to be installed for the API to be usable to the client.
Expand Down
1 change: 1 addition & 0 deletions packages/zowe-explorer-ftp-extension/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ All notable changes to the "vscode-extension-for-zowe" extension will be documen
### New features and enhancements

- Updated linter rules and addressed linter errors throughout the codebase. [#2184](https://github.com/zowe/vscode-extension-for-zowe/issues/2184)
- Added support for new setting `zowe.files.logsFolder.path` that can be used to override Zowe Explorer logs folder. [#2186](https://github.com/zowe/vscode-extension-for-zowe/issues/2186)

### Bug fixes

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,12 @@ export namespace Gui {
}
}

export namespace ZoweVsCodeExtension {
export function getZoweExplorerApi(requiredVersion?: string): any {
export class ZoweVsCodeExtension {
public static get customLoggingPath(): string | undefined {
return undefined;
}

public static getZoweExplorerApi(requiredVersion?: string): any {
return {
registerUssApi: () => {},
registerJesApi: () => {},
Expand Down
2 changes: 1 addition & 1 deletion packages/zowe-explorer-ftp-extension/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { CoreUtils } from "@zowe/zos-ftp-for-zowe-cli";
import { imperative } from "@zowe/cli";
import { FtpSession } from "./ftpSession";

export const ZoweLogger = new IZoweLogger("Zowe Explorer FTP Extension", path.join(__dirname, "..", ".."));
export const ZoweLogger = new IZoweLogger("Zowe Explorer FTP Extension", ZoweVsCodeExtension.customLoggingPath ?? path.join(__dirname, "..", ".."));

export function activate(_context: vscode.ExtensionContext): void {
void registerFtpApis();
Expand Down
1 change: 1 addition & 0 deletions packages/zowe-explorer/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ All notable changes to the "vscode-extension-for-zowe" extension will be documen
- Added an output channel, `Zowe Explorer`, for logging within VS Code's Output view. The log level is set by the new Zowe Explorer setting, `zowe.logger`.
- Opening a dialog for Upload or Download of files will now open at the project level directory or the user's home directory if no project is opened. [#2203](https://github.com/zowe/vscode-extension-for-zowe/issues/2203)
- Updated linter rules and addressed linter errors throughout the codebase. [#2184](https://github.com/zowe/vscode-extension-for-zowe/issues/2184)
- Added a new setting `zowe.files.logsFolder.path` that can be used to override Zowe Explorer logs folder if default location is read-only. [#2186](https://github.com/zowe/vscode-extension-for-zowe/issues/2186)

### Bug fixes

Expand Down
21 changes: 18 additions & 3 deletions packages/zowe-explorer/__tests__/__unit__/shared/init.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,18 @@ describe("Test src/shared/extension", () => {
{
name: "onDidChangeConfiguration:1",
mock: [
{ spy: jest.spyOn(test.value, "affectsConfiguration"), arg: [globals.SETTINGS_LOGS_FOLDER_PATH], ret: true },
{ spy: jest.spyOn(globals, "initLogger"), arg: [test.value] },
{ spy: jest.spyOn(test.value, "affectsConfiguration"), arg: [globals.SETTINGS_TEMP_FOLDER_PATH], ret: false },
{ spy: jest.spyOn(test.value, "affectsConfiguration"), arg: [globals.SETTINGS_AUTOMATIC_PROFILE_VALIDATION], ret: false },
{ spy: jest.spyOn(test.value, "affectsConfiguration"), arg: [globals.SETTINGS_TEMP_FOLDER_HIDE], ret: false },
{ spy: jest.spyOn(test.value, "affectsConfiguration"), arg: [globals.SETTINGS_SECURE_CREDENTIALS_ENABLED], ret: false },
],
},
{
name: "onDidChangeConfiguration:2",
mock: [
{ spy: jest.spyOn(test.value, "affectsConfiguration"), arg: [globals.SETTINGS_LOGS_FOLDER_PATH], ret: false },
{ spy: jest.spyOn(test.value, "affectsConfiguration"), arg: [globals.SETTINGS_TEMP_FOLDER_PATH], ret: true },
{ spy: jest.spyOn(tempFolder, "moveTempFolder"), arg: [undefined, test.value] },
{ spy: jest.spyOn(test.value, "affectsConfiguration"), arg: [globals.SETTINGS_AUTOMATIC_PROFILE_VALIDATION], ret: false },
Expand All @@ -62,8 +74,9 @@ describe("Test src/shared/extension", () => {
],
},
{
name: "onDidChangeConfiguration:2",
name: "onDidChangeConfiguration:3",
mock: [
{ spy: jest.spyOn(test.value, "affectsConfiguration"), arg: [globals.SETTINGS_LOGS_FOLDER_PATH], ret: false },
{ spy: jest.spyOn(test.value, "affectsConfiguration"), arg: [globals.SETTINGS_TEMP_FOLDER_PATH], ret: false },
{ spy: jest.spyOn(test.value, "affectsConfiguration"), arg: [globals.SETTINGS_AUTOMATIC_PROFILE_VALIDATION], ret: true },
{ spy: jest.spyOn(Profiles, "getInstance"), arg: [], ret: { refresh: jest.fn() } },
Expand All @@ -75,8 +88,9 @@ describe("Test src/shared/extension", () => {
],
},
{
name: "onDidChangeConfiguration:3",
name: "onDidChangeConfiguration:4",
mock: [
{ spy: jest.spyOn(test.value, "affectsConfiguration"), arg: [globals.SETTINGS_LOGS_FOLDER_PATH], ret: false },
{ spy: jest.spyOn(test.value, "affectsConfiguration"), arg: [globals.SETTINGS_TEMP_FOLDER_PATH], ret: false },
{ spy: jest.spyOn(test.value, "affectsConfiguration"), arg: [globals.SETTINGS_AUTOMATIC_PROFILE_VALIDATION], ret: false },
{ spy: jest.spyOn(test.value, "affectsConfiguration"), arg: [globals.SETTINGS_TEMP_FOLDER_HIDE], ret: true },
Expand All @@ -85,8 +99,9 @@ describe("Test src/shared/extension", () => {
],
},
{
name: "onDidChangeConfiguration:4",
name: "onDidChangeConfiguration:5",
mock: [
{ spy: jest.spyOn(test.value, "affectsConfiguration"), arg: [globals.SETTINGS_LOGS_FOLDER_PATH], ret: false },
{ spy: jest.spyOn(test.value, "affectsConfiguration"), arg: [globals.SETTINGS_TEMP_FOLDER_PATH], ret: false },
{ spy: jest.spyOn(test.value, "affectsConfiguration"), arg: [globals.SETTINGS_AUTOMATIC_PROFILE_VALIDATION], ret: false },
{ spy: jest.spyOn(test.value, "affectsConfiguration"), arg: [globals.SETTINGS_TEMP_FOLDER_HIDE], ret: false },
Expand Down
22 changes: 2 additions & 20 deletions packages/zowe-explorer/__tests__/__unit__/uss/actions.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
jest.mock("fs");

import * as zowe from "@zowe/cli";
import { Gui, ProfilesCache, ValidProfileEnum } from "@zowe/zowe-explorer-api";
import { Gui, ValidProfileEnum } from "@zowe/zowe-explorer-api";
import * as ussNodeActions from "../../../src/uss/actions";
import { UssFileTree, UssFileType, UssFileUtils } from "../../../src/uss/FileStructure";
import { createUSSTree, createUSSNode, createFavoriteUSSNode } from "../../../__mocks__/mockCreators/uss";
Expand All @@ -23,7 +23,6 @@ import {
createTextDocument,
createFileResponse,
createValidIProfile,
createInstanceOfProfileInfo,
} from "../../../__mocks__/mockCreators/shared";
import { ZoweExplorerApiRegister } from "../../../src/ZoweExplorerApiRegister";
import { Profiles } from "../../../src/Profiles";
Expand Down Expand Up @@ -75,23 +74,11 @@ function createGlobalMocks() {
Notification: 15,
};
}),
mockProfileInfo: createInstanceOfProfileInfo(),
mockProfilesCache: new ProfilesCache(zowe.imperative.Logger.getAppLogger()),
};

globalMocks.mockLoadNamedProfile.mockReturnValue(globalMocks.testProfile);
// Mock the logger
globals.defineGlobals("/test/path/");
const extensionMock = jest.fn(
() =>
({
subscriptions: [],
extensionPath: path.join(__dirname, "..", ".."),
} as vscode.ExtensionContext)
);
const mock = new extensionMock();
globals.defineGlobals("");
const profilesForValidation = { status: "active", name: "fake" };
globals.initLogger(mock);

Object.defineProperty(Gui, "setStatusBarMessage", { value: globalMocks.setStatusBarMessage, configurable: true });
Object.defineProperty(vscode.window, "showInputBox", { value: globalMocks.mockShowInputBox, configurable: true });
Expand Down Expand Up @@ -169,11 +156,6 @@ function createGlobalMocks() {
};
}),
});
Object.defineProperty(globalMocks.mockProfilesCache, "getProfileInfo", {
value: jest.fn(() => {
return { value: globalMocks.mockProfileInfo, configurable: true };
}),
});
Object.defineProperty(ZoweLogger, "error", { value: jest.fn(), configurable: true });
Object.defineProperty(ZoweLogger, "debug", { value: jest.fn(), configurable: true });
Object.defineProperty(ZoweLogger, "warn", { value: jest.fn(), configurable: true });
Expand Down
Loading

0 comments on commit 9a38388

Please sign in to comment.