Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix wizard bugs #566

Merged
merged 3 commits into from
Dec 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions vscode-plugin/media/wizardHTML.js
Original file line number Diff line number Diff line change
Expand Up @@ -302,10 +302,18 @@ function defaultValidateForEmptyValue() {
function validateForm() {
let valid = true;
if (isStartTab()) {
// call them all - we need to mark all invalid input
valid &= isPluginInstalledAndMarkValid("SFTP_")
valid &= isPluginInstalledAndMarkValid("SARIF_");
} else if (isConnectionTab()) {
if (!isPluginInstalledAndMarkValid("SFTP_")){
vscode.postMessage({
command: 'check_sftp_on_start'
});;
}
if(!isPluginInstalledAndMarkValid("SARIF_")){
vscode.postMessage({
command: 'check_sarif_on_start'
});;
}
}
if (isConnectionTab()) {
// call them all - we need to mark all invalid input
valid &= isConnectionPortValid($("portGRPCInput"), GRPC_PREFIX);
valid &= isConnectionPortValid($("portSFTPInput"), SFTP_PREFIX);
Expand Down
16 changes: 16 additions & 0 deletions vscode-plugin/src/config/defaultValues.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,22 @@ export class DefaultConfigValues {
return DefaultConfigValues.DEFAULT_SFTP_PORT;
}

public static getDefaultSFTPUsername(): string{
const username = vsUtils.getFromSftpConfig("username");
if ((username === undefined) || (username.length === 0)) {
return "utbot";
}
return username.toString();
}

public static getDefaultSFTPPassword(): string{
const password = vsUtils.getFromSftpConfig("password");
if ((password === undefined) || (password.length === 0)) {
return "utbot";
}
return password.toString();
}

public static getDefaultRemotePath(): string {
let remotePath = Prefs.getRemotePath();
if (remotePath.length === 0) {
Expand Down
19 changes: 17 additions & 2 deletions vscode-plugin/src/wizard/wizard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,12 @@ export class UtbotWizardPanel {
//logger.info(`check_plugins`);
this.checkPlugins();
break;
case 'check_sftp_on_start':
this.checkSFTPOnStart();
break;
case 'check_sarif_on_start':
this.checkSARIFOnStart();
break;
default: {
if (message.command.endsWith('test_connection')) {
//messages.showErrorMessage(`!!!!!! message (${message.command}) from WizardWebView: ${message}`);
Expand Down Expand Up @@ -122,6 +128,13 @@ export class UtbotWizardPanel {
sarifPluginInstalled: !!vs.extensions.getExtension(messages.defaultSARIFViewer)
});
}
private checkSFTPOnStart(): void {
messages.showWarningMessage(messages.installSFTP);
}

private checkSARIFOnStart(): void {
messages.showWarningMessage(messages.installSARIFViewer);
}

private static GENERATED = "This file is automatically generated by UnitTestBot.";
private async setupSFTP(
Expand Down Expand Up @@ -258,11 +271,13 @@ export class UtbotWizardPanel {
private lastSFTPRequest: Promise<any> | null = null;
private pingSFTPAction(host: string, port: number, successCmd: string, failureCmd: string): void {
const ssh = new NodeSSH();
const username = defcfg.DefaultConfigValues.getDefaultSFTPUsername().toString();
const password = defcfg.DefaultConfigValues.getDefaultSFTPPassword().toString();
const capturedPingPromiseForLambda = ssh.connect({
host: host,
port: port,
username: 'utbot',
password: 'utbot'
username: username,
password: password
});
this.lastSFTPRequest = capturedPingPromiseForLambda;
capturedPingPromiseForLambda.then( async () => {
Expand Down