Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VSC Proxy Support #3291

Merged
merged 34 commits into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
33b33fb
initial vsc proxy work
JillieBeanSim Oct 15, 2024
a1fa9f6
Merge branch 'main' into vsc-proxy-support
JillieBeanSim Oct 30, 2024
d536f51
fix circ dependency issues
JillieBeanSim Oct 30, 2024
b88c615
update zosmf session obtaining methods
JillieBeanSim Oct 30, 2024
7cd69de
update workflow and fix some unit tests
JillieBeanSim Nov 1, 2024
d196ff7
fix ZE API unit tests
JillieBeanSim Nov 4, 2024
325d9d6
fix ZE unit tests
JillieBeanSim Nov 4, 2024
d740e81
Merge remote-tracking branch 'origin/main' into vsc-proxy-support
JillieBeanSim Nov 4, 2024
a4e823a
add VscSettings unit tests
JillieBeanSim Nov 4, 2024
9907c04
profilesCache unit tests
JillieBeanSim Nov 4, 2024
3755ed1
add CHANGELOGs
JillieBeanSim Nov 4, 2024
7ede2bb
Merge remote-tracking branch 'origin/main' into vsc-proxy-support
JillieBeanSim Nov 5, 2024
9df5df9
update sdks
JillieBeanSim Nov 6, 2024
371f76e
fix unit tests
JillieBeanSim Nov 6, 2024
9f707a4
Merge branch 'main' into vsc-proxy-support
JillieBeanSim Nov 6, 2024
d15b808
update sdk version in changelogs
JillieBeanSim Nov 6, 2024
7c23f6e
Merge remote-tracking branch 'origin/main' into vsc-proxy-support
JillieBeanSim Nov 7, 2024
42c34ab
run prepublish
JillieBeanSim Nov 7, 2024
a69607f
Merge branch 'main' into vsc-proxy-support
JillieBeanSim Nov 13, 2024
20c1c38
Merge branch 'main' into vsc-proxy-support
JillieBeanSim Nov 14, 2024
ae40c7c
Merge branch 'main' into vsc-proxy-support
JillieBeanSim Nov 15, 2024
f92e5d0
Merge branch 'main' into vsc-proxy-support
zFernand0 Nov 19, 2024
8829262
Merge remote-tracking branch 'origin/main' into vsc-proxy-support
JillieBeanSim Nov 19, 2024
8c6af6a
Merge branch 'main' into vsc-proxy-support
zFernand0 Nov 20, 2024
415e801
address comments
JillieBeanSim Nov 20, 2024
16864bd
get lock from main
JillieBeanSim Nov 20, 2024
7891e31
update sdk changelog entry in ftp extenstion to match other packages
JillieBeanSim Nov 20, 2024
2bc1d38
Merge remote-tracking branch 'origin/main' into vsc-proxy-support
JillieBeanSim Nov 21, 2024
b8f090c
address feedback
JillieBeanSim Nov 21, 2024
3dfe351
Merge branch 'main' into vsc-proxy-support
JillieBeanSim Nov 21, 2024
c8e2675
Merge branch 'main' into vsc-proxy-support
JillieBeanSim Nov 21, 2024
ccae372
remove session check and undefined return type
JillieBeanSim Nov 21, 2024
aeb8393
Merge remote-tracking branch 'origin/main' into vsc-proxy-support
JillieBeanSim Nov 21, 2024
9e1b653
Merge branch 'main' into vsc-proxy-support
zFernand0 Nov 22, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`ZosmfUssApi constants should be unchanged 1`] = `"zosmf"`;
exports[`ZosmfUssApi misc constants should be unchanged 1`] = `"zosmf"`;

exports[`ZosmfUssApi constants should be unchanged 2`] = `"apimlAuthenticationToken"`;
exports[`ZosmfUssApi misc constants should be unchanged 2`] = `"apimlAuthenticationToken"`;
8 changes: 8 additions & 0 deletions packages/zowe-explorer-api/src/profiles/ProfilesCache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import { ZosTsoProfile } from "@zowe/zos-tso-for-zowe-sdk";
import { ZosUssProfile } from "@zowe/zos-uss-for-zowe-sdk";
import { Types } from "../Types";
import { VscSettings } from "../vscode/doc/VscSettings";

export class ProfilesCache {
public profilesForValidation: Validation.IValidationProfile[] = [];
Expand Down Expand Up @@ -387,6 +388,13 @@
return convertResult;
}

public static getProfileSessionWithVscProxy(session: imperative.Session): imperative.Session {
const VsCodeProxySettings = VscSettings.getVsCodeProxySettings();
Fixed Show fixed Hide fixed
// will be able to uncomment following line and assign with CLI udpates
// session.ISession.proxy = VsCodeProxySettings;
return session;
}

protected getCoreProfileTypes(): imperative.IProfileTypeConfiguration[] {
return [ZosmfProfile, ZosTsoProfile, ZosUssProfile];
}
Expand Down
11 changes: 9 additions & 2 deletions packages/zowe-explorer-api/src/profiles/ZoweExplorerZosmfApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import * as zosmf from "@zowe/zosmf-for-zowe-sdk";
import { MainframeInteraction } from "../extend/MainframeInteraction";
import { FileManagement } from "../utils";
import { Types } from "../Types";
import { ProfilesCache } from "../profiles/ProfilesCache";

/**
* Implementations of Zowe Explorer API for z/OSMF profiles
Expand All @@ -44,7 +45,10 @@ export namespace ZoweExplorerZosmf {
const sessCfg = zosmf.ZosmfSession.createSessCfgFromArgs(cmdArgs);
imperative.ConnectionPropsForSessCfg.resolveSessCfgProps(sessCfg, cmdArgs);
const sessionToUse = new imperative.Session(sessCfg);
return sessionToUse;
// const VsCodeProxySettings = VscSettings.getVsCodeProxySettings();
// will be able to uncomment following line and assign with CLI udpates
// sessionToUse.ISession.proxy = VsCodeProxySettings;
return ProfilesCache.getProfileSessionWithVscProxy(sessionToUse);
}

public getSession(profile?: imperative.IProfileLoaded): imperative.Session {
Expand All @@ -56,7 +60,10 @@ export namespace ZoweExplorerZosmf {
imperative.Logger.getAppLogger().error(error as string);
}
}
return this.session;
// const VsCodeProxySettings = VscSettings.getVsCodeProxySettings();
// will be able to uncomment following line and assign with CLI udpates
// this.session.ISession.proxy = VsCodeProxySettings;
return ProfilesCache.getProfileSessionWithVscProxy(this.session);
}

private _getSession(serviceProfile: imperative.IProfileLoaded): imperative.Session {
Expand Down
4 changes: 2 additions & 2 deletions packages/zowe-explorer-api/src/vscode/ZoweVsCodeExtension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@

import * as semver from "semver";
import * as vscode from "vscode";
import { ProfilesCache } from "../profiles";
import { ProfilesCache } from "../profiles/ProfilesCache";
import { Login, Logout } from "@zowe/core-for-zowe-sdk";
import * as imperative from "@zowe/imperative";
import { Gui } from "../globals/Gui";
import { PromptCredentialsOptions } from "./doc/PromptCredentials";
import { Types } from "../Types";
import { BaseProfileAuthOptions } from "./doc";
import { BaseProfileAuthOptions } from "./doc/BaseProfileAuth";

/**
* Collection of utility functions for writing Zowe Explorer VS Code extensions.
Expand Down
46 changes: 46 additions & 0 deletions packages/zowe-explorer-api/src/vscode/doc/VscSettings.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/**
* 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.
*
*/

import * as vscode from "vscode";

export class VscSettings {
/**
* Retrieves a generic setting either in user or workspace.
* @param {string} key - The config property that needs retrieving
* @param {T} defaultValue - Default value if config property is undefined
*/
public static getDirectValue<T>(key: string, defaultValue?: T): T {
const [first, ...rest] = key.split(".");
return vscode.workspace.getConfiguration(first).get(rest.join("."), defaultValue);
}
traeok marked this conversation as resolved.
Show resolved Hide resolved

// create mock ProxyVariables, able to remove after CLI changes adopted
public static proxyVars: {
http_proxy: string;
https_proxy: string;
no_proxy: string[];
proxy_authorization: string;
proxy_strict_ssl: boolean;
};
// Return will be Promise<imperative.ProxyVariables>
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
JillieBeanSim marked this conversation as resolved.
Show resolved Hide resolved
public static getVsCodeProxySettings() {
const proxySupport = this.getDirectValue("http.proxySupport");
if (proxySupport !== "on") {
return;
}
this.proxyVars.no_proxy = this.getDirectValue("http.noProxy");
this.proxyVars.proxy_strict_ssl = this.getDirectValue("http.proxyStrictSSL");
this.proxyVars.proxy_authorization = this.getDirectValue("http.proxyAuthorization");
this.proxyVars.http_proxy = this.proxyVars.https_proxy = this.getDirectValue("http.proxy");
return this.proxyVars;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,17 @@ import {
} from "../../__mocks__/mockCreators/shared";
import { createDatasetSessionNode, createDatasetTree } from "../../__mocks__/mockCreators/datasets";
import { createProfileManager } from "../../__mocks__/mockCreators/profiles";
import { imperative, Gui, ZoweTreeNode, ZoweVsCodeExtension, IZoweTree, IZoweTreeNode, Validation, FileManagement } from "@zowe/zowe-explorer-api";
import {
imperative,
Gui,
ZoweTreeNode,
ZoweVsCodeExtension,
IZoweTree,
IZoweTreeNode,
Validation,
FileManagement,
ProfilesCache,
} from "@zowe/zowe-explorer-api";
import { Profiles } from "../../../src/configuration/Profiles";
import { ZoweExplorerExtender } from "../../../src/extending/ZoweExplorerExtender";
import { ZoweExplorerApiRegister } from "../../../src/extending/ZoweExplorerApiRegister";
Expand Down Expand Up @@ -196,6 +206,10 @@ function createGlobalMocks(): { [key: string]: any } {
}),
configurable: true,
});
Object.defineProperty(ProfilesCache, "getProfileSessionWithVscProxy", {
value: jest.fn().mockReturnValue(newMocks.testSession),
configurable: true,
});

newMocks.testUSSTree = createUSSTree(undefined as any, [createUSSNode(newMocks.testSession, newMocks.testProfile)], createTreeView());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

import * as vscode from "vscode";
import * as zosfiles from "@zowe/zos-files-for-zowe-sdk";
import { Gui, imperative, Validation, Types } from "@zowe/zowe-explorer-api";
import { Gui, imperative, Validation, Types, ProfilesCache } from "@zowe/zowe-explorer-api";
import { DatasetFSProvider } from "../../../../src/trees/dataset/DatasetFSProvider";
import { bindMvsApi, createMvsApi } from "../../../__mocks__/mockCreators/api";
import {
Expand Down Expand Up @@ -132,6 +132,7 @@ const createBlockMocksShared = () => {
const testDatasetTree = createDatasetTree(datasetSessionNode, treeView);
const mvsApi = createMvsApi(imperativeProfile);
const fetchDsAtUri = jest.spyOn(DatasetFSProvider.instance, "fetchDatasetAtUri").mockImplementation();
Object.defineProperty(ProfilesCache, "getProfileSessionWithVscProxy", { value: jest.fn().mockReturnValue(zosmfSession), configurable: true });
bindMvsApi(mvsApi);

return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ function createGlobalMocks() {
Object.defineProperty(ZoweLogger, "warn", { value: jest.fn(), configurable: true });
Object.defineProperty(ZoweLogger, "info", { value: jest.fn(), configurable: true });
Object.defineProperty(ZoweLogger, "trace", { value: jest.fn(), configurable: true });
Object.defineProperty(ProfilesCache, "getProfileSessionWithVscProxy", { value: jest.fn().mockReturnValue(createISession()), configurable: true });

return globalMocks;
}
Expand Down
Loading