Blame tests/p_dovecot/dovecot_imap_login.sh

Karanbir Singh 0b5bb2
#!/bin/sh
Karanbir Singh 0b5bb2
# Author: Athmane Madjoudj <athmanem@gmail.com>
Christoph Galuschka 0e2392
#         Christoph Galuschka <christoph.galuschka@chello.at>
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
Christoph Galuschka 0e2392
mkdir -m 700 -p /home/imaptest/mail/.imap/INBOX 
Christoph Galuschka 0e2392
chown -R imaptest:imaptest /home/imaptest/mail/.imap/INBOX
Karanbir Singh 2dd0be
Christoph Galuschka 26f935
ret_val=1
Christoph Galuschka 26f935
Christoph Galuschka 0e2392
t_Log "Dovecot IMAP login test"
Athmane Madjoudj 87c52a
echo -e "01 LOGIN imaptest imaptest\n" | nc -w 5 localhost 143 | grep -q "Logged in."
Christoph Galuschka 26f935
ret_val=$?
Christoph Galuschka 26f935
Christoph Galuschka 26f935
if [ $ret_val == 1 ]
Christoph Galuschka 26f935
  then
Christoph Galuschka 26f935
  t_Log "Sometimes the first login fails (reason yet unknown to me)"
Christoph Galuschka 26f935
  t_Log "Trying a second time, as this seems to work, if not somethings really not working"
Athmane Madjoudj 87c52a
  echo -e "01 LOGIN imaptest imaptest\n" | nc -w 5 localhost 143 | grep -q "Logged in."
Christoph Galuschka 26f935
  ret_val=$?
Christoph Galuschka 26f935
fi
Athmane Madjoudj 3a45f5
Christoph Galuschka 26f935
t_CheckExitStatus $ret_val
Athmane Madjoudj 31ca2c
Athmane Madjoudj 31ca2c
userdel -rf imaptest