Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
a098b53d
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
a098b53d
编写于
5月 12, 2023
作者:
wmmhello
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'main' of
https://github.com/taosdata/TDengine
into fix/TD-24111
上级
d85f0f56
ba4d5e0b
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
37 addition
and
13 deletion
+37
-13
README-CN.md
README-CN.md
+1
-1
tests/system-test/0-others/user_privilege.py
tests/system-test/0-others/user_privilege.py
+36
-12
未找到文件。
README-CN.md
浏览文件 @
a098b53d
...
...
@@ -352,4 +352,4 @@ TDengine 提供了丰富的应用程序开发接口,其中包括 C/C++、Java
# 加入技术交流群
TDengine 官方社群「物联网大数据群」对外开放,欢迎您加入讨论。搜索微信号 "tdengine",加小 T 为好友,即可入群。
TDengine 官方社群「物联网大数据群」对外开放,欢迎您加入讨论。搜索微信号 "tdengine
1
",加小 T 为好友,即可入群。
tests/system-test/0-others/user_privilege.py
浏览文件 @
a098b53d
...
...
@@ -29,6 +29,7 @@ class TDTestCase:
self
.
stbname
=
'stb'
self
.
binary_length
=
20
# the length of binary for column_dict
self
.
nchar_length
=
20
# the length of nchar for column_dict
self
.
dbnames
=
[
'db1'
,
'db2'
]
self
.
column_dict
=
{
'ts'
:
'timestamp'
,
'col1'
:
'float'
,
...
...
@@ -57,21 +58,25 @@ class TDTestCase:
def
create_user
(
self
):
user_name
=
'test'
tdSql
.
execute
(
f
'create user
{
user_name
}
pass "test"'
)
tdSql
.
execute
(
f
'grant read on db.stb with t2 = "Beijing" to
{
user_name
}
'
)
tdSql
.
execute
(
f
'grant read on
{
self
.
dbnames
[
0
]
}
.
{
self
.
stbname
}
with t2 = "Beijing" to
{
user_name
}
'
)
tdSql
.
execute
(
f
'grant write on
{
self
.
dbnames
[
1
]
}
.
{
self
.
stbname
}
with t1 = 2 to
{
user_name
}
'
)
def
prepare_data
(
self
):
tdSql
.
execute
(
self
.
setsql
.
set_create_stable_sql
(
self
.
stbname
,
self
.
column_dict
,
self
.
tag_dict
))
for
i
in
range
(
self
.
tbnum
):
tdSql
.
execute
(
f
'create table
{
self
.
stbname
}
_
{
i
}
using
{
self
.
stbname
}
tags(
{
self
.
tag_list
[
i
]
}
)'
)
for
j
in
self
.
values_list
:
tdSql
.
execute
(
f
'insert into
{
self
.
stbname
}
_
{
i
}
values(
{
j
}
)'
)
for
db
in
self
.
dbnames
:
tdSql
.
execute
(
f
"create database
{
db
}
"
)
tdSql
.
execute
(
f
"use
{
db
}
"
)
tdSql
.
execute
(
self
.
setsql
.
set_create_stable_sql
(
self
.
stbname
,
self
.
column_dict
,
self
.
tag_dict
))
for
i
in
range
(
self
.
tbnum
):
tdSql
.
execute
(
f
'create table
{
self
.
stbname
}
_
{
i
}
using
{
self
.
stbname
}
tags(
{
self
.
tag_list
[
i
]
}
)'
)
for
j
in
self
.
values_list
:
tdSql
.
execute
(
f
'insert into
{
self
.
stbname
}
_
{
i
}
values(
{
j
}
)'
)
def
user_
privilege_check
(
self
):
def
user_
read_privilege_check
(
self
,
dbname
):
testconn
=
taos
.
connect
(
user
=
'test'
,
password
=
'test'
)
expectErrNotOccured
=
False
try
:
sql
=
"select count(*) from db
.stb where t2 = 'Beijing'"
sql
=
f
"select count(*) from
{
dbname
}
.stb where t2 = 'Beijing'"
res
=
testconn
.
query
(
sql
)
data
=
res
.
fetch_all
()
count
=
data
[
0
][
0
]
...
...
@@ -85,11 +90,30 @@ class TDTestCase:
tdLog
.
exit
(
f
"
{
sql
}
, expect result doesn't match"
)
pass
def
user_write_privilege_check
(
self
,
dbname
):
testconn
=
taos
.
connect
(
user
=
'test'
,
password
=
'test'
)
expectErrNotOccured
=
False
try
:
sql
=
f
"insert into
{
dbname
}
.stb_1 values(now, 1.1, 200, 0.3)"
testconn
.
execute
(
sql
)
except
BaseException
:
expectErrNotOccured
=
True
if
expectErrNotOccured
:
caller
=
inspect
.
getframeinfo
(
inspect
.
stack
()[
1
][
0
])
tdLog
.
exit
(
f
"
{
caller
.
filename
}
(
{
caller
.
lineno
}
) failed: sql:
{
sql
}
, expect error not occured"
)
else
:
pass
def
user_privilege_error_check
(
self
):
testconn
=
taos
.
connect
(
user
=
'test'
,
password
=
'test'
)
expectErrNotOccured
=
False
sql_list
=
[
"alter talbe db.stb_1 set t2 = 'Wuhan'"
,
"drop table db.stb_1"
]
sql_list
=
[
f
"alter talbe
{
self
.
dbnames
[
0
]
}
.stb_1 set t2 = 'Wuhan'"
,
f
"insert into
{
self
.
dbnames
[
0
]
}
.stb_1 values(now, 1.1, 200, 0.3)"
,
f
"drop table
{
self
.
dbnames
[
0
]
}
.stb_1"
,
f
"select count(*) from
{
self
.
dbnames
[
1
]
}
.stb"
]
for
sql
in
sql_list
:
try
:
...
...
@@ -104,11 +128,11 @@ class TDTestCase:
tdLog
.
exit
(
f
"
{
caller
.
filename
}
(
{
caller
.
lineno
}
) failed: sql:
{
sql
}
, expect error not occured"
)
pass
def
run
(
self
):
tdSql
.
prepare
()
def
run
(
self
):
self
.
prepare_data
()
self
.
create_user
()
self
.
user_privilege_check
()
self
.
user_read_privilege_check
(
self
.
dbnames
[
0
])
self
.
user_write_privilege_check
(
self
.
dbnames
[
1
])
self
.
user_privilege_error_check
()
def
stop
(
self
):
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录