Skip to content

Commit 17bf7e7

Browse files
authored
Add option to store sftp password. (#574)
Add opportunity to enter sftp password in pop-up window.
1 parent fd3ad0d commit 17bf7e7

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

vscode-plugin/src/config/defaultValues.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,15 @@ export class DefaultConfigValues {
6060
return username.toString();
6161
}
6262

63-
public static getDefaultSFTPPassword(): string{
63+
public static async getDefaultSFTPPassword(): Promise<string | undefined> {
6464
const password = vsUtils.getFromSftpConfig("password");
6565
if ((password === undefined) || (password.length === 0)) {
66-
return "utbot";
66+
vs.window.createInputBox().show();
67+
const passwordInput = vs.window.showInputBox({
68+
password: true,
69+
title: "Password",
70+
}) ?? '';
71+
return passwordInput;
6772
}
6873
return password.toString();
6974
}

vscode-plugin/src/wizard/wizard.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,18 @@ export class UtbotWizardPanel {
103103
break;
104104
}
105105
else if (message.command.startsWith(`SFTP_`)) {
106+
let password = await defcfg.DefaultConfigValues.getDefaultSFTPPassword();
107+
const username = defcfg.DefaultConfigValues.getDefaultSFTPUsername().toString();
108+
if (password === undefined){
109+
password = '';
110+
}
106111
this.pingSFTPAction(
107112
message.host,
108113
message.port,
109114
message.command + '_success',
110-
message.command + '_failure');
115+
message.command + '_failure',
116+
password.toString(),
117+
username);
111118
break;
112119
}
113120
}
@@ -269,10 +276,8 @@ export class UtbotWizardPanel {
269276
}
270277

271278
private lastSFTPRequest: Promise<any> | null = null;
272-
private pingSFTPAction(host: string, port: number, successCmd: string, failureCmd: string): void {
279+
private pingSFTPAction(host: string, port: number, successCmd: string, failureCmd: string, password: string, username: string): void {
273280
const ssh = new NodeSSH();
274-
const username = defcfg.DefaultConfigValues.getDefaultSFTPUsername().toString();
275-
const password = defcfg.DefaultConfigValues.getDefaultSFTPPassword().toString();
276281
const capturedPingPromiseForLambda = ssh.connect({
277282
host: host,
278283
port: port,

0 commit comments

Comments
 (0)