1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
|
#!/bin/ksh
#
# This file is part of rasdaman community.
#
# Rasdaman community is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Rasdaman community is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with rasdaman community. If not, see <http://www.gnu.org/licenses/>.
#
# Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009 Peter Baumann /
# rasdaman GmbH.
#
# For more information please see <http://www.rasdaman.org>
# or contact Peter Baumann via <baumann@rasdaman.com>.
# test_user - test rasdaman server authentication
#
# SYNOPSIS:
# test_user.sh
#
# DESCRIPTION
# Performs rasql test queries to check whether authentication is observed.
#
# RESPONDING TO INCIDENT
# -none-
#
# PROCEDURE
# Perform rasql calls performing different operations types requiring
# different authentication. check whether operations are recejcted/accepted
# properly.
#
# PRECONDITIONS
# - rasql utility available
# - rasdaman up and running, with database having user/password as defined below
#
# RETURN CODES
RC_OK=0 # everything went fine
RC_ERROR=1 # something went wrong
#
# CHANGE HISTORY
# 2006-jan-02 P.Baumann created
#
# RESTRICTIONS
# -/-
#
# --- CONSTANTS -----------------------------------------------------
RCTEXT_OK="OK"
RCTEXT_ERROR="NOT_OK"
ERROR=ERROR
INDENT="+++"
# name of script
PROG=`basename $0`
PROGBASE=`basename $0 .sh`
# log file output
LOG=$PROGBASE.log
# reference log file
REFLOG=$LOG.reference
# save old log here if it exists
SAVELOG=$LOG.save
# --- TEST SETTINGS -------------------------------------------------
# r/o login
USER_RO=rasguest
PASSWD_RO=rasguest
# r/w login
USER_RW=rasadmin
PASSWD_RW=rasadmin
# nonex login
USER_NONEX=nonex
PASSWD_NONEX=nonex
# test collection
TESTCOLL=AuthentTestCollection
TESTCOLL_TYPE=GreySet
# --- ACTION --------------------------------------------------------
# save old log if present
if [ -f $LOG ]
then
echo found old log file, shifting it to $SAVELOG
mv $LOG $SAVELOG
fi
echo $PROG: testing rasdaman authentication at `date` | tee $LOG
# good cases
echo $INDENT good cases | tee -a $LOG
echo $INDENT $INDENT write
( rasql --quiet -q "create collection $TESTCOLL $TESTCOLL_TYPE" --user $USER_RW --passwd $PASSWD_RW \
|| (export RC=$?; echo Fatal $ERROR, exit code $RC) ) | tee -a $LOG
( rasql --quiet -q "insert into $TESTCOLL values marray x in [1:10,1:10] values (char) x[0]" --user $USER_RW --passwd $PASSWD_RW \
|| (export RC=$?; echo Fatal $ERROR, exit code $RC) ) | tee -a $LOG
( rasql --quiet -q "update $TESTCOLL as m set m[1:1,1:1] assign marray x in [1:1,1:1] values 42c" --user $USER_RW --passwd $PASSWD_RW \
|| (export RC=$?; echo Fatal $ERROR, exit code $RC) ) | tee -a $LOG
echo $INDENT $INDENT read
( rasql --quiet -q "select a[1,1] from $TESTCOLL as a" --user $USER_RW --passwd $PASSWD_RW \
|| (export RC=$?; echo Fatal $ERROR, exit code $RC) ) | tee -a $LOG
( rasql --quiet -q "select a[1,1] from $TESTCOLL as a" --user $USER_RO --passwd $PASSWD_RO \
|| (export RC=$?; echo Fatal $ERROR, exit code $RC) ) | tee -a $LOG
echo $INDENT $INDENT "write (2)"
# not yet supported by server:
# ( rasql --quiet -q "delete from $TESTCOLL" --user $USER_RW --passwd $PASSWD_RW \
( rasql --quiet -q "delete from $TESTCOLL where true" --user $USER_RW --passwd $PASSWD_RW \
|| (export RC=$?; echo Fatal $ERROR, exit code $RC) ) | tee -a $LOG
( rasql --quiet -q "drop collection $TESTCOLL" --user $USER_RW --passwd $PASSWD_RW \
|| (export RC=$?; echo Fatal $ERROR, exit code $RC) ) | tee -a $LOG
echo $INDENT $INDENT set up test env for subsequent cases
( rasql --quiet -q "create collection $TESTCOLL $TESTCOLL_TYPE" --user $USER_RW --passwd $PASSWD_RW \
|| (export RC=$?; echo Fatal $ERROR, exit code $RC) ) | tee -a $LOG
( rasql --quiet -q "insert into $TESTCOLL values marray x in [1:10,1:10] values (char) x[0]" --user $USER_RW --passwd $PASSWD_RW \
|| (export RC=$?; echo Fatal $ERROR, exit code $RC) ) | tee -a $LOG
echo $INDENT good cases done. | tee -a $LOG
# bad cases
echo $INDENT bad cases | tee -a $LOG
echo $INDENT $INDENT nonex login
( rasql --quiet -q "select a[1,1] from $TESTCOLL as a" --user $USER_NONEX --passwd $PASSWD_NONEX \
|| (export RC=$?; echo Recognized bad case, exit code $RC) ) | tee -a $LOG
echo $INDENT $INDENT write op with r/o login
( rasql --quiet -q "update $TESTCOLL as m set m[1:1,1:1] assign marray x in [1:1,1:1] values 42c" --user $USER_RO --passwd $PASSWD_RO \
|| (export RC=$?; echo Recognized bad case, exit code $RC) ) | tee -a $LOG
( rasql --quiet -q "insert into $TESTCOLL values marray x in [1:10,1:10] values (char) x[0]" --user $USER_RO --passwd $PASSWD_RO \
|| (export RC=$?; echo Recognized bad case, exit code $RC) ) | tee -a $LOG
( rasql --quiet -q "delete from $TESTCOLL where true" --user $USER_RO --passwd $PASSWD_RO \
|| (export RC=$?; echo Recognized bad case, exit code $RC) ) | tee -a $LOG
echo $INDENT $INDENT wrong passwd
( rasql --quiet -q "select a[1,1] from $TESTCOLL as a" --user $USER_RO --passwd $PASSWD_NONEX \
|| (export RC=$?; echo Recognized bad case, exit code $RC) ) | tee -a $LOG
( rasql --quiet -q "update $TESTCOLL as m set m[1:1,1:1] assign marray x in [1:1,1:1] values 42c" --user $USER_RW --passwd $PASSWD_RO \
|| (export RC=$?; echo Recognized bad case, exit code $RC) ) | tee -a $LOG
echo $INDENT bad cases done. | tee -a $LOG
echo $INDENT cleanup:
( rasql --quiet -q "drop collection $TESTCOLL" --user $USER_RW --passwd $PASSWD_RW \
|| (export RC=$?; echo Fatal $ERROR, exit code $RC) ) | tee -a $LOG
echo $PROG: done at `date`.
exit $RC
|