Blame tests/p_dovecot/dovecot_imap_login.sh

Karanbir Singh 0b5bb2
#!/bin/sh
Karanbir Singh 0b5bb2
# Author: Athmane Madjoudj <athmanem@gmail.com>
Christoph Galuschka 7fc582
#         Christoph Galuschka <tigalch@tigalch.org>
Karanbir Singh 0b5bb2
Karanbir Singh 2dd0be
t_Log "Running $0 - adding imaptest local user account + attempting IMAP login"
Karanbir Singh 0b5bb2
Athmane Madjoudj 0a3c81
{ userdel -rf imaptest; useradd imaptest && echo imaptest | passwd --stdin imaptest; } &>/dev/null
Karanbir Singh 2dd0be
Christoph Galuschka 0e2392
# creating maildir in HOME, else test will fail at first try
Fabian Arrotin d766ac
mkdir -m 700 -p /home/imaptest/mail/.imap/INBOX 
Christoph Galuschka a0530a
chown -R imaptest:imaptest /home/imaptest/mail
Karanbir Singh 2dd0be
Christoph Galuschka 26f935
ret_val=1
Christoph Galuschka 26f935
Christoph Galuschka 0e2392
t_Log "Dovecot IMAP login test"
Christoph Galuschka 26f935
Fabian Arrotin d766ac
# EL7 comes with nmap-nc , different from nc so different options to use
Fabian Arrotin d766ac
Fabian Arrotin d766ac
if [ "$centos_ver" -ge 7 ];then
Fabian Arrotin d766ac
 nc_options="-d 3 -w 5"
Fabian Arrotin d766ac
else
Fabian Arrotin d766ac
 nc_options="-i 3 -w 5"
Fabian Arrotin d766ac
fi
Fabian Arrotin d766ac
Fabian Arrotin d766ac
echo -e "01 LOGIN imaptest imaptest\n" | nc ${nc_options} localhost 143 | grep -q "Logged in."
Christoph Galuschka 7fc582
Christoph Galuschka a0530a
ret_val=$?
Athmane Madjoudj 3a45f5
Christoph Galuschka 21fdc0
if [ $ret_val != 0 ]
Christoph Galuschka 21fdc0
then
Christoph Galuschka 21fdc0
  tail /var/log/secure
Christoph Galuschka 21fdc0
  tail /var/log/maillog
Christoph Galuschka 21fdc0
fi
Christoph Galuschka 26f935
t_CheckExitStatus $ret_val
Athmane Madjoudj 31ca2c
Athmane Madjoudj 31ca2c
userdel -rf imaptest