docker-postfix/unit-tests/email-anonymizer-noop.bats
Sergio Del Río Mayoral a1a2082ae1 Add email anonymizer option in case is needed for GDPR
This new feature will anonymize emails in the Postfix logs. This allows
you to keep them indefinetely while being compliant with GDPR.

Based on excellent work on [this pull request](https://github.com/bokysan/docker-postfix/pull/91).

Check `README.md` for more details.
2021-12-07 13:43:13 +01:00

46 lines
1.2 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
δοκιμή@παράδειγμα.δοκιμή
我買@屋企.香港
二ノ宮@黒川.日本
медведь@с-балалайкой.рф
संपर्क@डाटामेल.भारत
20211207101128.0805BA272@31bfa77a2cab
EOF
@test "verify noop email anonymizer" {
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 noop)"
result=${result%$'\n'} # Remove trailing new line
expected='{}'
if [ "$result" != "$expected" ]; then
echo "Expected '$expected', got: '$result'" >&2
exit 1
fi
done
}