From 7f48e2edc6a7abb7e21fe5d672f4e236f7c685c8 Mon Sep 17 00:00:00 2001 From: Jeff Malnick Date: Tue, 13 Oct 2020 07:41:14 -0700 Subject: [PATCH] tests: ensure default user can connect to default target and ensure created target has intended host sets (#646) --- internal/tests/cli/boundary/_targets.bash | 18 ++++++++++++++++++ internal/tests/cli/boundary/target.bats | 13 +++++++++++++ 2 files changed, 31 insertions(+) diff --git a/internal/tests/cli/boundary/_targets.bash b/internal/tests/cli/boundary/_targets.bash index a1ce711f23..be69148772 100644 --- a/internal/tests/cli/boundary/_targets.bash +++ b/internal/tests/cli/boundary/_targets.bash @@ -34,3 +34,21 @@ function target_id() { local name=$2 strip $(list_targets $sid | jq -c ".[] | select(.name | contains(\"$name\")) | .[\"id\"]") } + +function target_host_set_ids() { + local tid=$1 + boundary targets read -id $tid -format json | jq '.host_sets[].id' +} + +function target_has_host_set_id() { + local tid=$1 + local hsid=$2 + + ids=$(target_host_set_ids $tid) + for id in $ids; do + if [ $(strip "$id") == "$hsid" ]; then + return 0 + fi + done + return 1 +} diff --git a/internal/tests/cli/boundary/target.bats b/internal/tests/cli/boundary/target.bats index e6769d7be7..18a831f14b 100644 --- a/internal/tests/cli/boundary/target.bats +++ b/internal/tests/cli/boundary/target.bats @@ -11,6 +11,12 @@ load _helpers [ "$status" -eq 0 ] } +@test "boundary/target/connect: default user can connect to default target" { + run connect_nc $DEFAULT_TARGET + echo "$output" + [ "$status" -eq 0 ] +} + @test "boundary/target: default user can create target" { run create_tcp_target $DEFAULT_P_ID 22 $TGT_NAME [ "$status" -eq 0 ] @@ -34,6 +40,13 @@ load _helpers [ "$status" -eq 0 ] } +@test "boundary/target: created target has default host set" { + local id=$(target_id $DEFAULT_P_ID $TGT_NAME) + run target_has_host_set_id $id $DEFAULT_HOST_SET + echo "$output" + [ "$status" -eq 0 ] +} + @test "boundary/target/connect: default user can connect to created target" { local id=$(target_id $DEFAULT_P_ID $TGT_NAME) run connect_nc $id