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:
17 files changed
+101
-62
No files matched your search
@@ -9,7 +9,7 @@ function read_group() {
|
||||
}
|
||||
|
||||
function delete_group() {
|
||||
boundary groups delete -id $1
|
||||
boundary groups delete -id $1 -format json
|
||||
}
|
||||
|
||||
function list_groups() {
|
||||
@@ -27,7 +27,7 @@ function group_id() {
|
||||
|
||||
function group_member_ids() {
|
||||
local gid=$1
|
||||
boundary groups read -id $gid -format json | jq '.item["members"][]["id"]'
|
||||
boundary groups read -id $gid -format json | jq '.item["members"][]["id"]'
|
||||
}
|
||||
|
||||
function group_has_member_id() {
|
||||
@@ -36,10 +36,10 @@ function group_has_member_id() {
|
||||
ids=$(group_member_ids $gid)
|
||||
for id in $ids; do
|
||||
if [ $(strip "$id") == "$mid" ]; then
|
||||
return 0
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
return 1
|
||||
return 1
|
||||
}
|
||||
|
||||
function has_default_group_actions() {
|
||||
@@ -51,6 +51,6 @@ function has_default_group_actions() {
|
||||
$(has_authorized_action "$out" "$action") || {
|
||||
echo "failed to find $action action in output: $out"
|
||||
return 1
|
||||
}
|
||||
}
|
||||
done
|
||||
}
|
||||
Reference in new issue
Block a user