Skip to content

Commit 44d8f8b

Browse files
Added support for ltpa token (#219)
* Added support for the ltpa token Signed-off-by: enam-khan <[email protected]> * Removed unused import and variable in test Signed-off-by: enam-khan <[email protected]> * Some cleanup Signed-off-by: enam-khan <[email protected]> * Updated changelogs Signed-off-by: enam-khan <[email protected]> * Update packages/vsce/CHANGELOG.md Co-authored-by: Andrew <[email protected]> Signed-off-by: EKhan <[email protected]> * Update packages/sdk/CHANGELOG.md Co-authored-by: Andrew <[email protected]> Signed-off-by: EKhan <[email protected]> * Update packages/sdk/src/constants/CicsCmci.constants.ts Co-authored-by: Andrew <[email protected]> Signed-off-by: EKhan <[email protected]> * Update packages/vsce/src/commands/disableCommands/disableTransactionCommand.ts Co-authored-by: Andrew <[email protected]> Signed-off-by: EKhan <[email protected]> * Update packages/vsce/src/commands/openLocalFileCommand.ts Co-authored-by: Andrew <[email protected]> Signed-off-by: EKhan <[email protected]> * set tree to unauthorized on error Signed-off-by: Andrew Twydell <[email protected]> --------- Signed-off-by: enam-khan <[email protected]> Signed-off-by: EKhan <[email protected]> Signed-off-by: Andrew Twydell <[email protected]> Co-authored-by: Andrew <[email protected]> Co-authored-by: Andrew Twydell <[email protected]>
1 parent aec10bb commit 44d8f8b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+703
-480
lines changed

packages/sdk/CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22

33
All notable changes to the IBM® CICS® Plug-in for Zowe CLI will be documented in this file.
44

5+
6+
## Recent Changes
7+
8+
- Enhancement: Added CICS resource names to available constants. [#217](https://github.com/zowe/cics-for-zowe-client/issues/217)
9+
510
## `6.3.3`
611

712
- Enhancement: Add requestOptions to getResource and getCache method. [#220](https://github.com/zowe/cics-for-zowe-client/issues/220)

packages/sdk/src/constants/CicsCmci.constants.ts

+15
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ export const CicsCmciConstants = {
1818
*/
1919
CICS_SYSTEM_MANAGEMENT: "CICSSystemManagement",
2020

21+
/**
22+
* Specifies the required part of the REST interface URI to access system initialization parameters
23+
*/
24+
CICS_SYSTEM_PARAMETER: "CICSSystemParameter",
25+
2126
/**
2227
* Specifies the required part of the REST interface URI to access program definitions
2328
*/
@@ -38,6 +43,11 @@ export const CicsCmciConstants = {
3843
*/
3944
CICS_PROGRAM_RESOURCE: "CICSProgram",
4045

46+
/**
47+
* Specifies the required part of the REST interface URI to access library resources
48+
*/
49+
CICS_LIBRARY_RESOURCE: "CICSLibrary",
50+
4151
/**
4252
* Specifies the required part of the REST interface URI to access URIMap definitions
4353
*/
@@ -48,6 +58,11 @@ export const CicsCmciConstants = {
4858
*/
4959
CICS_DEFINITION_WEBSERVICE: "CICSDefinitionWebService",
5060

61+
/**
62+
* Specifies the required part of the REST interface URI to access tcp/ip service resources
63+
*/
64+
CICS_TCPIPSERVICE_RESOURCE: "CICSTCPIPService",
65+
5166
/*
5267
* Specifies the required part of the REST interface URI to access URIMaps
5368
*/

packages/vsce/CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@ All notable changes to the "cics-extension-for-zowe" extension will be documente
44

55
## Recent Changes
66

7+
- Enhancement: Use LTPA tokens to allow CMCI "sessions" [#217](https://github.com/zowe/cics-for-zowe-client/issues/217)
78
- Enhancement: Create icons for library and Web resources. [#229](https://github.com/zowe/cics-for-zowe-client/issues/229)
89
- Updated icon sizes [#235](https://github.com/zowe/cics-for-zowe-client/issues/235)
910

1011
## `3.3.3`
12+
1113
- BugFix: Duplicate CICSplex exist when connecting to a multi-CMAS system. [#227](https://github.com/zowe/cics-for-zowe-client/issues/227)
1214
- Enhancement: Show CMCI error response codes when failing to make requests. [#220](https://github.com/zowe/cics-for-zowe-client/issues/220)
1315

packages/vsce/__tests__/__unit__/trees/CICSRegionsContainer.unit.test.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,8 @@ describe("Test suite for CICSRegionsContainer", () => {
8787

8888
await sut.loadRegionsInCICSGroup(CICSTreeMock as any as CICSTree);
8989

90-
expect(getResourceMock).toHaveBeenCalledWith(sut.getParent().getParent().getSession(), testData);
90+
expect(getResourceMock).toHaveBeenCalledWith(sut.getParent().getParent().getSession(), testData,
91+
{ failOnNoData: false, useCICSCmciRestError: true });
9192
expect(sut.label).toBe("Regions (cics) [1/1]");
9293
expect(sut.collapsibleState).toBe(2);
9394
});
@@ -103,7 +104,7 @@ describe("Test suite for CICSRegionsContainer", () => {
103104

104105
it("Should load all regions of plex", async () => {
105106
await sut.loadRegionsInPlex();
106-
107+
107108
expect(getRegionInfoInPlexMock).toHaveBeenCalledTimes(1);
108109
expect(sut.label).toBe("Regions [2/2]");
109110
expect(sut.collapsibleState).toBe(2);

packages/vsce/__tests__/__unit__/trees/CICSSessionTree.unit.test.ts

+41-37
Original file line numberDiff line numberDiff line change
@@ -16,62 +16,66 @@ import { CICSRegionTree } from "../../../src/trees/CICSRegionTree";
1616
import { CICSSessionTree } from "../../../src/trees/CICSSessionTree";
1717
import * as globalMocks from "../../__utils__/globalMocks";
1818

19+
1920
jest.mock("@zowe/zowe-explorer-api");
2021
jest.mock("../../../src/utils/iconUtils", () => {
2122
return { getIconFilePathFromName: getIconFilePathFromNameMock };
2223
});
23-
const cicsTreeMock = jest.fn();
24+
const cicstreeMock = jest.fn();
2425
const treeResourceMock = globalMocks.getDummyTreeResources("cicsmanagedregion", "fileName*");
2526
const profile = {
2627
profile: { user: "user", password: "pwd", hostname: "hostname", protocol: "https", type: "basic", rejectUnauthorized: false, port: 8080 },
2728
};
2829
describe("Test suite for CICSSessionTree", () => {
2930
let sut: CICSSessionTree;
3031

31-
beforeEach(() => {
32-
getIconFilePathFromNameMock.mockReturnValue(treeResourceMock.iconPath);
32+
describe("Validation", () => {
3333

34-
sut = new CICSSessionTree(profile);
35-
sut.isUnauthorized = true;
36-
expect(getIconFilePathFromNameMock).toHaveBeenCalledWith("profile-unverified");
37-
});
34+
beforeEach(() => {
35+
getIconFilePathFromNameMock.mockReturnValue(treeResourceMock.iconPath);
3836

39-
afterEach(() => {
40-
jest.resetAllMocks();
41-
});
37+
sut = new CICSSessionTree(profile);
38+
sut.isUnauthorized = true;
39+
expect(getIconFilePathFromNameMock).toHaveBeenCalledWith("profile-unverified");
40+
});
4241

43-
describe("Test suite for addRegion", () => {
44-
it("should push CICSRegionTree object into children", () => {
45-
sut.addRegion(cicsTreeMock as any as CICSRegionTree);
46-
expect(sut.getChildren().length).toBeGreaterThanOrEqual(1);
42+
afterEach(() => {
43+
jest.resetAllMocks();
4744
});
48-
});
49-
describe("Test suite for addPlex", () => {
50-
it("should push CICSPlexTree object into children", () => {
51-
sut.addPlex(cicsTreeMock as any as CICSPlexTree);
52-
expect(sut.getChildren().length).toBeGreaterThanOrEqual(1);
45+
46+
describe("Test suite for addRegion", () => {
47+
it("should push CICSRegionTree object into children", () => {
48+
sut.addRegion(cicstreeMock as any as CICSRegionTree);
49+
expect(sut.getChildren().length).toBeGreaterThanOrEqual(1);
50+
});
5351
});
54-
});
55-
describe("Test suite for getChildren", () => {
56-
it("should return an array of childrens", () => {
57-
expect(sut.getChildren().length).toBeGreaterThanOrEqual(0);
52+
describe("Test suite for addPlex", () => {
53+
it("should push CICSPlexTree object into children", () => {
54+
sut.addPlex(cicstreeMock as any as CICSPlexTree);
55+
expect(sut.getChildren().length).toBeGreaterThanOrEqual(1);
56+
});
5857
});
59-
});
60-
describe("Test suite for setUnauthorized", () => {
61-
it("should set isUnauthorized to true", () => {
62-
sut.setUnauthorized();
63-
expect(sut.isUnauthorized).toBeTruthy();
58+
describe("Test suite for getChildren", () => {
59+
it("should return an array of childrens", () => {
60+
expect(sut.getChildren().length).toBeGreaterThanOrEqual(0);
61+
});
6462
});
65-
});
66-
describe("Test suite for setAuthorized", () => {
67-
it("should set isUnauthorized to false", () => {
68-
sut.setAuthorized();
69-
expect(sut.isUnauthorized).toBeFalsy();
63+
describe("Test suite for setUnauthorized", () => {
64+
it("should set isUnauthorized to true", () => {
65+
sut.setUnauthorized();
66+
expect(sut.isUnauthorized).toBeTruthy();
67+
});
7068
});
71-
});
72-
describe("Test suite for getIsUnauthorized", () => {
73-
it("should return the object of isUnauthorized", () => {
74-
expect(sut.getIsUnauthorized()).toBeTruthy();
69+
describe("Test suite for setAuthorized", () => {
70+
it("should set isUnauthorized to false", () => {
71+
sut.setAuthorized();
72+
expect(sut.isUnauthorized).toBeFalsy();
73+
});
74+
});
75+
describe("Test suite for getIsUnauthorized", () => {
76+
it("should return the object of isUnauthorized", () => {
77+
expect(sut.getIsUnauthorized()).toBeTruthy();
78+
});
7579
});
7680
});
7781
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
/**
2+
* This program and the accompanying materials are made available under the terms of the
3+
* Eclipse Public License v2.0 which accompanies this distribution, and is available at
4+
* https://www.eclipse.org/legal/epl-v20.html
5+
*
6+
* SPDX-License-Identifier: EPL-2.0
7+
*
8+
* Copyright Contributors to the Zowe Project.
9+
*
10+
*/
11+
12+
const getIconFilePathFromNameMock = jest.fn();
13+
14+
import { imperative } from "@zowe/zowe-explorer-api";
15+
import { CICSSessionTree } from "../../../src/trees/CICSSessionTree";
16+
17+
jest.mock("../../../src/utils/iconUtils", () => {
18+
return { getIconFilePathFromName: getIconFilePathFromNameMock };
19+
});
20+
21+
describe("Test suite for CICSSessionTree", () => {
22+
let sut: CICSSessionTree;
23+
let ses: imperative.Session;
24+
25+
const cicsProfileMock = {
26+
failNotFound: false,
27+
message: "",
28+
name: "A NAME",
29+
profile: {
30+
host: "a.b.c.d",
31+
port: 12345,
32+
rejectUnauthorized: false,
33+
protocol: "http",
34+
user: "A USER",
35+
password: "A PASSWORD",
36+
},
37+
type: "cics"
38+
};
39+
40+
describe("cookies", () => {
41+
42+
beforeEach(() => {
43+
sut = new CICSSessionTree(cicsProfileMock);
44+
});
45+
46+
afterEach(() => {
47+
jest.resetAllMocks();
48+
});
49+
50+
it("Should not store invalid cookie", () => {
51+
const cookie = {
52+
Cookie: "blah=hello"
53+
};
54+
55+
ses = sut.getSession();
56+
ses.storeCookie(cookie);
57+
58+
expect(ses.ISession.tokenType).toEqual("LtpaToken2");
59+
expect(ses.ISession.tokenValue).toBeUndefined();
60+
});
61+
62+
it("Should store valid cookie", () => {
63+
const cookies = {
64+
Cookie: "LtpaToken2=testValue"
65+
};
66+
67+
sut = new CICSSessionTree(cicsProfileMock);
68+
ses = sut.getSession();
69+
70+
ses.storeCookie(cookies);
71+
72+
expect(ses.ISession.tokenType).toEqual("LtpaToken2");
73+
expect(ses.ISession.tokenValue).toEqual("testValue");
74+
});
75+
76+
it("Should store valid cookie if more the one returned", () => {
77+
const cookies = {
78+
Cookie: "blah=hello;LtpaToken2=testValue"
79+
};
80+
81+
sut = new CICSSessionTree(cicsProfileMock);
82+
ses = sut.getSession();
83+
84+
ses.storeCookie(cookies);
85+
86+
expect(ses.ISession.tokenType).toEqual("LtpaToken2");
87+
expect(ses.ISession.tokenValue).toEqual("testValue");
88+
});
89+
});
90+
});

packages/vsce/src/commands/closeLocalFileCommand.ts

+11-14
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
*/
1111

12-
import { CicsCmciConstants, CicsCmciRestClient, ICMCIApiResponse, Utils, IGetResourceUriOptions } from "@zowe/cics-for-zowe-sdk";
12+
import { CicsCmciConstants, ICMCIApiResponse } from "@zowe/cics-for-zowe-sdk";
1313
import { imperative } from "@zowe/zowe-explorer-api";
1414
import { commands, ProgressLocation, TreeView, window } from "vscode";
1515
import { CICSCombinedLocalFileTree } from "../trees/CICSCombinedTrees/CICSCombinedLocalFileTree";
@@ -19,6 +19,7 @@ import { CICSTree } from "../trees/CICSTree";
1919
import { CICSLocalFileTreeItem } from "../trees/treeItems/CICSLocalFileTreeItem";
2020
import { findSelectedNodes, splitCmciErrorMessage } from "../utils/commandUtils";
2121
import { ICommandParams } from "./ICommandParams";
22+
import { runPutResource } from "../utils/resourceUtils";
2223
import constants from "../utils/constants";
2324

2425
export function getCloseLocalFileCommand(tree: CICSTree, treeview: TreeView<any>) {
@@ -116,12 +117,18 @@ export function getCloseLocalFileCommand(tree: CICSTree, treeview: TreeView<any>
116117
});
117118
}
118119

119-
function closeLocalFile(
120+
async function closeLocalFile(
120121
session: imperative.AbstractSession,
121122
parms: ICommandParams,
122123
busyDecision: string
123124
): Promise<ICMCIApiResponse> {
124-
const requestBody: any = {
125+
return runPutResource({
126+
session: session,
127+
resourceName: CicsCmciConstants.CICS_CMCI_LOCAL_FILE,
128+
cicsPlex: parms.cicsPlex,
129+
regionName: parms.regionName,
130+
params: {"criteria": `FILE='${parms.name}'`}
131+
}, {
125132
request: {
126133
action: {
127134
$: {
@@ -135,15 +142,5 @@ function closeLocalFile(
135142
},
136143
},
137144
},
138-
};
139-
140-
const options: IGetResourceUriOptions = {
141-
"cicsPlex": parms.cicsPlex,
142-
"regionName": parms.regionName,
143-
"criteria": `FILE='${parms.name}'`
144-
};
145-
146-
const cmciResource = Utils.getResourceUri(CicsCmciConstants.CICS_CMCI_LOCAL_FILE, options);
147-
148-
return CicsCmciRestClient.putExpectParsedXml(session, cmciResource, [], requestBody);
145+
});
149146
}

packages/vsce/src/commands/disableCommands/disableLocalFileCommand.ts

+11-14
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
*/
1111

12-
import { CicsCmciConstants, CicsCmciRestClient, ICMCIApiResponse, Utils, IGetResourceUriOptions } from "@zowe/cics-for-zowe-sdk";
12+
import { CicsCmciConstants, ICMCIApiResponse } from "@zowe/cics-for-zowe-sdk";
1313
import { imperative } from "@zowe/zowe-explorer-api";
1414
import { commands, ProgressLocation, TreeView, window } from "vscode";
1515
import { CICSCombinedLocalFileTree } from "../../trees/CICSCombinedTrees/CICSCombinedLocalFileTree";
@@ -20,6 +20,7 @@ import { findSelectedNodes } from "../../utils/commandUtils";
2020
import { ICommandParams } from "../ICommandParams";
2121
import { CICSLocalFileTreeItem } from "../../trees/treeItems/CICSLocalFileTreeItem";
2222
import constants from "../../utils/constants";
23+
import { runPutResource } from "../../utils/resourceUtils";
2324

2425
export function getDisableLocalFileCommand(tree: CICSTree, treeview: TreeView<any>) {
2526
return commands.registerCommand("cics-extension-for-zowe.disableLocalFile", async (clickedNode) => {
@@ -110,7 +111,13 @@ function disableLocalFile(
110111
parms: ICommandParams,
111112
busyDecision: string
112113
): Promise<ICMCIApiResponse> {
113-
const requestBody: any = {
114+
return runPutResource({
115+
session: session,
116+
resourceName: CicsCmciConstants.CICS_CMCI_LOCAL_FILE,
117+
cicsPlex: parms.cicsPlex,
118+
regionName: parms.regionName,
119+
params: {"criteria": `FILE='${parms.name}'`}
120+
}, {
114121
request: {
115122
action: {
116123
$: {
@@ -123,16 +130,6 @@ function disableLocalFile(
123130
},
124131
},
125132
},
126-
},
127-
};
128-
129-
const options: IGetResourceUriOptions = {
130-
"cicsPlex": parms.cicsPlex,
131-
"regionName": parms.regionName,
132-
"criteria": `FILE='${parms.name}'`
133-
};
134-
135-
const cmciResource = Utils.getResourceUri(CicsCmciConstants.CICS_CMCI_LOCAL_FILE, options);
136-
137-
return CicsCmciRestClient.putExpectParsedXml(session, cmciResource, [], requestBody);
133+
}
134+
});
138135
}

0 commit comments

Comments
 (0)