# Test that the install command creates a broctl-config.bro policy file
# with the correct contents.
#
# @TEST-EXEC: bash %INPUT
# @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-broctl-config btest-diff standalone
# @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-broctl-config btest-diff no-logger
# @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-broctl-config btest-diff logger

. broctl-test-setup

broctlcfg=$BROCTL_INSTALL_PREFIX/etc/broctl.cfg
broctlconfig=$BROCTL_INSTALL_PREFIX/spool/installed-scripts-do-not-touch/auto/broctl-config.bro

# Specify non-default values for options that are written to broctl-config.bro
echo "MailTo=broctltest@somedomain" >> ${broctlcfg}
echo "MailAlarmsTo=broctltest2@somedomain2" >> ${broctlcfg}
echo "SendMail=/path/to/sendmail" >> ${broctlcfg}
echo "MailSubjectPrefix=This is Subject" >> ${broctlcfg}
echo "MailFrom=broctltestuser@mydomain" >> ${broctlcfg}
echo "LogRotationInterval=12345" >> ${broctlcfg}
echo "MailAlarmsInterval=98765" >> ${broctlcfg}
echo "PcapSnaplen=1212" >> ${broctlcfg}
echo "PcapBufsize=256" >> ${broctlcfg}

test ! -e ${broctlconfig}

broctl install
cp ${broctlconfig} standalone

# Install a cluster config with no logger node.
while read line; do installfile $line; done << EOF
etc/node.cfg__cluster
EOF

broctl install
cp ${broctlconfig} no-logger

# Install a cluster config with a logger node.
while read line; do installfile $line; done << EOF
etc/node.cfg__logger
EOF

broctl install
cp ${broctlconfig} logger
