Skip to content

Commit

Permalink
merge next and resolve conflicts
Browse files Browse the repository at this point in the history
Signed-off-by: Rudy Flores <[email protected]>
  • Loading branch information
rudyflores committed Sep 22, 2023
2 parents 4ecc555 + 92e6446 commit 25d2212
Show file tree
Hide file tree
Showing 82 changed files with 1,311 additions and 504 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/zowe-explorer-samples.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Zowe Explorer Samples CI

on:
push:
paths:
- .github/workflows/zowe-explorer-samples.yml
- packages/zowe-explorer-api/**
- samples/**
pull_request:
paths:
- .github/workflows/zowe-explorer-samples.yml
- packages/zowe-explorer-api/**
- samples/**

jobs:
samples-build:
runs-on: ubuntu-latest
timeout-minutes: 30

concurrency:
group: node-${{ matrix.node-version }}-ze-samples-ci-${{ github.ref }}
cancel-in-progress: true

strategy:
# Continue to run tests on the other systems if one fails
fail-fast: false
matrix:
node-version: [16.x, 18.x]

if: (github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository) && !contains(github.event.head_commit.message, '[ci skip]')

steps:
- name: Check out code
uses: actions/checkout@v3

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}

# install yarn
- run: npm install -g yarn

- run: for dir in samples/*; do pushd $dir && yarn && yarn run compile && popd; done
shell: bash
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@
"url": "https://github.com/zowe/vscode-extension-for-zowe"
},
"private": true,
"workspaces": [
"packages/*",
"packages/zowe-explorer/webviews/*"
],
"engines": {
"vscode": "^1.63.0"
},
"workspaces": [
"packages/*"
],
"dependencies": {
"@zowe/cli": "7.18.0",
"vscode-nls": "4.1.2"
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 @@ -13,6 +13,12 @@ All notable changes to the "eslint-plugin-zowe-explorer" package will be documen

### Bug fixes

## `2.11.0`

### New features and enhancements

### Bug fixes

## `2.10.0`

### New features and enhancements
Expand Down
9 changes: 0 additions & 9 deletions packages/samples/README.md

This file was deleted.

11 changes: 11 additions & 0 deletions packages/zowe-explorer-api/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,17 @@ All notable changes to the "zowe-explorer-api" extension will be documented in t
- Added `madge` script in `package.json` to track circular dependencies. [#2148](https://github.com/zowe/vscode-extension-for-zowe/issues/2148)
- Migrated to new package manager PNPM from Yarn.

## `2.11.0`

### New features and enhancements

- Added optional `pendingActions` record to `IZoweTreeNode` to allow nodes to track pending promises.
- Added optional `wasDoubleClicked` variable to `IZoweTreeNode` to track whether a node was double-clicked during an action.

### Bug fixes

- Bump `@zowe/secrets-for-zowe-sdk` to 7.18.4 to handle install errors gracefully and to allow running without MSVC redistributables.

## `2.10.0`

### New features and enhancements
Expand Down
2 changes: 2 additions & 0 deletions packages/zowe-explorer-api/__mocks__/fs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
*/

const fs = jest.genMockFromModule("fs") as any;
const origExistsSync = jest.requireActual("fs").existsSync;
const origReadFileSync = jest.requireActual("fs").readFileSync;
const mockReadFileSync = fs.readFileSync;

Expand All @@ -28,5 +29,6 @@ function realpathSync(path: string): string {
fs.readFileSync = readFileSync;
fs.realpathSync = realpathSync;
fs.realpathSync.native = realpathSync;
fs.existsSync = origExistsSync;

module.exports = fs;
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
*/

import * as path from "path";
import * as fs from "fs";
import * as zowe from "@zowe/cli";
import { ProfilesCache } from "../../../src/profiles/ProfilesCache";
import { ZoweExplorerApi } from "../../../src";
Expand Down Expand Up @@ -131,6 +132,7 @@ describe("ProfilesCache", () => {
});

it("getProfileInfo should initialize ProfileInfo API", async () => {
const existsSync = jest.spyOn(fs, "existsSync").mockImplementation();
const profInfo = await new ProfilesCache(fakeLogger as unknown as zowe.imperative.Logger, __dirname).getProfileInfo();
expect(readProfilesFromDiskSpy).toHaveBeenCalledTimes(1);
expect(defaultCredMgrWithKeytarSpy).toHaveBeenCalledTimes(1);
Expand All @@ -143,6 +145,7 @@ describe("ProfilesCache", () => {
path.join(fakeZoweDir, teamConfig.userConfigName),
path.join(fakeZoweDir, teamConfig.configName),
]);
existsSync.mockRestore();
});

it("requireKeyring returns keyring module from Secrets SDK", async () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/zowe-explorer-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"dependencies": {
"@types/vscode": "^1.53.2",
"@zowe/cli": "^7.18.0",
"@zowe/secrets-for-zowe-sdk": "7.18.1",
"@zowe/secrets-for-zowe-sdk": "7.18.4",
"handlebars": "^4.7.7",
"semver": "^7.5.3"
},
Expand Down
12 changes: 12 additions & 0 deletions packages/zowe-explorer-api/src/tree/IZoweTreeNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
import * as vscode from "vscode";
import { imperative } from "@zowe/cli";

export enum NodeAction {
Download = "download",
}

/**
* The base interface for Zowe tree nodes that are implemented by vscode.TreeItem.
*
Expand Down Expand Up @@ -62,6 +66,14 @@ export interface IZoweTreeNode {
* This will show action `extension.deleteFolder` only for items with `contextValue` is `folder`.
*/
contextValue?: string;
/**
* Any ongoing actions that must be awaited before continuing
*/
ongoingActions?: Record<NodeAction | string, Promise<any>>;
/**
* whether the node was double-clicked
*/
wasDoubleClicked?: boolean;
/**
* Retrieves the node label
*/
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 @@ -9,6 +9,12 @@ All notable changes to the "zowe-explorer-ftp-extension" extension will be docum
- Added `madge` script in `package.json` to track circular dependencies. [#2148](https://github.com/zowe/vscode-extension-for-zowe/issues/2148)
- Migrated to new package manager PNPM from Yarn.

## `2.11.0`

### Bug fixes

- Bump `@zowe/zowe-explorer-api` to pick up latest, including `@zowe/secrets-for-zowe-sdk` 7.18.4 to handle install errors gracefully and to allow running without MSVC redistributables.

## `2.10.0`

### New features and enhancements
Expand Down
16 changes: 16 additions & 0 deletions packages/zowe-explorer/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,22 @@ All notable changes to the "vscode-extension-for-zowe" extension will be documen
- Added `madge` script in `package.json` to track circular dependencies. [#2148](https://github.com/zowe/vscode-extension-for-zowe/issues/2148)
- Migrated to new package manager PNPM from Yarn.

## `2.11.0`

### New features and enhancements

- Allow deleting migrated datasets [#2447](https://github.com/zowe/vscode-extension-for-zowe/issues/2447)

### Bug fixes

- Fixed issue with favorited Job filter search. [#2440](https://github.com/zowe/vscode-extension-for-zowe/issues/2440)
- Remove the 'Show Attributes' context menu action for migrated datasets. [#2033](https://github.com/zowe/vscode-extension-for-zowe/issues/2033)
- Fixed issue with endless credential prompt loop when logging out. [#2262](https://github.com/zowe/vscode-extension-for-zowe/issues/2262)
- Bump `@zowe/secrets-for-zowe-sdk` to 7.18.4 to handle install errors gracefully and to allow running without MSVC redistributables.
- Fixed issue where data set content does not always appear as soon as the editor is opened. [#2427](https://github.com/zowe/vscode-extension-for-zowe/issues/2427)
- Adjust scope of "Security: Secure Credentials Enabled" setting to `machine-overridable` so it appears again in certain cloud IDEs.
- Fixed issue where disabling "Automatic Profile Validation" caused the search prompts to stop appearing for all tree views. [#2454](https://github.com/zowe/vscode-extension-for-zowe/issues/2454)

## `2.10.0`

### New features and enhancements
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -832,7 +832,7 @@ describe("Profiles Unit Tests - function deleteProfile", () => {
});

describe("Profiles Unit Tests - function checkCurrentProfile", () => {
const environmentSetup = (globalMocks) => {
const environmentSetup = (globalMocks): void => {
globalMocks.testProfile.profile.password = null;
globalMocks.testProfile.profile.tokenType = "";
Object.defineProperty(Profiles.getInstance(), "profilesForValidation", {
Expand All @@ -858,23 +858,57 @@ describe("Profiles Unit Tests - function checkCurrentProfile", () => {
});
};

const setupProfilesCheck = (globalMocks): void => {
jest.spyOn(Profiles.getInstance(), "getDefaultProfile").mockReturnValue({ name: "base" } as any);
jest.spyOn(Profiles.getInstance(), "getProfileInfo").mockResolvedValue({
getTeamConfig: () => ({
properties: {
profiles: {
sestest: { ...globalMocks.testProfile.profile, secure: [] },
base: {
type: "base",
host: "test",
port: 1443,
rejectUnauthorized: false,
name: "base",
tokenType: "",
secure: [],
},
},
},
}),
} as any);
jest.spyOn(Profiles.getInstance(), "getLoadedProfConfig").mockResolvedValue(globalMocks.testProfile);
jest.spyOn(Profiles.getInstance(), "getSecurePropsForProfile").mockResolvedValue([]);
};

it("should show as active in status of profile", async () => {
const globalMocks = await createGlobalMocks();
environmentSetup(globalMocks);
setupProfilesCheck(globalMocks);
jest.spyOn(Profiles.getInstance(), "validateProfiles").mockReturnValue({ status: "active", name: "sestest" } as any);
jest.spyOn(Profiles.getInstance(), "promptCredentials").mockResolvedValue(["sestest", "12345", "base64Auth"]);
await expect(Profiles.getInstance().checkCurrentProfile(globalMocks.testProfile)).resolves.toEqual({ name: "sestest", status: "active" });
});
it("should show as unverified in status of profile", async () => {
const globalMocks = await createGlobalMocks();
environmentSetup(globalMocks);
setupProfilesCheck(globalMocks);
jest.spyOn(Profiles.getInstance(), "promptCredentials").mockResolvedValue(undefined);
await expect(Profiles.getInstance().checkCurrentProfile(globalMocks.testProfile)).resolves.toEqual({ name: "sestest", status: "unverified" });
});
it("should show as inactive in status of profile", async () => {
const globalMocks = await createGlobalMocks();
setupProfilesCheck(globalMocks);
await expect(Profiles.getInstance().checkCurrentProfile(globalMocks.testProfile)).resolves.toEqual({ name: "sestest", status: "inactive" });
});
it("should throw an error if using token auth and is logged out or has expired token", async () => {
const globalMocks = await createGlobalMocks();
jest.spyOn(utils, "errorHandling").mockImplementation();
jest.spyOn(utils, "isUsingTokenAuth").mockResolvedValue(true);
setupProfilesCheck(globalMocks);
await expect(Profiles.getInstance().checkCurrentProfile(globalMocks.testProfile)).resolves.toEqual({ name: "sestest", status: "unverified" });
});
});

describe("Profiles Unit Tests - function getProfileSetting", () => {
Expand Down Expand Up @@ -1030,6 +1064,47 @@ describe("Profiles Unit Tests - function ssoLogin", () => {
});
});

describe("Profiles Unit Tests - function ssoLogout", () => {
let testNode;
let globalMocks;
beforeEach(async () => {
globalMocks = await createGlobalMocks();
testNode = new (ZoweTreeNode as any)(
"fake",
vscode.TreeItemCollapsibleState.None,
undefined,
globalMocks.testSession,
globalMocks.testProfile
);
testNode.profile.profile.password = undefined;
testNode.profile.profile.user = "fake";
Object.defineProperty(Profiles.getInstance(), "allProfiles", {
value: [
{
name: "fake",
},
],
configurable: true,
});
jest.spyOn(Gui, "showMessage").mockImplementation();
});
it("should logout successfully and refresh zowe explorer", async () => {
const getTokenTypeNameMock = jest.fn();
const logoutMock = jest.fn();
jest.spyOn(ZoweExplorerApiRegister.getInstance(), "getCommonApi").mockImplementation(() => ({
logout: logoutMock,
getSession: jest.fn(),
getProfileTypeName: jest.fn(),
getTokenTypeName: getTokenTypeNameMock,
}));
const updateBaseProfileFileLogoutSpy = jest.spyOn(Profiles.getInstance() as any, "updateBaseProfileFileLogout").mockImplementation();
await expect(Profiles.getInstance().ssoLogout(testNode)).resolves.not.toThrow();
expect(getTokenTypeNameMock).toBeCalledTimes(1);
expect(logoutMock).toBeCalledTimes(1);
expect(updateBaseProfileFileLogoutSpy).toBeCalledTimes(1);
});
});

describe("Profiles Unit Tests - function updateBaseProfileFileLogin", () => {
it("should update the property of mProfileInfo", async () => {
const privateProfile = Profiles.getInstance() as any;
Expand Down Expand Up @@ -1129,3 +1204,26 @@ describe("Profiles Unit Tests - function loginCredentialPrompt", () => {
expect(showMessageSpy).toBeCalledTimes(1);
});
});

describe("Profiles Unit Tests - function getSecurePropsForProfile", () => {
afterEach(() => {
jest.clearAllMocks();
jest.resetAllMocks();
});
it("should retrieve the secure properties of a profile", async () => {
const globalMocks = await createGlobalMocks();
jest.spyOn(Profiles.getInstance(), "getProfileInfo").mockResolvedValue({
mergeArgsForProfile: () => ({
knownArgs: [
{
argName: "tokenValue",
secure: true,
} as any,
],
missingArgs: [],
}),
getAllProfiles: () => [],
} as any);
await expect(Profiles.getInstance().getSecurePropsForProfile(globalMocks.testProfile.name ?? "")).resolves.toEqual(["tokenValue"]);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ describe("ZoweJobNode unit tests - Function checkCurrentProfile", () => {
it("Tests that checkCurrentProfile is executed successfully with inactive status", async () => {
const globalMocks = await createGlobalMocks();
const blockMocks = await createBlockMocks(globalMocks);
blockMocks.jobNode.contextValue = "SERVER";
blockMocks.jobNode.contextValue = "session";
globalMocks.mockCheckCurrentProfile.mockReturnValueOnce({
name: globalMocks.testProfile.name,
status: "inactive",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,12 @@ function createGlobalMocks() {
}),
});
Object.defineProperty(zowe.Download, "dataSet", {
value: jest.fn(() => {
return {
success: true,
commandResponse: null,
apiResponse: {
etag: "123",
},
};
value: jest.fn().mockResolvedValue({
success: true,
commandResponse: null,
apiResponse: {
etag: "123",
},
}),
configurable: true,
});
Expand Down
Loading

0 comments on commit 25d2212

Please sign in to comment.