diff --git a/testing/internal/e2e/boundary/account.go b/testing/internal/e2e/boundary/account.go index 952135071..ee0973eb5 100644 --- a/testing/internal/e2e/boundary/account.go +++ b/testing/internal/e2e/boundary/account.go @@ -45,15 +45,18 @@ func CreateAccountApi(t testing.TB, ctx context.Context, client *api.Client, aut // CreateAccountCli creates a new account using the cli. // Returns the id of the new account as well as the password that was generated -func CreateAccountCli(t testing.TB, ctx context.Context, authMethodId string, loginName string) (string, string, error) { +func CreateAccountCli(t testing.TB, ctx context.Context, authMethodId string, loginName string, opt ...e2e.Option) (string, string, error) { name, err := base62.Random(16) if err != nil { return "", "", err } + var options []e2e.Option + password, err := base62.Random(16) require.NoError(t, err) - output := e2e.RunCommand(ctx, "boundary", + + options = append(options, e2e.WithArgs( "accounts", "create", "password", "-auth-method-id", authMethodId, @@ -65,6 +68,11 @@ func CreateAccountCli(t testing.TB, ctx context.Context, authMethodId string, lo ), e2e.WithEnv("E2E_TEST_ACCOUNT_PASSWORD", password), ) + options = append(options, opt...) + + output := e2e.RunCommand(ctx, "boundary", + options..., + ) if output.Err != nil { return "", "", fmt.Errorf("%w: %s", output.Err, string(output.Stderr)) } diff --git a/testing/internal/e2e/boundary/user.go b/testing/internal/e2e/boundary/user.go index 3f76c45e3..e45850ce4 100644 --- a/testing/internal/e2e/boundary/user.go +++ b/testing/internal/e2e/boundary/user.go @@ -36,13 +36,14 @@ func CreateUserApi(t testing.TB, ctx context.Context, client *api.Client, scopeI // CreateUserCli creates a new user using the cli. // Returns the id of the new user -func CreateUserCli(t testing.TB, ctx context.Context, scopeId string) (string, error) { +func CreateUserCli(t testing.TB, ctx context.Context, scopeId string, opt ...e2e.Option) (string, error) { name, err := base62.Random(16) if err != nil { return "", err } - output := e2e.RunCommand(ctx, "boundary", + var options []e2e.Option + options = append(options, e2e.WithArgs( "users", "create", "-scope-id", scopeId, @@ -51,6 +52,11 @@ func CreateUserCli(t testing.TB, ctx context.Context, scopeId string) (string, e "-format", "json", ), ) + options = append(options, opt...) + + output := e2e.RunCommand(ctx, "boundary", + options..., + ) if output.Err != nil { return "", fmt.Errorf("%w: %s", output.Err, string(output.Stderr)) } @@ -67,14 +73,20 @@ func CreateUserCli(t testing.TB, ctx context.Context, scopeId string) (string, e } // SetAccountToUserCli sets an account to a the specified user using the cli. -func SetAccountToUserCli(t testing.TB, ctx context.Context, userId string, accountId string) error { - output := e2e.RunCommand(ctx, "boundary", +func SetAccountToUserCli(t testing.TB, ctx context.Context, userId string, accountId string, opt ...e2e.Option) error { + var options []e2e.Option + options = append(options, e2e.WithArgs( "users", "set-accounts", "-id", userId, "-account", accountId, ), ) + options = append(options, opt...) + + output := e2e.RunCommand(ctx, "boundary", + options..., + ) if output.Err != nil { return fmt.Errorf("%w: %s", output.Err, string(output.Stderr)) }