test(enos): new e2e test for target address (#2732)

Co-authored-by: Hugo <hugoamvieira@users.noreply.github.com>
This commit is contained in:
Damian DebkowskiandHugo authored and Hugo Vieira committed 2023-01-09 15:39:55 +00:00
1 parent f85da3ee2b
commit b3ba9c5b4d
2 files changed
+392 -2

No files matched your search

+52 -2
View File
@@ -61,14 +61,64 @@ func CreateNewTargetCli(t testing.TB, ctx context.Context, projectId string, def
return newTargetId
}
// AddHostSourceToTargetCli uses the cli to add a host source (host set or host) to a target
func AddHostSourceToTargetCli(t testing.TB, ctx context.Context, targetId string, hostSourceId string) {
// CreateNewAddressTargetCli uses the cli to create a new target using an
// address in boundary.
// Returns the id of the new target.
func CreateNewAddressTargetCli(t testing.TB, ctx context.Context, projectId string, defaultPort string, address string) string {
output := e2e.RunCommand(ctx, "boundary",
e2e.WithArgs(
"targets", "create", "tcp",
"-scope-id", projectId,
"-default-port", defaultPort,
"-name", "e2e Target",
"-address", address,
"-format", "json",
),
)
require.NoError(t, output.Err, string(output.Stderr))
var newTargetResult targets.TargetCreateResult
err := json.Unmarshal(output.Stdout, &newTargetResult)
require.NoError(t, err)
newTargetId := newTargetResult.Item.Id
t.Logf("Created Target: %s", newTargetId)
return newTargetId
}
// AddHostSourceToTargetCli uses the cli to add a host source (host set or host)
// to a target.
// Boundary's `add-host-sources` functionality appends a new host source to the
// existing set of host sources in the target.
func AddHostSourceToTargetCli(t testing.TB, ctx context.Context, targetId, hostSourceId string) {
output := e2e.RunCommand(ctx, "boundary",
e2e.WithArgs("targets", "add-host-sources", "-id", targetId, "-host-source", hostSourceId),
)
require.NoError(t, output.Err, string(output.Stderr))
}
// SetHostSourceToTargetCli uses the cli to set a host source (host set or host)
// to a target.
// Boundary's `set-host-sources` functionality replaces all existing host sets
// on a target with the provided one.
func SetHostSourceToTargetCli(t testing.TB, ctx context.Context, targetId, hostSourceId string) {
output := e2e.RunCommand(ctx, "boundary",
e2e.WithArgs("targets", "set-host-sources", "-id", targetId, "-host-source", hostSourceId),
)
require.NoError(t, output.Err, string(output.Stderr))
}
// RemoveHostSourceFromTargetCli uses the cli to remove a host source (host set or host) to a target
func RemoveHostSourceFromTargetCli(t testing.TB, ctx context.Context, targetId, hostSourceId string) {
output := e2e.RunCommand(ctx, "boundary",
e2e.WithArgs(
"targets", "remove-host-sources",
"-id", targetId,
"-host-source", hostSourceId,
),
)
require.NoError(t, output.Err, string(output.Stderr))
}
// AddCredentialSourceToTargetCli uses the cli to add a credential source (credential library or
// credential) to a target
func AddCredentialSourceToTargetCli(t testing.TB, ctx context.Context, targetId string, credentialSourceId string) {