From 57ffc71849385ed3f019d9e2d3bfbb0a493565cb Mon Sep 17 00:00:00 2001 From: Michael Li Date: Tue, 25 Oct 2022 15:46:10 -0400 Subject: [PATCH] refact(e2e): Add context as an argument for cli methods This was done have some alignment with the corresponding api methods as well as matching standard Go conventions. --- testing/internal/e2e/boundary/account.go | 5 ++- testing/internal/e2e/boundary/boundary.go | 8 ++--- testing/internal/e2e/boundary/credential.go | 4 +-- testing/internal/e2e/boundary/host.go | 16 +++++----- testing/internal/e2e/boundary/scope.go | 8 ++--- testing/internal/e2e/boundary/target.go | 8 ++--- testing/internal/e2e/boundary/user.go | 9 +++--- .../e2e/credential/vault/vault_test.go | 21 ++++++------ .../e2e/host/aws/dynamichostcatalog_test.go | 12 +++---- .../host/static/connect_authz_token_test.go | 22 ++++++------- .../e2e/host/static/connect_ssh_test.go | 22 ++++++------- .../internal/e2e/host/static/connect_test.go | 20 ++++++------ .../host/static/session_cancel_admin_test.go | 20 ++++++------ .../host/static/session_cancel_user_test.go | 32 +++++++++---------- .../static/static_credential_store_test.go | 10 +++--- 15 files changed, 107 insertions(+), 110 deletions(-) diff --git a/testing/internal/e2e/boundary/account.go b/testing/internal/e2e/boundary/account.go index d91625c1d4..aa297aea31 100644 --- a/testing/internal/e2e/boundary/account.go +++ b/testing/internal/e2e/boundary/account.go @@ -39,11 +39,10 @@ func CreateNewAccountApi(t testing.TB, ctx context.Context, client *api.Client, // CreateNewAccountCli creates a new account using the cli. // Returns the id of the new account as well as the password that was generated -func CreateNewAccountCli(t testing.TB, loginName string) (string, string) { +func CreateNewAccountCli(t testing.TB, ctx context.Context, loginName string) (string, string) { c, err := loadConfig() require.NoError(t, err) - ctx := context.Background() password, err := base62.Random(16) require.NoError(t, err) output := e2e.RunCommand(ctx, "boundary", @@ -66,7 +65,7 @@ func CreateNewAccountCli(t testing.TB, loginName string) (string, string) { newAccountId := newAccountResult.Item.Id t.Cleanup(func() { - AuthenticateAdminCli(t) + AuthenticateAdminCli(t, context.Background()) output := e2e.RunCommand(ctx, "boundary", e2e.WithArgs("accounts", "delete", "-id", newAccountId), ) diff --git a/testing/internal/e2e/boundary/boundary.go b/testing/internal/e2e/boundary/boundary.go index d4a035d009..e972362b68 100644 --- a/testing/internal/e2e/boundary/boundary.go +++ b/testing/internal/e2e/boundary/boundary.go @@ -60,19 +60,19 @@ func NewApiClient() (*api.Client, error) { } // AuthenticateAdminCli uses the cli to authenticate the specified Boundary instance as an admin -func AuthenticateAdminCli(t testing.TB) { +func AuthenticateAdminCli(t testing.TB, ctx context.Context) { c, err := loadConfig() require.NoError(t, err) - AuthenticateCli(t, c.AdminLoginName, c.AdminLoginPassword) + AuthenticateCli(t, ctx, c.AdminLoginName, c.AdminLoginPassword) } // AuthenticateCli uses the cli to authenticate the specified Boundary instance -func AuthenticateCli(t testing.TB, loginName string, password string) { +func AuthenticateCli(t testing.TB, ctx context.Context, loginName string, password string) { c, err := loadConfig() require.NoError(t, err) - output := e2e.RunCommand(context.Background(), "boundary", + output := e2e.RunCommand(ctx, "boundary", e2e.WithArgs( "authenticate", "password", "-addr", c.Address, diff --git a/testing/internal/e2e/boundary/credential.go b/testing/internal/e2e/boundary/credential.go index 5170ff3ab8..51189afe1a 100644 --- a/testing/internal/e2e/boundary/credential.go +++ b/testing/internal/e2e/boundary/credential.go @@ -25,8 +25,8 @@ func CreateNewCredentialStoreStaticApi(t testing.TB, ctx context.Context, client // CreateNewCredentialStoreStaticCli creates a new static credential store using the cli. // Returns the id of the new credential store -func CreateNewCredentialStoreStaticCli(t testing.TB, projectId string) string { - output := e2e.RunCommand(context.Background(), "boundary", +func CreateNewCredentialStoreStaticCli(t testing.TB, ctx context.Context, projectId string) string { + output := e2e.RunCommand(ctx, "boundary", e2e.WithArgs( "credential-stores", "create", "static", "-scope-id", projectId, diff --git a/testing/internal/e2e/boundary/host.go b/testing/internal/e2e/boundary/host.go index ec2c8ac52d..9f01e3d07c 100644 --- a/testing/internal/e2e/boundary/host.go +++ b/testing/internal/e2e/boundary/host.go @@ -61,8 +61,8 @@ func AddHostToHostSetApi(t testing.TB, ctx context.Context, client *api.Client, // CreateNewHostCatalogCli creates a new host catalog in boundary using the cli. // Returns the id of the new host catalog. -func CreateNewHostCatalogCli(t testing.TB, projectId string) string { - output := e2e.RunCommand(context.Background(), "boundary", +func CreateNewHostCatalogCli(t testing.TB, ctx context.Context, projectId string) string { + output := e2e.RunCommand(ctx, "boundary", e2e.WithArgs( "host-catalogs", "create", "static", "-scope-id", projectId, @@ -82,8 +82,8 @@ func CreateNewHostCatalogCli(t testing.TB, projectId string) string { // CreateNewHostSetCli creates a new host set in boundary using the cli. // Returns the id of the new host set. -func CreateNewHostSetCli(t testing.TB, hostCatalogId string) string { - output := e2e.RunCommand(context.Background(), "boundary", +func CreateNewHostSetCli(t testing.TB, ctx context.Context, hostCatalogId string) string { + output := e2e.RunCommand(ctx, "boundary", e2e.WithArgs( "host-sets", "create", "static", "-host-catalog-id", hostCatalogId, @@ -103,8 +103,8 @@ func CreateNewHostSetCli(t testing.TB, hostCatalogId string) string { // CreateNewHostCli creates a new host in boundary using the cli. // Returns the id of the new host. -func CreateNewHostCli(t testing.TB, hostCatalogId string, address string) string { - output := e2e.RunCommand(context.Background(), "boundary", +func CreateNewHostCli(t testing.TB, ctx context.Context, hostCatalogId string, address string) string { + output := e2e.RunCommand(ctx, "boundary", e2e.WithArgs( "hosts", "create", "static", "-host-catalog-id", hostCatalogId, @@ -124,8 +124,8 @@ func CreateNewHostCli(t testing.TB, hostCatalogId string, address string) string } // AddHostToHostSetCli adds a host to a host set using the cli -func AddHostToHostSetCli(t testing.TB, hostSetId string, hostId string) { - output := e2e.RunCommand(context.Background(), "boundary", +func AddHostToHostSetCli(t testing.TB, ctx context.Context, hostSetId string, hostId string) { + output := e2e.RunCommand(ctx, "boundary", e2e.WithArgs("host-sets", "add-hosts", "-id", hostSetId, "-host", hostId), ) require.NoError(t, output.Err, string(output.Stderr)) diff --git a/testing/internal/e2e/boundary/scope.go b/testing/internal/e2e/boundary/scope.go index 7745bdf4aa..5e48300ad9 100644 --- a/testing/internal/e2e/boundary/scope.go +++ b/testing/internal/e2e/boundary/scope.go @@ -43,8 +43,7 @@ func CreateNewProjectApi(t testing.TB, ctx context.Context, client *api.Client, // CreateNewOrgCli creates a new organization in boundary using the cli. // Returns the id of the new org. -func CreateNewOrgCli(t testing.TB) string { - ctx := context.Background() +func CreateNewOrgCli(t testing.TB, ctx context.Context) string { output := e2e.RunCommand(ctx, "boundary", e2e.WithArgs( "scopes", "create", @@ -61,7 +60,7 @@ func CreateNewOrgCli(t testing.TB) string { newOrgId := newOrgResult.Item.Id t.Cleanup(func() { - AuthenticateAdminCli(t) + AuthenticateAdminCli(t, context.Background()) output := e2e.RunCommand(ctx, "boundary", e2e.WithArgs("scopes", "delete", "-id", newOrgId), ) @@ -75,8 +74,7 @@ func CreateNewOrgCli(t testing.TB) string { // CreateNewProjectCli creates a new project in boundary using the cli. The project will be created // under the provided org id. // Returns the id of the new project. -func CreateNewProjectCli(t testing.TB, orgId string) string { - ctx := context.Background() +func CreateNewProjectCli(t testing.TB, ctx context.Context, orgId string) string { output := e2e.RunCommand(ctx, "boundary", e2e.WithArgs( "scopes", "create", diff --git a/testing/internal/e2e/boundary/target.go b/testing/internal/e2e/boundary/target.go index 4829f6ba74..44ea8ba094 100644 --- a/testing/internal/e2e/boundary/target.go +++ b/testing/internal/e2e/boundary/target.go @@ -41,8 +41,8 @@ func AddHostSourceToTargetApi(t testing.TB, ctx context.Context, client *api.Cli // CreateNewTargetCli creates a new target in boundary using the cli // Returns the id of the new target. -func CreateNewTargetCli(t testing.TB, projectId string, defaultPort string) string { - output := e2e.RunCommand(context.Background(), "boundary", +func CreateNewTargetCli(t testing.TB, ctx context.Context, projectId string, defaultPort string) string { + output := e2e.RunCommand(ctx, "boundary", e2e.WithArgs( "targets", "create", "tcp", "-scope-id", projectId, @@ -62,8 +62,8 @@ func CreateNewTargetCli(t testing.TB, projectId string, defaultPort string) stri } // AddHostSourceToTargetCli adds a host source (host set or host) to a target using the cli -func AddHostSourceToTargetCli(t testing.TB, targetId string, hostSourceId string) { - output := e2e.RunCommand(context.Background(), "boundary", +func AddHostSourceToTargetCli(t testing.TB, ctx context.Context, targetId string, hostSourceId string) { + output := e2e.RunCommand(ctx, "boundary", e2e.WithArgs("targets", "add-host-sources", "-id", targetId, "-host-source", hostSourceId), ) require.NoError(t, output.Err, string(output.Stderr)) diff --git a/testing/internal/e2e/boundary/user.go b/testing/internal/e2e/boundary/user.go index 1a9273624d..b018811d52 100644 --- a/testing/internal/e2e/boundary/user.go +++ b/testing/internal/e2e/boundary/user.go @@ -29,8 +29,7 @@ func CreateNewUserApi(t testing.TB, ctx context.Context, client *api.Client, sco // CreateNewUserCli creates a new user using the cli. // Returns the id of the new user -func CreateNewUserCli(t testing.TB, scopeId string) string { - ctx := context.Background() +func CreateNewUserCli(t testing.TB, ctx context.Context, scopeId string) string { output := e2e.RunCommand(ctx, "boundary", e2e.WithArgs( "users", "create", @@ -48,7 +47,7 @@ func CreateNewUserCli(t testing.TB, scopeId string) string { newUserId := newUserResult.Item.Id t.Cleanup(func() { - AuthenticateAdminCli(t) + AuthenticateAdminCli(t, context.Background()) output := e2e.RunCommand(ctx, "boundary", e2e.WithArgs("users", "delete", "-id", newUserId), ) @@ -60,8 +59,8 @@ func CreateNewUserCli(t testing.TB, scopeId string) string { } // SetAccountToUserCli sets an account to a the specified user using the cli. -func SetAccountToUserCli(t testing.TB, userId string, accountId string) { - output := e2e.RunCommand(context.Background(), "boundary", +func SetAccountToUserCli(t testing.TB, ctx context.Context, userId string, accountId string) { + output := e2e.RunCommand(ctx, "boundary", e2e.WithArgs( "users", "set-accounts", "-id", userId, diff --git a/testing/internal/e2e/credential/vault/vault_test.go b/testing/internal/e2e/credential/vault/vault_test.go index 01ee565467..a927b4e95f 100644 --- a/testing/internal/e2e/credential/vault/vault_test.go +++ b/testing/internal/e2e/credential/vault/vault_test.go @@ -52,18 +52,19 @@ func TestCreateVaultCredentialStoreCli(t *testing.T) { c, err := loadConfig() require.NoError(t, err) - boundary.AuthenticateAdminCli(t) - newOrgId := boundary.CreateNewOrgCli(t) - newProjectId := boundary.CreateNewProjectCli(t, newOrgId) - newHostCatalogId := boundary.CreateNewHostCatalogCli(t, newProjectId) - newHostSetId := boundary.CreateNewHostSetCli(t, newHostCatalogId) - newHostId := boundary.CreateNewHostCli(t, newHostCatalogId, c.TargetIp) - boundary.AddHostToHostSetCli(t, newHostSetId, newHostId) - newTargetId := boundary.CreateNewTargetCli(t, newProjectId, c.TargetPort) - boundary.AddHostSourceToTargetCli(t, newTargetId, newHostSetId) + ctx := context.Background() + boundary.AuthenticateAdminCli(t, ctx) + newOrgId := boundary.CreateNewOrgCli(t, ctx) + newProjectId := boundary.CreateNewProjectCli(t, ctx, newOrgId) + newHostCatalogId := boundary.CreateNewHostCatalogCli(t, ctx, newProjectId) + newHostSetId := boundary.CreateNewHostSetCli(t, ctx, newHostCatalogId) + newHostId := boundary.CreateNewHostCli(t, ctx, newHostCatalogId, c.TargetIp) + boundary.AddHostToHostSetCli(t, ctx, newHostSetId, newHostId) + newTargetId := boundary.CreateNewTargetCli(t, ctx, newProjectId, c.TargetPort) + boundary.AddHostSourceToTargetCli(t, ctx, newTargetId, newHostSetId) // Configure vault - ctx := context.Background() + vaultAddr, boundaryPolicyName := vault.Setup(t) output := e2e.RunCommand(ctx, "vault", diff --git a/testing/internal/e2e/host/aws/dynamichostcatalog_test.go b/testing/internal/e2e/host/aws/dynamichostcatalog_test.go index 80ea4f1421..627ab30158 100644 --- a/testing/internal/e2e/host/aws/dynamichostcatalog_test.go +++ b/testing/internal/e2e/host/aws/dynamichostcatalog_test.go @@ -50,12 +50,12 @@ func TestCreateAwsDynamicHostCatalogCli(t *testing.T) { c, err := loadConfig() require.NoError(t, err) - boundary.AuthenticateAdminCli(t) - newOrgId := boundary.CreateNewOrgCli(t) - newProjectId := boundary.CreateNewProjectCli(t, newOrgId) + ctx := context.Background() + boundary.AuthenticateAdminCli(t, ctx) + newOrgId := boundary.CreateNewOrgCli(t, ctx) + newProjectId := boundary.CreateNewProjectCli(t, ctx, newOrgId) // Create a dynamic host catalog - ctx := context.Background() output := e2e.RunCommand(ctx, "boundary", e2e.WithArgs( "host-catalogs", "create", "plugin", @@ -228,8 +228,8 @@ func TestCreateAwsDynamicHostCatalogCli(t *testing.T) { assert.Equal(t, expectedHostCatalogCount, actualHostCatalogCount, "Numbers of hosts in host catalog did not match expected amount") // Create target - newTargetId := boundary.CreateNewTargetCli(t, newProjectId, c.TargetPort) - boundary.AddHostSourceToTargetCli(t, newTargetId, newHostSetId1) + newTargetId := boundary.CreateNewTargetCli(t, ctx, newProjectId, c.TargetPort) + boundary.AddHostSourceToTargetCli(t, ctx, newTargetId, newHostSetId1) // Connect to target output = e2e.RunCommand(ctx, "boundary", diff --git a/testing/internal/e2e/host/static/connect_authz_token_test.go b/testing/internal/e2e/host/static/connect_authz_token_test.go index a0e49c0247..a0a54e5adb 100644 --- a/testing/internal/e2e/host/static/connect_authz_token_test.go +++ b/testing/internal/e2e/host/static/connect_authz_token_test.go @@ -23,19 +23,19 @@ func TestConnectTargetWithAuthzTokenCli(t *testing.T) { c, err := loadConfig() require.NoError(t, err) - boundary.AuthenticateAdminCli(t) - newOrgId := boundary.CreateNewOrgCli(t) - newProjectId := boundary.CreateNewProjectCli(t, newOrgId) - newHostCatalogId := boundary.CreateNewHostCatalogCli(t, newProjectId) - newHostSetId := boundary.CreateNewHostSetCli(t, newHostCatalogId) - newHostId := boundary.CreateNewHostCli(t, newHostCatalogId, c.TargetIp) - boundary.AddHostToHostSetCli(t, newHostSetId, newHostId) - newTargetId := boundary.CreateNewTargetCli(t, newProjectId, c.TargetPort) - boundary.AddHostSourceToTargetCli(t, newTargetId, newHostSetId) - newCredentialStoreId := boundary.CreateNewCredentialStoreStaticCli(t, newProjectId) + ctx := context.Background() + boundary.AuthenticateAdminCli(t, ctx) + newOrgId := boundary.CreateNewOrgCli(t, ctx) + newProjectId := boundary.CreateNewProjectCli(t, ctx, newOrgId) + newHostCatalogId := boundary.CreateNewHostCatalogCli(t, ctx, newProjectId) + newHostSetId := boundary.CreateNewHostSetCli(t, ctx, newHostCatalogId) + newHostId := boundary.CreateNewHostCli(t, ctx, newHostCatalogId, c.TargetIp) + boundary.AddHostToHostSetCli(t, ctx, newHostSetId, newHostId) + newTargetId := boundary.CreateNewTargetCli(t, ctx, newProjectId, c.TargetPort) + boundary.AddHostSourceToTargetCli(t, ctx, newTargetId, newHostSetId) + newCredentialStoreId := boundary.CreateNewCredentialStoreStaticCli(t, ctx, newProjectId) // Create credentials - ctx := context.Background() output := e2e.RunCommand(ctx, "boundary", e2e.WithArgs( "credentials", "create", "ssh-private-key", diff --git a/testing/internal/e2e/host/static/connect_ssh_test.go b/testing/internal/e2e/host/static/connect_ssh_test.go index 54a6656348..d06871f6eb 100644 --- a/testing/internal/e2e/host/static/connect_ssh_test.go +++ b/testing/internal/e2e/host/static/connect_ssh_test.go @@ -23,19 +23,19 @@ func TestConnectTargetWithSshCli(t *testing.T) { c, err := loadConfig() require.NoError(t, err) - boundary.AuthenticateAdminCli(t) - newOrgId := boundary.CreateNewOrgCli(t) - newProjectId := boundary.CreateNewProjectCli(t, newOrgId) - newHostCatalogId := boundary.CreateNewHostCatalogCli(t, newProjectId) - newHostSetId := boundary.CreateNewHostSetCli(t, newHostCatalogId) - newHostId := boundary.CreateNewHostCli(t, newHostCatalogId, c.TargetIp) - boundary.AddHostToHostSetCli(t, newHostSetId, newHostId) - newTargetId := boundary.CreateNewTargetCli(t, newProjectId, c.TargetPort) - boundary.AddHostSourceToTargetCli(t, newTargetId, newHostSetId) - newCredentialStoreId := boundary.CreateNewCredentialStoreStaticCli(t, newProjectId) + ctx := context.Background() + boundary.AuthenticateAdminCli(t, ctx) + newOrgId := boundary.CreateNewOrgCli(t, ctx) + newProjectId := boundary.CreateNewProjectCli(t, ctx, newOrgId) + newHostCatalogId := boundary.CreateNewHostCatalogCli(t, ctx, newProjectId) + newHostSetId := boundary.CreateNewHostSetCli(t, ctx, newHostCatalogId) + newHostId := boundary.CreateNewHostCli(t, ctx, newHostCatalogId, c.TargetIp) + boundary.AddHostToHostSetCli(t, ctx, newHostSetId, newHostId) + newTargetId := boundary.CreateNewTargetCli(t, ctx, newProjectId, c.TargetPort) + boundary.AddHostSourceToTargetCli(t, ctx, newTargetId, newHostSetId) + newCredentialStoreId := boundary.CreateNewCredentialStoreStaticCli(t, ctx, newProjectId) // Create credentials - ctx := context.Background() output := e2e.RunCommand(ctx, "boundary", e2e.WithArgs( "credentials", "create", "ssh-private-key", diff --git a/testing/internal/e2e/host/static/connect_test.go b/testing/internal/e2e/host/static/connect_test.go index 695e6512ca..85a5f0258d 100644 --- a/testing/internal/e2e/host/static/connect_test.go +++ b/testing/internal/e2e/host/static/connect_test.go @@ -18,18 +18,18 @@ func TestConnectTargetCli(t *testing.T) { c, err := loadConfig() require.NoError(t, err) - boundary.AuthenticateAdminCli(t) - newOrgId := boundary.CreateNewOrgCli(t) - newProjectId := boundary.CreateNewProjectCli(t, newOrgId) - newHostCatalogId := boundary.CreateNewHostCatalogCli(t, newProjectId) - newHostSetId := boundary.CreateNewHostSetCli(t, newHostCatalogId) - newHostId := boundary.CreateNewHostCli(t, newHostCatalogId, c.TargetIp) - boundary.AddHostToHostSetCli(t, newHostSetId, newHostId) - newTargetId := boundary.CreateNewTargetCli(t, newProjectId, c.TargetPort) - boundary.AddHostSourceToTargetCli(t, newTargetId, newHostSetId) + ctx := context.Background() + boundary.AuthenticateAdminCli(t, ctx) + newOrgId := boundary.CreateNewOrgCli(t, ctx) + newProjectId := boundary.CreateNewProjectCli(t, ctx, newOrgId) + newHostCatalogId := boundary.CreateNewHostCatalogCli(t, ctx, newProjectId) + newHostSetId := boundary.CreateNewHostSetCli(t, ctx, newHostCatalogId) + newHostId := boundary.CreateNewHostCli(t, ctx, newHostCatalogId, c.TargetIp) + boundary.AddHostToHostSetCli(t, ctx, newHostSetId, newHostId) + newTargetId := boundary.CreateNewTargetCli(t, ctx, newProjectId, c.TargetPort) + boundary.AddHostSourceToTargetCli(t, ctx, newTargetId, newHostSetId) // Connect to target and print host's IP address - ctx := context.Background() output := e2e.RunCommand(ctx, "boundary", e2e.WithArgs( "connect", diff --git a/testing/internal/e2e/host/static/session_cancel_admin_test.go b/testing/internal/e2e/host/static/session_cancel_admin_test.go index 0dfe7b2c5b..4b5aaf460b 100644 --- a/testing/internal/e2e/host/static/session_cancel_admin_test.go +++ b/testing/internal/e2e/host/static/session_cancel_admin_test.go @@ -21,15 +21,16 @@ func TestSessionCancelAdminCli(t *testing.T) { c, err := loadConfig() require.NoError(t, err) - boundary.AuthenticateAdminCli(t) - newOrgId := boundary.CreateNewOrgCli(t) - newProjectId := boundary.CreateNewProjectCli(t, newOrgId) - newHostCatalogId := boundary.CreateNewHostCatalogCli(t, newProjectId) - newHostSetId := boundary.CreateNewHostSetCli(t, newHostCatalogId) - newHostId := boundary.CreateNewHostCli(t, newHostCatalogId, c.TargetIp) - boundary.AddHostToHostSetCli(t, newHostSetId, newHostId) - newTargetId := boundary.CreateNewTargetCli(t, newProjectId, c.TargetPort) - boundary.AddHostSourceToTargetCli(t, newTargetId, newHostSetId) + ctx := context.Background() + boundary.AuthenticateAdminCli(t, ctx) + newOrgId := boundary.CreateNewOrgCli(t, ctx) + newProjectId := boundary.CreateNewProjectCli(t, ctx, newOrgId) + newHostCatalogId := boundary.CreateNewHostCatalogCli(t, ctx, newProjectId) + newHostSetId := boundary.CreateNewHostSetCli(t, ctx, newHostCatalogId) + newHostId := boundary.CreateNewHostCli(t, ctx, newHostCatalogId, c.TargetIp) + boundary.AddHostToHostSetCli(t, ctx, newHostSetId, newHostId) + newTargetId := boundary.CreateNewTargetCli(t, ctx, newProjectId, c.TargetPort) + boundary.AddHostSourceToTargetCli(t, ctx, newTargetId, newHostSetId) // Connect to target to create a session ctxCancel, cancel := context.WithCancel(context.Background()) @@ -55,7 +56,6 @@ func TestSessionCancelAdminCli(t *testing.T) { t.Cleanup(cancel) // Get list of sessions - ctx := context.Background() var session *sessions.Session err = backoff.RetryNotify( func() error { diff --git a/testing/internal/e2e/host/static/session_cancel_user_test.go b/testing/internal/e2e/host/static/session_cancel_user_test.go index 31b2798675..311bad08c2 100644 --- a/testing/internal/e2e/host/static/session_cancel_user_test.go +++ b/testing/internal/e2e/host/static/session_cancel_user_test.go @@ -25,23 +25,23 @@ func TestSessionCancelUserCli(t *testing.T) { c, err := loadConfig() require.NoError(t, err) - boundary.AuthenticateAdminCli(t) - newOrgId := boundary.CreateNewOrgCli(t) - newProjectId := boundary.CreateNewProjectCli(t, newOrgId) - newHostCatalogId := boundary.CreateNewHostCatalogCli(t, newProjectId) - newHostSetId := boundary.CreateNewHostSetCli(t, newHostCatalogId) - newHostId := boundary.CreateNewHostCli(t, newHostCatalogId, c.TargetIp) - boundary.AddHostToHostSetCli(t, newHostSetId, newHostId) - newTargetId := boundary.CreateNewTargetCli(t, newProjectId, c.TargetPort) - boundary.AddHostSourceToTargetCli(t, newTargetId, newHostSetId) + ctx := context.Background() + boundary.AuthenticateAdminCli(t, ctx) + newOrgId := boundary.CreateNewOrgCli(t, ctx) + newProjectId := boundary.CreateNewProjectCli(t, ctx, newOrgId) + newHostCatalogId := boundary.CreateNewHostCatalogCli(t, ctx, newProjectId) + newHostSetId := boundary.CreateNewHostSetCli(t, ctx, newHostCatalogId) + newHostId := boundary.CreateNewHostCli(t, ctx, newHostCatalogId, c.TargetIp) + boundary.AddHostToHostSetCli(t, ctx, newHostSetId, newHostId) + newTargetId := boundary.CreateNewTargetCli(t, ctx, newProjectId, c.TargetPort) + boundary.AddHostSourceToTargetCli(t, ctx, newTargetId, newHostSetId) acctName := "e2e-account" - newAccountId, acctPassword := boundary.CreateNewAccountCli(t, acctName) - newUserId := boundary.CreateNewUserCli(t, "global") - boundary.SetAccountToUserCli(t, newUserId, newAccountId) + newAccountId, acctPassword := boundary.CreateNewAccountCli(t, ctx, acctName) + newUserId := boundary.CreateNewUserCli(t, ctx, "global") + boundary.SetAccountToUserCli(t, ctx, newUserId, newAccountId) // Try to connect to the target as a user without permissions - ctx := context.Background() - boundary.AuthenticateCli(t, acctName, acctPassword) + boundary.AuthenticateCli(t, ctx, acctName, acctPassword) output := e2e.RunCommand(ctx, "boundary", e2e.WithArgs( "connect", @@ -66,7 +66,7 @@ func TestSessionCancelUserCli(t *testing.T) { t.Log("Successfully received an error when connecting to target as a user without permissions") // Create a role - boundary.AuthenticateAdminCli(t) + boundary.AuthenticateAdminCli(t, ctx) output = e2e.RunCommand(ctx, "boundary", e2e.WithArgs( "roles", "create", @@ -106,7 +106,7 @@ func TestSessionCancelUserCli(t *testing.T) { ctxCancel, cancel := context.WithCancel(context.Background()) errChan := make(chan *e2e.CommandResult) go func() { - boundary.AuthenticateCli(t, acctName, acctPassword) + boundary.AuthenticateCli(t, ctx, acctName, acctPassword) t.Log("Starting session as user...") errChan <- e2e.RunCommand(ctxCancel, "boundary", e2e.WithArgs( diff --git a/testing/internal/e2e/host/static/static_credential_store_test.go b/testing/internal/e2e/host/static/static_credential_store_test.go index 9107529972..43c6dae35e 100644 --- a/testing/internal/e2e/host/static/static_credential_store_test.go +++ b/testing/internal/e2e/host/static/static_credential_store_test.go @@ -20,13 +20,13 @@ func TestStaticCredentialStoreCli(t *testing.T) { c, err := loadConfig() require.NoError(t, err) - boundary.AuthenticateAdminCli(t) - newOrgId := boundary.CreateNewOrgCli(t) - newProjectId := boundary.CreateNewProjectCli(t, newOrgId) - newCredentialStoreId := boundary.CreateNewCredentialStoreStaticCli(t, newProjectId) + ctx := context.Background() + boundary.AuthenticateAdminCli(t, ctx) + newOrgId := boundary.CreateNewOrgCli(t, ctx) + newProjectId := boundary.CreateNewProjectCli(t, ctx, newOrgId) + newCredentialStoreId := boundary.CreateNewCredentialStoreStaticCli(t, ctx, newProjectId) // Create ssh key credentials - ctx := context.Background() output := e2e.RunCommand(ctx, "boundary", e2e.WithArgs( "credentials", "create", "ssh-private-key",