Skip to content

Commit

Permalink
Merge pull request #2713 from zowe/port/2533+2692
Browse files Browse the repository at this point in the history
Port/2533+2692
  • Loading branch information
zFernand0 authored Feb 14, 2024
2 parents 95b63c1 + fb61f05 commit 000998e
Show file tree
Hide file tree
Showing 51 changed files with 988 additions and 1,200 deletions.
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "3.0.0-next.202402071248",
"version": "3.0.0-next.202402140000",
"command": {
"version": {
"forcePublish": true,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
},
"dependencies": {
"@vscode/l10n": "^0.0.18",
"@zowe/cli": "8.0.0-next.202401262128"
"@zowe/cli": "8.0.0-next.202402132108"
},
"devDependencies": {
"@types/jest": "^29.2.3",
Expand Down
4 changes: 3 additions & 1 deletion packages/eslint-plugin-zowe-explorer/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
All notable changes to the "eslint-plugin-zowe-explorer" package will be documented in this file.

## `3.0.0-next.202401241448`
## TBD Release

### New features and enhancements

### Bug fixes

## `3.0.0-next.202401241448`

## `3.0.0-next.202401121747`

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

### Bug fixes

- Fix login and logout operations when APIML dynamic tokens are enabled. [#2692](https://github.com/zowe/vscode-extension-for-zowe/pull/2692)
- Updated dependencies for technical currency purposes.

## `3.0.0-next.202402071248`

### New features and enhancements
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ describe("IZoweLogger", () => {
const loggerSpy = jest.spyOn(logger.getImperativeLogger() as any, methodName);
const logMessage = methodName.split("").reverse().join("");
logger.logImperativeMessage(logMessage, severity);
expect(loggerSpy).toBeCalledWith(`[${extensionName}] ${logMessage}`);
expect(loggerSpy).toHaveBeenCalledWith(`[${extensionName}] ${logMessage}`);
};

it("should use extension name and logging path", () => {
const initLoggerSpy = jest.spyOn(imperative.Logger, "initLogger");
const testLogger = new IZoweLogger(extensionName, loggingPath);
expect(testLogger.getExtensionName()).toBe(extensionName);
expect(initLoggerSpy).toBeCalledWith(loggerConfig);
expect(initLoggerSpy).toHaveBeenCalledWith(loggerConfig);
expect(Object.values(loggerConfig.log4jsConfig.appenders).every((appender) => appender.filename.startsWith(loggingPath))).toBe(true);
});

Expand Down Expand Up @@ -69,7 +69,7 @@ describe("IZoweLogger", () => {
const loggerSpy = jest.spyOn(testLogger.getImperativeLogger(), "debug");
const logMessage = "i haz error";
testLogger.logImperativeMessage(logMessage);
expect(loggerSpy).toBeCalledWith(`[${extensionName}] ${logMessage}`);
expect(loggerSpy).toHaveBeenCalledWith(`[${extensionName}] ${logMessage}`);
});

it("should fail to log Imperative message with invalid severity", () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ describe("ZosmfUssApi", () => {
configurable: true,
});
await expect(zosmfApi.updateAttributes("/test/path", { tag: "utf-8" })).resolves.not.toThrow();
expect(changeTagSpy).toBeCalledTimes(1);
expect(changeTagSpy).toHaveBeenCalledTimes(1);
});

const ussApis: ITestApi<ZoweExplorerZosmf.UssApi>[] = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,29 +25,29 @@ describe("KeytarApi", () => {
isCredsSecuredSpy.mockReturnValueOnce(true);
credMgrInitializeSpy.mockResolvedValueOnce();
await new KeytarApi(undefined as unknown as imperative.Logger).activateKeytar(false, false);
expect(isCredsSecuredSpy).toBeCalledTimes(1);
expect(credMgrInitializeSpy).toBeCalledTimes(1);
expect(isCredsSecuredSpy).toHaveBeenCalledTimes(1);
expect(credMgrInitializeSpy).toHaveBeenCalledTimes(1);
});

it("should do nothing if secure credential plugin is not active", async () => {
isCredsSecuredSpy.mockReturnValueOnce(false);
await new KeytarApi(undefined as unknown as imperative.Logger).activateKeytar(false, false);
expect(isCredsSecuredSpy).toBeCalledTimes(1);
expect(credMgrInitializeSpy).not.toBeCalled();
expect(isCredsSecuredSpy).toHaveBeenCalledTimes(1);
expect(credMgrInitializeSpy).not.toHaveBeenCalled();
});

it("should do nothing if API has already been initialized", async () => {
isCredsSecuredSpy.mockReturnValueOnce(true);
await new KeytarApi(undefined as unknown as imperative.Logger).activateKeytar(true, false);
expect(isCredsSecuredSpy).toBeCalledTimes(1);
expect(credMgrInitializeSpy).not.toBeCalled();
expect(isCredsSecuredSpy).toHaveBeenCalledTimes(1);
expect(credMgrInitializeSpy).not.toHaveBeenCalled();
});

it("should do nothing if Keytar module is missing", async () => {
jest.mock("@zowe/secrets-for-zowe-sdk", () => {});
isCredsSecuredSpy.mockReturnValueOnce(true);
await new KeytarApi(undefined as unknown as imperative.Logger).activateKeytar(false, false);
expect(isCredsSecuredSpy).toBeCalledTimes(1);
expect(credMgrInitializeSpy).not.toBeCalled();
expect(isCredsSecuredSpy).toHaveBeenCalledTimes(1);
expect(credMgrInitializeSpy).not.toHaveBeenCalled();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -314,10 +314,18 @@ describe("ZoweVsCodeExtension", () => {
delete testSession.ISession.password;
testSession.ISession.hostname = "service";
testSession.ISession.base64EncodedAuth = "dXNlcjpwYXNz";
testSession.ISession.tokenType = tempBaseProfile.profile.tokenType;

expect(loginSpy).toHaveBeenCalledWith(testSession);
expect(testSpy).toHaveBeenCalledWith(testCache, "service");
expect(testCache.updateBaseProfileFileLogin).toHaveBeenCalledWith(newServiceProfile, updProfile, true);
expect(testCache.updateBaseProfileFileLogin).toHaveBeenCalledWith(
newServiceProfile,
{
tokenType: tempBaseProfile.profile.tokenType,
tokenValue: "tokenValue",
},
true
);
});
it("should logout using the service profile given a simple profile name", async () => {
testCache.fetchBaseProfile.mockResolvedValue(baseProfile);
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": "8.0.0-next.202401262128",
"@zowe/cli": "8.0.0-next.202402132108",
"@zowe/secrets-for-zowe-sdk": "7.18.6",
"handlebars": "^4.7.7",
"semver": "^7.5.3"
Expand Down
8 changes: 5 additions & 3 deletions packages/zowe-explorer-api/src/vscode/ZoweVsCodeExtension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,8 @@ export class ZoweVsCodeExtension {
if (typeof serviceProfile === "string") {
serviceProfile = await ZoweVsCodeExtension.getServiceProfileForAuthPurposes(cache, serviceProfile);
}
const tokenType = loginTokenType ?? serviceProfile.profile.tokenType ?? imperative.SessConstants.TOKEN_TYPE_APIML;
const tokenType =
serviceProfile.profile.tokenType ?? baseProfile.profile.tokenType ?? loginTokenType ?? imperative.SessConstants.TOKEN_TYPE_APIML;
const updSession = new imperative.Session({
hostname: serviceProfile.profile.host,
port: serviceProfile.profile.port,
Expand All @@ -195,7 +196,7 @@ export class ZoweVsCodeExtension {

const loginToken = await (zeRegister?.getCommonApi(serviceProfile).login ?? Login.apimlLogin)(updSession);
const updBaseProfile: imperative.IProfile = {
tokenType,
tokenType: updSession.ISession.tokenType ?? tokenType,
tokenValue: loginToken,
};

Expand Down Expand Up @@ -248,8 +249,9 @@ export class ZoweVsCodeExtension {
serviceProfile = await ZoweVsCodeExtension.getServiceProfileForAuthPurposes(cache, serviceProfile);
}
const tokenType =
zeRegister?.getCommonApi(serviceProfile).getTokenTypeName() ??
serviceProfile.profile.tokenType ??
baseProfile.profile.tokenType ??
zeRegister?.getCommonApi(serviceProfile).getTokenTypeName() ??
imperative.SessConstants.TOKEN_TYPE_APIML;
const updSession = new imperative.Session({
hostname: serviceProfile.profile.host,
Expand Down
3 changes: 3 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,9 @@ All notable changes to the "zowe-explorer-ftp-extension" extension will be docum

## Bug fixes

- Fix Windows-specific hangs when saving members that contain JCL via the FTP extension. Thanks @tiantn & @std4lqi. [#2533](https://github.com/zowe/vscode-extension-for-zowe/issues/2533)
- Updated dependencies for technical currency purposes.

## `3.0.0-next.202402071248`

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

await instance.logout(session);

expect(session.releaseConnections).toBeCalledTimes(1);
expect(session.releaseConnections).toHaveBeenCalledTimes(1);
expect(globals.SESSION_MAP.size).toBe(0);
});

Expand Down Expand Up @@ -125,10 +125,13 @@ describe("AbstractFtpApi", () => {
failNotFound: true,
};
try {
expect(Gui.showMessage).toBeCalledWith("Internal error: ZoweVscFtpRestApi instance was not initialized with a valid Zowe profile.", {
severity: MessageSeverity.FATAL,
logger: globals.LOGGER,
});
expect(Gui.showMessage).toHaveBeenCalledWith(
"Internal error: ZoweVscFtpRestApi instance was not initialized with a valid Zowe profile.",
{
severity: MessageSeverity.FATAL,
logger: globals.LOGGER,
}
);
instance.checkedProfile();
} catch (err) {
expect(err).not.toBeUndefined();
Expand Down Expand Up @@ -186,7 +189,7 @@ describe("AbstractFtpApi", () => {
instance.releaseConnection({
close: connectionMock,
});
expect(connectionMock).toBeCalledTimes(1);
expect(connectionMock).toHaveBeenCalledTimes(1);
});

it("should return the profile type of 'zftp'", () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ describe("FtpJesApi", () => {
const result = await JesApi.getJobsByParameters(mockParams);

expect(result[0].jobname).toContain("JOB1");
expect(JobUtils.listJobs).toBeCalledTimes(1);
expect(JobUtils.listJobs).toHaveBeenCalledTimes(1);
expect(JesApi.releaseConnection).toHaveBeenCalledTimes(0);
});

Expand All @@ -61,8 +61,8 @@ describe("FtpJesApi", () => {
const result = await JesApi.getJob(mockParams.jobid);

expect(result.jobname).toContain("JOB1");
expect(JobUtils.findJobByID).toBeCalledTimes(1);
expect(JesApi.releaseConnection).toBeCalled();
expect(JobUtils.findJobByID).toHaveBeenCalledTimes(1);
expect(JesApi.releaseConnection).toHaveBeenCalled();
});

it("should get spoolfiles.", async () => {
Expand All @@ -75,26 +75,26 @@ describe("FtpJesApi", () => {
const result = await JesApi.getSpoolFiles(mockParams.jobname, mockParams.jobid);

expect(result[0].id).toContain("1");
expect(JobUtils.findJobByID).toBeCalledTimes(1);
expect(JesApi.releaseConnection).toBeCalled();
expect(JobUtils.findJobByID).toHaveBeenCalledTimes(1);
expect(JesApi.releaseConnection).toHaveBeenCalled();
});

it("should download spool content.", async () => {
const jobDetails = { jobid: "123", jobname: "JOB1", spoolFiles: [{ id: "1" }, { id: "2" }] };
JobUtils.findJobByID = jest.fn().mockReturnValue(jobDetails);
JobUtils.getSpoolFiles = jest.fn().mockReturnValue(jobDetails.spoolFiles);
DownloadJobs.getSpoolDownloadFile = jest.fn().mockReturnValue("/tmp/file1");
DownloadJobs.getSpoolDownloadFilePath = jest.fn().mockReturnValue("/tmp/file1");
imperative.IO.writeFile = jest.fn();
const mockParams = {
parms: { jobname: "JOB1", jobid: "123", outDir: "/a/b/c" },
};

await JesApi.downloadSpoolContent(mockParams.parms);
expect(JobUtils.findJobByID).toBeCalledTimes(1);
expect(JobUtils.getSpoolFiles).toBeCalledTimes(1);
expect(DownloadJobs.getSpoolDownloadFile).toBeCalledTimes(2);
expect(imperative.IO.writeFile).toBeCalledTimes(2);
expect(JesApi.releaseConnection).toBeCalled();
expect(JobUtils.findJobByID).toHaveBeenCalledTimes(1);
expect(JobUtils.getSpoolFiles).toHaveBeenCalledTimes(1);
expect(DownloadJobs.getSpoolDownloadFilePath).toHaveBeenCalledTimes(2);
expect(imperative.IO.writeFile).toHaveBeenCalledTimes(2);
expect(JesApi.releaseConnection).toHaveBeenCalled();
});

it("should throw an error when downloading spool content if no spool files are available.", async () => {
Expand All @@ -115,8 +115,8 @@ describe("FtpJesApi", () => {
await JesApi.getSpoolContentById(mockParams.jobname, mockParams.jobid, mockParams.spoolID);

expect((response._readableState.buffer.head?.data ?? response._readableState.buffer).toString()).toContain("Hello world");
expect(JobUtils.getSpoolFileContent).toBeCalledTimes(1);
expect(JesApi.releaseConnection).toBeCalled();
expect(JobUtils.getSpoolFileContent).toHaveBeenCalledTimes(1);
expect(JesApi.releaseConnection).toHaveBeenCalled();
});

it("should submit job.", async () => {
Expand All @@ -129,9 +129,9 @@ describe("FtpJesApi", () => {
};
const result = await JesApi.submitJob(mockParams.jobDataSet);
expect(result.jobid).toContain("123");
expect(JobUtils.submitJob).toBeCalledTimes(1);
expect(DataSetUtils.downloadDataSet).toBeCalledTimes(1);
expect(JesApi.releaseConnection).toBeCalled();
expect(JobUtils.submitJob).toHaveBeenCalledTimes(1);
expect(DataSetUtils.downloadDataSet).toHaveBeenCalledTimes(1);
expect(JesApi.releaseConnection).toHaveBeenCalled();
});

it("should delete job.", async () => {
Expand All @@ -141,8 +141,8 @@ describe("FtpJesApi", () => {
jobid: "123",
};
await JesApi.deleteJob(mockParams.jobname, mockParams.jobid);
expect(JobUtils.deleteJob).toBeCalledTimes(1);
expect(JesApi.releaseConnection).toBeCalled();
expect(JobUtils.deleteJob).toHaveBeenCalledTimes(1);
expect(JesApi.releaseConnection).toHaveBeenCalled();
});

it("should throw error when list jobs by owner and prefix failed.", async () => {
Expand Down
Loading

0 comments on commit 000998e

Please sign in to comment.