test(e2e): Add some other commands to execute over localhost (#4016)

pull/4022/head
Michael Li 3 years ago committed by GitHub
parent 12600617ba
commit 8e83cc87d3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -74,6 +74,56 @@ func TestCliTcpTargetConnectTargetWithLocalhost(t *testing.T) {
)
require.NoError(t, output.Err, string(output.Stderr))
require.Equal(t, c.TargetAddress, strings.TrimSpace(string(output.Stdout)))
require.Equal(t, 0, output.ExitCode)
// Run a bash command
output = e2e.RunCommand(ctx, "ssh",
e2e.WithArgs(
"localhost",
"-p", port,
"-l", c.TargetSshUser,
"-i", c.TargetSshKeyPath,
"-o", "UserKnownHostsFile=/dev/null",
"-o", "StrictHostKeyChecking=no",
"-o", "IdentitiesOnly=yes", // forces the use of the provided key
"bash -c 'mkdir /tmp/hello && rmdir /tmp/hello'",
),
)
require.NoError(t, output.Err, string(output.Stderr))
require.Equal(t, 0, output.ExitCode)
// Run another bash command
output = e2e.RunCommand(ctx, "ssh",
e2e.WithArgs(
"localhost",
"-p", port,
"-l", c.TargetSshUser,
"-i", c.TargetSshKeyPath,
"-o", "UserKnownHostsFile=/dev/null",
"-o", "StrictHostKeyChecking=no",
"-o", "IdentitiesOnly=yes", // forces the use of the provided key
"bash -c 'echo hello'",
),
)
require.NoError(t, output.Err, string(output.Stderr))
require.Equal(t, "hello", strings.TrimSpace(string(output.Stdout)))
require.Equal(t, 0, output.ExitCode)
// Run a command with exit code of 1
output = e2e.RunCommand(ctx, "ssh",
e2e.WithArgs(
"localhost",
"-p", port,
"-l", c.TargetSshUser,
"-i", c.TargetSshKeyPath,
"-o", "UserKnownHostsFile=/dev/null",
"-o", "StrictHostKeyChecking=no",
"-o", "IdentitiesOnly=yes", // forces the use of the provided key
"rm test.txt",
),
)
require.Error(t, output.Err, string(output.Stderr))
require.Equal(t, 1, output.ExitCode) // rm: cannot remove 'test.txt': No such file or directory
// Cancel session
cancel()

Loading…
Cancel
Save