Skip to content

Commit

Permalink
add bats test for get_random_pass
Browse files Browse the repository at this point in the history
  • Loading branch information
msimerson committed Mar 20, 2024
1 parent 0f23536 commit 16a0555
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion mail-toaster.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions test/mail-toaster.bats
Original file line number Diff line number Diff line change
Expand Up @@ -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 ""
}

0 comments on commit 16a0555

Please sign in to comment.