Skip to content

Add option to store sftp password. #574

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

Merged
merged 2 commits into from
Feb 2, 2023
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
9 changes: 8 additions & 1 deletion vscode-plugin/src/client/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,18 @@ export class Client {
if (this.noConnectionEstablishedBefore) {
this.noConnectionEstablishedBefore = false;
await this.events.onDidConnectFirstTimeEventEmitter.fire();
await Promise.all([
this.provideLogChannel(),
this.provideGTestChannel()
]);
}
if (!this.isConnectionEstablished()) {
messages.showInfoMessage(messages.successfullyConnected);
logger.info('Successfully connected to server');
await Promise.all([
this.provideLogChannel(),
this.provideGTestChannel()
]);
}
if (this.newClient || !response.getLinked()) {
await Promise.all([
Expand Down Expand Up @@ -238,7 +246,6 @@ export class Client {

private async writeGTestLog(responseAny: any): Promise<void> {
const gtestEntry = responseAny as LogEntry;
utbotUI.channels().outputGTestChannel.show(true);
utbotUI.channels().outputGTestChannel.appendLine(gtestEntry.getMessage());
}

Expand Down
9 changes: 7 additions & 2 deletions vscode-plugin/src/config/defaultValues.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,15 @@ export class DefaultConfigValues {
return username.toString();
}

public static getDefaultSFTPPassword(): string{
public static async getDefaultSFTPPassword(): Promise<string | undefined> {
const password = vsUtils.getFromSftpConfig("password");
if ((password === undefined) || (password.length === 0)) {
return "utbot";
vs.window.createInputBox().show();
const passwordInput = vs.window.showInputBox({
password: true,
title: "Password",
}) ?? '';
return passwordInput;
}
return password.toString();
}
Expand Down
13 changes: 9 additions & 4 deletions vscode-plugin/src/wizard/wizard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,18 @@ export class UtbotWizardPanel {
break;
}
else if (message.command.startsWith(`SFTP_`)) {
let password = await defcfg.DefaultConfigValues.getDefaultSFTPPassword();
const username = defcfg.DefaultConfigValues.getDefaultSFTPUsername().toString();
if (password === undefined){
password = '';
}
this.pingSFTPAction(
message.host,
message.port,
message.command + '_success',
message.command + '_failure');
message.command + '_failure',
password.toString(),
username);
break;
}
}
Expand Down Expand Up @@ -269,10 +276,8 @@ export class UtbotWizardPanel {
}

private lastSFTPRequest: Promise<any> | null = null;
private pingSFTPAction(host: string, port: number, successCmd: string, failureCmd: string): void {
private pingSFTPAction(host: string, port: number, successCmd: string, failureCmd: string, password: string, username: 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,
Expand Down