Skip to content

Commit

Permalink
refact(e2e): Consolidate tests (#4569)
Browse files Browse the repository at this point in the history
* refact(e2e): Move -remote-command check into ssh test

* refact(e2e): Remove duplicate test

* fix(e2e): Modify unnecessary use of Logf

* fix(e2e): Add error checks

* fix(e2e): Remove unused parameter
  • Loading branch information
moduli authored Mar 27, 2024
1 parent e0305f1 commit 8533433
Show file tree
Hide file tree
Showing 12 changed files with 36 additions and 266 deletions.
4 changes: 2 additions & 2 deletions testing/internal/e2e/tests/aws/worker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func TestCliWorker(t *testing.T) {
require.Error(t, output.Err, string(output.Stderr))
assert.Equal(t, 255, output.ExitCode)
require.Contains(t, string(output.Stderr), "timed out")
t.Logf("Successfully detected connection failure")
t.Log("Successfully detected connection failure")

// Set correct worker filter, expect connection success
t.Logf("Setting correct worker filter...")
Expand Down Expand Up @@ -94,5 +94,5 @@ func TestCliWorker(t *testing.T) {
),
)
require.NoError(t, output.Err, string(output.Stderr))
t.Logf("Successfully connected to target")
t.Log("Successfully connected to target")
}
2 changes: 1 addition & 1 deletion testing/internal/e2e/tests/base/auth_token_delete_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,5 +83,5 @@ func TestUserIsLoggedOutWhenAuthTokenIsDeletedCli(t *testing.T) {

// Expect error as the user got logged out
require.Error(t, output.Err, fmt.Sprintf("User '%s' is still logged in", testAccountName))
t.Logf("Successfully verified that token name is invalid")
t.Log("Successfully verified that token name is invalid")
}
9 changes: 6 additions & 3 deletions testing/internal/e2e/tests/base/authenticate_primary_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,12 @@ func TestCliAuthenticatePrimary(t *testing.T) {
require.NoError(t, err)
})

f.Write([]byte(bc.AdminLoginName + "\n"))
f.Write([]byte(bc.AdminLoginPassword + "\n"))
f.Write([]byte{4}) // EOT (End of Transmission - marks end of file stream)
_, err = f.Write([]byte(bc.AdminLoginName + "\n"))
require.NoError(t, err)
_, err = f.Write([]byte(bc.AdminLoginPassword + "\n"))
require.NoError(t, err)
_, err = f.Write([]byte{4}) // EOT (End of Transmission - marks end of file stream)
require.NoError(t, err)

// Get last line from output (authentication response)
var buf bytes.Buffer
Expand Down
2 changes: 1 addition & 1 deletion testing/internal/e2e/tests/base/credential_store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ func TestCliStaticCredentialStore(t *testing.T) {
},
)
require.NoError(t, err)
t.Logf("Successfully deleted credential store")
t.Log("Successfully deleted credential store")
}

func createPrivateKeyPemFile(fileName string) error {
Expand Down
3 changes: 2 additions & 1 deletion testing/internal/e2e/tests/base/paginate_session_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@ func TestApiPaginateSessions(t *testing.T) {
// Create enough sessions to overflow a single page
for i := 0; i < c.MaxPageSize+1; i++ {
// boundary.ConnectCli(t, ctx, newTargetId)
tClient.AuthorizeSession(ctx, newTargetId)
_, err := tClient.AuthorizeSession(ctx, newTargetId)
require.NoError(t, err)
}

// List sessions
Expand Down

This file was deleted.

17 changes: 17 additions & 0 deletions testing/internal/e2e/tests/base/target_tcp_connect_ssh_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"context"
"encoding/json"
"os"
"strings"
"testing"

"github.com/hashicorp/boundary/api/targets"
Expand Down Expand Up @@ -77,4 +78,20 @@ func TestCliTcpTargetConnectTargetWithSsh(t *testing.T) {
)
require.NoError(t, output.Err, string(output.Stderr))
t.Log("Successfully connected to target")

// Connect to target using ssh option with remote command
output = e2e.RunCommand(ctx, "boundary",
e2e.WithArgs(
"connect", "ssh",
"-target-id", newTargetId,
"-remote-command", "hostname -i",
"--",
"-o", "UserKnownHostsFile=/dev/null",
"-o", "StrictHostKeyChecking=no",
"-o", "IdentitiesOnly=yes", // forces the use of the provided key
),
)
require.NoError(t, output.Err, string(output.Stderr))
require.Equal(t, c.TargetAddress, strings.TrimSpace(string(output.Stdout)))
t.Log("Successfully connected to target")
}
4 changes: 2 additions & 2 deletions testing/internal/e2e/tests/base_plus/key_destruction_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ func TestCliKeyDestruction(t *testing.T) {
}
}

t.Logf("Successfully destroyed a root key and data key")
t.Log("Successfully destroyed a root key and data key")
}

// TestApiKeyDestruction uses the boundary Go api to test key destruction.
Expand Down Expand Up @@ -359,5 +359,5 @@ func TestApiKeyDestruction(t *testing.T) {
}
}

t.Logf("Successfully destroyed a root key and data key")
t.Log("Successfully destroyed a root key and data key")
}
4 changes: 2 additions & 2 deletions testing/internal/e2e/tests/base_plus/rate_limit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ func TestHttpRateLimit(t *testing.T) {
time.Sleep(time.Duration(retryAfter) * time.Second)

// Do another request. Verify that request is successful
t.Logf("Retrying...")
t.Log("Retrying...")
requestURL = fmt.Sprintf("%s/v1/hosts/%s", bc.Address, newHostId)
req, err = http.NewRequest(http.MethodGet, requestURL, nil)
require.NoError(t, err)
Expand Down Expand Up @@ -394,7 +394,7 @@ func TestCliRateLimit(t *testing.T) {
require.NoError(t, output.Err, string(output.Stderr))
require.Equal(t, 0, output.ExitCode)
}
t.Logf("Successfully auto-retried CLI request")
t.Log("Successfully auto-retried CLI request")
}

func getRateLimitStat(rateLimitHeader, stat string) (int, error) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func TestCliTcpTargetConnectPostgres(t *testing.T) {
require.NoError(t, err)

var buf bytes.Buffer
io.Copy(&buf, f)
_, _ = io.Copy(&buf, f)
require.Contains(t, buf.String(), "List of relations", "Session did not return expected output")
require.Contains(t, buf.String(), c.PostgresDbName, "Session did not return expected output")
t.Log("Successfully connected to target")
Expand Down

This file was deleted.

Loading

0 comments on commit 8533433

Please sign in to comment.