mirror of
https://github.com/google/cdc-file-transfer.git
synced 2026-09-13 01:10:44 +03:00
[RemoteUtil] Fix output from Windows SSH commands (#90)
Adds an ArchType argument to many RemoteUtil methods, which is used to replace -tt (forced pseudo-TTY allocation) by -T (no pseudo-TTY allocation). The -tt option adds tons of ANSI escape sequences to the output and makes it unparsable, even after removing the sequences, as some sequences like "delete the last X characters" are not honoured. An exception is BuildProcessStartInfoForSshPortForward, where replacing -tt by -T would make the port forwarding process exit immediately.
This commit is contained in:
@@ -59,8 +59,12 @@ class RemoteUtilTest : public ::testing::Test {
|
||||
};
|
||||
|
||||
TEST_F(RemoteUtilTest, BuildProcessStartInfoForSsh) {
|
||||
ProcessStartInfo si = util_.BuildProcessStartInfoForSsh(kCommand);
|
||||
ExpectContains(si.command, {"ssh", kUserHostArg, kCommand});
|
||||
ProcessStartInfo si =
|
||||
util_.BuildProcessStartInfoForSsh(kCommand, ArchType::kLinux_x86_64);
|
||||
ExpectContains(si.command, {"ssh", "-tt", kUserHostArg, kCommand});
|
||||
|
||||
si = util_.BuildProcessStartInfoForSsh(kCommand, ArchType::kWindows_x86_64);
|
||||
ExpectContains(si.command, {"ssh", "-T", kUserHostArg, kCommand});
|
||||
}
|
||||
|
||||
TEST_F(RemoteUtilTest, BuildProcessStartInfoForSshPortForward) {
|
||||
@@ -75,19 +79,20 @@ TEST_F(RemoteUtilTest, BuildProcessStartInfoForSshPortForward) {
|
||||
|
||||
TEST_F(RemoteUtilTest, BuildProcessStartInfoForSshPortForwardAndCommand) {
|
||||
ProcessStartInfo si = util_.BuildProcessStartInfoForSshPortForwardAndCommand(
|
||||
kLocalPort, kRemotePort, kRegular, kCommand);
|
||||
kLocalPort, kRemotePort, kRegular, kCommand, ArchType::kLinux_x86_64);
|
||||
ExpectContains(si.command,
|
||||
{"ssh", kUserHostArg, kPortForwardingArg, kCommand});
|
||||
|
||||
si = util_.BuildProcessStartInfoForSshPortForwardAndCommand(
|
||||
kLocalPort, kRemotePort, kReverse, kCommand);
|
||||
kLocalPort, kRemotePort, kReverse, kCommand, ArchType::kLinux_x86_64);
|
||||
ExpectContains(si.command,
|
||||
{"ssh", kUserHostArg, kReversePortForwardingArg, kCommand});
|
||||
}
|
||||
TEST_F(RemoteUtilTest, BuildProcessStartInfoForSshWithCustomCommand) {
|
||||
constexpr char kCustomSshCmd[] = "C:\\path\\to\\ssh.exe --fooarg --bararg=42";
|
||||
util_.SetSshCommand(kCustomSshCmd);
|
||||
ProcessStartInfo si = util_.BuildProcessStartInfoForSsh(kCommand);
|
||||
ProcessStartInfo si =
|
||||
util_.BuildProcessStartInfoForSsh(kCommand, ArchType::kLinux_x86_64);
|
||||
ExpectContains(si.command, {kCustomSshCmd});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user