system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/exec.sh -n dnode1 -s start
sql connect

print ============= step1
sql create user u_read pass 'taosdata1'
sql create user u_write pass 'taosdata1'

sql alter user u_read pass 'taosdata'
sql alter user u_write pass 'taosdata'

sql show users
if $rows != 3 then 
  return -1
endi

print ============= step2
print user u_read login
sql close
sql connect u_read

sql alter user u_read pass 'taosdata'
sql_error alter user u_write pass 'taosdata1' 

sql_error create user read1 pass 'taosdata1'
sql_error create user write1 pass 'taosdata1'

sql show users
if $rows != 3 then 
  return -1
endi

print ============= step3
print user u_write login
sql close
sql connect u_write

sql_error create user read2 pass 'taosdata1'
sql_error create user write2 pass 'taosdata1'
sql alter user u_write pass 'taosdata'
sql_error alter user u_read pass 'taosdata' 

sql show users
if $rows != 3 then 
  return -1
endi

print ============= step4
print user root login
sql close 
sql connect
sql create user oroot pass 'taosdata'
sql_error create user $user PASS 'abcd012345678901234567891234567890abcd012345678901234567891234567890abcd012345678901234567891234567890abcd012345678901234567891234567890123'
sql_error create userabcd012345678901234567891234567890abcd01234567890123456789123456789  PASS 'taosdata'
sql_error create user abcd0123456789012345678901234567890111 PASS '123'
sql create user abc01234567890123456789 PASS '123'

sql show users
if $rows != 5 then 
  return -1
endi

print ============= step5
sql create database db vgroups 1
sql_error ALTER USER o_root SYSINFO 0
sql_error ALTER USER o_root SYSINFO 1
sql_error ALTER USER o_root enable 0
sql_error ALTER USER o_root enable 1

sql_error create database db vgroups 1;
sql_error GRANT read ON db.* to o_root;
sql_error GRANT read ON *.* to o_root;
sql_error REVOKE read ON db.* from o_root;
sql_error REVOKE read ON *.* from o_root;
sql_error GRANT write ON db.* to o_root;
sql_error GRANT write ON *.* to o_root;
sql_error REVOKE write ON db.* from o_root;
sql_error REVOKE write ON *.* from o_root;
sql_error REVOKE write ON *.* from o_root;

sql_error GRANT all ON *.* to o_root;
sql_error REVOKE all ON *.* from o_root;
sql_error GRANT read,write ON *.* to o_root;
sql_error REVOKE read,write ON *.* from o_root;

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