From e04616d70e851ae899aebfdd2aba91d1bf1aab9f Mon Sep 17 00:00:00 2001 From: cpwu Date: Fri, 13 May 2022 11:25:27 +0800 Subject: [PATCH 01/11] fix case --- tests/system-test/0-others/user_control.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/system-test/0-others/user_control.py b/tests/system-test/0-others/user_control.py index ec3f8ce11a..f83865a461 100644 --- a/tests/system-test/0-others/user_control.py +++ b/tests/system-test/0-others/user_control.py @@ -6,6 +6,7 @@ import traceback from util.log import * from util.sql import * from util.cases import * +from util.dnodes import * PRIVILEGES_ALL = "ALL" @@ -282,6 +283,9 @@ class TDTestCase: self.login_err(self.__user_list[0], self.__passwd_list[0]) self.login_currrent(self.__user_list[0], f"new{self.__passwd_list[0]}") + tdDnodes.stop(1) + tdDnodes.start(1) + # 普通用户权限 # 密码登录 _, user = self.user_login(self.__user_list[0], f"new{self.__passwd_list[0]}") @@ -316,6 +320,20 @@ class TDTestCase: tdSql.checkData(0, 0, "root") tdSql.checkData(0, 1, "super") + tdDnodes.stop(1) + tdDnodes.start(1) + + # 删除后无法登录 + self.login_err(self.__user_list[0], self.__passwd_list[0]) + self.login_currrent(self.__user_list[0], f"new{self.__passwd_list[0]}") + self.login_err(self.__user_list[1], self.__passwd_list[1]) + self.login_currrent(self.__user_list[1], f"new{self.__passwd_list[1]}") + + tdSql.query("show users") + tdSql.checkRows(1) + tdSql.checkData(0, 0, "root") + tdSql.checkData(0, 1, "super") + def stop(self): tdSql.close() From 2704e48ba6d84e4eb6dca8deff3f97c9d56ae012 Mon Sep 17 00:00:00 2001 From: cpwu Date: Fri, 13 May 2022 11:40:33 +0800 Subject: [PATCH 02/11] fix case --- tests/system-test/0-others/user_control.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/system-test/0-others/user_control.py b/tests/system-test/0-others/user_control.py index f83865a461..8a1ce1a85c 100644 --- a/tests/system-test/0-others/user_control.py +++ b/tests/system-test/0-others/user_control.py @@ -286,6 +286,9 @@ class TDTestCase: tdDnodes.stop(1) tdDnodes.start(1) + tdSql.query("show users") + tdSql.checkRows(self.users_count + 2) + # 普通用户权限 # 密码登录 _, user = self.user_login(self.__user_list[0], f"new{self.__passwd_list[0]}") From 9038df4232fdb1ba8118dab5e153c65b8c478dbd Mon Sep 17 00:00:00 2001 From: cpwu Date: Fri, 13 May 2022 11:47:49 +0800 Subject: [PATCH 03/11] fix case --- tests/system-test/0-others/user_control.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/tests/system-test/0-others/user_control.py b/tests/system-test/0-others/user_control.py index 8a1ce1a85c..1f3c0f7cc7 100644 --- a/tests/system-test/0-others/user_control.py +++ b/tests/system-test/0-others/user_control.py @@ -291,27 +291,37 @@ class TDTestCase: # 普通用户权限 # 密码登录 - _, user = self.user_login(self.__user_list[0], f"new{self.__passwd_list[0]}") - with taos_connect(user=self.__user_list[0], passwd=f"new{self.__passwd_list[0]}") as conn: - user = conn + # _, user = self.user_login(self.__user_list[0], f"new{self.__passwd_list[0]}") # 不能创建用户 tdLog.printNoPrefix("==========step5: normal user can not create user") + with taos_connect(user=self.__user_list[0], passwd=f"new{self.__passwd_list[0]}") as user: pass user.error("create use utest1 pass 'utest1pass'") + # 可以查看用户 tdLog.printNoPrefix("==========step6: normal user can show user") + with taos_connect(user=self.__user_list[0], passwd=f"new{self.__passwd_list[0]}") as user: pass user.query("show users") assert user.queryRows == self.users_count + 2 + # 不可以修改其他用户的密码 tdLog.printNoPrefix("==========step7: normal user can not alter other user pass") + with taos_connect(user=self.__user_list[0], passwd=f"new{self.__passwd_list[0]}") as user: pass user.error(self.__alter_pass_sql(self.__user_list[1], self.__passwd_list[1] )) + with taos_connect(user=self.__user_list[0], passwd=f"new{self.__passwd_list[0]}") as user: pass user.error("root", "taosdata_root") + # 可以修改自己的密码 tdLog.printNoPrefix("==========step8: normal user can alter owner pass") + with taos_connect(user=self.__user_list[0], passwd=f"new{self.__passwd_list[0]}") as user: pass user.query(self.__alter_pass_sql(self.__user_list[0], self.__passwd_list[0])) + # 不可以删除用户,包括自己 tdLog.printNoPrefix("==========step9: normal user can not drop any user ") + with taos_connect(user=self.__user_list[0], passwd=f"new{self.__passwd_list[0]}") as user: pass user.error(f"drop user {self.__user_list[0]}") + with taos_connect(user=self.__user_list[0], passwd=f"new{self.__passwd_list[0]}") as user: pass user.error(f"drop user {self.__user_list[1]}") + with taos_connect(user=self.__user_list[0], passwd=f"new{self.__passwd_list[0]}") as user: pass user.error("drop user root") # root删除用户测试 From d3cfa1fa5759a3eee2606396cf04713e31310e26 Mon Sep 17 00:00:00 2001 From: cpwu Date: Fri, 13 May 2022 11:50:33 +0800 Subject: [PATCH 04/11] fix case --- tests/system-test/0-others/user_control.py | 52 +++++++++------------- 1 file changed, 21 insertions(+), 31 deletions(-) diff --git a/tests/system-test/0-others/user_control.py b/tests/system-test/0-others/user_control.py index 1f3c0f7cc7..bbbd02687b 100644 --- a/tests/system-test/0-others/user_control.py +++ b/tests/system-test/0-others/user_control.py @@ -292,37 +292,27 @@ class TDTestCase: # 普通用户权限 # 密码登录 # _, user = self.user_login(self.__user_list[0], f"new{self.__passwd_list[0]}") - # 不能创建用户 - tdLog.printNoPrefix("==========step5: normal user can not create user") - with taos_connect(user=self.__user_list[0], passwd=f"new{self.__passwd_list[0]}") as user: pass - user.error("create use utest1 pass 'utest1pass'") - - # 可以查看用户 - tdLog.printNoPrefix("==========step6: normal user can show user") - with taos_connect(user=self.__user_list[0], passwd=f"new{self.__passwd_list[0]}") as user: pass - user.query("show users") - assert user.queryRows == self.users_count + 2 - - # 不可以修改其他用户的密码 - tdLog.printNoPrefix("==========step7: normal user can not alter other user pass") - with taos_connect(user=self.__user_list[0], passwd=f"new{self.__passwd_list[0]}") as user: pass - user.error(self.__alter_pass_sql(self.__user_list[1], self.__passwd_list[1] )) - with taos_connect(user=self.__user_list[0], passwd=f"new{self.__passwd_list[0]}") as user: pass - user.error("root", "taosdata_root") - - # 可以修改自己的密码 - tdLog.printNoPrefix("==========step8: normal user can alter owner pass") - with taos_connect(user=self.__user_list[0], passwd=f"new{self.__passwd_list[0]}") as user: pass - user.query(self.__alter_pass_sql(self.__user_list[0], self.__passwd_list[0])) - - # 不可以删除用户,包括自己 - tdLog.printNoPrefix("==========step9: normal user can not drop any user ") - with taos_connect(user=self.__user_list[0], passwd=f"new{self.__passwd_list[0]}") as user: pass - user.error(f"drop user {self.__user_list[0]}") - with taos_connect(user=self.__user_list[0], passwd=f"new{self.__passwd_list[0]}") as user: pass - user.error(f"drop user {self.__user_list[1]}") - with taos_connect(user=self.__user_list[0], passwd=f"new{self.__passwd_list[0]}") as user: pass - user.error("drop user root") + with taos_connect(user=self.__user_list[0], passwd=f"new{self.__passwd_list[0]}") as user: + # user = conn + # 不能创建用户 + tdLog.printNoPrefix("==========step5: normal user can not create user") + user.error("create use utest1 pass 'utest1pass'") + # 可以查看用户 + tdLog.printNoPrefix("==========step6: normal user can show user") + user.query("show users") + assert user.queryRows == self.users_count + 2 + # 不可以修改其他用户的密码 + tdLog.printNoPrefix("==========step7: normal user can not alter other user pass") + user.error(self.__alter_pass_sql(self.__user_list[1], self.__passwd_list[1] )) + user.error("root", "taosdata_root") + # 可以修改自己的密码 + tdLog.printNoPrefix("==========step8: normal user can alter owner pass") + user.query(self.__alter_pass_sql(self.__user_list[0], self.__passwd_list[0])) + # 不可以删除用户,包括自己 + tdLog.printNoPrefix("==========step9: normal user can not drop any user ") + user.error(f"drop user {self.__user_list[0]}") + user.error(f"drop user {self.__user_list[1]}") + user.error("drop user root") # root删除用户测试 tdLog.printNoPrefix("==========step10: super user drop normal user") From c212602629cd804c1e694eee4f0e431438c810db Mon Sep 17 00:00:00 2001 From: cpwu Date: Fri, 13 May 2022 11:55:46 +0800 Subject: [PATCH 05/11] fix case --- tests/system-test/0-others/user_control.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/system-test/0-others/user_control.py b/tests/system-test/0-others/user_control.py index bbbd02687b..cae988b183 100644 --- a/tests/system-test/0-others/user_control.py +++ b/tests/system-test/0-others/user_control.py @@ -304,7 +304,7 @@ class TDTestCase: # 不可以修改其他用户的密码 tdLog.printNoPrefix("==========step7: normal user can not alter other user pass") user.error(self.__alter_pass_sql(self.__user_list[1], self.__passwd_list[1] )) - user.error("root", "taosdata_root") + user.error(self.__alter_pass_sql("root", "taosdata_root" )) # 可以修改自己的密码 tdLog.printNoPrefix("==========step8: normal user can alter owner pass") user.query(self.__alter_pass_sql(self.__user_list[0], self.__passwd_list[0])) From 39ee1144c5b3bb96eb44c397a8e69a54e40996ac Mon Sep 17 00:00:00 2001 From: cpwu Date: Fri, 13 May 2022 11:58:12 +0800 Subject: [PATCH 06/11] fix case --- tests/system-test/0-others/user_control.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/system-test/0-others/user_control.py b/tests/system-test/0-others/user_control.py index cae988b183..18246774e4 100644 --- a/tests/system-test/0-others/user_control.py +++ b/tests/system-test/0-others/user_control.py @@ -238,7 +238,7 @@ class TDTestCase: f"DROP user {self.__user_list[0]} , {self.__user_list[1]}", f"DROP users {self.__user_list[0]} {self.__user_list[1]}", f"DROP users {self.__user_list[0]} , {self.__user_list[1]}", - "DROP user root", + # "DROP user root", "DROP user abcde", "DROP user ALL", ] From 28915c9e0cd86b5905322432e15eb6c49d2d595e Mon Sep 17 00:00:00 2001 From: cpwu Date: Fri, 13 May 2022 12:00:56 +0800 Subject: [PATCH 07/11] fix case --- tests/system-test/0-others/user_control.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/system-test/0-others/user_control.py b/tests/system-test/0-others/user_control.py index 18246774e4..c466025847 100644 --- a/tests/system-test/0-others/user_control.py +++ b/tests/system-test/0-others/user_control.py @@ -162,6 +162,8 @@ class TDTestCase: for sql in sqls: tdSql.error(sql) + tdSql.execute("DROP USER u1") + def __alter_pass_sql(self, user, passwd): return f'''ALTER USER {user} PASS '{passwd}' ''' From 19a99450eef7d2689945e95ae721a18648e3e8c4 Mon Sep 17 00:00:00 2001 From: cpwu Date: Fri, 13 May 2022 12:02:28 +0800 Subject: [PATCH 08/11] fix case --- tests/system-test/0-others/user_control.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/system-test/0-others/user_control.py b/tests/system-test/0-others/user_control.py index c466025847..3bb21ea96e 100644 --- a/tests/system-test/0-others/user_control.py +++ b/tests/system-test/0-others/user_control.py @@ -270,7 +270,7 @@ class TDTestCase: # 查看用户 tdLog.printNoPrefix("==========step2: show user test") tdSql.query("show users") - tdSql.checkRows(self.users_count + 2) + tdSql.checkRows(self.users_count + 1) # 密码登录认证 self.login_currrent(self.__user_list[0], self.__passwd_list[0]) From 7efa74dc39471c811abc306ce95c5662d4fed024 Mon Sep 17 00:00:00 2001 From: cpwu Date: Fri, 13 May 2022 12:04:55 +0800 Subject: [PATCH 09/11] fix case --- tests/system-test/0-others/user_control.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/system-test/0-others/user_control.py b/tests/system-test/0-others/user_control.py index 3bb21ea96e..c3e5ad3191 100644 --- a/tests/system-test/0-others/user_control.py +++ b/tests/system-test/0-others/user_control.py @@ -289,7 +289,7 @@ class TDTestCase: tdDnodes.start(1) tdSql.query("show users") - tdSql.checkRows(self.users_count + 2) + tdSql.checkRows(self.users_count + 1) # 普通用户权限 # 密码登录 @@ -302,7 +302,7 @@ class TDTestCase: # 可以查看用户 tdLog.printNoPrefix("==========step6: normal user can show user") user.query("show users") - assert user.queryRows == self.users_count + 2 + assert user.queryRows == self.users_count + 1 # 不可以修改其他用户的密码 tdLog.printNoPrefix("==========step7: normal user can not alter other user pass") user.error(self.__alter_pass_sql(self.__user_list[1], self.__passwd_list[1] )) From 8895b3a5caf8d4b72bc38cbe1ef5f070dc1648cc Mon Sep 17 00:00:00 2001 From: cpwu Date: Fri, 13 May 2022 12:06:02 +0800 Subject: [PATCH 10/11] fix case --- tests/system-test/0-others/user_control.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/system-test/0-others/user_control.py b/tests/system-test/0-others/user_control.py index c3e5ad3191..78aefd5e9e 100644 --- a/tests/system-test/0-others/user_control.py +++ b/tests/system-test/0-others/user_control.py @@ -330,9 +330,9 @@ class TDTestCase: # 删除后无法登录 self.login_err(self.__user_list[0], self.__passwd_list[0]) - self.login_currrent(self.__user_list[0], f"new{self.__passwd_list[0]}") + self.login_err(self.__user_list[0], f"new{self.__passwd_list[0]}") self.login_err(self.__user_list[1], self.__passwd_list[1]) - self.login_currrent(self.__user_list[1], f"new{self.__passwd_list[1]}") + self.login_err(self.__user_list[1], f"new{self.__passwd_list[1]}") tdSql.query("show users") tdSql.checkRows(1) From a08771ea4a65a6b84b8899bfdd2e03f7a7165e35 Mon Sep 17 00:00:00 2001 From: cpwu Date: Fri, 13 May 2022 12:09:10 +0800 Subject: [PATCH 11/11] fix case --- tests/system-test/fulltest.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/system-test/fulltest.sh b/tests/system-test/fulltest.sh index 817f814873..c80206abbc 100755 --- a/tests/system-test/fulltest.sh +++ b/tests/system-test/fulltest.sh @@ -8,6 +8,8 @@ python3 ./test.py -f 0-others/taosShellNetChk.py python3 ./test.py -f 0-others/telemetry.py python3 ./test.py -f 0-others/taosdMonitor.py +python3 ./test.py -f 0-others/user_control.py + #python3 ./test.py -f 2-query/between.py python3 ./test.py -f 2-query/distinct.py python3 ./test.py -f 2-query/varchar.py @@ -53,5 +55,3 @@ python3 ./test.py -f 2-query/arctan.py # python3 ./test.py -f 2-query/query_cols_tags_and_or.py python3 ./test.py -f 7-tmq/basic5.py - -