diff --git a/.gitignore b/.gitignore index f515d16927b9120b742fc99e92996aa4c95a4b12..9abea6798556c6d3b0205396d5980257e4b8d19e 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,3 @@ build/* bin/* test/docker/*/agent/* test/docker/*/*.sh -test/log* diff --git a/test/create_users.sh b/test/create_users.sh index 6abc25d78bc0b7689bd4cf074d785105b2d5990b..d9db4b3a1f78e55bbd0403f84a2ad2d664dbc9b3 100755 --- a/test/create_users.sh +++ b/test/create_users.sh @@ -1,35 +1,28 @@ #!/bin/bash +declare -a ft_users=( user1 user2 user3 user4 ) +declare -a ft_dates=( -2d -1d -1d -0d ) -for username in user1 user2 user3 user4 +for i in $(seq 0 $(( ${#ft_users[@]} -1 ))) do -password="" -pass=$(perl -e 'print crypt($ARGV[0], "password")' $password) -useradd -m -p $pass $username -if [ $? -eq 0 ] -then - echo "$username has been added to system!" -else - echo "Failed to add $username!" -fi -{ -/usr/bin/expect << EOF -spawn login $username -sleep 2 -expect "Password: " -send "\r" -expect "\$ " -send "exit\r" -exit -EOF -} + ft_user=${ft_users[$i]} + ft_date=${ft_dates[$i]} -userdel $username -if [ $? -eq 0 ] -then - echo "$username has been deleted!" -else - echo "Failed to delete $username!" -fi + password="" + pass=$(perl -e 'print crypt($ARGV[0], "password")' $password) -done + useradd -m -p $pass $ft_user + if [ $? -ne 0 ] + then + echo "Failed to add $ft_user!" + fi + + faketime -f "${ft_date}" ./login.exp $ft_user &>/dev/null + + deluser --remove-home $ft_user >/dev/null + if [ $? -ne 0 ] + then + echo "Failed to delete $ft_user!" + fi + +done \ No newline at end of file diff --git a/test/login.exp b/test/login.exp new file mode 100755 index 0000000000000000000000000000000000000000..6813a6f26faca21482c21eff43249863cce99a30 --- /dev/null +++ b/test/login.exp @@ -0,0 +1,10 @@ +#!/usr/bin/expect + +set user [lindex $argv 0] + +spawn login -f $user +sleep 2 +expect "\$ " +send -- "logout\r" + +exit \ No newline at end of file