TDengine/tests/script/tsim/user/basic.sim

234 lines
4.7 KiB
Text
Raw Normal View History

2022-06-24 07:22:57 +00:00
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/exec.sh -n dnode1 -s start
sql connect
print =============== step0
2022-08-11 12:56:31 +00:00
sql select * from information_schema.ins_users
2022-06-24 07:22:57 +00:00
if $data(root)[1] != 1 then
return -1
endi
if $data(root)[2] != 1 then
return -1
endi
if $data(root)[3] != 1 then
return -1
endi
2024-06-04 10:14:20 +00:00
if $data(root)[4] != 1 then
return -1
endi
2022-06-24 07:22:57 +00:00
sql alter user root pass 'taosdata'
sql_error ALTER USER root SYSINFO 0
sql_error ALTER USER root SYSINFO 1
sql_error ALTER USER root enable 0
sql_error ALTER USER root enable 1
2024-06-04 10:14:20 +00:00
sql_error ALTER USER root createdb 0
sql_error ALTER USER root createdb 1
2022-06-24 07:22:57 +00:00
2022-07-07 08:33:32 +00:00
#sql_error create database db vgroups 1;
2022-06-24 07:22:57 +00:00
sql_error GRANT read ON db.* to root;
sql_error GRANT read ON *.* to root;
sql_error REVOKE read ON db.* from root;
sql_error REVOKE read ON *.* from root;
sql_error GRANT write ON db.* to root;
sql_error GRANT write ON *.* to root;
sql_error REVOKE write ON db.* from root;
sql_error REVOKE write ON *.* from root;
sql_error REVOKE write ON *.* from root;
sql_error GRANT all ON *.* to root;
sql_error REVOKE all ON *.* from root;
sql_error GRANT read,write ON *.* to root;
sql_error REVOKE read,write ON *.* from root;
print =============== step1: sysinfo create
sql CREATE USER u1 PASS 'taosdata' SYSINFO 0;
2022-08-11 12:56:31 +00:00
sql select * from information_schema.ins_users
2022-06-24 07:22:57 +00:00
if $rows != 2 then
return -1
endi
if $data(u1)[1] != 0 then
return -1
endi
if $data(u1)[2] != 1 then
return -1
endi
if $data(u1)[3] != 0 then
return -1
endi
2024-06-04 10:14:20 +00:00
if $data(u1)[4] != 0 then
return -1
endi
2022-06-24 07:22:57 +00:00
sql CREATE USER u2 PASS 'taosdata' SYSINFO 1;
2022-08-11 12:56:31 +00:00
sql select * from information_schema.ins_users
2022-06-24 07:22:57 +00:00
if $rows != 3 then
return -1
endi
if $data(u2)[1] != 0 then
return -1
endi
if $data(u2)[2] != 1 then
return -1
endi
if $data(u2)[3] != 1 then
return -1
endi
2024-06-04 10:14:20 +00:00
if $data(u2)[4] != 0 then
return -1
endi
2022-06-24 07:22:57 +00:00
print =============== step2: sysinfo alter
sql ALTER USER u1 SYSINFO 1
2022-08-11 12:56:31 +00:00
sql select * from information_schema.ins_users
2022-06-24 07:22:57 +00:00
if $data(u1)[1] != 0 then
return -1
endi
if $data(u1)[2] != 1 then
return -1
endi
if $data(u1)[3] != 1 then
return -1
endi
2024-06-04 10:14:20 +00:00
if $data(u1)[4] != 0 then
return -1
endi
2022-06-24 07:22:57 +00:00
sql ALTER USER u1 SYSINFO 0
2022-08-11 12:56:31 +00:00
sql select * from information_schema.ins_users
2022-06-24 07:22:57 +00:00
if $data(u1)[1] != 0 then
return -1
endi
if $data(u1)[2] != 1 then
return -1
endi
if $data(u1)[3] != 0 then
return -1
endi
2024-06-04 10:14:20 +00:00
if $data(u1)[4] != 0 then
return -1
endi
2022-06-24 07:22:57 +00:00
sql ALTER USER u1 SYSINFO 0
sql ALTER USER u1 SYSINFO 0
sql drop user u1
2022-08-11 12:56:31 +00:00
sql select * from information_schema.ins_users
2022-06-24 07:22:57 +00:00
if $rows != 2 then
return -1
endi
print =============== step3: enable alter
sql ALTER USER u2 enable 0
2022-08-11 12:56:31 +00:00
sql select * from information_schema.ins_users
2022-06-24 07:22:57 +00:00
if $rows != 2 then
return -1
endi
if $data(u2)[1] != 0 then
return -1
endi
if $data(u2)[2] != 0 then
return -1
endi
if $data(u2)[3] != 1 then
return -1
endi
2024-06-04 10:14:20 +00:00
if $data(u2)[4] != 0 then
return -1
endi
2022-06-24 07:22:57 +00:00
sql ALTER USER u2 enable 1
2022-08-11 12:56:31 +00:00
sql select * from information_schema.ins_users
2022-06-24 07:22:57 +00:00
if $data(u2)[1] != 0 then
return -1
endi
if $data(u2)[2] != 1 then
return -1
endi
if $data(u2)[3] != 1 then
return -1
endi
2024-06-04 10:14:20 +00:00
if $data(u2)[4] != 0 then
return -1
endi
2022-06-24 07:22:57 +00:00
sql ALTER USER u2 enable 1
sql ALTER USER u2 enable 1
2024-06-04 10:14:20 +00:00
print =============== step4: createdb alter
sql ALTER USER u2 createdb 1
sql select * from information_schema.ins_users
if $rows != 2 then
return -1
endi
if $data(u2)[1] != 0 then
return -1
endi
if $data(u2)[2] != 1 then
return -1
endi
if $data(u2)[3] != 1 then
return -1
endi
if $data(u2)[4] != 1 then
return -1
endi
sql ALTER USER u2 createdb 0
sql select * from information_schema.ins_users
if $data(u2)[1] != 0 then
return -1
endi
if $data(u2)[2] != 1 then
return -1
endi
if $data(u2)[3] != 1 then
return -1
endi
if $data(u2)[4] != 0 then
return -1
endi
2022-06-24 07:22:57 +00:00
print =============== restart taosd
system sh/exec.sh -n dnode1 -s stop
system sh/exec.sh -n dnode1 -s start
2024-06-04 10:14:20 +00:00
print =============== step5: enable privilege
2022-08-11 12:56:31 +00:00
sql select * from information_schema.ins_users
2022-06-24 07:22:57 +00:00
if $rows != 2 then
return -1
endi
if $data(u2)[1] != 0 then
return -1
endi
if $data(u2)[2] != 1 then
return -1
endi
if $data(u2)[3] != 1 then
return -1
endi
2024-06-04 10:14:20 +00:00
if $data(u2)[4] != 0 then
return -1
endi
2022-06-24 07:22:57 +00:00
sql_error CREATE USER u100 PASS 'taosdata' SYSINFO -1;
sql_error CREATE USER u101 PASS 'taosdata' SYSINFO 2;
sql_error CREATE USER u102 PASS 'taosdata' SYSINFO 20000;
2024-06-13 08:36:18 +00:00
sql_error CREATE USER u103 PASS 'taosdata' SYSINFO 1000;
sql_error ALTER USER u1 enable -1
sql_error ALTER USER u1 enable 2
2024-06-13 08:36:18 +00:00
sql_error ALTER USER u1 enable 1000
sql_error ALTER USER u1 enable 10000
sql_error ALTER USER u1 sysinfo -1
sql_error ALTER USER u1 sysinfo 2
2024-06-13 08:36:18 +00:00
sql_error ALTER USER u1 sysinfo 1000
sql_error ALTER USER u1 sysinfo -20000
sql_error ALTER USER u1 createdb -1
sql_error ALTER USER u1 createdb 3
2024-06-13 08:36:18 +00:00
sql_error ALTER USER u1 createdb 1000
sql_error ALTER USER u1 createdb 100000
2022-06-24 07:22:57 +00:00
system sh/exec.sh -n dnode1 -s stop -x SIGINT