bstinson / centos / t_functional

Forked from centos/t_functional 4 years ago
Clone

Blame tests/p_ipa-server/4-adduser.sh

James Hogarth a5d690
#!/bin/bash
James Hogarth a5d690
# Author: James Hogarth <james.hogarth@gmail.com>
James Hogarth a5d690
#
James Hogarth a5d690
James Hogarth abe41f
if (t_GetPkgRel basesystem | grep -qE 'el(6|7)')
James Hogarth acc301
then
James Hogarth acc301
James Hogarth a5d690
# Need admin credentials
James Hogarth a5d690
kdestroy &> /dev/null
James Hogarth a5d690
James Hogarth a5d690
klist 2>&1  | grep "No credentials" &> /dev/null
James Hogarth a5d690
James Hogarth a5d690
t_CheckExitStatus $?
James Hogarth a5d690
James Hogarth a5d690
expect -f - &> /dev/null <
James Hogarth a5d690
set send_human {.1 .3 1 .05 2}
James Hogarth a5d690
spawn kinit admin
James Hogarth a5d690
sleep 1
James Hogarth a5d690
expect "Password for admin@C6IPA.LOCAL:"
James Hogarth a5d690
send -h "p455w0rd\r"
James Hogarth a5d690
sleep 1
James Hogarth a5d690
close
James Hogarth a5d690
EOF
James Hogarth a5d690
James Hogarth a5d690
klist | grep "admin@C6IPA.LOCAL" &> /dev/null
James Hogarth a5d690
James Hogarth a5d690
t_CheckExitStatus $?
James Hogarth a5d690
James Hogarth a5d690
James Hogarth a5d690
James Hogarth a5d690
t_Log "Running $0 - test adding user"
James Hogarth 0a8a3f
userdetails="$(ipa user-add --first=test --last=user --random ipatestuser)"
James Hogarth 0a8a3f
echo "$userdetails" | grep 'Added user "ipatestuser"' &> /dev/null 
James Hogarth a5d690
James Hogarth a5d690
t_CheckExitStatus $?
James Hogarth a5d690
James Hogarth a5d690
t_Log "Running $0 - verify details of user"
James Hogarth a5d690
James Hogarth a5d690
echo "$userdetails" | grep ' First name: test' &> /dev/null 
James Hogarth a5d690
James Hogarth a5d690
t_CheckExitStatus $?
James Hogarth a5d690
James Hogarth a5d690
echo "$userdetails" | grep 'Last name: user' &> /dev/null 
James Hogarth a5d690
James Hogarth a5d690
t_CheckExitStatus $?
James Hogarth a5d690
James Hogarth a5d690
echo "$userdetails" | grep 'Full name: test user' &> /dev/null 
James Hogarth a5d690
James Hogarth a5d690
t_CheckExitStatus $?
James Hogarth a5d690
James Hogarth 0a8a3f
echo "$userdetails" | grep 'Home directory: /home/ipatestuser' &> /dev/null 
James Hogarth a5d690
James Hogarth a5d690
t_CheckExitStatus $?
James Hogarth a5d690
James Hogarth a5d690
t_Log "Running $0 - testing initial password change of user"
James Hogarth a5d690
kdestroy &> /dev/null
James Hogarth a5d690
James Hogarth a5d690
expect -f - &> /dev/null  <
James Hogarth a5d690
set send_human {.1 .3 1 .05 2}
James Hogarth 0a8a3f
spawn kinit ipatestuser
James Hogarth a5d690
sleep 1
James Hogarth 0a8a3f
expect "Password for ipatestuser@C6IPA.LOCAL: "
James Hogarth a5d690
send -h -- "$(echo "$userdetails" | awk '$0 ~ /Random password/ {print $3}')\r"
James Hogarth a5d690
sleep 1
James Hogarth a5d690
expect "Enter new password: "
James Hogarth a5d690
send -h -- "newp455w0rd\r"
James Hogarth a5d690
sleep 1
James Hogarth a5d690
expect "Enter it again: "
James Hogarth a5d690
send -h -- "newp455w0rd\r"
James Hogarth a5d690
sleep 1
James Hogarth a5d690
close
James Hogarth a5d690
EOF
James Hogarth a5d690
James Hogarth 0a8a3f
klist | grep "ipatestuser@C6IPA.LOCAL" &> /dev/null
James Hogarth a5d690
James Hogarth a5d690
t_CheckExitStatus $?
James Hogarth a5d690
James Hogarth a5d690
kdestroy &> /dev/null
James Hogarth a5d690
James Hogarth 689957
James Hogarth 689957
t_Log "Running $0 - testing ipatestuser is in getent"
James Hogarth 689957
getent passwd ipatestuser &> /dev/null
James Hogarth 689957
t_CheckExitStatus $?
James Hogarth 689957
James Hogarth acc301
else
James Hogarth acc301
    echo "Skipped on CentOS 5"
James Hogarth acc301
fi
James Hogarth a5d690
James Hogarth a5d690