Blame tests/p_ipa-server/3-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 |
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 |
a5d690 |
userdetails="$(ipa user-add --first=test --last=user --random testuser)"
|
|
James Hogarth |
a5d690 |
echo "$userdetails" | grep 'Added user "testuser"' &> /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 |
a5d690 |
echo "$userdetails" | grep 'Home directory: /home/testuser' &> /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 |
a5d690 |
spawn kinit testuser
|
|
James Hogarth |
a5d690 |
sleep 1
|
|
James Hogarth |
a5d690 |
expect "Password for testuser@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 |
a5d690 |
klist | grep "testuser@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 |
a5d690 |
|
|
James Hogarth |
a5d690 |
|