From d051600b2db1177ab180f2c583ef72be0620f5d4 Mon Sep 17 00:00:00 2001 From: Christoph Galuschka Date: Dec 08 2012 10:49:24 +0000 Subject: added test to really deliver email locally (using SMTP and ESMTP) reordered tests --- diff --git a/tests/p_exim/0-install_exim.sh b/tests/p_exim/0-install_exim.sh index d50c44c..1706e88 100755 --- a/tests/p_exim/0-install_exim.sh +++ b/tests/p_exim/0-install_exim.sh @@ -6,7 +6,7 @@ t_Log "Running $0 - remove unused MTAs and install exim" if (t_GetPkgRel basesystem | grep -q el5) then - t_InstallPackage exim + t_InstallPackage exim expect # Remove other MTAs t_ServiceControl postfix stop t_ServiceControl sendmail stop diff --git a/tests/p_exim/10-test-sendmail.sh b/tests/p_exim/10-test-sendmail.sh new file mode 100755 index 0000000..1e3fb80 --- /dev/null +++ b/tests/p_exim/10-test-sendmail.sh @@ -0,0 +1,23 @@ +#!/bin/bash +# Author: Christoph Galuschka + +t_Log "Running $0 - testing if /usr/sbin/sendmail for exim is sane." + +if (t_GetPkgRel basesystem | grep -q el5) +then + mta=$(ls -H /usr/sbin/sendmail) + + if [ $mta == '/usr/sbin/sendmail' ] + then + t_Log "link to sendmail seems to be sane" + ret_val=0 + else + t_Log "link to sendmail seems to be wrong" + ret_val=1 + fi +else + t_Log "This seems to be a C6 system - skipping" + ret_val=0 +fi + +t_CheckExitStatus $ret_val diff --git a/tests/p_exim/15_exim_smtp.sh b/tests/p_exim/15_exim_smtp.sh new file mode 100755 index 0000000..31d0ad9 --- /dev/null +++ b/tests/p_exim/15_exim_smtp.sh @@ -0,0 +1,16 @@ +#!/bin/sh +# Author: Athmane Madjoudj +# Christoph Galuschka + +t_Log "Running $0 - Exim SMTP test." + +if (t_GetPkgRel basesystem | grep -q el5) +then + echo "helo test" | nc -i 1 -w 3 localhost 25 | grep -q '250' + ret_val=$? +else + t_Log "This seems to be A C6 system - skipping" + ret_val=0 +fi + +t_CheckExitStatus $ret_val diff --git a/tests/p_exim/20_exim_mta_helo-test.sh b/tests/p_exim/20_exim_mta_helo-test.sh new file mode 100755 index 0000000..01d6adc --- /dev/null +++ b/tests/p_exim/20_exim_mta_helo-test.sh @@ -0,0 +1,39 @@ +#!/bin/sh +# Author: Christoph Galuschka + +t_Log "Running $0 - exim can accept and deliver local email." + +if [ $centos_ver == '5' ] + then + MAILSPOOL=/var/spool/exim/input/ + + # make shure spool dir is empty + rm -rf $MAILSPOOL* + ret_val=1 + + # send mail to localhost + ./tests/p_exim/_helper_exim_helo.expect | grep -q "250 OK" + if [ $? = 0 ] + then + t_Log 'Mail has been queued successfully' + MTA_ACCEPT=0 + fi + + sleep 1 + grep -q 't_functional test' $MAILSPOOL* + if [ $? = 0 ] + then + t_Log 'previously sent mail is in '$MAILSPOOL'*' + SPOOLFILE=0 + fi + + if ([ $MTA_ACCEPT = 0 ] && [ $SPOOLFILE = 0 ]) + then + ret_val=0 + fi +else + t_Log t_Log "This is not a C5 system - skipping" + ret_val=0 +fi + +t_CheckExitStatus $ret_val diff --git a/tests/p_exim/30_exim_mta_ehlo-test.sh b/tests/p_exim/30_exim_mta_ehlo-test.sh new file mode 100755 index 0000000..e4577b0 --- /dev/null +++ b/tests/p_exim/30_exim_mta_ehlo-test.sh @@ -0,0 +1,39 @@ +#!/bin/sh +# Author: Christoph Galuschka + +t_Log "Running $0 - exim can accept and deliver local email using ESMTP/PIPELINING." + +if [ $centos_ver == '5' ] + then + MAILSPOOL=/var/spool/exim/input/ + + # make shure spool dir is empty + rm -rf $MAILSPOOL* + ret_val=1 + + # send mail to localhost + ./tests/p_exim/_helper_exim_ehlo.expect | grep -q "250 OK" + if [ $? = 0 ] + then + t_Log 'Mail has been queued successfully' + MTA_ACCEPT=0 + fi + + sleep 1 + grep -q 't_functional test' $MAILSPOOL* + if [ $? = 0 ] + then + t_Log 'previously sent mail is in '$MAILSPOOL'*' + SPOOLFILE=0 + fi + + if ([ $MTA_ACCEPT = 0 ] && [ $SPOOLFILE = 0 ]) + then + ret_val=0 + fi +else + t_Log t_Log "This is not a C5 system - skipping" + ret_val=0 +fi + +t_CheckExitStatus $ret_val diff --git a/tests/p_exim/_helper_exim_ehlo.expect b/tests/p_exim/_helper_exim_ehlo.expect new file mode 100755 index 0000000..12ff1e1 --- /dev/null +++ b/tests/p_exim/_helper_exim_ehlo.expect @@ -0,0 +1,13 @@ +#!/usr/bin/expect -f +# Author: Christoph Galuschka + +set timeout 1 +spawn telnet localhost 25 +#match_max 6000 +expect "220 *" +send -- "ehlo localhost\n" +expect -- "250-PIPELINING" +send -- "mail from: root@localhost\nrcpt to: root@localhost\ndata\nt_functional test\n.\n" +expect -- "250\ OK" +send -- "quit\n" +expect "221*closing\ connection" diff --git a/tests/p_exim/_helper_exim_helo.expect b/tests/p_exim/_helper_exim_helo.expect new file mode 100755 index 0000000..cb64e46 --- /dev/null +++ b/tests/p_exim/_helper_exim_helo.expect @@ -0,0 +1,19 @@ +#!/usr/bin/expect -f +# Author: Christoph Galuschka + +set timeout 1 +spawn telnet localhost 25 +#match_max 6000 +expect "220 *" +send -- "helo localhost\n" +expect -- "250*Hello\ localhost*" +send -- "mail from: root@localhost\n" +expect -- "250\ OK" +send -- "rcpt to: root@localhost\n" +expect -- "250\ Accepted" +send -- "data\n" +expect -- "354*" +send -- "t_functional test\n.\n" +expect -- "250\ OK*" +send -- "quit\n" +expect "221*closing\ connection"