diff --git a/testing/internal/e2e/boundary/credential.go b/testing/internal/e2e/boundary/credential.go index 3cd2edfda4..399b2a2d93 100644 --- a/testing/internal/e2e/boundary/credential.go +++ b/testing/internal/e2e/boundary/credential.go @@ -142,3 +142,19 @@ func CreateNewStaticCredentialJsonCli(t testing.TB, ctx context.Context, credent return newCredentialsId } + +// CreateNewStaticCredentialPasswordApi uses the API to create a new password credential in the +// provided static credential store. +// Returns the id of the new credential +func CreateNewStaticCredentialPasswordApi(t testing.TB, ctx context.Context, client *api.Client, credentialStoreId string, user string, password string) string { + c := credentials.NewClient(client) + newCredentialsResult, err := c.Create(ctx, "username_password", credentialStoreId, + credentials.WithUsernamePasswordCredentialUsername(user), + credentials.WithUsernamePasswordCredentialPassword(password), + ) + require.NoError(t, err) + newCredentialsId := newCredentialsResult.Item.Id + t.Logf("Created Username/Password Credentials: %s", newCredentialsId) + + return newCredentialsId +}