# vim: set filetype=sh ts=4 sw=4 sts=4 et: # shellcheck shell=bash # shellcheck disable=SC2086,SC2016,SC2046 # below: convoluted way that forces shellcheck to source our caller # shellcheck source=tests/functional/launch_tests_on_instance.sh . "$(dirname "${BASH_SOURCE[0]}")"/dummy testsuite_groups() { grant accountCreate # first we need to create account1, account2 and account3 success accountCreate a0_create_a1 $a0 --osh accountCreate --always-active --account $account1 --uid $uid1 --public-key "\"$(cat $account1key1file.pub)\"" json .error_code OK .command accountCreate .value null #grant accountModify #success realm modify_account1 $a0 --osh accountModify --pam-auth-bypass yes --account $account1 #json .error_code OK .command accountModify run accountCreate a1_fail_to_create_a2_because_not_granted $a1 --osh accountCreate --always-active --account $account2 --uid $uid2 retvalshouldbe 106 contain "you to be specifically granted" json .command null .value null .error_code KO_RESTRICTED_COMMAND run account2access a2_cannot_connect_because_does_not_exist $a2 --osh info retvalshouldbe 255 nocontain "Your alias to connect" contain "Permission denied" # account with no key success accountCreate a0_create_a2_nokey $a0 --osh accountCreate --always-active --account $account2 --uid $uid2 --no-key contain "info" json .command accountCreate .error_code OK .value null grant accountListIngressKeys success accountListIngressKeys a0_check_a2_ingress_keys $a0 --osh accountListIngressKeys --account $account2 json .command accountListIngressKeys .error_code OK .value.account "$account2" .value.keys '[]' revoke accountListIngressKeys grant accountDelete script accountDelete a0_delete_a2 $a0 --osh accountDelete --account $account2 "<<< \"Yes, do as I say and delete $account2, kthxbye\"" retvalshouldbe 0 json .command accountDelete .error_code OK revoke accountDelete # /account with no key script accountCreate a0_create_a2 $a0 --osh accountCreate --always-active --account $account2 --uid $uid2 \< $account2key1file.pub retvalshouldbe 0 contain "info" json .command accountCreate .error_code OK .value null script accountCreate a0_fail_to_create_a2_already_exists $a0 --osh accountCreate --always-active --account $account2 --uid $uid2 \< $account2key1file.pub retvalshouldbe 100 contain "already exists" json .command accountCreate .error_code KO_ALREADY_EXISTING .value null #success realm modify_account1 $a0 --osh accountModify --pam-auth-bypass yes --account $account2 #json .error_code OK .command accountModify success account2access a2_can_access_the_bastion $a2 --osh info contain "Your alias to connect" json .command info .error_code OK .value.account $account2 # now create a3 directly, we'll need it to test groups script accountCreate a0_create_a3 $a0 --osh accountCreate --always-active --account $account3 --uid $uid3 \< $account3key1file.pub retvalshouldbe 0 contain "info" json .command accountCreate .error_code OK .value null #success realm modify_account1 $a0 --osh accountModify --pam-auth-bypass yes --account $account3 #json .error_code OK .command accountModify success account3access a3_can_access_the_bastion $a3 --osh info contain "Your alias to connect" json .command info .error_code OK .value.account $account3 revoke accountCreate # now create g1 grant groupCreate run groupCreate a2_fail_to_create_g1_with_a1_as_owner_because_not_granted $a2 --osh groupCreate --group $group1 --algo rsa --size 2048 --owner $account1 retvalshouldbe 106 contain "you to be specifically granted" json .command null .value null .error_code KO_RESTRICTED_COMMAND plgfail groupCreate a0_fail_to_create_g1_with_a1_as_owner_because_bad_key_size $a0 --osh groupCreate --group $group1 --algo rsa --size 1024 --owner $account1 contain "minimum configured key size" json .command groupCreate .error_code KO_KEY_SIZE_TOO_SMALL .value null plgfail groupCreate a0_fail_create_group_reserved_1 $a0 --osh groupCreate --group key --no-key --owner $account1 json .command groupCreate .error_code ERR_INVALID_PARAMETER plgfail groupCreate a0_fail_create_group_reserved_2 $a0 --osh groupCreate --group keytothegate --no-key --owner $account1 json .command groupCreate .error_code ERR_INVALID_PARAMETER success groupCreate a0_create_g1_with_a1_as_owner $a0 --osh groupCreate --group $group1 --algo rsa --size 4096 --owner $account1 contain "The public key of this group is" json $(cat < should get an early deny run groupAddOwner a2_fail_to_addowner_a3_on_g1_early_deny_owner_cmd $a2 --osh groupAddOwner --group $group1 --account $account3 retvalshouldbe 106 contain "owner" json .command null .value null .error_code KO_RESTRICTED_COMMAND run groupAddMember a2_fail_to_addmember_a3_on_g1_early_deny_gatekeeper_cmd $a2 --osh groupAddMember --group $group1 --account $account3 retvalshouldbe 106 contain "gatekeeper" json .command null .value null .error_code KO_RESTRICTED_COMMAND run groupAddOwner a2_fail_to_addserver_on_g1_early_deny_aclkeeper_cmd $a2 --osh groupAddServer --group $group1 --host 1.2.3.4 --port 1234 --user nobody retvalshouldbe 106 contain "aclkeeper" json .command null .value null .error_code KO_RESTRICTED_COMMAND # a0: create g3 and set a0, a2 and a3 as owner/gatekeeper/aclkeeper to rule out early denies for next tests # >>>BEGIN success groupCreate a0_create_g3_with_a0_as_owner $a0 --osh groupCreate --group $group3 --algo ecdsa --size 256 --owner $account0 json .error_code OK .command groupCreate .value.group $group3 .value.owner $account0 json .value.public_key.family ECDSA .value.public_key.typecode ecdsa-sha2-nistp256 .value.public_key.size 256 #g3_pubkey=$(get_json | $jq .value.public_key.line) #g3_fp=$( get_json | $jq .value.public_key.fingerprint) revoke groupCreate success groupInfo a0_info_on_g3_after_create $a0 --osh groupInfo --group $group3 json .error_code OK .command groupInfo .value.group $group3 json --arg want "$account0" '.value.owners|sort == ($want|split(" ")|sort)' true json --arg want "$account0" '.value.gatekeepers|sort == ($want|split(" ")|sort)' true json --arg want "$account0" '.value.aclkeepers|sort == ($want|split(" ")|sort)' true json --arg want "$account0" '.value.members|sort == ($want|split(" ")|sort)' true json .value.guests '[]' # ... we also take the opportunity to check with groupinfo that the add/del works as intended # ... we always try to remove a3 and fail, then add it, then add it again and fail, then remove it, then remove it and fail, then add it back # ...... for owner success groupDelOwner a0_del_a3_as_g3_owner_no_change $a0 --osh groupDelOwner --group $group3 --account $account3 json .error_code OK_NO_CHANGE .command groupDelOwner .value null success groupAddOwner a0_add_a3_as_g3_owner $a0 --osh groupAddOwner --group $group3 --account $account3 json .error_code OK .command groupAddOwner .value null success groupInfo a0_info_on_g3_after_owneradd $a0 --osh groupInfo --group $group3 json .error_code OK .command groupInfo .value.group $group3 json --arg want "$account0 $account3" '.value.owners|sort == ($want|split(" ")|sort)' true json --arg want "$account0" '.value.gatekeepers|sort == ($want|split(" ")|sort)' true json --arg want "$account0" '.value.aclkeepers|sort == ($want|split(" ")|sort)' true json --arg want "$account0" '.value.members|sort == ($want|split(" ")|sort)' true json .value.guests '[]' success groupAddOwner a0_add_a3_as_g3_owner_no_change $a0 --osh groupAddOwner --group $group3 --account $account3 json .error_code OK_NO_CHANGE .command groupAddOwner .value null success groupDelOwner a0_del_a3_as_g3_owner $a0 --osh groupDelOwner --group $group3 --account $account3 json .error_code OK .command groupDelOwner .value null success groupInfo a0_info_on_g3_after_ownerdel $a0 --osh groupInfo --group $group3 json .error_code OK .command groupInfo .value.group $group3 json --arg want "$account0" '.value.owners|sort == ($want|split(" ")|sort)' true json --arg want "$account0" '.value.gatekeepers|sort == ($want|split(" ")|sort)' true json --arg want "$account0" '.value.aclkeepers|sort == ($want|split(" ")|sort)' true json --arg want "$account0" '.value.members|sort == ($want|split(" ")|sort)' true json .value.guests '[]' success groupAddOwner a0_add_a3_as_g3_owner $a0 --osh groupAddOwner --group $group3 --account $account3 json .error_code OK .command groupAddOwner .value null success groupInfo a0_info_on_g3_after_owneradd2 $a0 --osh groupInfo --group $group3 json .error_code OK .command groupInfo .value.group $group3 json --arg want "$account0 $account3" '.value.owners|sort == ($want|split(" ")|sort)' true json --arg want "$account0" '.value.gatekeepers|sort == ($want|split(" ")|sort)' true json --arg want "$account0" '.value.aclkeepers|sort == ($want|split(" ")|sort)' true json --arg want "$account0" '.value.members|sort == ($want|split(" ")|sort)' true json .value.guests '[]' # ...... for gatekeeper success groupDelGatekeeper a0_del_a3_as_g3_gatekeeper_no_change $a0 --osh groupDelGatekeeper --group $group3 --account $account3 json .error_code OK_NO_CHANGE .command groupDelGatekeeper .value null success groupAddGatekeeper a0_add_a3_as_g3_gatekeeper $a0 --osh groupAddGatekeeper --group $group3 --account $account3 json .error_code OK .command groupAddGatekeeper .value null success groupInfo a0_info_on_g3_after_gatekeeperadd $a0 --osh groupInfo --group $group3 json .error_code OK .command groupInfo .value.group $group3 json --arg want "$account0 $account3" '.value.owners|sort == ($want|split(" ")|sort)' true json --arg want "$account0 $account3" '.value.gatekeepers|sort == ($want|split(" ")|sort)' true json --arg want "$account0" '.value.aclkeepers|sort == ($want|split(" ")|sort)' true json --arg want "$account0" '.value.members|sort == ($want|split(" ")|sort)' true json .value.guests '[]' success groupAddGatekeeper a0_add_a3_as_g3_gatekeeper_no_change $a0 --osh groupAddGatekeeper --group $group3 --account $account3 json .error_code OK_NO_CHANGE .command groupAddGatekeeper .value null success groupDelGatekeeper a0_del_a3_as_g3_gatekeeper $a0 --osh groupDelGatekeeper --group $group3 --account $account3 json .error_code OK .command groupDelGatekeeper .value null success groupInfo a0_info_on_g3_after_gatekeeperdel $a0 --osh groupInfo --group $group3 json .error_code OK .command groupInfo .value.group $group3 json --arg want "$account0 $account3" '.value.owners|sort == ($want|split(" ")|sort)' true json --arg want "$account0" '.value.gatekeepers|sort == ($want|split(" ")|sort)' true json --arg want "$account0" '.value.aclkeepers|sort == ($want|split(" ")|sort)' true json --arg want "$account0" '.value.members|sort == ($want|split(" ")|sort)' true json .value.guests '[]' success groupAddGatekeeper a0_add_a3_as_g3_gatekeeper $a0 --osh groupAddGatekeeper --group $group3 --account $account3 json .error_code OK .command groupAddGatekeeper .value null success groupInfo a0_info_on_g3_after_gatekeeperadd2 $a0 --osh groupInfo --group $group3 json .error_code OK .command groupInfo .value.group $group3 json --arg want "$account0 $account3" '.value.owners|sort == ($want|split(" ")|sort)' true json --arg want "$account0 $account3" '.value.gatekeepers|sort == ($want|split(" ")|sort)' true json --arg want "$account0" '.value.aclkeepers|sort == ($want|split(" ")|sort)' true json --arg want "$account0" '.value.members|sort == ($want|split(" ")|sort)' true json .value.guests '[]' # ...... for aclkeeper success groupDelAclkeeper a0_del_a3_as_g3_aclkeeper_no_change $a0 --osh groupDelAclkeeper --group $group3 --account $account3 json .error_code OK_NO_CHANGE .command groupDelAclkeeper .value null success groupAddAclkeeper a0_add_a3_as_g3_aclkeeper $a0 --osh groupAddAclkeeper --group $group3 --account $account3 json .error_code OK .command groupAddAclkeeper .value null #success postreq a0_g3_removembr $a0 --osh groupDelMember --group $group3 --account $account0 success postreq a0_g3_removeaclk $a0 --osh groupDelAclkeeper --group $group3 --account $account0 success postreq a0_g3_removegk $a0 --osh groupDelGatekeeper --group $group3 --account $account0 # START egress passwords # ... for groups success groupGeneratePassword works1 $a0 --osh groupGeneratePassword --group $group3 --size 17 --do-it json .command groupGeneratePassword .error_code OK .value.group $group3 md5a=$(get_json | $jq '.value.hashes.md5crypt') sha256a=$(get_json | $jq '.value.hashes.sha256crypt') sha512a=$(get_json | $jq '.value.hashes.sha512crypt') success groupListPasswords works $a0 --osh groupListPasswords --group $group3 json $(cat <