adding DSN to csql.conf based on the cache test mode
[csql.git] / test / cache / CacheTable / test002.ksh
blob804715343f0e1d9a1332b4e2c44af3c0e910c1ab
1 #!/bin/sh
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 DSN=$DSN >>$CSQL_CONFIG_FILE
24 isql $DSN < ${REL_PATH}/inputtest4.sql >/dev/null 2>&1
25 if [ $? -ne 0 ]
26 then
27 cp /tmp/csql.conf $CSQL_CONFIG_FILE
28 exit 1;
31 rm -f /tmp/csql/csqltable.conf /tmp/csql/csql.db
32 touch /tmp/csql/csqltable.conf /tmp/csql/csql.db
34 # check with correct username and correct password
35 $CSQL_INSTALL_ROOT/bin/cachetable -U root -P manager -t t1 >/dev/null 2>&1
36 if [ $? -ne 0 ]
37 then
38 cp /tmp/csql.conf $CSQL_CONFIG_FILE
39 exit 2;
42 # correct username and wrong password
43 $CSQL_INSTALL_ROOT/bin/cachetable -U root -P MANAGER -t t1 > /dev/null 2>&1
44 if [ $? -eq 0 ]
45 then
46 cp /tmp/csql.conf $CSQL_CONFIG_FILE
47 exit 3;
50 # wrong username and correct password
51 $CSQL_INSTALL_ROOT/bin/cachetable -U ROOT -P manager -t t1 > /dev/null 2>&1
52 if [ $? -eq 0 ]
53 then
54 cp /tmp/csql.conf $CSQL_CONFIG_FILE
55 exit 4;
58 #wrong username and wrong password
59 $CSQL_INSTALL_ROOT/bin/cachetable -U ROOT -P MANAGER -t t1 > /dev/null 2>&1
60 if [ $? -eq 0 ]
61 then
62 cp /tmp/csql.conf $CSQL_CONFIG_FILE
63 exit 5;
66 rm -f /tmp/csql/csqltable.conf /tmp/csql/csql.db
67 touch /tmp/csql/csqltable.conf /tmp/csql/csql.db
69 $CSQL_INSTALL_ROOT/bin/csql -s ${REL_PATH}/drop.sql > /dev/null 2>&1
70 isql $DSN < ${REL_PATH}/drop.sql >/dev/null 2>&1
71 #rm -f /tmp/csql/csqltable.conf /tmp/csql/csql.db
72 #touch /tmp/csql/csqltable.conf /tmp/csql/csql.db
74 cp /tmp/csql.conf $CSQL_CONFIG_FILE
75 exit 0;