From d0050ad881dc37eb0a62851df56153d26e3c1fa4 Mon Sep 17 00:00:00 2001 From: dillanb-hashi Date: Thu, 13 Nov 2025 13:19:33 -0700 Subject: [PATCH] refact(e2e): Enable token to be passed into methods (#6248) * ce: chore(e2e): Address setup flakiness when getting hostname * ce: refact(e2e): Enable token to be passed into methods Co-authored-by: Michael Li --- enos/modules/aws_rdp_member_server/main.tf | 6 +- testing/internal/e2e/boundary/connect.go | 3 +- testing/internal/e2e/boundary/credential.go | 60 ++++++++++++--- testing/internal/e2e/boundary/scope.go | 77 +++++++------------ testing/internal/e2e/boundary/target.go | 45 +++++------ .../dynamichostcatalog_host_set_empty_test.go | 2 +- .../aws/dynamichostcatalog_host_set_test.go | 4 +- testing/internal/e2e/tests/aws/worker_test.go | 2 +- testing/internal/e2e/tests/base/alias_test.go | 4 +- .../tests/base/bytes_up_down_empty_test.go | 2 +- .../e2e/tests/base/bytes_up_down_test.go | 2 +- .../e2e/tests/base/credential_store_test.go | 2 +- .../e2e/tests/base/paginate_session_test.go | 2 +- .../e2e/tests/base/paginate_target_test.go | 2 +- .../tests/base/session_cancel_admin_test.go | 2 +- .../tests/base/session_cancel_group_test.go | 2 +- .../tests/base/session_cancel_user_test.go | 2 +- .../base/session_end_delete_host_set_test.go | 2 +- .../base/session_end_delete_host_test.go | 2 +- .../base/session_end_delete_project_test.go | 2 +- .../base/session_end_delete_target_test.go | 2 +- .../base/session_end_delete_user_test.go | 2 +- .../e2e/tests/base/target_tcp_address_test.go | 6 +- .../target_tcp_connect_authz_token_test.go | 21 ++++- .../base/target_tcp_connect_cassandra_test.go | 2 +- ...rget_tcp_connect_connection_limits_test.go | 6 +- ...et_tcp_connect_default_client_port_test.go | 2 +- ...p_connect_exec_long_lasting_script_test.go | 6 +- .../base/target_tcp_connect_go_ssh_test.go | 2 +- .../base/target_tcp_connect_http_test.go | 4 +- .../target_tcp_connect_listen_port_test.go | 8 +- .../base/target_tcp_connect_localhost_test.go | 2 +- .../base/target_tcp_connect_mongo_test.go | 2 +- .../base/target_tcp_connect_mysql_test.go | 2 +- .../base/target_tcp_connect_redis_test.go | 2 +- .../tests/base/target_tcp_connect_scp_test.go | 2 +- ...et_tcp_connect_session_max_seconds_test.go | 12 ++- .../tests/base/target_tcp_connect_ssh_test.go | 2 +- .../e2e/tests/base/target_tcp_connect_test.go | 6 +- .../target_tcp_connect_postgres_test.go | 2 +- .../credential_library_vault_ldap_test.go | 2 +- .../base_with_vault/credential_store_test.go | 2 +- ..._vault_generic_connect_authz_token_test.go | 2 +- ...rget_tcp_vault_generic_connect_ssh_test.go | 2 +- .../target_tcp_vault_generic_connect_test.go | 2 +- .../target_tcp_worker_connect_ssh_test.go | 6 +- .../e2e/tests/database/migration_test.go | 8 +- .../dynamichostcatalog_host_set_empty_test.go | 2 +- .../gcp/dynamichostcatalog_host_set_test.go | 2 +- 49 files changed, 195 insertions(+), 151 deletions(-) diff --git a/enos/modules/aws_rdp_member_server/main.tf b/enos/modules/aws_rdp_member_server/main.tf index c3d64d882..41ed16844 100644 --- a/enos/modules/aws_rdp_member_server/main.tf +++ b/enos/modules/aws_rdp_member_server/main.tf @@ -249,9 +249,9 @@ locals { private_key = abspath(var.domain_controller_private_key) } -resource "time_sleep" "wait_2_minutes" { +resource "time_sleep" "wait_5_minutes" { depends_on = [aws_instance.member_server] - create_duration = "2m" + create_duration = "5m" } # wait for the SSH service to be available on the instance. We specifically use @@ -259,7 +259,7 @@ resource "time_sleep" "wait_2_minutes" { # can just SSH using the private key resource "enos_local_exec" "wait_for_ssh" { count = var.server_version != "2016" ? 1 : 0 - depends_on = [time_sleep.wait_2_minutes] + depends_on = [time_sleep.wait_5_minutes] inline = ["timeout 600s bash -c 'until ssh -i ${local.private_key} -o BatchMode=Yes -o IdentitiesOnly=yes -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no Administrator@${aws_instance.member_server.public_ip} \"echo ready\"; do sleep 10; done'"] } diff --git a/testing/internal/e2e/boundary/connect.go b/testing/internal/e2e/boundary/connect.go index ba2a24d1d..fb437d4f2 100644 --- a/testing/internal/e2e/boundary/connect.go +++ b/testing/internal/e2e/boundary/connect.go @@ -7,6 +7,7 @@ import ( "bufio" "context" "encoding/json" + "fmt" "os/exec" "testing" @@ -82,7 +83,7 @@ func ConnectCliStdoutPipe(t testing.TB, ctx context.Context, targetId string) Co // Parse the JSON output var connectOutput ConnectCliOutput err = json.Unmarshal([]byte(outputLine), &connectOutput) - require.NoError(t, err) + require.NoError(t, err, fmt.Sprintf("received output: %s", outputLine)) return connectOutput } diff --git a/testing/internal/e2e/boundary/credential.go b/testing/internal/e2e/boundary/credential.go index 12eeb6166..a933457f9 100644 --- a/testing/internal/e2e/boundary/credential.go +++ b/testing/internal/e2e/boundary/credential.go @@ -68,13 +68,14 @@ func CreateCredentialStoreVaultApi(t testing.TB, ctx context.Context, client *ap // CreateCredentialStoreVaultCli uses the cli to create a Vault credential store // Returns the id of the new credential store -func CreateCredentialStoreVaultCli(t testing.TB, ctx context.Context, projectId string, vaultAddr string, vaultToken string) (string, error) { +func CreateCredentialStoreVaultCli(t testing.TB, ctx context.Context, projectId string, vaultAddr string, vaultToken string, opt ...e2e.Option) (string, error) { name, err := base62.Random(16) if err != nil { return "", err } - output := e2e.RunCommand(ctx, "boundary", + var options []e2e.Option + options = append(options, e2e.WithArgs( "credential-stores", "create", "vault", "-scope-id", projectId, @@ -85,6 +86,11 @@ func CreateCredentialStoreVaultCli(t testing.TB, ctx context.Context, projectId "-format", "json", ), ) + options = append(options, opt...) + + output := e2e.RunCommand(ctx, "boundary", + options..., + ) if output.Err != nil { return "", fmt.Errorf("%w: %s", output.Err, string(output.Stderr)) } @@ -102,13 +108,14 @@ func CreateCredentialStoreVaultCli(t testing.TB, ctx context.Context, projectId // CreateCredentialStoreStaticCli uses the cli to create a new static credential store. // Returns the id of the new credential store -func CreateCredentialStoreStaticCli(t testing.TB, ctx context.Context, projectId string) (string, error) { +func CreateCredentialStoreStaticCli(t testing.TB, ctx context.Context, projectId string, opt ...e2e.Option) (string, error) { name, err := base62.Random(16) if err != nil { return "", err } - output := e2e.RunCommand(ctx, "boundary", + var options []e2e.Option + options = append(options, e2e.WithArgs( "credential-stores", "create", "static", "-scope-id", projectId, @@ -117,6 +124,11 @@ func CreateCredentialStoreStaticCli(t testing.TB, ctx context.Context, projectId "-format", "json", ), ) + options = append(options, opt...) + + output := e2e.RunCommand(ctx, "boundary", + options..., + ) if output.Err != nil { return "", fmt.Errorf("%w: %s", output.Err, string(output.Stderr)) } @@ -135,13 +147,14 @@ func CreateCredentialStoreStaticCli(t testing.TB, ctx context.Context, projectId // CreateVaultGenericCredentialLibraryCli creates a vault-generic credential // library using the cli // Returns the id of the credential library or an error -func CreateVaultGenericCredentialLibraryCli(t testing.TB, ctx context.Context, credentialStoreId string, vaultPath string, credentialType string) (string, error) { +func CreateVaultGenericCredentialLibraryCli(t testing.TB, ctx context.Context, credentialStoreId string, vaultPath string, credentialType string, opt ...e2e.Option) (string, error) { name, err := base62.Random(16) if err != nil { return "", err } - output := e2e.RunCommand(ctx, "boundary", + var options []e2e.Option + options = append(options, e2e.WithArgs( "credential-libraries", "create", "vault-generic", "-credential-store-id", credentialStoreId, @@ -152,6 +165,11 @@ func CreateVaultGenericCredentialLibraryCli(t testing.TB, ctx context.Context, c "-format", "json", ), ) + options = append(options, opt...) + + output := e2e.RunCommand(ctx, "boundary", + options..., + ) if output.Err != nil { return "", fmt.Errorf("%w: %s", output.Err, string(output.Stderr)) } @@ -205,13 +223,14 @@ func CreateStaticCredentialPrivateKeyCli(t testing.TB, ctx context.Context, cred // CreateStaticCredentialUsernamePasswordCli uses the cli to create a new password credential in the // provided static credential store. // Returns the id of the new credential -func CreateStaticCredentialUsernamePasswordCli(t testing.TB, ctx context.Context, credentialStoreId string, user string, password string) (string, error) { +func CreateStaticCredentialUsernamePasswordCli(t testing.TB, ctx context.Context, credentialStoreId string, user string, password string, opt ...e2e.Option) (string, error) { name, err := base62.Random(16) if err != nil { return "", err } - output := e2e.RunCommand(ctx, "boundary", + var options []e2e.Option + options = append(options, e2e.WithArgs( "credentials", "create", "username-password", "-credential-store-id", credentialStoreId, @@ -223,6 +242,11 @@ func CreateStaticCredentialUsernamePasswordCli(t testing.TB, ctx context.Context ), e2e.WithEnv("E2E_CREDENTIALS_PASSWORD", password), ) + options = append(options, opt...) + + output := e2e.RunCommand(ctx, "boundary", + options..., + ) if output.Err != nil { return "", fmt.Errorf("%w: %s", output.Err, string(output.Stderr)) } @@ -241,13 +265,14 @@ func CreateStaticCredentialUsernamePasswordCli(t testing.TB, ctx context.Context // CreateStaticCredentialUsernamePasswordDomainCli uses the cli to create a new username password domain credential in the // provided static credential store. // Returns the id of the new credential -func CreateStaticCredentialUsernamePasswordDomainCli(t testing.TB, ctx context.Context, credentialStoreId string, user string, password string, domain string) (string, error) { +func CreateStaticCredentialUsernamePasswordDomainCli(t testing.TB, ctx context.Context, credentialStoreId string, user string, password string, domain string, opt ...e2e.Option) (string, error) { name, err := base62.Random(16) if err != nil { return "", err } - output := e2e.RunCommand(ctx, "boundary", + var options []e2e.Option + options = append(options, e2e.WithArgs( "credentials", "create", "username-password-domain", "-credential-store-id", credentialStoreId, @@ -260,6 +285,11 @@ func CreateStaticCredentialUsernamePasswordDomainCli(t testing.TB, ctx context.C ), e2e.WithEnv("E2E_CREDENTIALS_PASSWORD", password), ) + options = append(options, opt...) + + output := e2e.RunCommand(ctx, "boundary", + options..., + ) if output.Err != nil { return "", fmt.Errorf("%w: %s", output.Err, string(output.Stderr)) } @@ -350,13 +380,14 @@ func CreateVaultLdapCredentialLibraryApi(t testing.TB, ctx context.Context, clie return res.GetItem().Id, nil } -func CreateVaultLdapCredentialLibraryCli(t testing.TB, ctx context.Context, credentialStoreId string, vaultPath string) (string, error) { +func CreateVaultLdapCredentialLibraryCli(t testing.TB, ctx context.Context, credentialStoreId string, vaultPath string, opts ...e2e.Option) (string, error) { name, err := base62.Random(16) if err != nil { return "", err } - output := e2e.RunCommand(ctx, "boundary", + var options []e2e.Option + options = append(options, e2e.WithArgs( "credential-libraries", "create", "vault-ldap", "-credential-store-id", credentialStoreId, @@ -366,6 +397,11 @@ func CreateVaultLdapCredentialLibraryCli(t testing.TB, ctx context.Context, cred "-format", "json", ), ) + options = append(options, opts...) + + output := e2e.RunCommand(ctx, "boundary", + options..., + ) if output.Err != nil { return "", fmt.Errorf("%w: %s", output.Err, string(output.Stderr)) } diff --git a/testing/internal/e2e/boundary/scope.go b/testing/internal/e2e/boundary/scope.go index c0c9c15ff..96625470e 100644 --- a/testing/internal/e2e/boundary/scope.go +++ b/testing/internal/e2e/boundary/scope.go @@ -56,13 +56,14 @@ func CreateProjectApi(t testing.TB, ctx context.Context, client *api.Client, org // CreateOrgCli creates a new organization in boundary using the cli. // Returns the id of the new org. -func CreateOrgCli(t testing.TB, ctx context.Context) (string, error) { +func CreateOrgCli(t testing.TB, ctx context.Context, opt ...e2e.Option) (string, error) { name, err := base62.Random(16) if err != nil { return "", err } - output := e2e.RunCommand(ctx, "boundary", + var options []e2e.Option + options = append(options, e2e.WithArgs( "scopes", "create", "-name", fmt.Sprintf("e2e Org %s", name), @@ -71,6 +72,11 @@ func CreateOrgCli(t testing.TB, ctx context.Context) (string, error) { "-format", "json", ), ) + options = append(options, opt...) + + output := e2e.RunCommand(ctx, "boundary", + options..., + ) if output.Err != nil { return "", fmt.Errorf("%w: %s", output.Err, string(output.Stderr)) } @@ -89,36 +95,33 @@ func CreateOrgCli(t testing.TB, ctx context.Context) (string, error) { // CreateProjectCli creates a new project in boundary using the cli. The project will be created // under the provided org id. // Returns the id of the new project. -func CreateProjectCli(t testing.TB, ctx context.Context, orgId string, opt ...ScopeOption) (string, error) { - opts := getScopeOpts(opt...) - var args []string - - args = append(args, - "scopes", "create", - "-scope-id", orgId, - "-description", "e2e", - "-format", "json", - ) - - if opts.WithName != "" { - args = append(args, "-name", opts.WithName) - } else { - name, err := base62.Random(16) - if err != nil { - return "", err - } - args = append(args, "-name", fmt.Sprintf("e2e Project %s", name)) +func CreateProjectCli(t testing.TB, ctx context.Context, orgId string, opt ...e2e.Option) (string, error) { + name, err := base62.Random(16) + if err != nil { + return "", err } - output := e2e.RunCommand(ctx, "boundary", - e2e.WithArgs(args...), + var options []e2e.Option + options = append(options, + e2e.WithArgs("scopes", "create", + "-scope-id", orgId, + "-name", fmt.Sprintf("e2e Org %s", name), + "-description", "e2e", + "-format", "json"), ) + + options = append(options, opt...) + + output := e2e.RunCommand(ctx, "boundary", + options..., + ) + if output.Err != nil { return "", fmt.Errorf("%w: %s", output.Err, string(output.Stderr)) } var createProjResult scopes.ScopeCreateResult - err := json.Unmarshal(output.Stdout, &createProjResult) + err = json.Unmarshal(output.Stdout, &createProjResult) if err != nil { return "", err } @@ -127,29 +130,3 @@ func CreateProjectCli(t testing.TB, ctx context.Context, orgId string, opt ...Sc t.Logf("Created Project Id: %s", projectId) return projectId, nil } - -// getScopeOpts iterates the inbound ScopeOptions and returns a struct -func getScopeOpts(opt ...ScopeOption) scopeOptions { - opts := scopeOptions{ - WithName: "", - } - for _, o := range opt { - o(&opts) - } - return opts -} - -// ScopeOption represents how Options are passed as arguments -type ScopeOption func(*scopeOptions) - -// scopeOptions is a struct representing available options for scopes -type scopeOptions struct { - WithName string -} - -// WithName provides an option to search by a friendly name -func WithName(name string) ScopeOption { - return func(o *scopeOptions) { - o.WithName = name - } -} diff --git a/testing/internal/e2e/boundary/target.go b/testing/internal/e2e/boundary/target.go index a814478d3..d228b7c28 100644 --- a/testing/internal/e2e/boundary/target.go +++ b/testing/internal/e2e/boundary/target.go @@ -107,65 +107,66 @@ func AddBrokeredCredentialSourceToTargetApi(t testing.TB, ctx context.Context, c // CreateTargetCli uses the cli to create a new target in boundary // Returns the id of the new target. -func CreateTargetCli(t testing.TB, ctx context.Context, projectId string, defaultPort string, opt ...target.Option) (string, error) { +func CreateTargetCli(t testing.TB, ctx context.Context, projectId string, defaultPort string, targetOpts []target.Option, opt ...e2e.Option) (string, error) { name, err := base62.Random(16) if err != nil { return "", err } - opts := target.GetOpts(opt...) - var args []string + opts := target.GetOpts(targetOpts...) + var args []e2e.Option + args = append(args, e2e.WithArgs("targets", "create")) // Set target type. Default to tcp if not specified if opts.WithType != "" { - args = append(args, string(opts.WithType)) + args = append(args, e2e.WithArgs(string(opts.WithType))) } else { - args = append(args, "tcp") + args = append(args, e2e.WithArgs("tcp")) } args = append(args, - "-scope-id", projectId, - "-default-port", defaultPort, - "-description", "e2e", - "-format", "json", + e2e.WithArgs("-scope-id", projectId, + "-default-port", defaultPort, + "-description", "e2e", + "-format", "json"), ) if opts.WithName != "" { - args = append(args, "-name", opts.WithName) + args = append(args, e2e.WithArgs("-name", opts.WithName)) } else { - args = append(args, "-name", fmt.Sprintf("e2e Target %s", name)) + args = append(args, e2e.WithArgs("-name", fmt.Sprintf("e2e Target %s", name))) } if opts.WithDescription != "" { - args = append(args, "-description", opts.WithDescription) + args = append(args, e2e.WithArgs("-description", opts.WithDescription)) } if opts.WithAddress != "" { - args = append(args, "-address", opts.WithAddress) + args = append(args, e2e.WithArgs("-address", opts.WithAddress)) } if opts.WithDefaultClientPort != 0 { - args = append(args, "-default-client-port", fmt.Sprintf("%d", opts.WithDefaultClientPort)) + args = append(args, e2e.WithArgs("-default-client-port", fmt.Sprintf("%d", opts.WithDefaultClientPort))) } if opts.WithEnableSessionRecording != false { - args = append(args, "-enable-session-recording", fmt.Sprintf("%v", opts.WithEnableSessionRecording)) + args = append(args, e2e.WithArgs("-enable-session-recording", fmt.Sprintf("%v", opts.WithEnableSessionRecording))) } if opts.WithStorageBucketId != "" { - args = append(args, "-storage-bucket-id", opts.WithStorageBucketId) + args = append(args, e2e.WithArgs("-storage-bucket-id", opts.WithStorageBucketId)) } if opts.WithIngressWorkerFilter != "" { - args = append(args, "-ingress-worker-filter", opts.WithIngressWorkerFilter) + args = append(args, e2e.WithArgs("-ingress-worker-filter", opts.WithIngressWorkerFilter)) } if opts.WithEgressWorkerFilter != "" { - args = append(args, "-egress-worker-filter", opts.WithEgressWorkerFilter) + args = append(args, e2e.WithArgs("-egress-worker-filter", opts.WithEgressWorkerFilter)) } if opts.WithSessionConnectionLimit != 0 { - args = append(args, "-session-connection-limit", fmt.Sprintf("%d", opts.WithSessionConnectionLimit)) + args = append(args, e2e.WithArgs("-session-connection-limit", fmt.Sprintf("%d", opts.WithSessionConnectionLimit))) } if opts.WithSessionMaxSeconds != 0 { - args = append(args, "-session-max-seconds", fmt.Sprintf("%d", opts.WithSessionMaxSeconds)) + args = append(args, e2e.WithArgs("-session-max-seconds", fmt.Sprintf("%d", opts.WithSessionMaxSeconds))) } + args = append(args, opt...) output := e2e.RunCommand(ctx, "boundary", - e2e.WithArgs("targets", "create"), - e2e.WithArgs(args...), + args..., ) if output.Err != nil { return "", fmt.Errorf("%w: %s", output.Err, string(output.Stderr)) diff --git a/testing/internal/e2e/tests/aws/dynamichostcatalog_host_set_empty_test.go b/testing/internal/e2e/tests/aws/dynamichostcatalog_host_set_empty_test.go index 0b8ab051c..716c6d947 100644 --- a/testing/internal/e2e/tests/aws/dynamichostcatalog_host_set_empty_test.go +++ b/testing/internal/e2e/tests/aws/dynamichostcatalog_host_set_empty_test.go @@ -96,7 +96,7 @@ func TestCliCreateAwsDynamicHostCatalogWithEmptyHostSet(t *testing.T) { t.Log("Successfully detected zero hosts in the host catalog") // Create target - targetId, err := boundary.CreateTargetCli(t, ctx, projectId, c.TargetPort) + targetId, err := boundary.CreateTargetCli(t, ctx, projectId, c.TargetPort, nil) require.NoError(t, err) err = boundary.AddHostSourceToTargetCli(t, ctx, targetId, hostSetId) require.NoError(t, err) diff --git a/testing/internal/e2e/tests/aws/dynamichostcatalog_host_set_test.go b/testing/internal/e2e/tests/aws/dynamichostcatalog_host_set_test.go index 8e41be1c1..91b5eedb5 100644 --- a/testing/internal/e2e/tests/aws/dynamichostcatalog_host_set_test.go +++ b/testing/internal/e2e/tests/aws/dynamichostcatalog_host_set_test.go @@ -119,10 +119,10 @@ func TestCliCreateAwsDynamicHostCatalogWithHostSet(t *testing.T) { // Create target var targetId string if c.IpVersion == "4" { - targetId, err = boundary.CreateTargetCli(t, ctx, projectId, c.TargetPort) + targetId, err = boundary.CreateTargetCli(t, ctx, projectId, c.TargetPort, nil) } else { targetId, err = boundary.CreateTargetCli(t, ctx, projectId, c.TargetPort, - target.WithIngressWorkerFilter(fmt.Sprintf(`"%s" in "/tags/type"`, c.WorkerTagCollocated)), + []target.Option{target.WithIngressWorkerFilter(fmt.Sprintf(`"%s" in "/tags/type"`, c.WorkerTagCollocated))}, ) } diff --git a/testing/internal/e2e/tests/aws/worker_test.go b/testing/internal/e2e/tests/aws/worker_test.go index 564c7cee1..70ba3db52 100644 --- a/testing/internal/e2e/tests/aws/worker_test.go +++ b/testing/internal/e2e/tests/aws/worker_test.go @@ -32,7 +32,7 @@ func TestCliWorker(t *testing.T) { }) projectId, err := boundary.CreateProjectCli(t, ctx, orgId) require.NoError(t, err) - targetId, err := boundary.CreateTargetCli(t, ctx, projectId, c.TargetPort, target.WithAddress(c.TargetAddress)) + targetId, err := boundary.CreateTargetCli(t, ctx, projectId, c.TargetPort, []target.Option{target.WithAddress(c.TargetAddress)}) require.NoError(t, err) // Set incorrect worker filter, expect connection failure diff --git a/testing/internal/e2e/tests/base/alias_test.go b/testing/internal/e2e/tests/base/alias_test.go index d4a75758d..3e15e587d 100644 --- a/testing/internal/e2e/tests/base/alias_test.go +++ b/testing/internal/e2e/tests/base/alias_test.go @@ -44,7 +44,7 @@ func TestCliAlias(t *testing.T) { ctx, projectId, c.TargetPort, - target.WithAddress(c.TargetAddress), + []target.Option{target.WithAddress(c.TargetAddress)}, ) require.NoError(t, err) aliasTargetAddress := "example.alias.boundary" @@ -127,7 +127,7 @@ func TestCliAlias(t *testing.T) { ctx, projectId, c.TargetPort, - target.WithName("targetWithHost"), + []target.Option{target.WithName("targetWithHost")}, ) require.NoError(t, err) err = boundary.AddHostSourceToTargetCli(t, ctx, targetWithHost, hostSetId) diff --git a/testing/internal/e2e/tests/base/bytes_up_down_empty_test.go b/testing/internal/e2e/tests/base/bytes_up_down_empty_test.go index a6e59e40e..a205dd9d8 100644 --- a/testing/internal/e2e/tests/base/bytes_up_down_empty_test.go +++ b/testing/internal/e2e/tests/base/bytes_up_down_empty_test.go @@ -44,7 +44,7 @@ func TestCliBytesUpDownEmpty(t *testing.T) { ctx, projectId, c.TargetPort, - target.WithAddress(c.TargetAddress), + []target.Option{target.WithAddress(c.TargetAddress)}, ) require.NoError(t, err) diff --git a/testing/internal/e2e/tests/base/bytes_up_down_test.go b/testing/internal/e2e/tests/base/bytes_up_down_test.go index 73b7428c8..df19a963b 100644 --- a/testing/internal/e2e/tests/base/bytes_up_down_test.go +++ b/testing/internal/e2e/tests/base/bytes_up_down_test.go @@ -45,7 +45,7 @@ func TestCliBytesUpDownTransferData(t *testing.T) { ctx, projectId, c.TargetPort, - target.WithAddress(c.TargetAddress), + []target.Option{target.WithAddress(c.TargetAddress)}, ) require.NoError(t, err) diff --git a/testing/internal/e2e/tests/base/credential_store_test.go b/testing/internal/e2e/tests/base/credential_store_test.go index ed3e841fe..9ec9015ec 100644 --- a/testing/internal/e2e/tests/base/credential_store_test.go +++ b/testing/internal/e2e/tests/base/credential_store_test.go @@ -60,7 +60,7 @@ func TestCliStaticCredentialStore(t *testing.T) { require.NoError(t, err) err = boundary.AddHostToHostSetCli(t, ctx, hostSetId, hostId) require.NoError(t, err) - targetId, err := boundary.CreateTargetCli(t, ctx, projectId, c.TargetPort) + targetId, err := boundary.CreateTargetCli(t, ctx, projectId, c.TargetPort, nil) require.NoError(t, err) err = boundary.AddHostSourceToTargetCli(t, ctx, targetId, hostSetId) require.NoError(t, err) diff --git a/testing/internal/e2e/tests/base/paginate_session_test.go b/testing/internal/e2e/tests/base/paginate_session_test.go index c56fe61ff..750c6e7c6 100644 --- a/testing/internal/e2e/tests/base/paginate_session_test.go +++ b/testing/internal/e2e/tests/base/paginate_session_test.go @@ -48,7 +48,7 @@ func TestCliPaginateSessions(t *testing.T) { require.NoError(t, err) err = boundary.AddHostToHostSetCli(t, ctx, hostSetId, hostId) require.NoError(t, err) - targetId, err := boundary.CreateTargetCli(t, ctx, projectId, c.TargetPort) + targetId, err := boundary.CreateTargetCli(t, ctx, projectId, c.TargetPort, nil) require.NoError(t, err) err = boundary.AddHostSourceToTargetCli(t, ctx, targetId, hostSetId) require.NoError(t, err) diff --git a/testing/internal/e2e/tests/base/paginate_target_test.go b/testing/internal/e2e/tests/base/paginate_target_test.go index 549238f3b..5d1284750 100644 --- a/testing/internal/e2e/tests/base/paginate_target_test.go +++ b/testing/internal/e2e/tests/base/paginate_target_test.go @@ -86,7 +86,7 @@ func TestCliPaginateTargets(t *testing.T) { assert.Empty(t, initialTargets.ListToken) // Create a new target and destroy one of the other targets - targetId, err := boundary.CreateTargetCli(t, ctx, projectId, c.TargetPort, target.WithAddress(c.TargetAddress)) + targetId, err := boundary.CreateTargetCli(t, ctx, projectId, c.TargetPort, []target.Option{target.WithAddress(c.TargetAddress)}) require.NoError(t, err) output = e2e.RunCommand(ctx, "boundary", e2e.WithArgs( diff --git a/testing/internal/e2e/tests/base/session_cancel_admin_test.go b/testing/internal/e2e/tests/base/session_cancel_admin_test.go index 29fb6b6d5..de642d703 100644 --- a/testing/internal/e2e/tests/base/session_cancel_admin_test.go +++ b/testing/internal/e2e/tests/base/session_cancel_admin_test.go @@ -41,7 +41,7 @@ func TestCliSessionCancelAdmin(t *testing.T) { require.NoError(t, err) err = boundary.AddHostToHostSetCli(t, ctx, hostSetId, hostId) require.NoError(t, err) - targetId, err := boundary.CreateTargetCli(t, ctx, projectId, c.TargetPort) + targetId, err := boundary.CreateTargetCli(t, ctx, projectId, c.TargetPort, nil) require.NoError(t, err) err = boundary.AddHostSourceToTargetCli(t, ctx, targetId, hostSetId) require.NoError(t, err) diff --git a/testing/internal/e2e/tests/base/session_cancel_group_test.go b/testing/internal/e2e/tests/base/session_cancel_group_test.go index b00ab305f..eae54c98d 100644 --- a/testing/internal/e2e/tests/base/session_cancel_group_test.go +++ b/testing/internal/e2e/tests/base/session_cancel_group_test.go @@ -54,7 +54,7 @@ func TestCliSessionCancelGroup(t *testing.T) { require.NoError(t, err) err = boundary.AddHostToHostSetCli(t, ctx, hostSetId, hostId) require.NoError(t, err) - targetId, err := boundary.CreateTargetCli(t, ctx, projectId, c.TargetPort) + targetId, err := boundary.CreateTargetCli(t, ctx, projectId, c.TargetPort, nil) require.NoError(t, err) err = boundary.AddHostSourceToTargetCli(t, ctx, targetId, hostSetId) require.NoError(t, err) diff --git a/testing/internal/e2e/tests/base/session_cancel_user_test.go b/testing/internal/e2e/tests/base/session_cancel_user_test.go index e8e72d978..9334aca05 100644 --- a/testing/internal/e2e/tests/base/session_cancel_user_test.go +++ b/testing/internal/e2e/tests/base/session_cancel_user_test.go @@ -53,7 +53,7 @@ func TestCliSessionCancelUser(t *testing.T) { require.NoError(t, err) err = boundary.AddHostToHostSetCli(t, ctx, hostSetId, hostId) require.NoError(t, err) - targetId, err := boundary.CreateTargetCli(t, ctx, projectId, c.TargetPort) + targetId, err := boundary.CreateTargetCli(t, ctx, projectId, c.TargetPort, nil) require.NoError(t, err) err = boundary.AddHostSourceToTargetCli(t, ctx, targetId, hostSetId) require.NoError(t, err) diff --git a/testing/internal/e2e/tests/base/session_end_delete_host_set_test.go b/testing/internal/e2e/tests/base/session_end_delete_host_set_test.go index 8ea53b174..603f84b6a 100644 --- a/testing/internal/e2e/tests/base/session_end_delete_host_set_test.go +++ b/testing/internal/e2e/tests/base/session_end_delete_host_set_test.go @@ -44,7 +44,7 @@ func TestCliSessionEndWhenHostSetIsDeleted(t *testing.T) { require.NoError(t, err) err = boundary.AddHostToHostSetCli(t, ctx, hostSetId, hostId) require.NoError(t, err) - targetId, err := boundary.CreateTargetCli(t, ctx, projectId, c.TargetPort) + targetId, err := boundary.CreateTargetCli(t, ctx, projectId, c.TargetPort, nil) require.NoError(t, err) err = boundary.AddHostSourceToTargetCli(t, ctx, targetId, hostSetId) require.NoError(t, err) diff --git a/testing/internal/e2e/tests/base/session_end_delete_host_test.go b/testing/internal/e2e/tests/base/session_end_delete_host_test.go index ebeeacf44..0b90cc5d2 100644 --- a/testing/internal/e2e/tests/base/session_end_delete_host_test.go +++ b/testing/internal/e2e/tests/base/session_end_delete_host_test.go @@ -44,7 +44,7 @@ func TestCliSessionEndWhenHostIsDeleted(t *testing.T) { require.NoError(t, err) err = boundary.AddHostToHostSetCli(t, ctx, hostSetId, hostId) require.NoError(t, err) - targetId, err := boundary.CreateTargetCli(t, ctx, projectId, c.TargetPort) + targetId, err := boundary.CreateTargetCli(t, ctx, projectId, c.TargetPort, nil) require.NoError(t, err) err = boundary.AddHostSourceToTargetCli(t, ctx, targetId, hostSetId) require.NoError(t, err) diff --git a/testing/internal/e2e/tests/base/session_end_delete_project_test.go b/testing/internal/e2e/tests/base/session_end_delete_project_test.go index 67d4f0755..ccabc2604 100644 --- a/testing/internal/e2e/tests/base/session_end_delete_project_test.go +++ b/testing/internal/e2e/tests/base/session_end_delete_project_test.go @@ -37,7 +37,7 @@ func TestCliSessionEndWhenProjectIsDeleted(t *testing.T) { }) projectId, err := boundary.CreateProjectCli(t, ctx, orgId) require.NoError(t, err) - targetId, err := boundary.CreateTargetCli(t, ctx, projectId, c.TargetPort, target.WithAddress(c.TargetAddress)) + targetId, err := boundary.CreateTargetCli(t, ctx, projectId, c.TargetPort, []target.Option{target.WithAddress(c.TargetAddress)}) require.NoError(t, err) acctName := "e2e-account" accountId, acctPassword, err := boundary.CreateAccountCli(t, ctx, bc.AuthMethodId, acctName) diff --git a/testing/internal/e2e/tests/base/session_end_delete_target_test.go b/testing/internal/e2e/tests/base/session_end_delete_target_test.go index 6de6b01ce..d46bddf28 100644 --- a/testing/internal/e2e/tests/base/session_end_delete_target_test.go +++ b/testing/internal/e2e/tests/base/session_end_delete_target_test.go @@ -44,7 +44,7 @@ func TestCliSessionEndWhenTargetIsDeleted(t *testing.T) { require.NoError(t, err) err = boundary.AddHostToHostSetCli(t, ctx, hostSetId, hostId) require.NoError(t, err) - targetId, err := boundary.CreateTargetCli(t, ctx, projectId, c.TargetPort) + targetId, err := boundary.CreateTargetCli(t, ctx, projectId, c.TargetPort, nil) require.NoError(t, err) err = boundary.AddHostSourceToTargetCli(t, ctx, targetId, hostSetId) require.NoError(t, err) diff --git a/testing/internal/e2e/tests/base/session_end_delete_user_test.go b/testing/internal/e2e/tests/base/session_end_delete_user_test.go index 5f6eeb471..d3964dc18 100644 --- a/testing/internal/e2e/tests/base/session_end_delete_user_test.go +++ b/testing/internal/e2e/tests/base/session_end_delete_user_test.go @@ -46,7 +46,7 @@ func TestCliSessionEndWhenUserIsDeleted(t *testing.T) { require.NoError(t, err) err = boundary.AddHostToHostSetCli(t, ctx, hostSetId, hostId) require.NoError(t, err) - targetId, err := boundary.CreateTargetCli(t, ctx, projectId, c.TargetPort) + targetId, err := boundary.CreateTargetCli(t, ctx, projectId, c.TargetPort, nil) require.NoError(t, err) err = boundary.AddHostSourceToTargetCli(t, ctx, targetId, hostSetId) require.NoError(t, err) diff --git a/testing/internal/e2e/tests/base/target_tcp_address_test.go b/testing/internal/e2e/tests/base/target_tcp_address_test.go index d2bead53f..34dfac187 100644 --- a/testing/internal/e2e/tests/base/target_tcp_address_test.go +++ b/testing/internal/e2e/tests/base/target_tcp_address_test.go @@ -35,7 +35,7 @@ func TestCliCreateUpdateTargetAddress(t *testing.T) { }) projectId, err := boundary.CreateProjectCli(t, ctx, orgId) require.NoError(t, err) - targetId, err := boundary.CreateTargetCli(t, ctx, projectId, c.TargetPort, target.WithAddress(c.TargetAddress)) + targetId, err := boundary.CreateTargetCli(t, ctx, projectId, c.TargetPort, []target.Option{target.WithAddress(c.TargetAddress)}) require.NoError(t, err) // Connect to target and print host's IP address @@ -161,7 +161,7 @@ func TestCliTargetAddressToHostSource(t *testing.T) { require.NoError(t, err) err = boundary.AddHostToHostSetCli(t, ctx, hostSetId, hostId) require.NoError(t, err) - targetId, err := boundary.CreateTargetCli(t, ctx, projectId, c.TargetPort, target.WithAddress(c.TargetAddress)) + targetId, err := boundary.CreateTargetCli(t, ctx, projectId, c.TargetPort, []target.Option{target.WithAddress(c.TargetAddress)}) require.NoError(t, err) // Connect to target and print host's IP address @@ -287,7 +287,7 @@ func TestCliTargetHostSourceToAddress(t *testing.T) { require.NoError(t, err) err = boundary.AddHostToHostSetCli(t, ctx, hostSetId, hostId) require.NoError(t, err) - targetId, err := boundary.CreateTargetCli(t, ctx, projectId, c.TargetPort) + targetId, err := boundary.CreateTargetCli(t, ctx, projectId, c.TargetPort, nil) require.NoError(t, err) err = boundary.AddHostSourceToTargetCli(t, ctx, targetId, hostSetId) require.NoError(t, err) diff --git a/testing/internal/e2e/tests/base/target_tcp_connect_authz_token_test.go b/testing/internal/e2e/tests/base/target_tcp_connect_authz_token_test.go index af08e99c0..29e299850 100644 --- a/testing/internal/e2e/tests/base/target_tcp_connect_authz_token_test.go +++ b/testing/internal/e2e/tests/base/target_tcp_connect_authz_token_test.go @@ -11,6 +11,7 @@ import ( "strings" "testing" + "github.com/hashicorp/boundary/api/scopes" "github.com/hashicorp/boundary/api/targets" "github.com/hashicorp/boundary/internal/target" "github.com/hashicorp/boundary/testing/internal/e2e" @@ -37,7 +38,21 @@ func TestCliTcpTargetConnectTargetWithAuthzToken(t *testing.T) { require.NoError(t, output.Err, string(output.Stderr)) }) testProjectName := `E2E/Project-With\Name` - projectId, err := boundary.CreateProjectCli(t, ctx, orgId, boundary.WithName(testProjectName)) + output := e2e.RunCommand(ctx, "boundary", + e2e.WithArgs( + "scopes", "create", + "-scope-id", orgId, + "-description", "e2e", + "-name", testProjectName, + "-format", "json", + ), + ) + require.NoError(t, output.Err, string(output.Stderr)) + var createProjResult scopes.ScopeCreateResult + err = json.Unmarshal(output.Stdout, &createProjResult) + require.NoError(t, err) + projectId := createProjResult.Item.Id + t.Logf("Created Project Id: %s", projectId) require.NoError(t, err) hostCatalogId, err := boundary.CreateHostCatalogCli(t, ctx, projectId) require.NoError(t, err) @@ -48,7 +63,7 @@ func TestCliTcpTargetConnectTargetWithAuthzToken(t *testing.T) { err = boundary.AddHostToHostSetCli(t, ctx, hostSetId, hostId) require.NoError(t, err) testTargetName := `E2E/Test-Target-With\Name` - targetId, err := boundary.CreateTargetCli(t, ctx, projectId, c.TargetPort, target.WithName(testTargetName)) + targetId, err := boundary.CreateTargetCli(t, ctx, projectId, c.TargetPort, []target.Option{target.WithName(testTargetName)}) require.NoError(t, err) err = boundary.AddHostSourceToTargetCli(t, ctx, targetId, hostSetId) require.NoError(t, err) @@ -60,7 +75,7 @@ func TestCliTcpTargetConnectTargetWithAuthzToken(t *testing.T) { require.NoError(t, err) // Get credentials for target - output := e2e.RunCommand(ctx, "boundary", + output = e2e.RunCommand(ctx, "boundary", e2e.WithArgs("targets", "authorize-session", "-id", targetId, "-format", "json"), ) require.NoError(t, output.Err, string(output.Stderr)) diff --git a/testing/internal/e2e/tests/base/target_tcp_connect_cassandra_test.go b/testing/internal/e2e/tests/base/target_tcp_connect_cassandra_test.go index 5951624ff..49b999724 100644 --- a/testing/internal/e2e/tests/base/target_tcp_connect_cassandra_test.go +++ b/testing/internal/e2e/tests/base/target_tcp_connect_cassandra_test.go @@ -75,7 +75,7 @@ func TestCliTcpTargetConnectCassandra(t *testing.T) { ctx, projectId, port, - target.WithAddress(hostname), + []target.Option{target.WithAddress(hostname)}, ) require.NoError(t, err) diff --git a/testing/internal/e2e/tests/base/target_tcp_connect_connection_limits_test.go b/testing/internal/e2e/tests/base/target_tcp_connect_connection_limits_test.go index afac7d306..1cc942c49 100644 --- a/testing/internal/e2e/tests/base/target_tcp_connect_connection_limits_test.go +++ b/testing/internal/e2e/tests/base/target_tcp_connect_connection_limits_test.go @@ -43,8 +43,10 @@ func TestCliTcpTargetConnectTargetWithConnectionLimits(t *testing.T) { ctx, projectId, c.TargetPort, - target.WithAddress(c.TargetAddress), - target.WithSessionConnectionLimit(int32(sessionConnectionLimit)), + []target.Option{ + target.WithAddress(c.TargetAddress), + target.WithSessionConnectionLimit(int32(sessionConnectionLimit)), + }, ) require.NoError(t, err) diff --git a/testing/internal/e2e/tests/base/target_tcp_connect_default_client_port_test.go b/testing/internal/e2e/tests/base/target_tcp_connect_default_client_port_test.go index 60648ed93..4f8cf086f 100644 --- a/testing/internal/e2e/tests/base/target_tcp_connect_default_client_port_test.go +++ b/testing/internal/e2e/tests/base/target_tcp_connect_default_client_port_test.go @@ -45,7 +45,7 @@ func TestCliTcpTargetConnectTargetWithTargetClientPort(t *testing.T) { require.NoError(t, err) err = boundary.AddHostToHostSetCli(t, ctx, hostSetId, hostId) require.NoError(t, err) - targetId, err := boundary.CreateTargetCli(t, ctx, projectId, c.TargetPort, target.WithDefaultClientPort(expPort)) + targetId, err := boundary.CreateTargetCli(t, ctx, projectId, c.TargetPort, []target.Option{target.WithDefaultClientPort(expPort)}) require.NoError(t, err) err = boundary.AddHostSourceToTargetCli(t, ctx, targetId, hostSetId) require.NoError(t, err) diff --git a/testing/internal/e2e/tests/base/target_tcp_connect_exec_long_lasting_script_test.go b/testing/internal/e2e/tests/base/target_tcp_connect_exec_long_lasting_script_test.go index 02dfc102c..d9511ca32 100644 --- a/testing/internal/e2e/tests/base/target_tcp_connect_exec_long_lasting_script_test.go +++ b/testing/internal/e2e/tests/base/target_tcp_connect_exec_long_lasting_script_test.go @@ -50,8 +50,10 @@ func TestCliTcpTargetConnectExecLongLastingScript(t *testing.T) { // Create TCP target targetId, err := boundary.CreateTargetCli(t, ctx, projectId, c.TargetPort, - target.WithType("tcp"), - target.WithAddress(c.TargetAddress), + []target.Option{ + target.WithType("tcp"), + target.WithAddress(c.TargetAddress), + }, ) require.NoError(t, err) err = boundary.AddBrokeredCredentialSourceToTargetCli(t, ctx, targetId, credentialId) diff --git a/testing/internal/e2e/tests/base/target_tcp_connect_go_ssh_test.go b/testing/internal/e2e/tests/base/target_tcp_connect_go_ssh_test.go index c00cb4b8a..37ff2c4ee 100644 --- a/testing/internal/e2e/tests/base/target_tcp_connect_go_ssh_test.go +++ b/testing/internal/e2e/tests/base/target_tcp_connect_go_ssh_test.go @@ -35,7 +35,7 @@ func TestCliTcpTargetConnectGoSsh(t *testing.T) { }) projectId, err := boundary.CreateProjectCli(t, ctx, orgId) require.NoError(t, err) - targetId, err := boundary.CreateTargetCli(t, ctx, projectId, c.TargetPort, target.WithAddress(c.TargetAddress)) + targetId, err := boundary.CreateTargetCli(t, ctx, projectId, c.TargetPort, []target.Option{target.WithAddress(c.TargetAddress)}) require.NoError(t, err) // Start a session diff --git a/testing/internal/e2e/tests/base/target_tcp_connect_http_test.go b/testing/internal/e2e/tests/base/target_tcp_connect_http_test.go index 7c43c427e..44b273efa 100644 --- a/testing/internal/e2e/tests/base/target_tcp_connect_http_test.go +++ b/testing/internal/e2e/tests/base/target_tcp_connect_http_test.go @@ -36,7 +36,7 @@ func TestCliTcpTargetConnectHttp(t *testing.T) { }) projectId, err := boundary.CreateProjectCli(t, ctx, orgId) require.NoError(t, err) - targetId, err := boundary.CreateTargetCli(t, ctx, projectId, c.TargetPort, target.WithAddress(c.TargetAddress)) + targetId, err := boundary.CreateTargetCli(t, ctx, projectId, c.TargetPort, []target.Option{target.WithAddress(c.TargetAddress)}) require.NoError(t, err) storeId, err := boundary.CreateCredentialStoreStaticCli(t, ctx, projectId) require.NoError(t, err) @@ -83,7 +83,7 @@ Server: netcat-can-you-believe-it boundary.WaitForSessionStatusCli(t, ctx, s.Id, session.StatusActive.String()) // Create http target and connect to it - httpTargetId, err := boundary.CreateTargetCli(t, ctx, projectId, destPort, target.WithAddress(c.TargetAddress)) + httpTargetId, err := boundary.CreateTargetCli(t, ctx, projectId, destPort, []target.Option{target.WithAddress(c.TargetAddress)}) require.NoError(t, err) output := e2e.RunCommand(ctx, "boundary", e2e.WithArgs( diff --git a/testing/internal/e2e/tests/base/target_tcp_connect_listen_port_test.go b/testing/internal/e2e/tests/base/target_tcp_connect_listen_port_test.go index 90bef7d63..1bc15b903 100644 --- a/testing/internal/e2e/tests/base/target_tcp_connect_listen_port_test.go +++ b/testing/internal/e2e/tests/base/target_tcp_connect_listen_port_test.go @@ -36,7 +36,7 @@ func TestCliTcpTargetConnectListenPort(t *testing.T) { projectId, err := boundary.CreateProjectCli(t, ctx, orgId) require.NoError(t, err) targetId, err := boundary.CreateTargetCli(t, ctx, projectId, c.TargetPort, - target.WithAddress(c.TargetAddress), + []target.Option{target.WithAddress(c.TargetAddress)}, ) require.NoError(t, err) @@ -97,8 +97,10 @@ func TestCliTcpTargetConnectDefaultClientPort(t *testing.T) { projectId, err := boundary.CreateProjectCli(t, ctx, orgId) require.NoError(t, err) targetId, err := boundary.CreateTargetCli(t, ctx, projectId, c.TargetPort, - target.WithAddress(c.TargetAddress), - target.WithDefaultClientPort(DefaultClientPort), + []target.Option{ + target.WithAddress(c.TargetAddress), + target.WithDefaultClientPort(DefaultClientPort), + }, ) require.NoError(t, err) diff --git a/testing/internal/e2e/tests/base/target_tcp_connect_localhost_test.go b/testing/internal/e2e/tests/base/target_tcp_connect_localhost_test.go index 45e1cc7a2..17de377a9 100644 --- a/testing/internal/e2e/tests/base/target_tcp_connect_localhost_test.go +++ b/testing/internal/e2e/tests/base/target_tcp_connect_localhost_test.go @@ -43,7 +43,7 @@ func TestCliTcpTargetConnectTargetWithLocalhost(t *testing.T) { require.NoError(t, err) err = boundary.AddHostToHostSetCli(t, ctx, hostSetId, hostId) require.NoError(t, err) - targetId, err := boundary.CreateTargetCli(t, ctx, projectId, c.TargetPort) + targetId, err := boundary.CreateTargetCli(t, ctx, projectId, c.TargetPort, nil) require.NoError(t, err) err = boundary.AddHostSourceToTargetCli(t, ctx, targetId, hostSetId) require.NoError(t, err) diff --git a/testing/internal/e2e/tests/base/target_tcp_connect_mongo_test.go b/testing/internal/e2e/tests/base/target_tcp_connect_mongo_test.go index 1492dc412..d87e85d6d 100644 --- a/testing/internal/e2e/tests/base/target_tcp_connect_mongo_test.go +++ b/testing/internal/e2e/tests/base/target_tcp_connect_mongo_test.go @@ -76,7 +76,7 @@ func TestCliTcpTargetConnectMongo(t *testing.T) { ctx, projectId, port, - target.WithAddress(hostname), + []target.Option{target.WithAddress(hostname)}, ) require.NoError(t, err) diff --git a/testing/internal/e2e/tests/base/target_tcp_connect_mysql_test.go b/testing/internal/e2e/tests/base/target_tcp_connect_mysql_test.go index 475ad5ad3..9df285e33 100644 --- a/testing/internal/e2e/tests/base/target_tcp_connect_mysql_test.go +++ b/testing/internal/e2e/tests/base/target_tcp_connect_mysql_test.go @@ -75,7 +75,7 @@ func TestCliTcpTargetConnectMysql(t *testing.T) { ctx, projectId, port, - target.WithAddress(hostname), + []target.Option{target.WithAddress(hostname)}, ) require.NoError(t, err) diff --git a/testing/internal/e2e/tests/base/target_tcp_connect_redis_test.go b/testing/internal/e2e/tests/base/target_tcp_connect_redis_test.go index 6455e6c63..7e6e19f7c 100644 --- a/testing/internal/e2e/tests/base/target_tcp_connect_redis_test.go +++ b/testing/internal/e2e/tests/base/target_tcp_connect_redis_test.go @@ -77,7 +77,7 @@ func TestCliTcpTargetConnectRedis(t *testing.T) { ctx, projectId, port, - target.WithAddress(hostname), + []target.Option{target.WithAddress(hostname)}, ) require.NoError(t, err) diff --git a/testing/internal/e2e/tests/base/target_tcp_connect_scp_test.go b/testing/internal/e2e/tests/base/target_tcp_connect_scp_test.go index 91d428b1f..0167b1e90 100644 --- a/testing/internal/e2e/tests/base/target_tcp_connect_scp_test.go +++ b/testing/internal/e2e/tests/base/target_tcp_connect_scp_test.go @@ -43,7 +43,7 @@ func TestCliTcpTargetConnectTargetAndScp(t *testing.T) { ctx, projectId, c.TargetPort, - target.WithAddress(c.TargetAddress), + []target.Option{target.WithAddress(c.TargetAddress)}, ) require.NoError(t, err) diff --git a/testing/internal/e2e/tests/base/target_tcp_connect_session_max_seconds_test.go b/testing/internal/e2e/tests/base/target_tcp_connect_session_max_seconds_test.go index 4cc981657..c47034069 100644 --- a/testing/internal/e2e/tests/base/target_tcp_connect_session_max_seconds_test.go +++ b/testing/internal/e2e/tests/base/target_tcp_connect_session_max_seconds_test.go @@ -41,8 +41,10 @@ func TestCliTcpTargetConnectTargetWithSessionMaxSecondsTearDown(t *testing.T) { ctx, projectId, c.TargetPort, - target.WithAddress(c.TargetAddress), - target.WithSessionMaxSeconds(uint32(sessionMaxSeconds)), + []target.Option{ + target.WithAddress(c.TargetAddress), + target.WithSessionMaxSeconds(uint32(sessionMaxSeconds)), + }, ) require.NoError(t, err) @@ -113,8 +115,10 @@ func TestCliTcpTargetConnectTargetWithSessionMaxSecondsRejectNew(t *testing.T) { ctx, projectId, c.TargetPort, - target.WithAddress(c.TargetAddress), - target.WithSessionMaxSeconds(uint32(sessionMaxSeconds)), + []target.Option{ + target.WithAddress(c.TargetAddress), + target.WithSessionMaxSeconds(uint32(sessionMaxSeconds)), + }, ) require.NoError(t, err) diff --git a/testing/internal/e2e/tests/base/target_tcp_connect_ssh_test.go b/testing/internal/e2e/tests/base/target_tcp_connect_ssh_test.go index 19950e3fd..0ac14c41b 100644 --- a/testing/internal/e2e/tests/base/target_tcp_connect_ssh_test.go +++ b/testing/internal/e2e/tests/base/target_tcp_connect_ssh_test.go @@ -44,7 +44,7 @@ func TestCliTcpTargetConnectTargetWithSsh(t *testing.T) { require.NoError(t, err) err = boundary.AddHostToHostSetCli(t, ctx, hostSetId, hostId) require.NoError(t, err) - targetId, err := boundary.CreateTargetCli(t, ctx, projectId, c.TargetPort) + targetId, err := boundary.CreateTargetCli(t, ctx, projectId, c.TargetPort, nil) require.NoError(t, err) err = boundary.AddHostSourceToTargetCli(t, ctx, targetId, hostSetId) require.NoError(t, err) diff --git a/testing/internal/e2e/tests/base/target_tcp_connect_test.go b/testing/internal/e2e/tests/base/target_tcp_connect_test.go index 44e26d808..b5a9af4fa 100644 --- a/testing/internal/e2e/tests/base/target_tcp_connect_test.go +++ b/testing/internal/e2e/tests/base/target_tcp_connect_test.go @@ -43,7 +43,7 @@ func TestCliTcpTargetConnectTargetBasic(t *testing.T) { require.NoError(t, err) err = boundary.AddHostToHostSetCli(t, ctx, hostSetId, hostId) require.NoError(t, err) - targetId, err := boundary.CreateTargetCli(t, ctx, projectId, c.TargetPort) + targetId, err := boundary.CreateTargetCli(t, ctx, projectId, c.TargetPort, nil) require.NoError(t, err) err = boundary.AddHostSourceToTargetCli(t, ctx, targetId, hostSetId) require.NoError(t, err) @@ -93,7 +93,7 @@ func TestCliTcpTargetConnectTargetViaTargetAndScopeNames(t *testing.T) { }) testProjectName := `E2E/Project-With\Name` testTargetName := `E2E/Test-Target-With\Name` - projectId, err := boundary.CreateProjectCli(t, ctx, orgId, boundary.WithName(testProjectName)) + projectId, err := boundary.CreateProjectCli(t, ctx, orgId, e2e.WithArgs("-name", testProjectName)) require.NoError(t, err) hostCatalogId, err := boundary.CreateHostCatalogCli(t, ctx, projectId) require.NoError(t, err) @@ -103,7 +103,7 @@ func TestCliTcpTargetConnectTargetViaTargetAndScopeNames(t *testing.T) { require.NoError(t, err) err = boundary.AddHostToHostSetCli(t, ctx, hostSetId, hostId) require.NoError(t, err) - targetId, err := boundary.CreateTargetCli(t, ctx, projectId, c.TargetPort, target.WithName(testTargetName)) + targetId, err := boundary.CreateTargetCli(t, ctx, projectId, c.TargetPort, []target.Option{target.WithName(testTargetName)}) require.NoError(t, err) err = boundary.AddHostSourceToTargetCli(t, ctx, targetId, hostSetId) require.NoError(t, err) diff --git a/testing/internal/e2e/tests/base_plus/target_tcp_connect_postgres_test.go b/testing/internal/e2e/tests/base_plus/target_tcp_connect_postgres_test.go index 04d5e7c96..2f8032ddf 100644 --- a/testing/internal/e2e/tests/base_plus/target_tcp_connect_postgres_test.go +++ b/testing/internal/e2e/tests/base_plus/target_tcp_connect_postgres_test.go @@ -42,7 +42,7 @@ func TestCliTcpTargetConnectPostgres(t *testing.T) { ctx, projectId, c.TargetPort, - target.WithAddress(c.TargetAddress), + []target.Option{target.WithAddress(c.TargetAddress)}, ) require.NoError(t, err) storeId, err := boundary.CreateCredentialStoreStaticCli(t, ctx, projectId) diff --git a/testing/internal/e2e/tests/base_with_vault/credential_library_vault_ldap_test.go b/testing/internal/e2e/tests/base_with_vault/credential_library_vault_ldap_test.go index 77e723ab4..205e4bec4 100644 --- a/testing/internal/e2e/tests/base_with_vault/credential_library_vault_ldap_test.go +++ b/testing/internal/e2e/tests/base_with_vault/credential_library_vault_ldap_test.go @@ -230,7 +230,7 @@ func TestCliVaultLdapCredentialLibrary(t *testing.T) { require.NoError(t, err) err = boundary.AddHostToHostSetCli(t, t.Context(), hostSetId, hostId) require.NoError(t, err) - targetId, err := boundary.CreateTargetCli(t, t.Context(), projectId, c.TargetPort) + targetId, err := boundary.CreateTargetCli(t, t.Context(), projectId, c.TargetPort, nil) require.NoError(t, err) err = boundary.AddHostSourceToTargetCli(t, t.Context(), targetId, hostSetId) require.NoError(t, err) diff --git a/testing/internal/e2e/tests/base_with_vault/credential_store_test.go b/testing/internal/e2e/tests/base_with_vault/credential_store_test.go index 50a0008e6..dd934b350 100644 --- a/testing/internal/e2e/tests/base_with_vault/credential_store_test.go +++ b/testing/internal/e2e/tests/base_with_vault/credential_store_test.go @@ -49,7 +49,7 @@ func TestCliVaultCredentialStore(t *testing.T) { require.NoError(t, err) err = boundary.AddHostToHostSetCli(t, ctx, hostSetId, hostId) require.NoError(t, err) - targetId, err := boundary.CreateTargetCli(t, ctx, projectId, c.TargetPort) + targetId, err := boundary.CreateTargetCli(t, ctx, projectId, c.TargetPort, nil) require.NoError(t, err) err = boundary.AddHostSourceToTargetCli(t, ctx, targetId, hostSetId) require.NoError(t, err) diff --git a/testing/internal/e2e/tests/base_with_vault/target_tcp_vault_generic_connect_authz_token_test.go b/testing/internal/e2e/tests/base_with_vault/target_tcp_vault_generic_connect_authz_token_test.go index 77b3edf05..a2fa24d57 100644 --- a/testing/internal/e2e/tests/base_with_vault/target_tcp_vault_generic_connect_authz_token_test.go +++ b/testing/internal/e2e/tests/base_with_vault/target_tcp_vault_generic_connect_authz_token_test.go @@ -47,7 +47,7 @@ func TestCliTcpTargetVaultGenericConnectTargetWithAuthzToken(t *testing.T) { require.NoError(t, err) err = boundary.AddHostToHostSetCli(t, ctx, hostSetId, hostId) require.NoError(t, err) - targetId, err := boundary.CreateTargetCli(t, ctx, projectId, c.TargetPort) + targetId, err := boundary.CreateTargetCli(t, ctx, projectId, c.TargetPort, nil) require.NoError(t, err) err = boundary.AddHostSourceToTargetCli(t, ctx, targetId, hostSetId) require.NoError(t, err) diff --git a/testing/internal/e2e/tests/base_with_vault/target_tcp_vault_generic_connect_ssh_test.go b/testing/internal/e2e/tests/base_with_vault/target_tcp_vault_generic_connect_ssh_test.go index 02e70dee2..becbef74f 100644 --- a/testing/internal/e2e/tests/base_with_vault/target_tcp_vault_generic_connect_ssh_test.go +++ b/testing/internal/e2e/tests/base_with_vault/target_tcp_vault_generic_connect_ssh_test.go @@ -47,7 +47,7 @@ func TestCliTcpTargetVaultGenericConnectTargetWithSsh(t *testing.T) { require.NoError(t, err) err = boundary.AddHostToHostSetCli(t, ctx, hostSetId, hostId) require.NoError(t, err) - targetId, err := boundary.CreateTargetCli(t, ctx, projectId, c.TargetPort) + targetId, err := boundary.CreateTargetCli(t, ctx, projectId, c.TargetPort, nil) require.NoError(t, err) err = boundary.AddHostSourceToTargetCli(t, ctx, targetId, hostSetId) require.NoError(t, err) diff --git a/testing/internal/e2e/tests/base_with_vault/target_tcp_vault_generic_connect_test.go b/testing/internal/e2e/tests/base_with_vault/target_tcp_vault_generic_connect_test.go index fd813a556..62a828d75 100644 --- a/testing/internal/e2e/tests/base_with_vault/target_tcp_vault_generic_connect_test.go +++ b/testing/internal/e2e/tests/base_with_vault/target_tcp_vault_generic_connect_test.go @@ -48,7 +48,7 @@ func TestCliTcpTargetVaultGenericConnectTarget(t *testing.T) { require.NoError(t, err) err = boundary.AddHostToHostSetCli(t, ctx, hostSetId, hostId) require.NoError(t, err) - targetId, err := boundary.CreateTargetCli(t, ctx, projectId, c.TargetPort) + targetId, err := boundary.CreateTargetCli(t, ctx, projectId, c.TargetPort, nil) require.NoError(t, err) err = boundary.AddHostSourceToTargetCli(t, ctx, targetId, hostSetId) require.NoError(t, err) diff --git a/testing/internal/e2e/tests/base_with_worker/target_tcp_worker_connect_ssh_test.go b/testing/internal/e2e/tests/base_with_worker/target_tcp_worker_connect_ssh_test.go index ed3a55c30..2c3e04d09 100644 --- a/testing/internal/e2e/tests/base_with_worker/target_tcp_worker_connect_ssh_test.go +++ b/testing/internal/e2e/tests/base_with_worker/target_tcp_worker_connect_ssh_test.go @@ -129,8 +129,10 @@ func TestCliTcpTargetWorkerConnectTarget(t *testing.T) { ctx, projectId, c.TargetPort, - target.WithAddress("openssh-server"), - target.WithEgressWorkerFilter(fmt.Sprintf(`"%s" in "/tags/type"`, c.WorkerTagEgress)), + []target.Option{ + target.WithAddress("openssh-server"), + target.WithEgressWorkerFilter(fmt.Sprintf(`"%s" in "/tags/type"`, c.WorkerTagEgress)), + }, ) require.NoError(t, err) diff --git a/testing/internal/e2e/tests/database/migration_test.go b/testing/internal/e2e/tests/database/migration_test.go index 96ba59431..ec05fb1c4 100644 --- a/testing/internal/e2e/tests/database/migration_test.go +++ b/testing/internal/e2e/tests/database/migration_test.go @@ -224,7 +224,7 @@ func populateBoundaryDatabase(t testing.TB, ctx context.Context, c *config, te T require.NoError(t, err) err = boundary.AddHostToHostSetCli(t, ctx, hostSetId, hostId) require.NoError(t, err) - targetId, err := boundary.CreateTargetCli(t, ctx, projectId, "2222") // openssh-server uses port 2222 + targetId, err := boundary.CreateTargetCli(t, ctx, projectId, "2222", nil) // openssh-server uses port 2222 require.NoError(t, err) err = boundary.AddHostSourceToTargetCli(t, ctx, targetId, hostSetId) require.NoError(t, err) @@ -235,8 +235,10 @@ func populateBoundaryDatabase(t testing.TB, ctx context.Context, c *config, te T ctx, projectId, "2222", - target.WithName("e2e target with address"), - target.WithAddress(te.Target.UriNetwork), + []target.Option{ + target.WithName("e2e target with address"), + target.WithAddress(te.Target.UriNetwork), + }, ) require.NoError(t, err) diff --git a/testing/internal/e2e/tests/gcp/dynamichostcatalog_host_set_empty_test.go b/testing/internal/e2e/tests/gcp/dynamichostcatalog_host_set_empty_test.go index f96574c1a..500e9811c 100644 --- a/testing/internal/e2e/tests/gcp/dynamichostcatalog_host_set_empty_test.go +++ b/testing/internal/e2e/tests/gcp/dynamichostcatalog_host_set_empty_test.go @@ -97,7 +97,7 @@ func TestCliCreateGcpDynamicHostCatalogWithEmptyHostSet(t *testing.T) { t.Log("Successfully detected zero hosts in the host catalog") // Create target - targetId, err := boundary.CreateTargetCli(t, ctx, projectId, c.GcpTargetPort) + targetId, err := boundary.CreateTargetCli(t, ctx, projectId, c.GcpTargetPort, nil) require.NoError(t, err) err = boundary.AddHostSourceToTargetCli(t, ctx, targetId, hostSetId) require.NoError(t, err) diff --git a/testing/internal/e2e/tests/gcp/dynamichostcatalog_host_set_test.go b/testing/internal/e2e/tests/gcp/dynamichostcatalog_host_set_test.go index 898263eac..b2e1f4257 100644 --- a/testing/internal/e2e/tests/gcp/dynamichostcatalog_host_set_test.go +++ b/testing/internal/e2e/tests/gcp/dynamichostcatalog_host_set_test.go @@ -117,7 +117,7 @@ func TestCliCreateGcpDynamicHostCatalogWithHostSet(t *testing.T) { assert.Equal(t, 1, actualHostCatalogCount, "Numbers of hosts in host catalog did not match expected amount") // Create target - targetId, err := boundary.CreateTargetCli(t, ctx, projectId, c.GcpTargetPort) + targetId, err := boundary.CreateTargetCli(t, ctx, projectId, c.GcpTargetPort, nil) require.NoError(t, err) err = boundary.AddHostSourceToTargetCli(t, ctx, targetId, hostSetId1) require.NoError(t, err)