docker-postfix/unit-tests/email-anonymizer-paranoid.bats
Bojan Čekrlić 9178904f47 Fix: Remove unneccessary unit tests
`paranoid` and `smart` analyzers were testing for message-ids. As it
turns out, these are not as simple as we thought. Detecting message ids
has been changed and, consequentially, this test methods are no longer
neccessary.
2022-04-12 16:21:10 +02:00

79 lines
1.6 KiB
Bash
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env bats
mapfile EMAILS <<'EOF'
prettyandsimple@example.com
very.common@example.com
disposable.style.email.with+symbol@example.com
other.email-with-dash@example.com
x@example.com
"much.more unusual"@example.com
"very.unusual.@.unusual.com"@example.com
"very.(),:;<>[]\".VERY.\"very@\ \"very\".unusual"@strange.example.com
example-indeed@strange-example.com
admin@mailserver1
#!$%&'*+-/=?^_`{}|~@example.org
"()<>[]:,;@\\"!#$%&'-/=?^_`{}| ~.a"@example.org
" "@example.org
example@localhost
example@s.solutions
user@com
user@localserver
user@[127.0.0.1]
user@[IPv6:2001:db8::1]
Pelé@example.com
δοκιμή@παράδειγμα.δοκιμή
我買@屋企.香港
二ノ宮@黒川.日本
медведь@с-балалайкой.рф
संपर्क@डाटामेल.भारत
EOF
mapfile SMART <<'EOF'
*@*.com
*@*.com
*@*.com
*@*.com
*@*.com
*@*.com
*@*.com
*@*.com
*@*.com
*@*
*@*.org
*@*.org
*@*.org
*@*
*@*.solutions
*@*
*@*
*@[*]
*@[IPv6:*]
*@*.com
*@*.δοκιμή
*@*.香港
*@*.日本
*@*.рф
*@*.भारत
EOF
@test "verify paranoid email anonymizer" {
local error
local email
for index in "${!EMAILS[@]}"; do
email="${EMAILS[$index]}"
email=${email%$'\n'} # Remove trailing new line
result="$(echo "$email" | /code/scripts/email-anonymizer.sh paranoid)"
result=${result%$'\n'} # Remove trailing new line
expected="${SMART[$index]}"
expected=${expected%$'\n'} # Remove trailing new line
expected="{\"msg\": \"${expected}\"}"
if [ "$result" != "$expected" ]; then
echo "Expected '$expected', got: '$result' for email: $email" >&2
error=1
fi
done
if [[ -n "$error" ]]; then
exit 1
fi
}