test(e2e): Add some other commands to execute over localhost (#4016)
This commit is contained in:
1 parent
12600617ba
commit
8e83cc87d3
1 file changed
+50
@@ -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()
|
||||
|
||||
Reference in new issue
Block a user