Files
threshold/internal/tests/cli/boundary/_host_catalogs.bash
T
Timothy Messier e66ea15fef fix(cli): Status code on api error
When using the json output of the cli (`-format=json`), a successful
call to the controller API would place the HTTP status code in the JSON
as `status_code`. However, if there was an error from the API the status
code would be placed in the JSON as `status`. In order to be consistent,
this adds a `status_code` field to the error response case. For
backwards compatibility it still populates `status` in the error case.

This inconsistency was missed partially due to a bug in the CLI tests.
The assertion on status code was not valid and would always be
successful. Thus this also fixes the assertions and tests.
2023-02-03 17:00:34 +00:00

42 lines
933 B
Bash

load _authorized_actions
function create_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 host-catalogs read -id $1 -format json
}
function delete_host_catalog() {
boundary host-catalogs delete -id $1 -format json
}
function list_host_catalogs() {
boundary host-catalogs list -scope-id $1 -format json
}
function host_catalog_id() {
local id=$1
local sid=$2
strip $(list_host_catalogs $sid | jq -c ".items[] | select(.name | contains(\"$id\")) | .[\"id\"]")
}
function has_default_host_catalog_actions() {
local out=$1
local actions=('read' 'update' 'delete')
for action in ${actions[@]}; do
$(has_authorized_action "$out" "$action") || {
echo "failed to find $action action in output: $out"
return 1
}
done
}