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.
This commit is contained in:
Michael Li committed 2022-10-25 16:23:52 -04:00
1 parent a956e8dec9
commit 57ffc71849
15 files changed
+107 -110

No files matched your search

@@ -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",
@@ -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",
@@ -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",
@@ -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 {
@@ -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(
@@ -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",