the-bastion/tests/functional/tests.d/300-activeness.sh

59 lines
2.3 KiB
Bash
Raw Normal View History

2020-10-16 00:32:37 +08:00
# 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_activeness()
{
grant accountCreate
# create account1 on local bastion
success create_account1 $a0 --osh accountCreate --account $account1 --uid $uid1 --public-key \""$(cat $account1key1file.pub)"\"
2020-10-16 00:32:37 +08:00
json .error_code OK .command accountCreate .value null
success create_account2 $a0 --osh accountCreate --account $account2 --uid $uid2 --public-key \""$(cat $account2key1file.pub)"\"
2020-10-16 00:32:37 +08:00
json .error_code OK .command accountCreate .value null
success create_account3 $a0 --osh accountCreate --account $account3 --uid $uid3 --always-active --public-key \""$(cat $account3key1file.pub)"\"
2020-10-16 00:32:37 +08:00
json .error_code OK .command accountCreate .value null
revoke accountCreate
configchg 's=^\\\\x22accountExternalValidationProgram\\\\x22.+=\\\\x22accountExternalValidationProgram\\\\x22:\\\\x22/opt/bastion/bin/other/doesnotexist.pl\\\\x22,='
success test_invalid_config_but_always_active $a3 --osh info
2020-10-16 00:32:37 +08:00
2020-12-14 16:57:43 +08:00
ignorecodewarn 'is not readable+executable'
run test_invalid_config $a1 --osh info
2020-10-16 00:32:37 +08:00
retvalshouldbe 101
configchg 's=^\\\\x22accountExternalValidationProgram\\\\x22.+=\\\\x22accountExternalValidationProgram\\\\x22:\\\\x22/opt/bastion/bin/other/check-active-account-fortestsonly.pl\\\\x22,='
run test_account1 $a1 --osh info
2020-10-16 00:32:37 +08:00
retvalshouldbe 101
success test_account2 $a2 --osh info
2020-10-16 00:32:37 +08:00
success test_account3 $a3 --osh info
2020-10-16 00:32:37 +08:00
# for remaining tests, disable the feature
configchg 's=^\\\\x22accountExternalValidationProgram\\\\x22.+=\\\\x22accountExternalValidationProgram\\\\x22:\\\\x22\\\\x22,='
grant accountDelete
# delete account1
success account1_cleanup $a0 --osh accountDelete --account $account1 --no-confirm
2020-10-16 00:32:37 +08:00
# delete account2
script account2_cleanup "$a0 --osh accountDelete --account $account2 <<< \"Yes, do as I say and delete $account2, kthxbye\""
2020-10-16 00:32:37 +08:00
retvalshouldbe 0
# delete account3
success account3_cleanup $a0 --osh accountDelete --account $account3 --no-confirm
2020-10-16 00:32:37 +08:00
revoke accountDelete
}
testsuite_activeness