Skip to content

Commit 372531d

Browse files
authored
Merge pull request #540 from KxSystems/ee-auth
Pass connection labels to custom auth
2 parents e337765 + 3cbbbbd commit 372531d

File tree

7 files changed

+26
-15
lines changed

7 files changed

+26
-15
lines changed

src/classes/localConnection.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import { QueryResult, QueryResultType } from "../models/queryResult";
2222
export class LocalConnection {
2323
public connected: boolean;
2424
public connLabel: string;
25+
public labels: string[];
2526
private options: nodeq.ConnectionParameters;
2627
private connection?: nodeq.Connection;
2728
private isError: boolean = false;
@@ -30,6 +31,7 @@ export class LocalConnection {
3031
constructor(
3132
connectionString: string,
3233
connLabel: string,
34+
labels: string[],
3335
creds?: string[],
3436
tls?: boolean,
3537
) {
@@ -62,6 +64,7 @@ export class LocalConnection {
6264
}
6365

6466
this.connLabel = connLabel;
67+
this.labels = labels;
6568
this.options = options;
6669
this.connected = false;
6770
}
@@ -373,7 +376,8 @@ export class LocalConnection {
373376
async getCustomAuthOptions(): Promise<nodeq.ConnectionParameters> {
374377
if (ext.customAuth) {
375378
const { kdb } = await ext.customAuth.auth({
376-
label: this.connLabel,
379+
name: this.connLabel,
380+
labels: this.labels,
377381
kdb: {
378382
host: this.options.host,
379383
port: this.options.port,

src/models/customAuth.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
*/
1313

1414
export interface CustomAuthParams {
15-
label: string;
15+
name: string;
16+
labels: string[];
1617
kdb?: {
1718
host?: string;
1819
port?: number;

src/services/connectionManagerService.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ export class ConnectionManagementService {
137137
const localConnection = new LocalConnection(
138138
connectionString,
139139
connLabel,
140+
retrieveConnLabelsNames(connection),
140141
authCredentials ? authCredentials.split(":") : undefined,
141142
connection.details.tls,
142143
);

test/suite/classes.test.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ describe("LocalConnection", () => {
2525
let getConnectionStub: sinon.SinonStub;
2626

2727
beforeEach(() => {
28-
localConn = new LocalConnection("127.0.0.1:5001", "testLabel");
28+
localConn = new LocalConnection("127.0.0.1:5001", "testLabel", []);
2929
connectStub = sinon.stub(localConn, "connect");
3030
disconnectStub = sinon.stub(localConn, "disconnect");
3131
getConnectionStub = sinon.stub(localConn, "getConnection");
@@ -38,7 +38,7 @@ describe("LocalConnection", () => {
3838
});
3939

4040
it("Should create a new connection object", () => {
41-
const conn = new LocalConnection("server:5001", "server1");
41+
const conn = new LocalConnection("server:5001", "server1", []);
4242
assert.strictEqual(
4343
conn.connected,
4444
false,
@@ -50,6 +50,7 @@ describe("LocalConnection", () => {
5050
const conn = new LocalConnection(
5151
"server:5001",
5252
"server1",
53+
[],
5354
["username", "password"],
5455
true,
5556
);
@@ -61,7 +62,7 @@ describe("LocalConnection", () => {
6162
});
6263

6364
it("Should create a new connection object", () => {
64-
const conn = new LocalConnection("server:5001", "server1");
65+
const conn = new LocalConnection("server:5001", "server1", []);
6566
conn.disconnect();
6667
assert.strictEqual(
6768
conn.connected,

test/suite/commands.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ describe("dataSourceCommand", () => {
8787

8888
describe("dataSourceCommand2", () => {
8989
let dummyDataSourceFiles: DataSourceFiles;
90-
const localConn = new LocalConnection("localhost:5001", "test");
90+
const localConn = new LocalConnection("localhost:5001", "test", []);
9191
const insightsNode = new InsightsNode(
9292
[],
9393
"insightsnode1",
@@ -1937,7 +1937,7 @@ describe("serverCommand", () => {
19371937
insightsNode.label,
19381938
insightsNode,
19391939
);
1940-
const localConn = new LocalConnection("localhost:5001", "server1");
1940+
const localConn = new LocalConnection("localhost:5001", "server1", []);
19411941
beforeEach(() => {
19421942
isVisibleStub = sinon.stub(ext.resultsViewProvider, "isVisible");
19431943
executeQueryStub = sinon.stub(connMangService, "executeQuery");

test/suite/services.test.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1059,7 +1059,7 @@ describe("connectionManagerService", () => {
10591059
);
10601060
ext.serverProvider = new KdbTreeProvider(servers, insights);
10611061

1062-
const localConn = new LocalConnection("127.0.0.1:5001", "testLabel");
1062+
const localConn = new LocalConnection("127.0.0.1:5001", "testLabel", []);
10631063

10641064
const insightsConn = new InsightsConnection(insightNode.label, insightNode);
10651065
describe("retrieveConnection", () => {
@@ -1322,7 +1322,11 @@ describe("connectionManagerService", () => {
13221322
});
13231323

13241324
it("disconnectBehaviour", () => {
1325-
const testConnection = new LocalConnection("localhost:5001", "server1");
1325+
const testConnection = new LocalConnection(
1326+
"localhost:5001",
1327+
"server1",
1328+
[],
1329+
);
13261330
ext.connectedConnectionList.push(testConnection);
13271331
ext.activeConnection = testConnection;
13281332

@@ -2089,7 +2093,7 @@ describe("dataSourceEditorProvider", () => {
20892093
insightsNode.label,
20902094
insightsNode,
20912095
);
2092-
const localConn = new LocalConnection("127.0.0.1:5001", "testLabel");
2096+
const localConn = new LocalConnection("127.0.0.1:5001", "testLabel", []);
20932097
const connMngService = new ConnectionManagementService();
20942098
let isConnetedStub, retrieveConnectedConnectionStub: sinon.SinonStub;
20952099
beforeEach(() => {
@@ -2530,15 +2534,15 @@ describe("kdbTreeService", () => {
25302534
});
25312535

25322536
it("Should return sorted views", async () => {
2533-
ext.activeConnection = new LocalConnection("localhost:5001", "server1");
2537+
ext.activeConnection = new LocalConnection("localhost:5001", "server1", []);
25342538
sinon.stub(ext.activeConnection, "executeQuery").resolves(["vw1", "vw2"]);
25352539
const result = await KdbTreeService.loadViews();
25362540
assert.strictEqual(result[0], "vw1", "Should return the first view");
25372541
sinon.restore();
25382542
});
25392543

25402544
it("Should return sorted views (reverse order)", async () => {
2541-
ext.activeConnection = new LocalConnection("localhost:5001", "server1");
2545+
ext.activeConnection = new LocalConnection("localhost:5001", "server1", []);
25422546
sinon.stub(ext.activeConnection, "executeQuery").resolves(["vw1", "vw2"]);
25432547
const result = await KdbTreeService.loadViews();
25442548
assert.strictEqual(result[0], "vw1", "Should return the first view");

test/suite/utils.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ describe("Utils", () => {
221221
});
222222

223223
describe("getServerIconState", () => {
224-
const localConn = new LocalConnection("127.0.0.1:5001", "testLabel");
224+
const localConn = new LocalConnection("127.0.0.1:5001", "testLabel", []);
225225
afterEach(() => {
226226
ext.activeConnection = undefined;
227227
ext.connectedConnectionList.length = 0;
@@ -248,7 +248,7 @@ describe("Utils", () => {
248248
});
249249

250250
describe("getStatus", () => {
251-
const localConn = new LocalConnection("127.0.0.1:5001", "testLabel");
251+
const localConn = new LocalConnection("127.0.0.1:5001", "testLabel", []);
252252

253253
afterEach(() => {
254254
ext.activeConnection = undefined;
@@ -276,7 +276,7 @@ describe("Utils", () => {
276276
});
277277

278278
describe("getWorkspaceIconsState", () => {
279-
const localConn = new LocalConnection("127.0.0.1:5001", "testLabel");
279+
const localConn = new LocalConnection("127.0.0.1:5001", "testLabel", []);
280280
afterEach(() => {
281281
ext.connectedConnectionList.length = 0;
282282
});

0 commit comments

Comments
 (0)