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.
This commit is contained in:
Timothy Messier committed 2023-02-03 17:00:34 +00:00
1 parent 99a8875d3e
commit e66ea15fef
17 files changed
+101 -62

No files matched your search

+4 -4
View File
@@ -16,7 +16,7 @@ function read_scope() {
function delete_scope() {
local sid=$1
boundary scopes delete -id $sid
boundary scopes delete -id $sid -format json
}
function list_scopes() {
@@ -26,7 +26,7 @@ function list_scopes() {
function scope_id() {
local name=$1
local sid=$2
strip $(list_scopes $sid | jq -c ".items[] | select(.name | contains(\"$name\")) | .[\"id\"]")
}
@@ -37,7 +37,7 @@ function has_default_scope_actions() {
for action in ${actions[@]}; do
$(has_authorized_action "$out" "$action") || {
echo "failed to find $action action in output: $out"
return 1
}
return 1
}
done
}