2023-02-02 17:15:17 -08:00
|
|
|
# Copyright (c) HashiCorp, Inc.
|
|
|
|
|
# SPDX-License-Identifier: BUSL-1.1
|
|
|
|
|
|
2021-01-29 08:04:46 -08:00
|
|
|
load _authorized_actions
|
|
|
|
|
|
2020-10-12 10:26:26 -07:00
|
|
|
function create_user() {
|
|
|
|
|
boundary users create -scope-id global -name $1 -description 'test user'
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function read_user() {
|
2021-01-29 08:04:46 -08:00
|
|
|
boundary users read -id $1 -format json
|
2020-10-12 10:26:26 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function delete_user() {
|
2023-02-01 20:54:08 +00:00
|
|
|
boundary users delete -id $1 -format json
|
2020-10-12 10:26:26 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function list_users() {
|
|
|
|
|
boundary users list -format json
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function assoc_user_acct() {
|
|
|
|
|
boundary users add-accounts -account $1 -id $2
|
|
|
|
|
}
|
|
|
|
|
|
2021-01-29 08:04:46 -08:00
|
|
|
function has_default_user_actions() {
|
|
|
|
|
# tests that the user resource contains default actions
|
|
|
|
|
local out=$1
|
|
|
|
|
local actions=('read' 'update' 'delete' 'add-accounts' 'set-accounts' 'remove-accounts')
|
|
|
|
|
|
|
|
|
|
for action in ${actions[@]}; do
|
|
|
|
|
$(has_authorized_action "$out" "$action") || {
|
|
|
|
|
echo "failed to find $action action in output: $out"
|
2023-02-01 20:54:08 +00:00
|
|
|
return 1
|
|
|
|
|
}
|
2021-01-29 08:04:46 -08:00
|
|
|
done
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-12 10:26:26 -07:00
|
|
|
function user_id() {
|
|
|
|
|
local user=$1
|
2021-02-25 12:43:17 -05:00
|
|
|
strip $(list_users | jq -c ".items[] | select(.name | contains(\"$user\")) | .[\"id\"]")
|
2020-10-12 10:26:26 -07:00
|
|
|
}
|