privilege_db.sim 2.3 KB
Newer Older
1 2 3 4 5
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/exec.sh -n dnode1 -s start
sql connect

6
print =============== create db
7 8 9
sql create database d1 vgroups 1;
sql create database d2 vgroups 1;
sql create database d3 vgroups 1;
X
Xiaoyu Wang 已提交
10
sql select * from information_schema.ins_databases
11 12 13 14 15 16 17
if $rows != 5 then 
  return -1
endi

print =============== create users
sql create user user1 PASS 'user1'
sql create user user2 PASS 'user2'
X
Xiaoyu Wang 已提交
18
sql select * from information_schema.ins_users
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
if $rows != 3 then 
  return -1
endi

print =============== test read 
sql_error GRANT read ON d1.* to a;
sql_error GRANT read ON d0.* to user1;

sql GRANT read ON d1.* to user1;
sql GRANT read ON d2.* to user1;
sql GRANT read ON *.* to user1;

sql REVOKE read ON d1.* from user1;
sql REVOKE read ON d2.* from user1;
sql REVOKE read ON *.* from user1;

print =============== test write 
sql_error GRANT write ON d1.* to a;
sql_error GRANT write ON d0.* to user1;

sql GRANT write ON d1.* to user1;
sql GRANT write ON d2.* to user1;
sql GRANT write ON *.* to user1;

sql REVOKE write ON d1.* from user1;
sql REVOKE write ON d2.* from user1;
sql REVOKE write ON *.* from user1;

print =============== test all 
sql_error GRANT all ON d1.* to a;
sql_error GRANT all ON d0.* to user1;

sql GRANT all ON d1.* to user1;
sql GRANT all ON d2.* to user1;
sql GRANT all ON *.* to user1;

sql REVOKE all ON d1.* from user1;
sql REVOKE all ON d2.* from user1;
sql REVOKE all ON *.* from user1;

print =============== test read write 
sql_error GRANT read,write ON d1.* to a;
sql_error GRANT read,write ON d0.* to user1;

sql GRANT read,write ON d1.* to user1;
sql GRANT read,write ON d2.* to user1;
sql GRANT read,write ON *.* to user1;

sql REVOKE read,write ON d1.* from user1;
sql REVOKE read,write ON d2.* from user1;
sql REVOKE read,write ON *.* from user1;

71 72 73

print =============== create users
sql create user u1 PASS 'taosdata'
X
Xiaoyu Wang 已提交
74
sql select * from information_schema.ins_users
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
if $rows != 4 then 
  return -1
endi

sql GRANT read ON d1.* to u1;
sql GRANT write ON d2.* to u1;

print =============== re connect
print user u1 login
sql close
sql connect u1

sql_error drop database d1;
sql_error drop database d2;

sql_error create stable d1.st (ts timestamp, i int) tags (j int)
sql create stable d2.st (ts timestamp, i int) tags (j int)

93
system sh/exec.sh -n dnode1 -s stop -x SIGINT