adding test scripts
[csql.git] / test / cache / CacheTable / test002.ksh
blobbae7200720f9f8746a711745d2eb87070e5ea37a
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 # $ cachetable [-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/CacheTable/inputtest4.sql
16 REL_PATH=.
17 if [ -s "$input" ]
18 then
19 REL_PATH=${PWD}/cache/CacheTable
21 cp $CSQL_CONFIG_FILE /tmp/csql.conf
22 echo CACHE_TABLE=true >>$CSQL_CONFIG_FILE
23 echo DSN=$DSN >>$CSQL_CONFIG_FILE
24 DS="$DSN $DBUSER $PASSWORD"
25 rm -f /tmp/csql/csqlds.conf
26 touch /tmp/csql/csqlds.conf
27 $CSQL_INSTALL_ROOT/bin/csqlds -U $DBUSER -P $PASSWORD -D $DSN -N $TDB -a
28 if [ $? -ne 0 ]
29 then
30 cp /tmp/csql.conf $CSQL_CONFIG_FILE
31 exit 1;
33 echo $DS
34 isql $DS < ${REL_PATH}/inputtest4.sql >/dev/null 2>&1
35 if [ $? -ne 0 ]
36 then
37 cp /tmp/csql.conf $CSQL_CONFIG_FILE
38 exit 1;
41 rm -f /tmp/csql/csqltable.conf
42 touch /tmp/csql/csqltable.conf
44 # check with correct username and correct password
45 $CSQL_INSTALL_ROOT/bin/cachetable -U root -P manager -t t1
46 if [ $? -ne 0 ]
47 then
48 cp /tmp/csql.conf $CSQL_CONFIG_FILE
49 exit 2;
52 # correct username and wrong password
53 $CSQL_INSTALL_ROOT/bin/cachetable -U root -P MANAGER -t t1 > /dev/null 2>&1
54 if [ $? -eq 0 ]
55 then
56 cp /tmp/csql.conf $CSQL_CONFIG_FILE
57 exit 3;
60 # wrong username and correct password
61 $CSQL_INSTALL_ROOT/bin/cachetable -U ROOT -P manager -t t1 > /dev/null 2>&1
62 if [ $? -eq 0 ]
63 then
64 cp /tmp/csql.conf $CSQL_CONFIG_FILE
65 exit 4;
68 #wrong username and wrong password
69 $CSQL_INSTALL_ROOT/bin/cachetable -U ROOT -P MANAGER -t t1 > /dev/null 2>&1
70 if [ $? -eq 0 ]
71 then
72 cp /tmp/csql.conf $CSQL_CONFIG_FILE
73 exit 5;
76 rm -f /tmp/csql/csqltable.conf
77 touch /tmp/csql/csqltable.conf
79 $CSQL_INSTALL_ROOT/bin/csql -s ${REL_PATH}/drop.sql > /dev/null 2>&1
80 isql $DS < ${REL_PATH}/drop.sql >/dev/null 2>&1
81 #rm -f /tmp/csql/csqltable.conf
82 #touch /tmp/csql/csqltable.conf
84 cp /tmp/csql.conf $CSQL_CONFIG_FILE
85 exit 0;