From 16a0555f992a3013469527cea8ef80df63db34c4 Mon Sep 17 00:00:00 2001 From: Matt Simerson Date: Tue, 19 Mar 2024 21:35:17 -0700 Subject: [PATCH] add bats test for get_random_pass --- mail-toaster.sh | 2 +- test/mail-toaster.bats | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/mail-toaster.sh b/mail-toaster.sh index 5c8c9a49..487cfca7 100755 --- a/mail-toaster.sh +++ b/mail-toaster.sh @@ -1360,7 +1360,7 @@ get_random_pass() if [ -z "$2" ]; then # default, good, limited by base64 charset - openssl rand -base64 $(echo "$_pass_len + 4" | bc) | head -c "$_pass_len" + openssl rand -base64 "$(echo "$_pass_len + 4" | bc)" | head -c "$_pass_len" else # https://unix.stackexchange.com/questions/230673/how-to-generate-a-random-string # more entropy with 94 ASCII chars but special chars are often problematic diff --git a/test/mail-toaster.bats b/test/mail-toaster.bats index a2e96958..1ce76ef4 100644 --- a/test/mail-toaster.bats +++ b/test/mail-toaster.bats @@ -56,3 +56,10 @@ setup() { assert_success assert_output --partial "Success! A new 'test' jail is provisioned" } + +@test "get_random_pass" { + run get_random_pass 15 + assert_success + echo "# $output" >&3 + #assert_output --partial "" +}