From 9a6b0d26cbef8e50fa0af1c49f55991eb17c13bd Mon Sep 17 00:00:00 2001 From: Michael Li Date: Wed, 6 Sep 2023 17:29:35 -0400 Subject: [PATCH] test(e2e): Add test for `boundary connect postgres` (#3671) * refact(e2e): Rename env * test(e2e): Add test for `connect postgres` * fixup! test(e2e): Add test for `connect postgres` --- .github/workflows/enos-run.yml | 1 + .../enos-scenario-e2e-aws-base-with-vault.hcl | 2 +- enos/enos-scenario-e2e-aws-base.hcl | 2 +- enos/enos-scenario-e2e-aws.hcl | 2 +- ...scenario-e2e-docker-base-with-postgres.hcl | 116 ++++++++++++++++++ ...os-scenario-e2e-docker-base-with-vault.hcl | 2 +- enos/enos-scenario-e2e-docker-base.hcl | 2 +- enos/enos-scenario-e2e-ui.hcl | 2 +- enos/modules/docker_postgres/main.tf | 29 ++++- enos/modules/test_e2e/main.tf | 8 +- enos/modules/test_e2e_docker/main.tf | 23 +++- enos/modules/test_e2e_docker/test.sh | 3 +- enos/modules/test_e2e_docker/test_runner.sh | 7 +- enos/modules/test_e2e_ui/main.tf | 8 +- testing/internal/e2e/tests/aws/env_test.go | 4 +- testing/internal/e2e/tests/aws/worker_test.go | 2 +- .../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 | 4 +- testing/internal/e2e/tests/base/env_test.go | 8 +- .../tests/base/session_cancel_admin_test.go | 2 +- .../tests/base/session_cancel_group_test.go | 4 +- .../tests/base/session_cancel_user_test.go | 4 +- .../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 | 24 ++-- .../target_tcp_connect_authz_token_test.go | 4 +- .../base/target_tcp_connect_localhost_test.go | 4 +- ...get_tcp_connect_ssh_remote_command_test.go | 4 +- .../tests/base/target_tcp_connect_ssh_test.go | 2 +- .../e2e/tests/base/target_tcp_connect_test.go | 12 +- .../e2e/tests/base_with_postgres/env_test.go | 24 ++++ .../target_tcp_connect_postgres_test.go | 79 ++++++++++++ .../base_with_vault/credential_store_test.go | 4 +- .../e2e/tests/base_with_vault/env_test.go | 8 +- .../target_tcp_vault_connect_test.go | 4 +- ..._vault_generic_connect_authz_token_test.go | 2 +- ...rget_tcp_vault_generic_connect_ssh_test.go | 2 +- .../target_tcp_vault_generic_connect_test.go | 4 +- .../internal/e2e/tests/database/env_test.go | 2 +- 43 files changed, 346 insertions(+), 82 deletions(-) create mode 100644 enos/enos-scenario-e2e-docker-base-with-postgres.hcl create mode 100644 testing/internal/e2e/tests/base_with_postgres/env_test.go create mode 100644 testing/internal/e2e/tests/base_with_postgres/target_tcp_connect_postgres_test.go diff --git a/.github/workflows/enos-run.yml b/.github/workflows/enos-run.yml index c3412c0f72..5f81acc6e6 100644 --- a/.github/workflows/enos-run.yml +++ b/.github/workflows/enos-run.yml @@ -80,6 +80,7 @@ jobs: - filter: 'e2e_database' - filter: 'e2e_docker_base builder:crt' - filter: 'e2e_docker_base_with_vault builder:crt' + - filter: 'e2e_docker_base_with_postgres builder:crt' runs-on: ${{ fromJSON(vars.RUNNER_LARGE) }} env: GITHUB_TOKEN: ${{ secrets.SERVICE_USER_GITHUB_TOKEN }} diff --git a/enos/enos-scenario-e2e-aws-base-with-vault.hcl b/enos/enos-scenario-e2e-aws-base-with-vault.hcl index d5cf48db28..3bd77a00e5 100644 --- a/enos/enos-scenario-e2e-aws-base-with-vault.hcl +++ b/enos/enos-scenario-e2e-aws-base-with-vault.hcl @@ -152,7 +152,7 @@ scenario "e2e_aws_base_with_vault" { auth_password = step.create_boundary_cluster.auth_password local_boundary_dir = local.local_boundary_dir aws_ssh_private_key_path = local.aws_ssh_private_key_path - target_ip = step.create_target.target_ips[0] + target_address = step.create_target.target_ips[0] target_user = "ubuntu" target_port = "22" vault_addr = step.create_vault_cluster.instance_public_ips[0] diff --git a/enos/enos-scenario-e2e-aws-base.hcl b/enos/enos-scenario-e2e-aws-base.hcl index 63ef4053eb..28180fa7db 100644 --- a/enos/enos-scenario-e2e-aws-base.hcl +++ b/enos/enos-scenario-e2e-aws-base.hcl @@ -129,7 +129,7 @@ scenario "e2e_aws_base" { auth_password = step.create_boundary_cluster.auth_password local_boundary_dir = local.local_boundary_dir aws_ssh_private_key_path = local.aws_ssh_private_key_path - target_ip = step.create_target.target_ips[0] + target_address = step.create_target.target_ips[0] target_user = "ubuntu" target_port = "22" } diff --git a/enos/enos-scenario-e2e-aws.hcl b/enos/enos-scenario-e2e-aws.hcl index 71d5451bb7..4e74217040 100644 --- a/enos/enos-scenario-e2e-aws.hcl +++ b/enos/enos-scenario-e2e-aws.hcl @@ -246,7 +246,7 @@ scenario "e2e_aws" { aws_host_set_ips1 = step.create_targets_with_tag1.target_ips aws_host_set_filter2 = step.create_tag2_inputs.tag_string aws_host_set_ips2 = step.create_targets_with_tag2.target_ips - target_ip = step.create_isolated_target.target_ips[0] + target_address = step.create_isolated_target.target_ips[0] worker_tags = step.create_isolated_worker.worker_tags } } diff --git a/enos/enos-scenario-e2e-docker-base-with-postgres.hcl b/enos/enos-scenario-e2e-docker-base-with-postgres.hcl new file mode 100644 index 0000000000..d8b8eb8769 --- /dev/null +++ b/enos/enos-scenario-e2e-docker-base-with-postgres.hcl @@ -0,0 +1,116 @@ +# Copyright (c) HashiCorp, Inc. +# SPDX-License-Identifier: BUSL-1.1 + +# For this scenario to work, add the following line to /etc/hosts +# 127.0.0.1 localhost boundary + +scenario "e2e_docker_base_with_postgres" { + terraform_cli = terraform_cli.default + terraform = terraform.default + providers = [ + provider.enos.default + ] + + matrix { + builder = ["local", "crt"] + } + + locals { + aws_ssh_private_key_path = abspath(var.aws_ssh_private_key_path) + local_boundary_dir = abspath(var.local_boundary_dir) + local_boundary_src_dir = abspath(var.local_boundary_src_dir) + boundary_docker_image_file = abspath(var.boundary_docker_image_file) + license_path = abspath(var.boundary_license_path != null ? var.boundary_license_path : joinpath(path.root, "./support/boundary.hclic")) + + network_cluster = "e2e_cluster" + + build_path = { + "local" = "/tmp", + "crt" = var.crt_bundle_path == null ? null : abspath(var.crt_bundle_path) + } + tags = merge({ + "Project Name" : var.project_name + "Project" : "Enos", + "Environment" : "ci" + }, var.tags) + } + + step "build_boundary_docker_image" { + module = matrix.builder == "crt" ? module.build_boundary_docker_crt : module.build_boundary_docker_local + + variables { + path = matrix.builder == "crt" ? local.boundary_docker_image_file : "" + cli_build_path = local.build_path[matrix.builder] + } + } + + step "create_docker_network" { + module = module.docker_network + variables { + network_name = local.network_cluster + } + } + + step "create_boundary_database" { + depends_on = [ + step.create_docker_network + ] + variables { + image_name = "${var.docker_mirror}/library/postgres:latest" + network_name = [local.network_cluster] + } + module = module.docker_postgres + } + + step "read_license" { + skip_step = var.boundary_edition == "oss" + module = module.read_license + + variables { + file_name = local.license_path + } + } + + step "create_boundary" { + module = module.docker_boundary + depends_on = [ + step.create_docker_network, + step.create_boundary_database, + step.build_boundary_docker_image + ] + variables { + image_name = matrix.builder == "crt" ? var.boundary_docker_image_name : step.build_boundary_docker_image.image_name + network_name = [local.network_cluster] + database_network = local.network_cluster + postgres_address = step.create_boundary_database.address + boundary_license = var.boundary_edition != "oss" ? step.read_license.license : "" + } + } + + step "run_e2e_test" { + module = module.test_e2e_docker + depends_on = [ + step.create_boundary, + ] + variables { + test_package = "github.com/hashicorp/boundary/testing/internal/e2e/tests/base_with_postgres" + docker_mirror = var.docker_mirror + network_name = step.create_docker_network.network_name + go_version = var.go_version + debug_no_run = var.e2e_debug_no_run + alb_boundary_api_addr = step.create_boundary.address + auth_method_id = step.create_boundary.auth_method_id + auth_login_name = step.create_boundary.login_name + auth_password = step.create_boundary.password + local_boundary_dir = step.build_boundary_docker_image.cli_zip_path + local_boundary_src_dir = local.local_boundary_src_dir + aws_ssh_private_key_path = local.aws_ssh_private_key_path + target_address = step.create_boundary_database.container_name + target_port = step.create_boundary_database.port + target_user = "ubuntu" + postgres_user = step.create_boundary_database.user + postgres_password = step.create_boundary_database.password + postgres_database_name = step.create_boundary_database.database_name + } + } +} diff --git a/enos/enos-scenario-e2e-docker-base-with-vault.hcl b/enos/enos-scenario-e2e-docker-base-with-vault.hcl index fc10c6264c..debbe02407 100644 --- a/enos/enos-scenario-e2e-docker-base-with-vault.hcl +++ b/enos/enos-scenario-e2e-docker-base-with-vault.hcl @@ -130,7 +130,7 @@ scenario "e2e_docker_base_with_vault" { local_boundary_dir = step.build_boundary_docker_image.cli_zip_path local_boundary_src_dir = local.local_boundary_src_dir aws_ssh_private_key_path = local.aws_ssh_private_key_path - target_ip = step.create_host.address + target_address = step.create_host.address target_port = step.create_host.port target_user = "ubuntu" vault_addr = step.create_vault.address diff --git a/enos/enos-scenario-e2e-docker-base.hcl b/enos/enos-scenario-e2e-docker-base.hcl index 20cd5bc3b4..ceffcd35d7 100644 --- a/enos/enos-scenario-e2e-docker-base.hcl +++ b/enos/enos-scenario-e2e-docker-base.hcl @@ -118,7 +118,7 @@ scenario "e2e_docker_base" { local_boundary_dir = step.build_boundary_docker_image.cli_zip_path local_boundary_src_dir = local.local_boundary_src_dir aws_ssh_private_key_path = local.aws_ssh_private_key_path - target_ip = step.create_host.address + target_address = step.create_host.address target_port = step.create_host.port target_user = "ubuntu" } diff --git a/enos/enos-scenario-e2e-ui.hcl b/enos/enos-scenario-e2e-ui.hcl index 49fd12c933..6201cd941e 100644 --- a/enos/enos-scenario-e2e-ui.hcl +++ b/enos/enos-scenario-e2e-ui.hcl @@ -220,7 +220,7 @@ scenario "e2e_ui" { local_boundary_dir = local.local_boundary_dir local_boundary_ui_src_dir = local.local_boundary_ui_src_dir aws_ssh_private_key_path = local.aws_ssh_private_key_path - target_ip = step.create_targets_with_tag1.target_ips[0] + target_address = step.create_targets_with_tag1.target_ips[0] target_user = "ubuntu" target_port = "22" vault_addr = step.create_vault_cluster.instance_public_ips[0] diff --git a/enos/modules/docker_postgres/main.tf b/enos/modules/docker_postgres/main.tf index fcf21bb81c..04c3fd1cea 100644 --- a/enos/modules/docker_postgres/main.tf +++ b/enos/modules/docker_postgres/main.tf @@ -43,6 +43,11 @@ variable "database_name" { type = string default = "boundarydb" } +variable "port" { + description = "Docker container port to use" + type = number + default = 5432 +} resource "docker_image" "postgres" { name = var.image_name @@ -63,8 +68,8 @@ resource "docker_container" "postgres" { container_path = "/etc/postgresql/" } ports { - internal = 5432 - external = 5432 + internal = var.port + external = var.port } healthcheck { test = ["CMD", "pg_isready", "-U", "${var.user}", "-d", "${var.database_name}"] @@ -93,3 +98,23 @@ resource "enos_local_exec" "wait" { output "address" { value = "postgres://${var.user}:${var.password}@${var.container_name}:5432/${var.database_name}?sslmode=disable" } + +output "user" { + value = var.user +} + +output "password" { + value = var.password +} + +output "database_name" { + value = var.database_name +} + +output "port" { + value = var.port +} + +output "container_name" { + value = var.container_name +} diff --git a/enos/modules/test_e2e/main.tf b/enos/modules/test_e2e/main.tf index 771d5dbfcc..45c5f2e897 100644 --- a/enos/modules/test_e2e/main.tf +++ b/enos/modules/test_e2e/main.tf @@ -52,8 +52,8 @@ variable "aws_ssh_private_key_path" { type = string default = "" } -variable "target_ip" { - description = "IP address of target" +variable "target_address" { + description = "Address of target" type = string default = "" } @@ -157,9 +157,9 @@ resource "enos_local_exec" "run_e2e_test" { E2E_PASSWORD_AUTH_METHOD_ID = var.auth_method_id, E2E_PASSWORD_ADMIN_LOGIN_NAME = var.auth_login_name, E2E_PASSWORD_ADMIN_PASSWORD = var.auth_password, - E2E_TARGET_IP = var.target_ip, + E2E_TARGET_ADDRESS = var.target_address, + E2E_TARGET_PORT = var.target_port, E2E_SSH_USER = var.target_user, - E2E_SSH_PORT = var.target_port, E2E_SSH_KEY_PATH = local.aws_ssh_private_key_path, E2E_SSH_CA_KEY = "", VAULT_ADDR = local.vault_addr, diff --git a/enos/modules/test_e2e_docker/main.tf b/enos/modules/test_e2e_docker/main.tf index a7de8ffb65..27cb5490a0 100644 --- a/enos/modules/test_e2e_docker/main.tf +++ b/enos/modules/test_e2e_docker/main.tf @@ -80,8 +80,8 @@ variable "aws_ssh_private_key_path" { type = string default = "" } -variable "target_ip" { - description = "IP address of target" +variable "target_address" { + description = "Address of target" type = string default = "" } @@ -164,6 +164,18 @@ variable "worker_tags" { type = list(string) default = [""] } +variable "postgres_user" { + type = string + default = "" +} +variable "postgres_password" { + type = string + default = "" +} +variable "postgres_database_name" { + type = string + default = "" +} variable "test_timeout" { type = string default = "15m" @@ -203,9 +215,9 @@ resource "enos_local_exec" "run_e2e_test" { E2E_PASSWORD_AUTH_METHOD_ID = var.auth_method_id, E2E_PASSWORD_ADMIN_LOGIN_NAME = var.auth_login_name, E2E_PASSWORD_ADMIN_PASSWORD = var.auth_password, - E2E_TARGET_IP = var.target_ip, + E2E_TARGET_ADDRESS = var.target_address, + E2E_TARGET_PORT = var.target_port, E2E_SSH_USER = var.target_user, - E2E_SSH_PORT = var.target_port, E2E_SSH_KEY_PATH = local.aws_ssh_private_key_path, E2E_SSH_CA_KEY = var.target_ca_key, VAULT_ADDR = local.vault_addr, @@ -221,6 +233,9 @@ resource "enos_local_exec" "run_e2e_test" { E2E_AWS_REGION = var.aws_region, E2E_AWS_BUCKET_NAME = var.aws_bucket_name, E2E_WORKER_TAG = jsonencode(var.worker_tags), + E2E_POSTGRES_USER = var.postgres_user + E2E_POSTGRES_PASSWORD = var.postgres_password + E2E_POSTGRES_DB_NAME = var.postgres_database_name BOUNDARY_DIR = abspath(var.local_boundary_src_dir), BOUNDARY_CLI_DIR = abspath(var.local_boundary_dir), MODULE_DIR = abspath(path.module) diff --git a/enos/modules/test_e2e_docker/test.sh b/enos/modules/test_e2e_docker/test.sh index ed8a193c6f..c1488cd581 100755 --- a/enos/modules/test_e2e_docker/test.sh +++ b/enos/modules/test_e2e_docker/test.sh @@ -13,7 +13,8 @@ apt update # unzip is used to unzip boundary.zip # pass is used to store the auth token from `boundary authenticate`` # lsb-release is used for adding the hashicorp apt source -apt install unzip pass lsb-release -y +# postgresql is used for postgres tests +apt install unzip pass lsb-release postgresql-client -y # Create a GPG key export KEY_PW=boundary diff --git a/enos/modules/test_e2e_docker/test_runner.sh b/enos/modules/test_e2e_docker/test_runner.sh index 4ffc5ffe37..65e7ce4986 100644 --- a/enos/modules/test_e2e_docker/test_runner.sh +++ b/enos/modules/test_e2e_docker/test_runner.sh @@ -17,9 +17,9 @@ docker run \ -e "E2E_PASSWORD_AUTH_METHOD_ID=$E2E_PASSWORD_AUTH_METHOD_ID" \ -e "E2E_PASSWORD_ADMIN_LOGIN_NAME=$E2E_PASSWORD_ADMIN_LOGIN_NAME" \ -e "E2E_PASSWORD_ADMIN_PASSWORD=$E2E_PASSWORD_ADMIN_PASSWORD" \ - -e "E2E_TARGET_IP=$E2E_TARGET_IP" \ + -e "E2E_TARGET_ADDRESS=$E2E_TARGET_ADDRESS" \ -e "E2E_SSH_USER=$E2E_SSH_USER" \ - -e "E2E_SSH_PORT=$E2E_SSH_PORT" \ + -e "E2E_TARGET_PORT=$E2E_TARGET_PORT" \ -e "E2E_SSH_CA_KEY=$E2E_SSH_CA_KEY" \ -e "E2E_SSH_KEY_PATH=/keys/target.pem" \ -e "VAULT_ADDR=$VAULT_ADDR_INTERNAL" \ @@ -33,6 +33,9 @@ docker run \ -e "E2E_AWS_HOST_SET_IPS2=$E2E_AWS_HOST_SET_IPS2" \ -e "E2E_AWS_REGION=$E2E_AWS_REGION" \ -e "E2E_AWS_BUCKET_NAME=$E2E_AWS_BUCKET_NAME" \ + -e "E2E_POSTGRES_USER=$E2E_POSTGRES_USER" \ + -e "E2E_POSTGRES_PASSWORD=$E2E_POSTGRES_PASSWORD" \ + -e "E2E_POSTGRES_DB_NAME=$E2E_POSTGRES_DB_NAME" \ -e "E2E_WORKER_TAG=$E2E_WORKER_TAG" \ --mount type=bind,src=$BOUNDARY_DIR,dst=/src/boundary/ \ --mount type=bind,src=$MODULE_DIR/../..,dst=/testlogs \ diff --git a/enos/modules/test_e2e_ui/main.tf b/enos/modules/test_e2e_ui/main.tf index 277b89a0ac..6dcd67e379 100644 --- a/enos/modules/test_e2e_ui/main.tf +++ b/enos/modules/test_e2e_ui/main.tf @@ -52,8 +52,8 @@ variable "aws_ssh_private_key_path" { type = string default = "" } -variable "target_ip" { - description = "IP address of target" +variable "target_address" { + description = "Address of target" type = string default = "" } @@ -132,9 +132,9 @@ resource "enos_local_exec" "run_e2e_ui_test" { E2E_PASSWORD_AUTH_METHOD_ID = var.auth_method_id, E2E_PASSWORD_ADMIN_LOGIN_NAME = var.auth_login_name, E2E_PASSWORD_ADMIN_PASSWORD = var.auth_password, - E2E_TARGET_IP = var.target_ip, + E2E_TARGET_ADDRESS = var.target_address, + E2E_TARGET_PORT = var.target_port, E2E_SSH_USER = var.target_user, - E2E_SSH_PORT = var.target_port, E2E_SSH_KEY_PATH = local.aws_ssh_private_key_path, VAULT_ADDR = local.vault_addr, VAULT_TOKEN = var.vault_root_token, diff --git a/testing/internal/e2e/tests/aws/env_test.go b/testing/internal/e2e/tests/aws/env_test.go index 8f14080ff8..9875e24a9f 100644 --- a/testing/internal/e2e/tests/aws/env_test.go +++ b/testing/internal/e2e/tests/aws/env_test.go @@ -16,8 +16,8 @@ type config struct { AwsRegion string `envconfig:"E2E_AWS_REGION" required:"true"` // e.g. "us-east-1" TargetSshKeyPath string `envconfig:"E2E_SSH_KEY_PATH" required:"true"` // e.g. "/Users/username/key.pem" TargetSshUser string `envconfig:"E2E_SSH_USER" required:"true"` // e.g. "ubuntu" - TargetPort string `envconfig:"E2E_SSH_PORT" required:"true"` // e.g. "22" - TargetIp string `envconfig:"E2E_TARGET_IP" required:"true"` // e.g. "192.168.0.1" + TargetPort string `envconfig:"E2E_TARGET_PORT" required:"true"` // e.g. "22" + TargetAddress string `envconfig:"E2E_TARGET_ADDRESS" required:"true"` // e.g. "192.168.0.1" WorkerTags string `envconfig:"E2E_WORKER_TAG" required:"true"` // e.g. "[\"tag1\", \"tag2\"]" } diff --git a/testing/internal/e2e/tests/aws/worker_test.go b/testing/internal/e2e/tests/aws/worker_test.go index 2238b87cf7..403e4b57d7 100644 --- a/testing/internal/e2e/tests/aws/worker_test.go +++ b/testing/internal/e2e/tests/aws/worker_test.go @@ -31,7 +31,7 @@ func TestCliWorker(t *testing.T) { require.NoError(t, output.Err, string(output.Stderr)) }) newProjectId := boundary.CreateNewProjectCli(t, ctx, newOrgId) - newTargetId := boundary.CreateNewTargetCli(t, ctx, newProjectId, c.TargetPort, target.WithAddress(c.TargetIp)) + newTargetId := boundary.CreateNewTargetCli(t, ctx, newProjectId, c.TargetPort, target.WithAddress(c.TargetAddress)) // Set incorrect worker filter, expect connection failure t.Logf("Setting incorrect worker filter...") 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 8cc47d3a1b..d60f461edd 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 @@ -35,7 +35,7 @@ func TestCliBytesUpDownEmpty(t *testing.T) { newProjectId := boundary.CreateNewProjectCli(t, ctx, newOrgId) newHostCatalogId := boundary.CreateNewHostCatalogCli(t, ctx, newProjectId) newHostSetId := boundary.CreateNewHostSetCli(t, ctx, newHostCatalogId) - newHostId := boundary.CreateNewHostCli(t, ctx, newHostCatalogId, c.TargetIp) + newHostId := boundary.CreateNewHostCli(t, ctx, newHostCatalogId, c.TargetAddress) boundary.AddHostToHostSetCli(t, ctx, newHostSetId, newHostId) newTargetId := boundary.CreateNewTargetCli(t, ctx, newProjectId, c.TargetPort) boundary.AddHostSourceToTargetCli(t, ctx, newTargetId, newHostSetId) 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 f9c9a18e87..d2d1f23f8c 100644 --- a/testing/internal/e2e/tests/base/bytes_up_down_test.go +++ b/testing/internal/e2e/tests/base/bytes_up_down_test.go @@ -36,7 +36,7 @@ func TestCliBytesUpDownTransferData(t *testing.T) { newProjectId := boundary.CreateNewProjectCli(t, ctx, newOrgId) newHostCatalogId := boundary.CreateNewHostCatalogCli(t, ctx, newProjectId) newHostSetId := boundary.CreateNewHostSetCli(t, ctx, newHostCatalogId) - newHostId := boundary.CreateNewHostCli(t, ctx, newHostCatalogId, c.TargetIp) + newHostId := boundary.CreateNewHostCli(t, ctx, newHostCatalogId, c.TargetAddress) boundary.AddHostToHostSetCli(t, ctx, newHostSetId, newHostId) newTargetId := boundary.CreateNewTargetCli(t, ctx, newProjectId, c.TargetPort) boundary.AddHostSourceToTargetCli(t, ctx, newTargetId, newHostSetId) diff --git a/testing/internal/e2e/tests/base/credential_store_test.go b/testing/internal/e2e/tests/base/credential_store_test.go index e61fc57676..657a5bff69 100644 --- a/testing/internal/e2e/tests/base/credential_store_test.go +++ b/testing/internal/e2e/tests/base/credential_store_test.go @@ -50,7 +50,7 @@ func TestCliStaticCredentialStore(t *testing.T) { newProjectId := boundary.CreateNewProjectCli(t, ctx, newOrgId) newHostCatalogId := boundary.CreateNewHostCatalogCli(t, ctx, newProjectId) newHostSetId := boundary.CreateNewHostSetCli(t, ctx, newHostCatalogId) - newHostId := boundary.CreateNewHostCli(t, ctx, newHostCatalogId, c.TargetIp) + newHostId := boundary.CreateNewHostCli(t, ctx, newHostCatalogId, c.TargetAddress) boundary.AddHostToHostSetCli(t, ctx, newHostSetId, newHostId) newTargetId := boundary.CreateNewTargetCli(t, ctx, newProjectId, c.TargetPort) boundary.AddHostSourceToTargetCli(t, ctx, newTargetId, newHostSetId) @@ -191,7 +191,7 @@ func TestApiStaticCredentialStore(t *testing.T) { newProjectId := boundary.CreateNewProjectApi(t, ctx, client, newOrgId) newHostCatalogId := boundary.CreateNewHostCatalogApi(t, ctx, client, newProjectId) newHostSetId := boundary.CreateNewHostSetApi(t, ctx, client, newHostCatalogId) - newHostId := boundary.CreateNewHostApi(t, ctx, client, newHostCatalogId, c.TargetIp) + newHostId := boundary.CreateNewHostApi(t, ctx, client, newHostCatalogId, c.TargetAddress) boundary.AddHostToHostSetApi(t, ctx, client, newHostSetId, newHostId) newTargetId := boundary.CreateNewTargetApi(t, ctx, client, newProjectId, c.TargetPort) boundary.AddHostSourceToTargetApi(t, ctx, client, newTargetId, newHostSetId) diff --git a/testing/internal/e2e/tests/base/env_test.go b/testing/internal/e2e/tests/base/env_test.go index 22178c75a1..dc6dc6cdf5 100644 --- a/testing/internal/e2e/tests/base/env_test.go +++ b/testing/internal/e2e/tests/base/env_test.go @@ -6,10 +6,10 @@ package base_test import "github.com/kelseyhightower/envconfig" type config struct { - TargetIp string `envconfig:"E2E_TARGET_IP" required:"true"` // e.g. 192.168.0.1 - TargetSshKeyPath string `envconfig:"E2E_SSH_KEY_PATH" required:"true"` // e.g. /Users/username/key.pem - TargetSshUser string `envconfig:"E2E_SSH_USER" required:"true"` // e.g. ubuntu - TargetPort string `envconfig:"E2E_SSH_PORT" required:"true"` + TargetAddress string `envconfig:"E2E_TARGET_ADDRESS" required:"true"` // e.g. 192.168.0.1 + TargetSshKeyPath string `envconfig:"E2E_SSH_KEY_PATH" required:"true"` // e.g. /Users/username/key.pem + TargetSshUser string `envconfig:"E2E_SSH_USER" required:"true"` // e.g. ubuntu + TargetPort string `envconfig:"E2E_TARGET_PORT" required:"true"` } func loadTestConfig() (*config, error) { 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 dcaaa0285d..59479aaa35 100644 --- a/testing/internal/e2e/tests/base/session_cancel_admin_test.go +++ b/testing/internal/e2e/tests/base/session_cancel_admin_test.go @@ -33,7 +33,7 @@ func TestCliSessionCancelAdmin(t *testing.T) { newProjectId := boundary.CreateNewProjectCli(t, ctx, newOrgId) newHostCatalogId := boundary.CreateNewHostCatalogCli(t, ctx, newProjectId) newHostSetId := boundary.CreateNewHostSetCli(t, ctx, newHostCatalogId) - newHostId := boundary.CreateNewHostCli(t, ctx, newHostCatalogId, c.TargetIp) + newHostId := boundary.CreateNewHostCli(t, ctx, newHostCatalogId, c.TargetAddress) boundary.AddHostToHostSetCli(t, ctx, newHostSetId, newHostId) newTargetId := boundary.CreateNewTargetCli(t, ctx, newProjectId, c.TargetPort) boundary.AddHostSourceToTargetCli(t, ctx, newTargetId, newHostSetId) 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 189a04c044..feeb588cf4 100644 --- a/testing/internal/e2e/tests/base/session_cancel_group_test.go +++ b/testing/internal/e2e/tests/base/session_cancel_group_test.go @@ -44,7 +44,7 @@ func TestCliSessionCancelGroup(t *testing.T) { newProjectId := boundary.CreateNewProjectCli(t, ctx, newOrgId) newHostCatalogId := boundary.CreateNewHostCatalogCli(t, ctx, newProjectId) newHostSetId := boundary.CreateNewHostSetCli(t, ctx, newHostCatalogId) - newHostId := boundary.CreateNewHostCli(t, ctx, newHostCatalogId, c.TargetIp) + newHostId := boundary.CreateNewHostCli(t, ctx, newHostCatalogId, c.TargetAddress) boundary.AddHostToHostSetCli(t, ctx, newHostSetId, newHostId) newTargetId := boundary.CreateNewTargetCli(t, ctx, newProjectId, c.TargetPort) boundary.AddHostSourceToTargetCli(t, ctx, newTargetId, newHostSetId) @@ -171,7 +171,7 @@ func TestApiCreateGroup(t *testing.T) { newProjectId := boundary.CreateNewProjectApi(t, ctx, client, newOrgId) newHostCatalogId := boundary.CreateNewHostCatalogApi(t, ctx, client, newProjectId) newHostSetId := boundary.CreateNewHostSetApi(t, ctx, client, newHostCatalogId) - newHostId := boundary.CreateNewHostApi(t, ctx, client, newHostCatalogId, c.TargetIp) + newHostId := boundary.CreateNewHostApi(t, ctx, client, newHostCatalogId, c.TargetAddress) boundary.AddHostToHostSetApi(t, ctx, client, newHostSetId, newHostId) newTargetId := boundary.CreateNewTargetApi(t, ctx, client, newProjectId, c.TargetPort) boundary.AddHostSourceToTargetApi(t, ctx, client, newTargetId, newHostSetId) 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 ca70e81c0f..dd71977e7d 100644 --- a/testing/internal/e2e/tests/base/session_cancel_user_test.go +++ b/testing/internal/e2e/tests/base/session_cancel_user_test.go @@ -43,7 +43,7 @@ func TestCliSessionCancelUser(t *testing.T) { newProjectId := boundary.CreateNewProjectCli(t, ctx, newOrgId) newHostCatalogId := boundary.CreateNewHostCatalogCli(t, ctx, newProjectId) newHostSetId := boundary.CreateNewHostSetCli(t, ctx, newHostCatalogId) - newHostId := boundary.CreateNewHostCli(t, ctx, newHostCatalogId, c.TargetIp) + newHostId := boundary.CreateNewHostCli(t, ctx, newHostCatalogId, c.TargetAddress) boundary.AddHostToHostSetCli(t, ctx, newHostSetId, newHostId) newTargetId := boundary.CreateNewTargetCli(t, ctx, newProjectId, c.TargetPort) boundary.AddHostSourceToTargetCli(t, ctx, newTargetId, newHostSetId) @@ -166,7 +166,7 @@ func TestApiCreateUser(t *testing.T) { newProjectId := boundary.CreateNewProjectApi(t, ctx, client, newOrgId) newHostCatalogId := boundary.CreateNewHostCatalogApi(t, ctx, client, newProjectId) newHostSetId := boundary.CreateNewHostSetApi(t, ctx, client, newHostCatalogId) - newHostId := boundary.CreateNewHostApi(t, ctx, client, newHostCatalogId, c.TargetIp) + newHostId := boundary.CreateNewHostApi(t, ctx, client, newHostCatalogId, c.TargetAddress) boundary.AddHostToHostSetApi(t, ctx, client, newHostSetId, newHostId) newTargetId := boundary.CreateNewTargetApi(t, ctx, client, newProjectId, c.TargetPort) boundary.AddHostSourceToTargetApi(t, ctx, client, newTargetId, newHostSetId) 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 c0241c07ad..97c9130a5f 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 @@ -36,7 +36,7 @@ func TestCliSessionEndWhenHostSetIsDeleted(t *testing.T) { newProjectId := boundary.CreateNewProjectCli(t, ctx, newOrgId) newHostCatalogId := boundary.CreateNewHostCatalogCli(t, ctx, newProjectId) newHostSetId := boundary.CreateNewHostSetCli(t, ctx, newHostCatalogId) - newHostId := boundary.CreateNewHostCli(t, ctx, newHostCatalogId, c.TargetIp) + newHostId := boundary.CreateNewHostCli(t, ctx, newHostCatalogId, c.TargetAddress) boundary.AddHostToHostSetCli(t, ctx, newHostSetId, newHostId) newTargetId := boundary.CreateNewTargetCli(t, ctx, newProjectId, c.TargetPort) boundary.AddHostSourceToTargetCli(t, ctx, newTargetId, newHostSetId) 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 92e9056985..7c7d96cfb6 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 @@ -36,7 +36,7 @@ func TestCliSessionEndWhenHostIsDeleted(t *testing.T) { newProjectId := boundary.CreateNewProjectCli(t, ctx, newOrgId) newHostCatalogId := boundary.CreateNewHostCatalogCli(t, ctx, newProjectId) newHostSetId := boundary.CreateNewHostSetCli(t, ctx, newHostCatalogId) - newHostId := boundary.CreateNewHostCli(t, ctx, newHostCatalogId, c.TargetIp) + newHostId := boundary.CreateNewHostCli(t, ctx, newHostCatalogId, c.TargetAddress) boundary.AddHostToHostSetCli(t, ctx, newHostSetId, newHostId) newTargetId := boundary.CreateNewTargetCli(t, ctx, newProjectId, c.TargetPort) boundary.AddHostSourceToTargetCli(t, ctx, newTargetId, newHostSetId) 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 fc7affc1ba..a00caee840 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 @@ -35,7 +35,7 @@ func TestCliSessionEndWhenProjectIsDeleted(t *testing.T) { require.NoError(t, output.Err, string(output.Stderr)) }) newProjectId := boundary.CreateNewProjectCli(t, ctx, newOrgId) - newTargetId := boundary.CreateNewTargetCli(t, ctx, newProjectId, c.TargetPort, target.WithAddress(c.TargetIp)) + newTargetId := boundary.CreateNewTargetCli(t, ctx, newProjectId, c.TargetPort, target.WithAddress(c.TargetAddress)) acctName := "e2e-account" newAccountId, acctPassword := boundary.CreateNewAccountCli(t, ctx, bc.AuthMethodId, acctName) t.Cleanup(func() { 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 3b7ea3a40c..954ce74f04 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 @@ -36,7 +36,7 @@ func TestCliSessionEndWhenTargetIsDeleted(t *testing.T) { newProjectId := boundary.CreateNewProjectCli(t, ctx, newOrgId) newHostCatalogId := boundary.CreateNewHostCatalogCli(t, ctx, newProjectId) newHostSetId := boundary.CreateNewHostSetCli(t, ctx, newHostCatalogId) - newHostId := boundary.CreateNewHostCli(t, ctx, newHostCatalogId, c.TargetIp) + newHostId := boundary.CreateNewHostCli(t, ctx, newHostCatalogId, c.TargetAddress) boundary.AddHostToHostSetCli(t, ctx, newHostSetId, newHostId) newTargetId := boundary.CreateNewTargetCli(t, ctx, newProjectId, c.TargetPort) boundary.AddHostSourceToTargetCli(t, ctx, newTargetId, newHostSetId) 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 3a8f0b54d8..3337cf9b96 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 @@ -38,7 +38,7 @@ func TestCliSessionEndWhenUserIsDeleted(t *testing.T) { newProjectId := boundary.CreateNewProjectCli(t, ctx, newOrgId) newHostCatalogId := boundary.CreateNewHostCatalogCli(t, ctx, newProjectId) newHostSetId := boundary.CreateNewHostSetCli(t, ctx, newHostCatalogId) - newHostId := boundary.CreateNewHostCli(t, ctx, newHostCatalogId, c.TargetIp) + newHostId := boundary.CreateNewHostCli(t, ctx, newHostCatalogId, c.TargetAddress) boundary.AddHostToHostSetCli(t, ctx, newHostSetId, newHostId) newTargetId := boundary.CreateNewTargetCli(t, ctx, newProjectId, c.TargetPort) boundary.AddHostSourceToTargetCli(t, ctx, newTargetId, newHostSetId) 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 c1ca435af8..689ed1bf20 100644 --- a/testing/internal/e2e/tests/base/target_tcp_address_test.go +++ b/testing/internal/e2e/tests/base/target_tcp_address_test.go @@ -33,7 +33,7 @@ func TestCliCreateUpdateTargetAddress(t *testing.T) { require.NoError(t, output.Err, string(output.Stderr)) }) newProjectId := boundary.CreateNewProjectCli(t, ctx, newOrgId) - newTargetId := boundary.CreateNewTargetCli(t, ctx, newProjectId, c.TargetPort, target.WithAddress(c.TargetIp)) + newTargetId := boundary.CreateNewTargetCli(t, ctx, newProjectId, c.TargetPort, target.WithAddress(c.TargetAddress)) // Connect to target and print host's IP address output := e2e.RunCommand(ctx, "boundary", @@ -55,7 +55,7 @@ func TestCliCreateUpdateTargetAddress(t *testing.T) { parts := strings.Fields(string(output.Stdout)) hostIp := parts[len(parts)-1] - require.Equal(t, c.TargetIp, hostIp, "SSH session did not return expected output") + require.Equal(t, c.TargetAddress, hostIp, "SSH session did not return expected output") t.Log("Successfully connected to target") // Remove target address. We have now no address or host sources. @@ -98,7 +98,7 @@ func TestCliCreateUpdateTargetAddress(t *testing.T) { e2e.WithArgs( "targets", "update", "tcp", "-id", newTargetId, - "-address", c.TargetIp, + "-address", c.TargetAddress, "-format", "json", ), ) @@ -124,7 +124,7 @@ func TestCliCreateUpdateTargetAddress(t *testing.T) { parts = strings.Fields(string(output.Stdout)) hostIp = parts[len(parts)-1] - require.Equal(t, c.TargetIp, hostIp, "SSH session did not return expected output") + require.Equal(t, c.TargetAddress, hostIp, "SSH session did not return expected output") t.Log("Successfully connected to target") } @@ -150,9 +150,9 @@ func TestCliTargetAddressToHostSource(t *testing.T) { newProjectId := boundary.CreateNewProjectCli(t, ctx, newOrgId) newHostCatalogId := boundary.CreateNewHostCatalogCli(t, ctx, newProjectId) newHostSetId := boundary.CreateNewHostSetCli(t, ctx, newHostCatalogId) - newHostId := boundary.CreateNewHostCli(t, ctx, newHostCatalogId, c.TargetIp) + newHostId := boundary.CreateNewHostCli(t, ctx, newHostCatalogId, c.TargetAddress) boundary.AddHostToHostSetCli(t, ctx, newHostSetId, newHostId) - newTargetId := boundary.CreateNewTargetCli(t, ctx, newProjectId, c.TargetPort, target.WithAddress(c.TargetIp)) + newTargetId := boundary.CreateNewTargetCli(t, ctx, newProjectId, c.TargetPort, target.WithAddress(c.TargetAddress)) // Connect to target and print host's IP address output := e2e.RunCommand(ctx, "boundary", @@ -174,7 +174,7 @@ func TestCliTargetAddressToHostSource(t *testing.T) { parts := strings.Fields(string(output.Stdout)) hostIp := parts[len(parts)-1] - require.Equal(t, c.TargetIp, hostIp, "SSH session did not return expected output") + require.Equal(t, c.TargetAddress, hostIp, "SSH session did not return expected output") t.Log("Successfully connected to target") // Attempt add-host-sources. Should error because the target has an address. @@ -240,7 +240,7 @@ func TestCliTargetAddressToHostSource(t *testing.T) { parts = strings.Fields(string(output.Stdout)) hostIp = parts[len(parts)-1] - require.Equal(t, c.TargetIp, hostIp, "SSH session did not return expected output") + require.Equal(t, c.TargetAddress, hostIp, "SSH session did not return expected output") t.Log("Successfully connected to target") } @@ -267,7 +267,7 @@ func TestCliTargetHostSourceToAddress(t *testing.T) { newProjectId := boundary.CreateNewProjectCli(t, ctx, newOrgId) newHostCatalogId := boundary.CreateNewHostCatalogCli(t, ctx, newProjectId) newHostSetId := boundary.CreateNewHostSetCli(t, ctx, newHostCatalogId) - newHostId := boundary.CreateNewHostCli(t, ctx, newHostCatalogId, c.TargetIp) + newHostId := boundary.CreateNewHostCli(t, ctx, newHostCatalogId, c.TargetAddress) boundary.AddHostToHostSetCli(t, ctx, newHostSetId, newHostId) newTargetId := boundary.CreateNewTargetCli(t, ctx, newProjectId, c.TargetPort) boundary.AddHostSourceToTargetCli(t, ctx, newTargetId, newHostSetId) @@ -292,7 +292,7 @@ func TestCliTargetHostSourceToAddress(t *testing.T) { parts := strings.Fields(string(output.Stdout)) hostIp := parts[len(parts)-1] - require.Equal(t, c.TargetIp, hostIp, "SSH session did not return expected output") + require.Equal(t, c.TargetAddress, hostIp, "SSH session did not return expected output") t.Log("Successfully connected to target") // Attempt to add an address to the target - should error because we have @@ -301,7 +301,7 @@ func TestCliTargetHostSourceToAddress(t *testing.T) { e2e.WithArgs( "targets", "update", "tcp", "-id", newTargetId, - "-address", c.TargetIp, + "-address", c.TargetAddress, "-format", "json", ), ) @@ -318,7 +318,7 @@ func TestCliTargetHostSourceToAddress(t *testing.T) { e2e.WithArgs( "targets", "update", "tcp", "-id", newTargetId, - "-address", c.TargetIp, + "-address", c.TargetAddress, "-format", "json", ), ) 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 c5d9d005bc..699bb331ad 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 @@ -37,7 +37,7 @@ func TestCliTcpTargetConnectTargetWithAuthzToken(t *testing.T) { newProjectId := boundary.CreateNewProjectCli(t, ctx, newOrgId) newHostCatalogId := boundary.CreateNewHostCatalogCli(t, ctx, newProjectId) newHostSetId := boundary.CreateNewHostSetCli(t, ctx, newHostCatalogId) - newHostId := boundary.CreateNewHostCli(t, ctx, newHostCatalogId, c.TargetIp) + newHostId := boundary.CreateNewHostCli(t, ctx, newHostCatalogId, c.TargetAddress) boundary.AddHostToHostSetCli(t, ctx, newHostSetId, newHostId) newTargetId := boundary.CreateNewTargetCli(t, ctx, newProjectId, c.TargetPort) boundary.AddHostSourceToTargetCli(t, ctx, newTargetId, newHostSetId) @@ -99,6 +99,6 @@ func TestCliTcpTargetConnectTargetWithAuthzToken(t *testing.T) { parts := strings.Fields(string(output.Stdout)) hostIp := parts[len(parts)-1] - require.Equal(t, c.TargetIp, hostIp, "SSH session did not return expected output") + require.Equal(t, c.TargetAddress, hostIp, "SSH session did not return expected output") t.Log("Successfully connected to target") } 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 6928835177..436bd8431d 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 @@ -35,7 +35,7 @@ func TestCliTcpTargetConnectTargetWithLocalhost(t *testing.T) { newProjectId := boundary.CreateNewProjectCli(t, ctx, newOrgId) newHostCatalogId := boundary.CreateNewHostCatalogCli(t, ctx, newProjectId) newHostSetId := boundary.CreateNewHostSetCli(t, ctx, newHostCatalogId) - newHostId := boundary.CreateNewHostCli(t, ctx, newHostCatalogId, c.TargetIp) + newHostId := boundary.CreateNewHostCli(t, ctx, newHostCatalogId, c.TargetAddress) boundary.AddHostToHostSetCli(t, ctx, newHostSetId, newHostId) newTargetId := boundary.CreateNewTargetCli(t, ctx, newProjectId, c.TargetPort) boundary.AddHostSourceToTargetCli(t, ctx, newTargetId, newHostSetId) @@ -73,7 +73,7 @@ func TestCliTcpTargetConnectTargetWithLocalhost(t *testing.T) { ), ) require.NoError(t, output.Err, string(output.Stderr)) - require.Equal(t, c.TargetIp, strings.TrimSpace(string(output.Stdout))) + require.Equal(t, c.TargetAddress, strings.TrimSpace(string(output.Stdout))) // Cancel session cancel() diff --git a/testing/internal/e2e/tests/base/target_tcp_connect_ssh_remote_command_test.go b/testing/internal/e2e/tests/base/target_tcp_connect_ssh_remote_command_test.go index d028ad15da..a601d6c9ae 100644 --- a/testing/internal/e2e/tests/base/target_tcp_connect_ssh_remote_command_test.go +++ b/testing/internal/e2e/tests/base/target_tcp_connect_ssh_remote_command_test.go @@ -36,7 +36,7 @@ func TestCliTcpTargetConnectTargetWithSshRemoteCommand(t *testing.T) { newProjectId := boundary.CreateNewProjectCli(t, ctx, newOrgId) newHostCatalogId := boundary.CreateNewHostCatalogCli(t, ctx, newProjectId) newHostSetId := boundary.CreateNewHostSetCli(t, ctx, newHostCatalogId) - newHostId := boundary.CreateNewHostCli(t, ctx, newHostCatalogId, c.TargetIp) + newHostId := boundary.CreateNewHostCli(t, ctx, newHostCatalogId, c.TargetAddress) boundary.AddHostToHostSetCli(t, ctx, newHostSetId, newHostId) newTargetId := boundary.CreateNewTargetCli(t, ctx, newProjectId, c.TargetPort) boundary.AddHostSourceToTargetCli(t, ctx, newTargetId, newHostSetId) @@ -79,6 +79,6 @@ func TestCliTcpTargetConnectTargetWithSshRemoteCommand(t *testing.T) { ), ) require.NoError(t, output.Err, string(output.Stderr)) - require.Equal(t, c.TargetIp, strings.TrimSpace(string(output.Stdout))) + require.Equal(t, c.TargetAddress, strings.TrimSpace(string(output.Stdout))) t.Log("Successfully connected to target") } 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 df45277642..a7d80e5823 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 @@ -35,7 +35,7 @@ func TestCliTcpTargetConnectTargetWithSsh(t *testing.T) { newProjectId := boundary.CreateNewProjectCli(t, ctx, newOrgId) newHostCatalogId := boundary.CreateNewHostCatalogCli(t, ctx, newProjectId) newHostSetId := boundary.CreateNewHostSetCli(t, ctx, newHostCatalogId) - newHostId := boundary.CreateNewHostCli(t, ctx, newHostCatalogId, c.TargetIp) + newHostId := boundary.CreateNewHostCli(t, ctx, newHostCatalogId, c.TargetAddress) boundary.AddHostToHostSetCli(t, ctx, newHostSetId, newHostId) newTargetId := boundary.CreateNewTargetCli(t, ctx, newProjectId, c.TargetPort) boundary.AddHostSourceToTargetCli(t, ctx, newTargetId, newHostSetId) 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 e1144d3188..28d0d0dbfc 100644 --- a/testing/internal/e2e/tests/base/target_tcp_connect_test.go +++ b/testing/internal/e2e/tests/base/target_tcp_connect_test.go @@ -36,7 +36,7 @@ func TestCliTcpTargetConnectTargetBasic(t *testing.T) { newProjectId := boundary.CreateNewProjectCli(t, ctx, newOrgId) newHostCatalogId := boundary.CreateNewHostCatalogCli(t, ctx, newProjectId) newHostSetId := boundary.CreateNewHostSetCli(t, ctx, newHostCatalogId) - newHostId := boundary.CreateNewHostCli(t, ctx, newHostCatalogId, c.TargetIp) + newHostId := boundary.CreateNewHostCli(t, ctx, newHostCatalogId, c.TargetAddress) boundary.AddHostToHostSetCli(t, ctx, newHostSetId, newHostId) newTargetId := boundary.CreateNewTargetCli(t, ctx, newProjectId, c.TargetPort) boundary.AddHostSourceToTargetCli(t, ctx, newTargetId, newHostSetId) @@ -61,7 +61,7 @@ func TestCliTcpTargetConnectTargetBasic(t *testing.T) { parts := strings.Fields(string(output.Stdout)) hostIp := parts[len(parts)-1] - require.Equal(t, c.TargetIp, hostIp, "SSH session did not return expected output") + require.Equal(t, c.TargetAddress, hostIp, "SSH session did not return expected output") t.Log("Successfully connected to target") } @@ -88,7 +88,7 @@ func TestCliTcpTargetConnectTargetViaTargetAndScopeNames(t *testing.T) { newProjectId := boundary.CreateNewProjectCli(t, ctx, newOrgId, boundary.WithName(testProjectName)) newHostCatalogId := boundary.CreateNewHostCatalogCli(t, ctx, newProjectId) newHostSetId := boundary.CreateNewHostSetCli(t, ctx, newHostCatalogId) - newHostId := boundary.CreateNewHostCli(t, ctx, newHostCatalogId, c.TargetIp) + newHostId := boundary.CreateNewHostCli(t, ctx, newHostCatalogId, c.TargetAddress) boundary.AddHostToHostSetCli(t, ctx, newHostSetId, newHostId) newTargetId := boundary.CreateNewTargetCli(t, ctx, newProjectId, c.TargetPort, target.WithName(testTargetName)) boundary.AddHostSourceToTargetCli(t, ctx, newTargetId, newHostSetId) @@ -114,7 +114,7 @@ func TestCliTcpTargetConnectTargetViaTargetAndScopeNames(t *testing.T) { parts := strings.Fields(string(output.Stdout)) hostIp := parts[len(parts)-1] - require.Equal(t, c.TargetIp, hostIp, "SSH session did not return expected output") + require.Equal(t, c.TargetAddress, hostIp, "SSH session did not return expected output") t.Log("Successfully connected to target by its name and scope name") // Connect to target via target name and scope ID, and print host's IP address @@ -138,7 +138,7 @@ func TestCliTcpTargetConnectTargetViaTargetAndScopeNames(t *testing.T) { parts = strings.Fields(string(output.Stdout)) hostIp = parts[len(parts)-1] - require.Equal(t, c.TargetIp, hostIp, "SSH session did not return expected output") + require.Equal(t, c.TargetAddress, hostIp, "SSH session did not return expected output") t.Log("Successfully connected to target by its name and scope ID") } @@ -162,7 +162,7 @@ func TestCliTcpTargetConnectTargetWithTargetClientPort(t *testing.T) { newProjectId := boundary.CreateNewProjectCli(t, ctx, newOrgId) newHostCatalogId := boundary.CreateNewHostCatalogCli(t, ctx, newProjectId) newHostSetId := boundary.CreateNewHostSetCli(t, ctx, newHostCatalogId) - newHostId := boundary.CreateNewHostCli(t, ctx, newHostCatalogId, c.TargetIp) + newHostId := boundary.CreateNewHostCli(t, ctx, newHostCatalogId, c.TargetAddress) boundary.AddHostToHostSetCli(t, ctx, newHostSetId, newHostId) newTargetId := boundary.CreateNewTargetCli(t, ctx, newProjectId, c.TargetPort, target.WithDefaultClientPort(expPort)) boundary.AddHostSourceToTargetCli(t, ctx, newTargetId, newHostSetId) diff --git a/testing/internal/e2e/tests/base_with_postgres/env_test.go b/testing/internal/e2e/tests/base_with_postgres/env_test.go new file mode 100644 index 0000000000..8f4b5c4626 --- /dev/null +++ b/testing/internal/e2e/tests/base_with_postgres/env_test.go @@ -0,0 +1,24 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: BUSL-1.1 + +package base_with_postgres_test + +import "github.com/kelseyhightower/envconfig" + +type config struct { + TargetAddress string `envconfig:"E2E_TARGET_ADDRESS" required:"true"` // e.g. 192.168.0.1 + TargetPort string `envconfig:"E2E_TARGET_PORT" required:"true"` + PostgresDbName string `envconfig:"E2E_POSTGRES_DB_NAME" required:"true"` + PostgresUser string `envconfig:"E2E_POSTGRES_USER" required:"true"` + PostgresPassword string `envconfig:"E2E_POSTGRES_PASSWORD" required:"true"` +} + +func loadTestConfig() (*config, error) { + var c config + err := envconfig.Process("", &c) + if err != nil { + return nil, err + } + + return &c, nil +} diff --git a/testing/internal/e2e/tests/base_with_postgres/target_tcp_connect_postgres_test.go b/testing/internal/e2e/tests/base_with_postgres/target_tcp_connect_postgres_test.go new file mode 100644 index 0000000000..c4ddc99d9f --- /dev/null +++ b/testing/internal/e2e/tests/base_with_postgres/target_tcp_connect_postgres_test.go @@ -0,0 +1,79 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: BUSL-1.1 + +package base_with_postgres_test + +import ( + "bytes" + "context" + "io" + "os/exec" + "testing" + + "github.com/creack/pty" + "github.com/stretchr/testify/require" + + "github.com/hashicorp/boundary/internal/target" + "github.com/hashicorp/boundary/testing/internal/e2e" + "github.com/hashicorp/boundary/testing/internal/e2e/boundary" +) + +// TestCliTcpTargetConnectPostgres uses the boundary cli to connect to a +// target using `connect postgres` +func TestCliTcpTargetConnectPostgres(t *testing.T) { + e2e.MaybeSkipTest(t) + c, err := loadTestConfig() + require.NoError(t, err) + + ctx := context.Background() + boundary.AuthenticateAdminCli(t, ctx) + newOrgId := boundary.CreateNewOrgCli(t, ctx) + t.Cleanup(func() { + ctx := context.Background() + boundary.AuthenticateAdminCli(t, ctx) + output := e2e.RunCommand(ctx, "boundary", e2e.WithArgs("scopes", "delete", "-id", newOrgId)) + require.NoError(t, output.Err, string(output.Stderr)) + }) + newProjectId := boundary.CreateNewProjectCli(t, ctx, newOrgId) + newTargetId := boundary.CreateNewTargetCli( + t, + ctx, + newProjectId, + c.TargetPort, + target.WithAddress(c.TargetAddress), + ) + newCredentialStoreId := boundary.CreateNewCredentialStoreStaticCli(t, ctx, newProjectId) + newCredentialsId := boundary.CreateNewStaticCredentialPasswordCli( + t, + ctx, + newCredentialStoreId, + c.PostgresUser, + c.PostgresPassword, + ) + boundary.AddBrokeredCredentialSourceToTargetCli(t, ctx, newTargetId, newCredentialsId) + + var cmd *exec.Cmd + cmd = exec.CommandContext(ctx, + "boundary", + "connect", "postgres", + "-target-id", newTargetId, + "-dbname", c.PostgresDbName, + ) + f, err := pty.Start(cmd) + require.NoError(t, err) + t.Cleanup(func() { + err := f.Close() + require.NoError(t, err) + }) + + f.Write([]byte("\\pset pager off\n")) // disables pagination in output + f.Write([]byte("\\dt\n")) // list all tables + f.Write([]byte("\\q\n")) // exit psql session + f.Write([]byte{4}) // EOT (End of Transmission - marks end of file stream) + + var buf bytes.Buffer + io.Copy(&buf, f) + require.Contains(t, buf.String(), "List of relations", "Session did not return expected output") + require.Contains(t, buf.String(), c.PostgresDbName, "Session did not return expected output") + t.Log("Successfully connected to target") +} 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 797f6eed5d..46c5250089 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 @@ -39,7 +39,7 @@ func TestCliVaultCredentialStore(t *testing.T) { newProjectId := boundary.CreateNewProjectCli(t, ctx, newOrgId) newHostCatalogId := boundary.CreateNewHostCatalogCli(t, ctx, newProjectId) newHostSetId := boundary.CreateNewHostSetCli(t, ctx, newHostCatalogId) - newHostId := boundary.CreateNewHostCli(t, ctx, newHostCatalogId, c.TargetIp) + newHostId := boundary.CreateNewHostCli(t, ctx, newHostCatalogId, c.TargetAddress) boundary.AddHostToHostSetCli(t, ctx, newHostSetId, newHostId) newTargetId := boundary.CreateNewTargetCli(t, ctx, newProjectId, c.TargetPort) boundary.AddHostSourceToTargetCli(t, ctx, newTargetId, newHostSetId) @@ -203,7 +203,7 @@ func TestApiVaultCredentialStore(t *testing.T) { newProjectId := boundary.CreateNewProjectApi(t, ctx, client, newOrgId) newHostCatalogId := boundary.CreateNewHostCatalogApi(t, ctx, client, newProjectId) newHostSetId := boundary.CreateNewHostSetApi(t, ctx, client, newHostCatalogId) - newHostId := boundary.CreateNewHostApi(t, ctx, client, newHostCatalogId, c.TargetIp) + newHostId := boundary.CreateNewHostApi(t, ctx, client, newHostCatalogId, c.TargetAddress) boundary.AddHostToHostSetApi(t, ctx, client, newHostSetId, newHostId) newTargetId := boundary.CreateNewTargetApi(t, ctx, client, newProjectId, c.TargetPort) boundary.AddHostSourceToTargetApi(t, ctx, client, newTargetId, newHostSetId) diff --git a/testing/internal/e2e/tests/base_with_vault/env_test.go b/testing/internal/e2e/tests/base_with_vault/env_test.go index 229c91678e..161a8bc799 100644 --- a/testing/internal/e2e/tests/base_with_vault/env_test.go +++ b/testing/internal/e2e/tests/base_with_vault/env_test.go @@ -6,10 +6,10 @@ package base_with_vault_test import "github.com/kelseyhightower/envconfig" type config struct { - TargetIp string `envconfig:"E2E_TARGET_IP" required:"true"` // e.g. 192.168.0.1 - TargetSshUser string `envconfig:"E2E_SSH_USER" required:"true"` // e.g. ubuntu - TargetSshKeyPath string `envconfig:"E2E_SSH_KEY_PATH" required:"true"` // e.g. /Users/username/key.pem - TargetPort string `envconfig:"E2E_SSH_PORT" required:"true"` // e.g. 22 + TargetAddress string `envconfig:"E2E_TARGET_ADDRESS" required:"true"` // e.g. 192.168.0.1 + TargetSshUser string `envconfig:"E2E_SSH_USER" required:"true"` // e.g. ubuntu + TargetSshKeyPath string `envconfig:"E2E_SSH_KEY_PATH" required:"true"` // e.g. /Users/username/key.pem + TargetPort string `envconfig:"E2E_TARGET_PORT" required:"true"` // e.g. 22 // Note: Key is base64 encoded TargetCaKey string `envconfig:"E2E_SSH_CA_KEY" required:"true"` // VaultAddr is the address that the Boundary server uses to interact with the running Vault instance diff --git a/testing/internal/e2e/tests/base_with_vault/target_tcp_vault_connect_test.go b/testing/internal/e2e/tests/base_with_vault/target_tcp_vault_connect_test.go index 7f81bf237c..139b7c79d5 100644 --- a/testing/internal/e2e/tests/base_with_vault/target_tcp_vault_connect_test.go +++ b/testing/internal/e2e/tests/base_with_vault/target_tcp_vault_connect_test.go @@ -41,7 +41,7 @@ func TestCliTcpTargetVaultConnectTarget(t *testing.T) { newProjectId := boundary.CreateNewProjectCli(t, ctx, newOrgId) newHostCatalogId := boundary.CreateNewHostCatalogCli(t, ctx, newProjectId) newHostSetId := boundary.CreateNewHostSetCli(t, ctx, newHostCatalogId) - newHostId := boundary.CreateNewHostCli(t, ctx, newHostCatalogId, c.TargetIp) + newHostId := boundary.CreateNewHostCli(t, ctx, newHostCatalogId, c.TargetAddress) boundary.AddHostToHostSetCli(t, ctx, newHostSetId, newHostId) newTargetId := boundary.CreateNewTargetCli(t, ctx, newProjectId, c.TargetPort) boundary.AddHostSourceToTargetCli(t, ctx, newTargetId, newHostSetId) @@ -171,6 +171,6 @@ func TestCliTcpTargetVaultConnectTarget(t *testing.T) { parts := strings.Fields(string(output.Stdout)) hostIp := parts[len(parts)-1] - require.Equal(t, c.TargetIp, hostIp, "SSH session did not return expected output") + require.Equal(t, c.TargetAddress, hostIp, "SSH session did not return expected output") t.Log("Successfully connected to target") } 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 b6e6fb8e98..02cb9eeb91 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 @@ -40,7 +40,7 @@ func TestCliTcpTargetVaultGenericConnectTargetWithAuthzToken(t *testing.T) { newProjectId := boundary.CreateNewProjectCli(t, ctx, newOrgId) newHostCatalogId := boundary.CreateNewHostCatalogCli(t, ctx, newProjectId) newHostSetId := boundary.CreateNewHostSetCli(t, ctx, newHostCatalogId) - newHostId := boundary.CreateNewHostCli(t, ctx, newHostCatalogId, c.TargetIp) + newHostId := boundary.CreateNewHostCli(t, ctx, newHostCatalogId, c.TargetAddress) boundary.AddHostToHostSetCli(t, ctx, newHostSetId, newHostId) newTargetId := boundary.CreateNewTargetCli(t, ctx, newProjectId, c.TargetPort) boundary.AddHostSourceToTargetCli(t, ctx, newTargetId, newHostSetId) 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 b5c74e32c0..c7343d478d 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 @@ -40,7 +40,7 @@ func TestCliTcpTargetVaultGenericConnectTargetWithSsh(t *testing.T) { newProjectId := boundary.CreateNewProjectCli(t, ctx, newOrgId) newHostCatalogId := boundary.CreateNewHostCatalogCli(t, ctx, newProjectId) newHostSetId := boundary.CreateNewHostSetCli(t, ctx, newHostCatalogId) - newHostId := boundary.CreateNewHostCli(t, ctx, newHostCatalogId, c.TargetIp) + newHostId := boundary.CreateNewHostCli(t, ctx, newHostCatalogId, c.TargetAddress) boundary.AddHostToHostSetCli(t, ctx, newHostSetId, newHostId) newTargetId := boundary.CreateNewTargetCli(t, ctx, newProjectId, c.TargetPort) boundary.AddHostSourceToTargetCli(t, ctx, newTargetId, newHostSetId) 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 325c8cb75b..a6b571542a 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 @@ -41,7 +41,7 @@ func TestCliTcpTargetVaultGenericConnectTarget(t *testing.T) { newProjectId := boundary.CreateNewProjectCli(t, ctx, newOrgId) newHostCatalogId := boundary.CreateNewHostCatalogCli(t, ctx, newProjectId) newHostSetId := boundary.CreateNewHostSetCli(t, ctx, newHostCatalogId) - newHostId := boundary.CreateNewHostCli(t, ctx, newHostCatalogId, c.TargetIp) + newHostId := boundary.CreateNewHostCli(t, ctx, newHostCatalogId, c.TargetAddress) boundary.AddHostToHostSetCli(t, ctx, newHostSetId, newHostId) newTargetId := boundary.CreateNewTargetCli(t, ctx, newProjectId, c.TargetPort) boundary.AddHostSourceToTargetCli(t, ctx, newTargetId, newHostSetId) @@ -171,6 +171,6 @@ func TestCliTcpTargetVaultGenericConnectTarget(t *testing.T) { parts := strings.Fields(string(output.Stdout)) hostIp := parts[len(parts)-1] - require.Equal(t, c.TargetIp, hostIp, "SSH session did not return expected output") + require.Equal(t, c.TargetAddress, hostIp, "SSH session did not return expected output") t.Log("Successfully connected to target") } diff --git a/testing/internal/e2e/tests/database/env_test.go b/testing/internal/e2e/tests/database/env_test.go index 154be3cde6..a4dc744979 100644 --- a/testing/internal/e2e/tests/database/env_test.go +++ b/testing/internal/e2e/tests/database/env_test.go @@ -8,7 +8,7 @@ import "github.com/kelseyhightower/envconfig" type config struct { TargetSshUser string `envconfig:"E2E_SSH_USER" required:"true"` // e.g. ubuntu TargetSshKeyPath string `envconfig:"E2E_SSH_KEY_PATH" required:"true"` // e.g. /Users/username/key.pem - TargetPort string `envconfig:"E2E_SSH_PORT" default:"22"` + TargetPort string `envconfig:"E2E_TARGET_PORT" default:"22"` VaultSecretPath string `envconfig:"E2E_VAULT_SECRET_PATH" default:"e2e_secrets"` AwsAccessKeyId string `envconfig:"E2E_AWS_ACCESS_KEY_ID" required:"true"` AwsSecretAccessKey string `envconfig:"E2E_AWS_SECRET_ACCESS_KEY" required:"true"`