refact(e2e): Create credential store function
This commit is contained in:
1 parent
ab223493a3
commit
79bc3d4878
6 files changed
+58
-49
No files matched your search
@@ -9,7 +9,6 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/boundary/api/credentials"
|
||||
"github.com/hashicorp/boundary/api/credentialstores"
|
||||
"github.com/hashicorp/boundary/api/targets"
|
||||
"github.com/hashicorp/boundary/testing/internal/e2e"
|
||||
"github.com/hashicorp/boundary/testing/internal/e2e/boundary"
|
||||
@@ -33,22 +32,11 @@ func TestConnectTargetWithAuthzTokenCli(t *testing.T) {
|
||||
boundary.AddHostToHostSetCli(t, newHostSetId, newHostId)
|
||||
newTargetId := boundary.CreateNewTargetCli(t, newProjectId, c.TargetPort)
|
||||
boundary.AddHostSourceToTargetCli(t, newTargetId, newHostSetId)
|
||||
|
||||
// Create a credential store
|
||||
ctx := context.Background()
|
||||
output := e2e.RunCommand(ctx, "boundary", "credential-stores", "create", "static",
|
||||
"-scope-id", newProjectId,
|
||||
"-format", "json",
|
||||
)
|
||||
require.NoError(t, output.Err, string(output.Stderr))
|
||||
var newCredentialStoreResult credentialstores.CredentialStoreCreateResult
|
||||
err = json.Unmarshal(output.Stdout, &newCredentialStoreResult)
|
||||
require.NoError(t, err)
|
||||
newCredentialStoreId := newCredentialStoreResult.Item.Id
|
||||
t.Logf("Created Credential Store: %s", newCredentialStoreId)
|
||||
newCredentialStoreId := boundary.CreateNewCredentialStoreStaticCli(t, newProjectId)
|
||||
|
||||
// Create credentials
|
||||
output = e2e.RunCommand(ctx, "boundary", "credentials", "create", "ssh-private-key",
|
||||
ctx := context.Background()
|
||||
output := e2e.RunCommand(ctx, "boundary", "credentials", "create", "ssh-private-key",
|
||||
"-credential-store-id", newCredentialStoreId,
|
||||
"-username", c.TargetSshUser,
|
||||
"-private-key", "file://"+c.TargetSshKeyPath,
|
||||
|
||||
@@ -8,7 +8,6 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/boundary/api/credentials"
|
||||
"github.com/hashicorp/boundary/api/credentialstores"
|
||||
"github.com/hashicorp/boundary/api/targets"
|
||||
"github.com/hashicorp/boundary/testing/internal/e2e"
|
||||
"github.com/hashicorp/boundary/testing/internal/e2e/boundary"
|
||||
@@ -33,22 +32,11 @@ func TestConnectTargetWithSshCli(t *testing.T) {
|
||||
boundary.AddHostToHostSetCli(t, newHostSetId, newHostId)
|
||||
newTargetId := boundary.CreateNewTargetCli(t, newProjectId, c.TargetPort)
|
||||
boundary.AddHostSourceToTargetCli(t, newTargetId, newHostSetId)
|
||||
|
||||
// Create a credential store
|
||||
ctx := context.Background()
|
||||
output := e2e.RunCommand(ctx, "boundary", "credential-stores", "create", "static",
|
||||
"-scope-id", newProjectId,
|
||||
"-format", "json",
|
||||
)
|
||||
require.NoError(t, output.Err, string(output.Stderr))
|
||||
var newCredentialStoreResult credentialstores.CredentialStoreCreateResult
|
||||
err = json.Unmarshal(output.Stdout, &newCredentialStoreResult)
|
||||
require.NoError(t, err)
|
||||
newCredentialStoreId := newCredentialStoreResult.Item.Id
|
||||
t.Logf("Created Credential Store: %s", newCredentialStoreId)
|
||||
newCredentialStoreId := boundary.CreateNewCredentialStoreStaticCli(t, newProjectId)
|
||||
|
||||
// Create credentials
|
||||
output = e2e.RunCommand(ctx, "boundary", "credentials", "create", "ssh-private-key",
|
||||
ctx := context.Background()
|
||||
output := e2e.RunCommand(ctx, "boundary", "credentials", "create", "ssh-private-key",
|
||||
"-credential-store-id", newCredentialStoreId,
|
||||
"-username", c.TargetSshUser,
|
||||
"-private-key", "file://"+c.TargetSshKeyPath,
|
||||
@@ -115,13 +103,7 @@ func TestCreateTargetWithStaticCredentialStoreApi(t *testing.T) {
|
||||
boundary.AddHostToHostSetApi(t, ctx, client, newHostSetId, newHostId)
|
||||
newTargetId := boundary.CreateNewTargetApi(t, ctx, client, newProjectId, c.TargetPort)
|
||||
boundary.AddHostSourceToTargetApi(t, ctx, client, newTargetId, newHostSetId)
|
||||
|
||||
// Create a credential store
|
||||
csClient := credentialstores.NewClient(client)
|
||||
newCredentialStoreResult, err := csClient.Create(ctx, "static", newProjectId)
|
||||
require.NoError(t, err)
|
||||
newCredentialStoreId := newCredentialStoreResult.Item.Id
|
||||
t.Logf("Created Credential Store: %s", newCredentialStoreId)
|
||||
newCredentialStoreId := boundary.CreateNewCredentialStoreStaticApi(t, ctx, client, newProjectId)
|
||||
|
||||
// Create credentials
|
||||
cClient := credentials.NewClient(client)
|
||||
|
||||
Reference in new issue
Block a user