From bee1412785e4482c492e90414f6348c1dd63ceca Mon Sep 17 00:00:00 2001 From: Jeff Malnick Date: Mon, 12 Oct 2020 16:44:45 -0700 Subject: [PATCH] tests: add host catalog CLI tests (#639) --- .../tests/cli/boundary/_host_catalogs.bash | 14 +++-- .../tests/cli/boundary/host_catalogs.bats | 53 +++++++++++++++++++ 2 files changed, 62 insertions(+), 5 deletions(-) create mode 100644 internal/tests/cli/boundary/host_catalogs.bats diff --git a/internal/tests/cli/boundary/_host_catalogs.bash b/internal/tests/cli/boundary/_host_catalogs.bash index 6be28993f..f960dc998 100644 --- a/internal/tests/cli/boundary/_host_catalogs.bash +++ b/internal/tests/cli/boundary/_host_catalogs.bash @@ -1,15 +1,19 @@ function create_host_catalog() { - local sid=$1 - local name=$2 - boundary host-catalogs create static -scope-id $sid -name $name -description 'test host catalog' + local name=$1 + local sid=$2 + echo "sid $sid" + boundary host-catalogs create static \ + -scope-id $sid \ + -name $name \ + -description 'test host catalog' } function read_host_catalog() { - boundary hosts read -id $1 + boundary host-catalogs read -id $1 } function delete_host_catalog() { - boundary hosts delete -id $1 + boundary host-catalogs delete -id $1 } function list_host_catalogs() { diff --git a/internal/tests/cli/boundary/host_catalogs.bats b/internal/tests/cli/boundary/host_catalogs.bats new file mode 100644 index 000000000..752214aca --- /dev/null +++ b/internal/tests/cli/boundary/host_catalogs.bats @@ -0,0 +1,53 @@ +#!/usr/bin/env bats + +load _auth +load _host_catalogs +load _helpers + +export NEW_HOST_CATALOG='test' + +@test "boundary/login: can login as default user" { + run login $DEFAULT_USER + echo "$output" + [ "$status" -eq 0 ] +} + +@test "boundary/hosts-catalogs: can create $NEW_HOST_CATALOG host catalog in default project scope" { + run create_host_catalog $NEW_HOST_CATALOG $DEFAULT_P_ID + echo "$output" + [ "$status" -eq 0 ] +} + +@test "boundary/hosts: can not create already created $NEW_HOST_CATALOG host catalog in default project scope" { + run create_host_catalog $NEW_HOST_CATALOG + echo "$output" + [ "$status" -eq 1 ] +} + +@test "boundary/hosts: can read $NEW_HOST_CATALOG host catalog in default project scope" { + local hid=$(host_catalog_id $NEW_HOST_CATALOG $DEFAULT_P_ID) + run read_host_catalog $hid + echo "$output" + [ "$status" -eq 0 ] +} + +@test "boundary/host: can delete $NEW_HOST_CATALOG host in default project scope" { + local hid=$(host_catalog_id $NEW_HOST_CATALOG $DEFAULT_P_ID) + run delete_host_catalog $hid + echo "$output" + [ "$status" -eq 0 ] +} + +@test "boundary/host: can not delete already deleted $NEW_HOST_CATALOG host in default project scope" { + local hid=$(host_catalog_id $NEW_HOST_CATALOG $DEFAULT_P_ID) + run delete_host_catalog $hid + echo "$output" + [ "$status" -eq 1 ] +} + +@test "boundary/hosts: can not read deleted $NEW_HOST_CATALOG host in default project scope" { + local hid=$(host_catalog_id $NEW_HOST_CATALOG $DEFAULT_P_ID) + run read_host_catalog $hid + echo "$output" + [ "$status" -eq 1 ] +}