diff --git a/internal/tests/cli/boundary/_connect.bash b/internal/tests/cli/boundary/_connect.bash index 9242ce7a06..bb8666289b 100644 --- a/internal/tests/cli/boundary/_connect.bash +++ b/internal/tests/cli/boundary/_connect.bash @@ -11,4 +11,11 @@ function connect_alias() { local alias=$1 # Note: When this command returns, the session immediately goes into a "canceling" state echo "foo" | boundary connect $alias -exec nc -- {{boundary.ip}} {{boundary.port}} +} + +function connect_alias_with_host_id() { + local alias=$1 + local hostid=$2 + # Note: When this command returns, the session immediately goes into a "canceling" state + echo "foo" | boundary connect $alias -host-id $hostid -exec nc -- {{boundary.ip}} {{boundary.port}} } \ No newline at end of file diff --git a/internal/tests/cli/boundary/alias.bats b/internal/tests/cli/boundary/alias.bats index ac2ce7ab89..cb0583a5ac 100644 --- a/internal/tests/cli/boundary/alias.bats +++ b/internal/tests/cli/boundary/alias.bats @@ -4,10 +4,13 @@ load _auth load _connect load _aliases load _helpers +load _hosts +load _host_sets load _targets export ALIAS_VALUE='test' export UPDATE_ALIAS_VALUE='test.change' +export NEW_HOST="host_for_alias_test" @test "boundary/login: can login as admin user" { run login $DEFAULT_LOGIN @@ -36,12 +39,60 @@ export UPDATE_ALIAS_VALUE='test.change' [ "$status" -eq 0 ] } -@test "boundary/alias: admin user can update created alias " { +@test "boundary/alias: admin user can read target using an alias" { + run read_target $ALIAS_VALUE + [ "$status" -eq 0 ] +} + +@test "boundary/alias: admin user can connect to target using an alias" { + run connect_alias $ALIAS_VALUE + [ "$status" -eq 0 ] +} + +@test "boundary/alias: admin user can connect passing in a host id" { + run connect_alias_with_host_id $ALIAS_VALUE $DEFAULT_HOST + [ "$status" -eq 0 ] +} + +@test "boundary/alias: admin user can update alias host id" { local id=$(alias_id_from_target_alias $ALIAS_VALUE) run update_target_alias_host_id $id $DEFAULT_HOST [ "$status" -eq 0 ] - local hostid=$(host_id_from_alias_id $id) - [ "$hostid" == "$DEFAULT_HOST" ] +} + +@test "boundary/alias: admin user can connect using an alias configured with host id" { + run connect_alias $ALIAS_VALUE + [ "$status" -eq 0 ] +} + +@test "boundary/alias: admin user can connect using an alias configured with host id passing in same host id" { + run connect_alias_with_host_id $ALIAS_VALUE $DEFAULT_HOST + [ "$status" -eq 0 ] +} + +@test "boundary/host: admin can create new host" { + run create_host $NEW_HOST $DEFAULT_HOST_CATALOG + echo "$output" + [ "$status" -eq 0 ] +} + +@test "boundary/host: admin can associate new host to host set" { + local new_host_id=$(host_id $NEW_HOST $DEFAULT_HOST_CATALOG) + run assoc_host_set_host $new_host_id $DEFAULT_HOST_SET + echo "$output" + [ "$status" -eq 0 ] +} + +@test "boundary/alias: admin user cannot connect using an alias configured with host id passing in different host id" { + local new_host_id=$(host_id NEW_HOST $DEFAULT_HOST_CATALOG) + run connect_alias_with_host_id $ALIAS_VALUE $new_host_id + [ "$status" -eq 1 ] +} + +@test "boundary/host: admin can delete new host" { + local new_host_id=$(host_id $NEW_HOST $DEFAULT_HOST_CATALOG) + run delete_host $new_host_id + [ "$status" -eq 0 ] } @test "boundary/alias: admin user can remove destination id and host id will also be cleared out" { @@ -63,22 +114,6 @@ export UPDATE_ALIAS_VALUE='test.change' [ "$status" -eq 0 ] } -@test "boundary/alias: admin user can re-create alias" { - run create_target_alias $ALIAS_VALUE $DEFAULT_TARGET - echo $output - [ "$status" -eq 0 ] -} - -@test "boundary/alias: admin user can connect to target using an alias" { - run connect_alias $ALIAS_VALUE - [ "$status" -eq 0 ] -} - -@test "boundary/alias: admin user can read target using an alias" { - run read_target $ALIAS_VALUE - [ "$status" -eq 0 ] -} - @test "boundary/alias: can login as unpriv user" { run login $DEFAULT_UNPRIVILEGED_LOGIN [ "$status" -eq 0 ]