feat: static json credentials (#2423)

This commit is contained in:
Damian Debkowski authored and GitHub committed 2022-09-16 15:00:04 -07:00
1 parent 8c53d931aa
commit 546c5dc5be
42 files changed
+3207 -165

No files matched your search

@@ -15,6 +15,18 @@ function create_username_password_credential() {
-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
}
+69 -1
View File
@@ -6,7 +6,8 @@ load _credential_stores
load _credentials
export NEW_STORE='credentials-test-store'
export NEW_CREDENTIAL='test'
export NEW_CREDENTIAL='test-up'
export NEW_JSON_CREDENTIAL='test-json'
@test "boundary/login: can login as default user" {
run login $DEFAULT_LOGIN
@@ -27,6 +28,13 @@ export NEW_CREDENTIAL='test'
[ "$status" -eq 0 ]
}
@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'
echo "$output"
[ "$status" -eq 0 ]
}
@test "boundary/credentials: can not create already created $NEW_CREDENTIAL credential" {
local csid=$(credential_store_id $NEW_STORE $DEFAULT_P_ID)
run create_username_password_credential $NEW_CREDENTIAL $csid 'username' 'password'
@@ -34,6 +42,13 @@ export NEW_CREDENTIAL='test'
[ "$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'
echo "$output"
[ "$status" -eq 1 ]
}
@test "boundary/credentials: can read $NEW_CREDENTIAL credential" {
local csid=$(credential_store_id $NEW_STORE $DEFAULT_P_ID)
local cid=$(credential_id $NEW_CREDENTIAL $csid)
@@ -42,6 +57,14 @@ export NEW_CREDENTIAL='test'
[ "$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)
run read_credential $cid
echo "$output"
[ "$status" -eq 0 ]
}
@test "boundary/credentials: can delete $NEW_CREDENTIAL credential" {
local csid=$(credential_store_id $NEW_STORE $DEFAULT_P_ID)
local cid=$(credential_id $NEW_CREDENTIAL $csid)
@@ -51,6 +74,43 @@ export NEW_CREDENTIAL='test'
[ "$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)
run delete_credential $cid
echo "$output"
run has_status_code "$output" "204"
[ "$status" -eq 0 ]
}
@test "boundary/credentials: can not use object flag with kv flags for json credential" {
echo "{\"key\":\"value\"}" > cred_json_object
local object_file_path="file://$(pwd)/cred_json_object"
local csid=$(credential_store_id $NEW_STORE $DEFAULT_P_ID)
local name='object & kv flag test'
run create_json_credential $name $csid "-object $object_file_path -kv password=pass"
echo "$output"
[ "$status" -eq 1 ]
local name='object & bool-kv flag test'
run create_json_credential $name $csid "-object $object_file_path -bool-kv password=true"
echo "$output"
[ "$status" -eq 1 ]
local name='object & num-kv flag test'
run create_json_credential $name $csid "-object $object_file_path -num-kv password=1234"
echo "$output"
[ "$status" -eq 1 ]
local name='object & string-kv flag test'
run create_json_credential $name $csid "-object $object_file_path -string-kv password=pass"
echo "$output"
[ "$status" -eq 1 ]
rm cred_json_object
}
@test "boundary/credential-stores: can not read deleted $NEW_CREDENTIAL credential" {
local csid=$(credential_store_id $NEW_STORE $DEFAULT_P_ID)
local cid=$(credential_id $NEW_CREDENTIAL $csid)
@@ -72,4 +132,12 @@ export NEW_CREDENTIAL='test'
run read_credential_store $csid
echo "$output"
[ "$status" -eq 1 ]
}
@test "boundary/credential-stores: can not read deleted $NEW_JSON_CREDENTIAL credential" {
local csid=$(credential_store_id $NEW_STORE $DEFAULT_P_ID)
local cid=$(credential_id $NEW_JSON_CREDENTIAL $csid)
run read_credential $cid
echo "$output"
[ "$status" -eq 1 ]
}
@@ -12,6 +12,7 @@ export NEW_STORE='test-for-add-credential-sources'
export NEW_CREDENTIAL='first-credential'
export NEW_CREDENTIAL1='second-credential'
export NEW_CREDENTIAL2='third-credential'
export NEW_JSON_CREDENTIAL='json-credential'
@test "boundary/login: can login as admin user" {
run login $DEFAULT_LOGIN
@@ -31,6 +32,13 @@ export NEW_CREDENTIAL2='third-credential'
[ "$status" -eq 0 ]
}
@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'
echo "$output"
[ "$status" -eq 0 ]
}
@test "boundary/target: can add $NEW_CREDENTIAL credential source" {
local csid=$(credential_store_id $NEW_STORE $DEFAULT_P_ID)
local cid=$(credential_id $NEW_CREDENTIAL $csid)
@@ -47,6 +55,26 @@ export NEW_CREDENTIAL2='third-credential'
[ "$status" -eq 0 ]
}
@test "boundary/target: can add $NEW_JSON_CREDENTIAL credential source" {
local csid=$(credential_store_id $NEW_STORE $DEFAULT_P_ID)
local cid=$(credential_id $NEW_JSON_CREDENTIAL $csid)
run add_target_brokered_credential_sources $DEFAULT_TARGET $cid
echo "$output"
[ "$status" -eq 0 ]
}
@test "boundary/target: validate $NEW_CREDENTIAL & $NEW_JSON_CREDENTIAL credential source present" {
local csid=$(credential_store_id $NEW_STORE $DEFAULT_P_ID)
local credup_id=$(credential_id $NEW_CREDENTIAL $csid)
local credjson_id=$(credential_id $NEW_JSON_CREDENTIAL $csid)
run validate_credential_sources $DEFAULT_TARGET $credup_id
echo "$output"
[ "$status" -eq 0 ]
run validate_credential_sources $DEFAULT_TARGET $credjson_id
echo "$output"
[ "$status" -eq 0 ]
}
@test "boundary/target: cannot add duplicate credential source" {
local csid=$(credential_store_id $NEW_STORE $DEFAULT_P_ID)
local cid=$(credential_id $NEW_CREDENTIAL $csid)
@@ -71,6 +99,22 @@ export NEW_CREDENTIAL2='third-credential'
[ "$status" -eq 0 ]
}
@test "boundary/target: can delete $NEW_JSON_CREDENTIAL credential source" {
local csid=$(credential_store_id $NEW_STORE $DEFAULT_P_ID)
local cid=$(credential_id $NEW_JSON_CREDENTIAL $csid)
run remove_target_brokered_credential_sources $DEFAULT_TARGET $cid
echo "$output"
[ "$status" -eq 0 ]
}
@test "boundary/target: validate $NEW_JSON_CREDENTIAL credential source removed" {
local csid=$(credential_store_id $NEW_STORE $DEFAULT_P_ID)
local cid=$(credential_id $NEW_JSON_CREDENTIAL $csid)
run validate_credential_sources_not_present $DEFAULT_TARGET $cid
echo "$output"
[ "$status" -eq 0 ]
}
@test "boundary/credentials: can create additional credentials in $NEW_STORE store" {
local csid=$(credential_store_id $NEW_STORE $DEFAULT_P_ID)
run create_username_password_credential $NEW_CREDENTIAL1 $csid 'username' 'password'