Skip to content

Commit 38df8f5

Browse files
laerobgajjala8
authored andcommitted
feat(cli): Add support for password credential in redis helper (#6213)
1 parent 0443a52 commit 38df8f5

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

testing/internal/e2e/boundary/credential.go

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,41 @@ func CreateStaticCredentialUsernamePasswordCli(t testing.TB, ctx context.Context
238238
return credentialId, nil
239239
}
240240

241+
// CreateStaticCredentialPasswordCli uses the cli to create a new password credential in the
242+
// provided static credential store.
243+
// Returns the id of the new credential
244+
func CreateStaticCredentialPasswordCli(t testing.TB, ctx context.Context, credentialStoreId string, password string) (string, error) {
245+
name, err := base62.Random(16)
246+
if err != nil {
247+
return "", err
248+
}
249+
250+
output := e2e.RunCommand(ctx, "boundary",
251+
e2e.WithArgs(
252+
"credentials", "create", "password",
253+
"-credential-store-id", credentialStoreId,
254+
"-password", "env://E2E_CREDENTIALS_PASSWORD",
255+
"-name", fmt.Sprintf("e2e Credential %s", name),
256+
"-description", "e2e",
257+
"-format", "json",
258+
),
259+
e2e.WithEnv("E2E_CREDENTIALS_PASSWORD", password),
260+
)
261+
if output.Err != nil {
262+
return "", fmt.Errorf("%w: %s", output.Err, string(output.Stderr))
263+
}
264+
265+
var createCredentialsResult credentials.CredentialCreateResult
266+
err = json.Unmarshal(output.Stdout, &createCredentialsResult)
267+
if err != nil {
268+
return "", err
269+
}
270+
271+
credentialId := createCredentialsResult.Item.Id
272+
t.Logf("Created Password Credential: %s", credentialId)
273+
return credentialId, nil
274+
}
275+
241276
// CreateStaticCredentialUsernamePasswordDomainCli uses the cli to create a new username password domain credential in the
242277
// provided static credential store.
243278
// Returns the id of the new credential

testing/internal/e2e/tests/base/target_tcp_connect_redis_username_password_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ func TestCliTcpTargetConnectRedisUsernamePassword(t *testing.T) {
5050

5151
storeId, err := boundary.CreateCredentialStoreStaticCli(t, ctx, projectId)
5252
require.NoError(t, err)
53-
5453
credentialId, err := boundary.CreateStaticCredentialUsernamePasswordCli(
5554
t,
5655
ctx,

0 commit comments

Comments
 (0)