Files
threshold/internal/tests/cli/boundary/_credentials.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

48 lines
1015 B
Bash

load _authorized_actions
function create_username_password_credential() {
local name=$1
local sid=$2
local user=$3
local pass=$4
export BP="${pass}"
boundary credentials create username-password \
-name $name \
-description 'test username password credential' \
-credential-store-id $sid \
-username $user \
-password env://BP
}
function create_json_credential() {
local name=$1
local sid=$2
local args=$3
boundary credentials create json \
-name $name \
-description 'test json credential' \
-credential-store-id $sid \
$args
}
function read_credential() {
boundary credentials read -id $1 -format json
}
function delete_credential() {
boundary credentials delete -id $1 -format json
}
function list_credentials() {
boundary credentials list -credential-store-id $1 -format json
}
function credential_id() {
local name=$1
local sid=$2
strip $(list_credentials $sid | jq -c ".items[] | select(.name | contains(\"$name\")) | .[\"id\"]")
}