zeek/auxil/zeekctl/testing/helper/archive-log-no-mail.test
Patrick Kelley 8fd444092b initial
2025-05-07 15:35:15 -04:00

49 lines
1.4 KiB
Plaintext

# Test that if the archive-log script is archiving conn.log and if
# MailConnectionSummary=0, then a connection summary report is archived,
# but not emailed.
#
# @TEST-EXEC: bash %INPUT
. zeekctl-test-setup
while read line; do installfile $line; done << EOF
etc/zeekctl.cfg__test_sendmail
bin/sendmail__test --new
EOF
replaceprefix etc/zeekctl.cfg
echo "MailConnectionSummary=0" >> $ZEEKCTL_INSTALL_PREFIX/etc/zeekctl.cfg
archivelog=$ZEEKCTL_INSTALL_PREFIX/share/zeekctl/scripts/archive-log
logdir=$ZEEKCTL_INSTALL_PREFIX/logs/2013-12-30
connlog=${logdir}/conn.22:24:20-22:30:00.log.gz
connsummarylog=${logdir}/conn-summary.22:24:20-22:30:00.log.gz
origconnlog=conn.2013-12-30-22-24-20.log
zeekctl install
# Create Zeek's working directory, chdir to that dir, and create rotated logs
mkdir $ZEEKCTL_INSTALL_PREFIX/spool/zeek
cd $ZEEKCTL_INSTALL_PREFIX/spool/zeek
cat > ${origconnlog} << _EOF_
# This is a test conn.log
_EOF_
###############################################
# Test archive-log for the conn.log file
${archivelog} ${origconnlog} conn 13-12-30_22.24.20 13-12-30_22.30.00 0 ascii
# verify that the logs were archived
test ! -f ${origconnlog}
test -f ${connlog}
test -f ${connsummarylog}
# verify that the logs were compressed
! grep -q "This is a test" ${connlog}
! grep -q ">== Total ===" ${connsummarylog}
# verify that no email was sent
test ! -f $ZEEKCTL_INSTALL_PREFIX/sendmail.out