From 9047d5b22aaa3ceeee0f84ab7d1617d292da0a31 Mon Sep 17 00:00:00 2001 From: Johan Brandhorst-Satzkorn Date: Fri, 8 Dec 2023 15:41:05 -0800 Subject: [PATCH] testing/e2e: add credential store API helper --- testing/internal/e2e/boundary/credential.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/testing/internal/e2e/boundary/credential.go b/testing/internal/e2e/boundary/credential.go index 399b2a2d93..535e3250b4 100644 --- a/testing/internal/e2e/boundary/credential.go +++ b/testing/internal/e2e/boundary/credential.go @@ -27,6 +27,23 @@ func CreateNewCredentialStoreStaticApi(t testing.TB, ctx context.Context, client return newCredentialStoreId } +// CreateNewCredentialStoreVaultApi uses the API to create a Vault credential store +// Returns the id of the new credential store +func CreateNewCredentialStoreVaultApi(t testing.TB, ctx context.Context, client *api.Client, projectId string, vaultAddr string, vaultToken string) string { + c := credentialstores.NewClient(client) + newCredentialStoreResult, err := c.Create( + ctx, "vault", projectId, + credentialstores.WithName("e2e Credential Store"), + credentialstores.WithVaultCredentialStoreAddress(vaultAddr), + credentialstores.WithVaultCredentialStoreToken(vaultToken), + ) + require.NoError(t, err) + newVaultCredentialStoreId := newCredentialStoreResult.Item.Id + t.Logf("Created Credential Store: %s", newVaultCredentialStoreId) + + return newVaultCredentialStoreId +} + // CreateNewCredentialStoreVaultCli uses the cli to create a Vault credential store // Returns the id of the new credential store func CreateNewCredentialStoreVaultCli(t testing.TB, ctx context.Context, projectId string, vaultAddr string, vaultToken string) string {