Skip to content

Commit 7a3eb2a

Browse files
committed
Some cleanup
Signed-off-by: enam-khan <[email protected]>
1 parent fd79504 commit 7a3eb2a

File tree

4 files changed

+18
-52
lines changed

4 files changed

+18
-52
lines changed

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

+4-29
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ describe("Test suite for CICSSessionTree", () => {
3636

3737
describe("validation", () => {
3838
beforeEach(() => {
39-
cst = new CICSSessionTree(cicsProfileMock, undefined, getIconFilePathFromName("profile"));
39+
cst = new CICSSessionTree(cicsProfileMock, getIconFilePathFromName("profile"));
4040
ses = cst.getSession();
4141
});
4242

@@ -98,7 +98,7 @@ describe("Test suite for CICSSessionTree", () => {
9898
Cookie: "blah=hello"
9999
};
100100

101-
cst = new CICSSessionTree(cicsProfileMock, undefined, getIconFilePathFromName("profile"));
101+
cst = new CICSSessionTree(cicsProfileMock, getIconFilePathFromName("profile"));
102102
ses = cst.getSession();
103103

104104
ses.storeCookie(cookie);
@@ -112,7 +112,7 @@ describe("Test suite for CICSSessionTree", () => {
112112
Cookie: "LtpaToken2=testValue"
113113
};
114114

115-
cst = new CICSSessionTree(cicsProfileMock, undefined, getIconFilePathFromName("profile"));
115+
cst = new CICSSessionTree(cicsProfileMock, getIconFilePathFromName("profile"));
116116
ses = cst.getSession();
117117

118118
ses.storeCookie(cookies);
@@ -126,32 +126,7 @@ describe("Test suite for CICSSessionTree", () => {
126126
Cookie: "blah=hello;LtpaToken2=testValue"
127127
};
128128

129-
cst = new CICSSessionTree(cicsProfileMock, undefined, getIconFilePathFromName("profile"));
130-
ses = cst.getSession();
131-
132-
ses.storeCookie(cookies);
133-
134-
expect(ses.ISession.tokenType).toEqual("LtpaToken2");
135-
expect(ses.ISession.tokenValue).toEqual("testValue");
136-
});
137-
138-
139-
it("Should store valid cookie if the session is provided", () => {
140-
const cookies = {
141-
Cookie: "blah=hello;LtpaToken2=testValue"
142-
};
143-
144-
const mockSession = new imperative.Session({
145-
type: SessConstants.AUTH_TYPE_TOKEN,
146-
storeCookie: true,
147-
tokenType: SessConstants.TOKEN_TYPE_LTPA,
148-
hostname: cicsProfileMock.profile.host,
149-
port: Number(cicsProfileMock.profile.port),
150-
user: cicsProfileMock.profile.user || "",
151-
password: cicsProfileMock.profile.password || "",
152-
rejectUnauthorized: cicsProfileMock.profile.rejectUnauthorized});
153-
154-
cst = new CICSSessionTree(cicsProfileMock, mockSession, getIconFilePathFromName("profile"));
129+
cst = new CICSSessionTree(cicsProfileMock, getIconFilePathFromName("profile"));
155130
ses = cst.getSession();
156131

157132
ses.storeCookie(cookies);

packages/vsce/src/extension.ts

+1-5
Original file line numberDiff line numberDiff line change
@@ -122,11 +122,7 @@ export async function activate(context: ExtensionContext) {
122122
try {
123123
plexExpansionHandler(node.element, treeDataProv);
124124
} catch (error) {
125-
const newSessionTree = new CICSSessionTree(
126-
node.element.getParent().profile,
127-
node.element.getParent().getSession(),
128-
getIconFilePathFromName("profile-disconnected"));
129-
treeDataProv.loadedProfiles.splice(treeDataProv.getLoadedProfiles().indexOf(node.element.getParent()), 1, newSessionTree);
125+
node.element.getParent().iconPath = getIconFilePathFromName("profile-disconnected");
130126
treeDataProv._onDidChangeTreeData.fire(undefined);
131127
}
132128
},

packages/vsce/src/trees/CICSSessionTree.ts

+11-16
Original file line numberDiff line numberDiff line change
@@ -24,28 +24,23 @@ export class CICSSessionTree extends TreeItem {
2424

2525
constructor(
2626
profile: any,
27-
session?: Session,
2827
public readonly iconPath = getIconFilePathFromName("profile-unverified"),
2928
) {
3029
super(profile.name, TreeItemCollapsibleState.Collapsed);
3130
this.children = [];
3231
this.contextValue = `cicssession.${profile.name}`;
3332

34-
if (session) {
35-
this.session = session;
36-
} else {
37-
this.session = new imperative.Session({
38-
type: SessConstants.AUTH_TYPE_TOKEN,
39-
storeCookie: true,
40-
tokenType: SessConstants.TOKEN_TYPE_LTPA,
41-
hostname: profile.profile!.host,
42-
port: Number(profile.profile!.port),
43-
user: profile.profile!.user || "",
44-
password: profile.profile!.password || "",
45-
rejectUnauthorized: profile.profile!.rejectUnauthorized,
46-
protocol: profile.profile!.protocol,
47-
});
48-
}
33+
this.session = new imperative.Session({
34+
type: SessConstants.AUTH_TYPE_TOKEN,
35+
storeCookie: true,
36+
tokenType: SessConstants.TOKEN_TYPE_LTPA,
37+
hostname: profile.profile!.host,
38+
port: Number(profile.profile!.port),
39+
user: profile.profile!.user || "",
40+
password: profile.profile!.password || "",
41+
rejectUnauthorized: profile.profile!.rejectUnauthorized,
42+
protocol: profile.profile!.protocol,
43+
});
4944

5045
this.profile = profile;
5146
this.isUnauthorized = undefined;

packages/vsce/src/trees/CICSTree.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ export class CICSTree implements TreeDataProvider<CICSSessionTree> {
267267
}
268268

269269
// Initialise session tree
270-
newSessionTree = new CICSSessionTree(profile, undefined, getIconFilePathFromName("profile"));
270+
newSessionTree = new CICSSessionTree(profile, getIconFilePathFromName("profile"));
271271
const plexInfo: InfoLoaded[] = await ProfileManagement.getPlexInfo(profile, newSessionTree.getSession());
272272

273273
// For each InfoLoaded object - happens if there are multiple plexes
@@ -315,7 +315,7 @@ export class CICSTree implements TreeDataProvider<CICSSessionTree> {
315315
this._onDidChangeTreeData.fire(undefined);
316316
} catch (error) {
317317
// Change session tree icon to disconnected upon error
318-
newSessionTree = new CICSSessionTree(profile, undefined, getIconFilePathFromName("profile-disconnected"));
318+
newSessionTree = new CICSSessionTree(profile, getIconFilePathFromName("profile-disconnected"));
319319
// If method was called when expanding profile
320320
if (sessionTree) {
321321
this.loadedProfiles.splice(position, 1, newSessionTree);

0 commit comments

Comments
 (0)