code reorg for Transactionw!
[csql.git] / test / cache / CacheVerify / test002.ksh
blob2ee438e40fa0ef46e0e96ab6fa39bdd08720e238
1 #!/bin/ksh
2 # Test Case
3 # 2. Create table t1 with primary key in mysql. Cache the table in csql.
4 # Check for user authentication:
5 # $ cacheverify [-U username] [-P password] -t t1
6 # by entering
7 # a. correct username correct password - should pass
8 # b. correct username wrong password - should return error
9 # c. wrong username correct password - should return error
10 # d. wrong username wrong password - should return error
12 #Run this test only under csql/test or on this directory.
13 #Otherwise, it may fail
15 input=${PWD}/cache/CacheVerify/inputtest4.sql
16 REL_PATH=.
17 if [ -s "$input" ]
18 then
19 REL_PATH=${PWD}/cache/CacheVerify
21 cp $CSQL_CONFIG_FILE /tmp/csql.conf
22 export CSQL_CONFIG_FILE=/tmp/csql.conf
23 echo CACHE_TABLE=true >>$CSQL_CONFIG_FILE
24 echo DSN=$DSN >>$CSQL_CONFIG_FILE
25 DS="$DSN $DBUSER $PASSWORD"
26 rm -f /tmp/csql/csqlds.conf
27 touch /tmp/csql/csqlds.conf
28 $CSQL_INSTALL_ROOT/bin/csqlds -U $DBUSER -P $PASSWORD -D $DSN -N $TDB -a
29 if [ $? -ne 0 ]
30 then
31 exit 1;
34 isql $DS < ${REL_PATH}/inputtest4.sql >/dev/null 2>&1
35 if [ $? -ne 0 ]
36 then
37 exit 1;
40 rm -f /tmp/csql/csqltable.conf
41 touch /tmp/csql/csqltable.conf
42 #$CSQL_INSTALL_ROOT/bin/csql -s ${REL_PATH}/inputtest4.sql > /dev/null 2>&1
43 $CSQL_INSTALL_ROOT/bin/cachetable -t t1
44 #> /dev/null 2>&1
45 if [ $? -ne 0 ]
46 then
47 isql $DS < ${REL_PATH}/drop.sql >/dev/null 2>&1
48 exit 2;
52 # check with correct username and correct password
53 $CSQL_INSTALL_ROOT/bin/cacheverify -U root -P manager -t t1
54 #> /dev/null 2>&1
55 if [ $? -ne 0 ]
56 then
57 isql $DS < ${REL_PATH}/drop.sql >/dev/null 2>&1
58 exit 3;
61 # correct username and wrong password
62 $CSQL_INSTALL_ROOT/bin/cacheverify -U root -P MANAGER -t t1 > /dev/null 2>&1
63 if [ $? -eq 0 ]
64 then
65 isql $DS < ${REL_PATH}/drop.sql >/dev/null 2>&1
66 exit 4;
69 # wrong username and correct password
70 $CSQL_INSTALL_ROOT/bin/cacheverify -U ROOT -P manager -t t1 > /dev/null 2>&1
71 if [ $? -eq 0 ]
72 then
73 isql $DS < ${REL_PATH}/drop.sql >/dev/null 2>&1
74 exit 5;
77 #wrong username and wrong password
78 $CSQL_INSTALL_ROOT/bin/cacheverify -U ROOT -P MANAGER -t t1 > /dev/null 2>&1
79 if [ $? -eq 0 ]
80 then
81 isql $DS < ${REL_PATH}/drop.sql >/dev/null 2>&1
82 exit 6;
85 rm -f /tmp/csql/csqltable.conf
86 touch /tmp/csql/csqltable.conf
87 $CSQL_INSTALL_ROOT/bin/csql -s ${REL_PATH}/drop.sql > /dev/null 2>&1
88 isql $DS < ${REL_PATH}/drop.sql >/dev/null 2>&1
89 exit 0;