bringing in testkit tools
[feisty_meow.git] / testkit / library / tear_down_test_infrastructure.sh
1 #!/bin/bash
2
3 # Tears down the demo users previously set up for multi-user testing.
4 #
5 # Author: Chris Koeritz
6
7 export WORKDIR="$( \cd "$(\dirname "$0")" && \pwd )"  # obtain the script's working directory.
8 cd "$WORKDIR"
9
10 if [ -z "$TESTKIT_SENTINEL" ]; then echo Please run prepare_tools.sh before testing.; exit 3; fi
11 source "$TESTKIT_ROOT/library/establish_environment.sh"
12
13 progname="$(basename "$0")"
14
15 if [ $# -lt 1 ]; then
16   echo "$progname: This script needs a single parameter, which is the container"
17   echo "path to use for the authentication (e.g. $STS_LOC)"
18   exit 3
19 fi
20
21 ADMIN_CONTAINER=$1; shift
22 echo "container location is $ADMIN_CONTAINER "
23
24 # we test for ten users currently.
25 user_count=10
26
27 # login the right power user that can delete other user entries.
28 testLoginAsAdmin()
29 {
30   if [ -z "$NON_INTERACTIVE" ]; then
31     login_a_user admin
32   fi
33 }
34
35 # now that we're logged in appropriately, delete our corresponding set of users.
36 testDeleteUsers()
37 {
38   local x
39   for (( x=0; x < ${#MULTI_USER_LIST[*]}; x++ )); do
40     username="${MULTI_USER_LIST[$x]}"
41     echo "Whacking user '$username'..."
42     passwd="${MULTI_PASSWORD_LIST[$x]}"
43     # now do the heavy lifting to get that user set up.
44     silent_grid script "local:'$TESTKIT_ROOT/library/delete_one_user.xml'" "$CONTAINERPATH" "$(basename $username)" "$username" "$SUBMIT_GROUP"
45     assertEquals "Should delete user '$username' successfully" 0 $?
46   done
47 }
48
49 # make sure we don't leave them logged in as an administrator.
50 testLogoutAgain()
51 {
52   if [ -z "$NON_INTERACTIVE" ]; then
53     silent_grid logout --all
54     assertEquals "Final logout of the grid" 0 $?
55   fi
56 }
57
58 testLoginNormalUser()
59 {
60   if [ -z "$NON_INTERACTIVE" ]; then
61     login_a_user normal
62   fi
63 }
64
65 # load and run shUnit2
66 source "$SHUNIT_DIR/shunit2"
67