test(e2e): Updated testing helper functions for rdp tests (#6686)

* test(e2e): Updated testing helper functions for rdp tests
This commit is contained in:
dillanb-hashi authored and GitHub committed 2026-05-06 13:56:30 -07:00
1 parent d76a3de802
commit 0396adc690
2 files changed
+26 -6

No files matched your search

+10 -2
View File
@@ -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))
}
+16 -4
View File
@@ -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))
}