feat(cli): Support creating/updating a Username-Password-Domain static credential (#1525)

Co-authored-by: Andrew Gaffney <andrew@gaffney.cc>
Co-authored-by: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>
This commit is contained in:
authored and irenarindos committed 2025-09-02 15:12:38 -04:00
1 parent 0824dd7d16
commit 582efa2fd2
9 files changed
+784

No files matched your search

@@ -18,6 +18,39 @@ function create_username_password_credential() {
-password env://BP
}
function create_username_password_domain_credential_with_domain() {
local name=$1
local sid=$2
local user=$3
local pass=$4
local domain=$5
export BP="${pass}"
boundary credentials create username-password-domain \
-name $name \
-description 'test username password domain credential with domain' \
-credential-store-id $sid \
-username $user \
-password env://BP \
-domain $domain
}
function create_username_password_domain_credential() {
local name=$1
local sid=$2
local user=$3
local pass=$4
export BP="${pass}"
boundary credentials create username-password-domain \
-name $name \
-description 'test username password domain credential with domain parsed from username' \
-credential-store-id $sid \
-username $user \
-password env://BP
}
function create_json_credential() {
local name=$1
local sid=$2
@@ -7,6 +7,10 @@ load _credentials
export NEW_STORE='credentials-test-store'
export NEW_CREDENTIAL='test-up'
export NEW_UPD_CREDENTIAL='test-user-pass-domain'
export NEW_UPD_AT_CREDENTIAL='test-at-user-domain-pass'
export NEW_UPD_SLASH_CREDENTIAL='test-slash-domain-user-pass'
export NEW_UPD_CREDENTIAL_DOMAIN='test-domain-user-plus-domain'
export NEW_JSON_CREDENTIAL='test-json'
@test "boundary/login: can login as default user" {
@@ -28,6 +32,42 @@ export NEW_JSON_CREDENTIAL='test-json'
[ "$status" -eq 0 ]
}
@test "boundary/credentials: can create $NEW_UPD_CREDENTIAL credential in $NEW_STORE store" {
local csid=$(credential_store_id $NEW_STORE $DEFAULT_P_ID)
run create_username_password_domain_credential_with_domain $NEW_UPD_CREDENTIAL $csid 'username' 'password' 'domain'
echo "$output"
[ "$status" -eq 0 ]
}
@test "boundary/credentials: can create $NEW_UPD_AT_CREDENTIAL credential in $NEW_STORE store" {
local csid=$(credential_store_id $NEW_STORE $DEFAULT_P_ID)
run create_username_password_domain_credential $NEW_UPD_AT_CREDENTIAL $csid 'username@domain' 'password'
echo "$output"
[ "$status" -eq 0 ]
}
@test "boundary/credentials: can create $NEW_UPD_SLASH_CREDENTIAL credential in $NEW_STORE store" {
local csid=$(credential_store_id $NEW_STORE $DEFAULT_P_ID)
run create_username_password_domain_credential $NEW_UPD_SLASH_CREDENTIAL $csid 'domain\username' 'password'
echo "$output"
[ "$status" -eq 0 ]
}
@test "boundary/credentials: can not create username@domain with domain $NEW_UPD_CREDENTIAL_DOMAIN credential in $NEW_STORE store" {
local csid=$(credential_store_id $NEW_STORE $DEFAULT_P_ID)
run create_username_password_domain_credential_with_domain $NEW_UPD_CREDENTIAL_DOMAIN $csid 'username@domain' 'password' 'domain2'
[ "$status" -ne 0 ]
[[ "$output" == *"Error parsing username and domain"* ]]
}
@test "boundary/credentials: can not create domain/username with domain $NEW_UPD_CREDENTIAL_DOMAIN credential in $NEW_STORE store" {
local csid=$(credential_store_id $NEW_STORE $DEFAULT_P_ID)
run create_username_password_domain_credential_with_domain $NEW_UPD_CREDENTIAL_DOMAIN $csid 'domain\username' 'password' 'domain2'
[ "$status" -ne 0 ]
[[ "$output" == *"Error parsing username and domain"* ]]
}
@test "boundary/credentials: can create $NEW_JSON_CREDENTIAL credential in $NEW_STORE store" {
local csid=$(credential_store_id $NEW_STORE $DEFAULT_P_ID)
run create_json_credential $NEW_JSON_CREDENTIAL $csid '-string-kv username=admin -string-kv password=pass'
@@ -42,6 +82,27 @@ export NEW_JSON_CREDENTIAL='test-json'
[ "$status" -eq 1 ]
}
@test "boundary/credentials: can not create already created $NEW_UPD_CREDENTIAL credential in $NEW_STORE store" {
local csid=$(credential_store_id $NEW_STORE $DEFAULT_P_ID)
run create_username_password_domain_credential_with_domain $NEW_UPD_CREDENTIAL $csid 'username' 'password' 'domain'
echo "$output"
[ "$status" -eq 1 ]
}
@test "boundary/credentials: can not create already created $NEW_UPD_AT_CREDENTIAL credential in $NEW_STORE store" {
local csid=$(credential_store_id $NEW_STORE $DEFAULT_P_ID)
run create_username_password_domain_credential $NEW_UPD_AT_CREDENTIAL $csid 'username@domain' 'password'
echo "$output"
[ "$status" -eq 1 ]
}
@test "boundary/credentials: can not create already created $NEW_UPD_SLASH_CREDENTIAL credential in $NEW_STORE store" {
local csid=$(credential_store_id $NEW_STORE $DEFAULT_P_ID)
run create_username_password_domain_credential $NEW_UPD_SLASH_CREDENTIAL $csid 'domain\username' 'password'
echo "$output"
[ "$status" -eq 1 ]
}
@test "boundary/credentials: can not create already created $NEW_JSON_CREDENTIAL credential" {
local csid=$(credential_store_id $NEW_STORE $DEFAULT_P_ID)
run create_json_credential $NEW_JSON_CREDENTIAL $csid '-string-kv username=admin -string-kv password=pass'
@@ -57,6 +118,30 @@ export NEW_JSON_CREDENTIAL='test-json'
[ "$status" -eq 0 ]
}
@test "boundary/credentials: can read $NEW_UPD_CREDENTIAL credential" {
local csid=$(credential_store_id $NEW_STORE $DEFAULT_P_ID)
local cid=$(credential_id $NEW_UPD_CREDENTIAL $csid)
run read_credential $cid
echo "$output"
[ "$status" -eq 0 ]
}
@test "boundary/credentials: can read $NEW_UPD_AT_CREDENTIAL credential" {
local csid=$(credential_store_id $NEW_STORE $DEFAULT_P_ID)
local cid=$(credential_id $NEW_UPD_AT_CREDENTIAL $csid)
run read_credential $cid
echo "$output"
[ "$status" -eq 0 ]
}
@test "boundary/credentials: can read $NEW_UPD_SLASH_CREDENTIAL credential" {
local csid=$(credential_store_id $NEW_STORE $DEFAULT_P_ID)
local cid=$(credential_id $NEW_UPD_SLASH_CREDENTIAL $csid)
run read_credential $cid
echo "$output"
[ "$status" -eq 0 ]
}
@test "boundary/credentials: can read $NEW_JSON_CREDENTIAL credential" {
local csid=$(credential_store_id $NEW_STORE $DEFAULT_P_ID)
local cid=$(credential_id $NEW_JSON_CREDENTIAL $csid)
@@ -74,6 +159,33 @@ export NEW_JSON_CREDENTIAL='test-json'
[ "$status" -eq 0 ]
}
@test "boundary/credentials: can delete $NEW_UPD_CREDENTIAL credential" {
local csid=$(credential_store_id $NEW_STORE $DEFAULT_P_ID)
local cid=$(credential_id $NEW_UPD_CREDENTIAL $csid)
run delete_credential $cid
echo "$output"
run has_status_code "$output" "204"
[ "$status" -eq 0 ]
}
@test "boundary/credentials: can delete $NEW_UPD_AT_CREDENTIAL credential" {
local csid=$(credential_store_id $NEW_STORE $DEFAULT_P_ID)
local cid=$(credential_id $NEW_UPD_AT_CREDENTIAL $csid)
run delete_credential $cid
echo "$output"
run has_status_code "$output" "204"
[ "$status" -eq 0 ]
}
@test "boundary/credentials: can delete $NEW_UPD_SLASH_CREDENTIAL credential" {
local csid=$(credential_store_id $NEW_STORE $DEFAULT_P_ID)
local cid=$(credential_id $NEW_UPD_SLASH_CREDENTIAL $csid)
run delete_credential $cid
echo "$output"
run has_status_code "$output" "204"
[ "$status" -eq 0 ]
}
@test "boundary/credentials: can delete $NEW_JSON_CREDENTIAL credential" {
local csid=$(credential_store_id $NEW_STORE $DEFAULT_P_ID)
local cid=$(credential_id $NEW_JSON_CREDENTIAL $csid)
@@ -119,6 +231,30 @@ export NEW_JSON_CREDENTIAL='test-json'
[ "$status" -eq 1 ]
}
@test "boundary/credential-stores: can not read deleted $NEW_UPD_CREDENTIAL credential" {
local csid=$(credential_store_id $NEW_STORE $DEFAULT_P_ID)
local cid=$(credential_id $NEW_UPD_CREDENTIAL $csid)
run read_credential $cid
echo "$output"
[ "$status" -eq 1 ]
}
@test "boundary/credential-stores: can not read deleted $NEW_UPD_AT_CREDENTIAL credential" {
local csid=$(credential_store_id $NEW_STORE $DEFAULT_P_ID)
local cid=$(credential_id $NEW_UPD_AT_CREDENTIAL $csid)
run read_credential $cid
echo "$output"
[ "$status" -eq 1 ]
}
@test "boundary/credential-stores: can not read deleted $NEW_UPD_SLASH_CREDENTIAL credential" {
local csid=$(credential_store_id $NEW_STORE $DEFAULT_P_ID)
local cid=$(credential_id $NEW_UPD_SLASH_CREDENTIAL $csid)
run read_credential $cid
echo "$output"
[ "$status" -eq 1 ]
}
@test "boundary/credential-stores: can delete $NEW_STORE static store" {
local csid=$(credential_store_id $NEW_STORE $DEFAULT_P_ID)
run delete_credential_store $csid