docker-postfix/integration-tests/tester/test.bats
Bojan Čekrlić c7c56d3ff1 Upd: Add new integration and unit tests
Test a few more functionalities in the image. Change how postfix
message IDs are detected. Message ID can be set by the client and
hence detecting them via regex is not the best way to go around it.

This fix will actually look at the log line and try to determine
if we're looking at the message ID or not.
2022-04-10 17:52:12 +02:00

58 lines
No EOL
1 KiB
Bash
Executable file

#!/usr/bin/env bats
if [[ "$#" -gt 0 ]]; then
FROM=$1
fi
if [[ "$#" -gt 1 ]]; then
TO=$2
fi
if [ -z "$FROM" ]; then
FROM="demo@example.org"
fi
if [ -z "$TO" ]; then
TO="test@gmail.com"
fi
# Wait for postfix to startup
wait-for-service -q tcp://postfix_test_587:587
SMTP_DATA="-smtp postfix_test_587 -port 587"
@test "Get server info" {
mailsend -info $SMTP_DATA
}
@test "Send a simple mail" {
mailsend \
-sub "Test email 1" $SMTP_DATA \
-from "$FROM" -to "$TO" \
body \
-msg "Hello world!\nThis is a simple test message!"
}
@test "Send mail with attachment" {
mailsend \
-sub "Test with attachment" $SMTP_DATA \
-from "$FROM" -to "$TO" \
body \
-msg "Hi!\nThis is an example of an attachment." \
attach \
-file "/usr/local/bin/mailsend"
}
@test "Send mail from non-supported sender" {
if [[ "$SKIP_INVALID_DOMAIN_SEND" == "1" ]]; then
skip
fi
if mailsend \
-sub "Test email 1" $SMTP_DATA \
-from "test@gmail.com" -to "$TO" \
body \
-msg "Hello world!\nThis is a simple test message!"; then
return 1
fi
}