Skip to content

Commit 7d4cee9

Browse files
authored
Fix wizard bugs (#566)
* Add opportunity to skip plugins install page * Add opportunity to install own username/password from sftp.json * Add warning messages after start page if SFTP and SARIF are not installed.
1 parent e8a5e79 commit 7d4cee9

File tree

3 files changed

+45
-6
lines changed

3 files changed

+45
-6
lines changed

vscode-plugin/media/wizardHTML.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -302,10 +302,18 @@ function defaultValidateForEmptyValue() {
302302
function validateForm() {
303303
let valid = true;
304304
if (isStartTab()) {
305-
// call them all - we need to mark all invalid input
306-
valid &= isPluginInstalledAndMarkValid("SFTP_")
307-
valid &= isPluginInstalledAndMarkValid("SARIF_");
308-
} else if (isConnectionTab()) {
305+
if (!isPluginInstalledAndMarkValid("SFTP_")){
306+
vscode.postMessage({
307+
command: 'check_sftp_on_start'
308+
});;
309+
}
310+
if(!isPluginInstalledAndMarkValid("SARIF_")){
311+
vscode.postMessage({
312+
command: 'check_sarif_on_start'
313+
});;
314+
}
315+
}
316+
if (isConnectionTab()) {
309317
// call them all - we need to mark all invalid input
310318
valid &= isConnectionPortValid($("portGRPCInput"), GRPC_PREFIX);
311319
valid &= isConnectionPortValid($("portSFTPInput"), SFTP_PREFIX);

vscode-plugin/src/config/defaultValues.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,22 @@ export class DefaultConfigValues {
5252
return DefaultConfigValues.DEFAULT_SFTP_PORT;
5353
}
5454

55+
public static getDefaultSFTPUsername(): string{
56+
const username = vsUtils.getFromSftpConfig("username");
57+
if ((username === undefined) || (username.length === 0)) {
58+
return "utbot";
59+
}
60+
return username.toString();
61+
}
62+
63+
public static getDefaultSFTPPassword(): string{
64+
const password = vsUtils.getFromSftpConfig("password");
65+
if ((password === undefined) || (password.length === 0)) {
66+
return "utbot";
67+
}
68+
return password.toString();
69+
}
70+
5571
public static getDefaultRemotePath(): string {
5672
let remotePath = Prefs.getRemotePath();
5773
if (remotePath.length === 0) {

vscode-plugin/src/wizard/wizard.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,12 @@ export class UtbotWizardPanel {
8585
//logger.info(`check_plugins`);
8686
this.checkPlugins();
8787
break;
88+
case 'check_sftp_on_start':
89+
this.checkSFTPOnStart();
90+
break;
91+
case 'check_sarif_on_start':
92+
this.checkSARIFOnStart();
93+
break;
8894
default: {
8995
if (message.command.endsWith('test_connection')) {
9096
//messages.showErrorMessage(`!!!!!! message (${message.command}) from WizardWebView: ${message}`);
@@ -122,6 +128,13 @@ export class UtbotWizardPanel {
122128
sarifPluginInstalled: !!vs.extensions.getExtension(messages.defaultSARIFViewer)
123129
});
124130
}
131+
private checkSFTPOnStart(): void {
132+
messages.showWarningMessage(messages.installSFTP);
133+
}
134+
135+
private checkSARIFOnStart(): void {
136+
messages.showWarningMessage(messages.installSARIFViewer);
137+
}
125138

126139
private static GENERATED = "This file is automatically generated by UnitTestBot.";
127140
private async setupSFTP(
@@ -258,11 +271,13 @@ export class UtbotWizardPanel {
258271
private lastSFTPRequest: Promise<any> | null = null;
259272
private pingSFTPAction(host: string, port: number, successCmd: string, failureCmd: string): void {
260273
const ssh = new NodeSSH();
274+
const username = defcfg.DefaultConfigValues.getDefaultSFTPUsername().toString();
275+
const password = defcfg.DefaultConfigValues.getDefaultSFTPPassword().toString();
261276
const capturedPingPromiseForLambda = ssh.connect({
262277
host: host,
263278
port: port,
264-
username: 'utbot',
265-
password: 'utbot'
279+
username: username,
280+
password: password
266281
});
267282
this.lastSFTPRequest = capturedPingPromiseForLambda;
268283
capturedPingPromiseForLambda.then( async () => {

0 commit comments

Comments
 (0)