Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
c88516e0
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看板
未验证
提交
c88516e0
编写于
5月 06, 2023
作者:
H
Hui Li
提交者:
GitHub
5月 06, 2023
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #21042 from taosdata/test/TS-3105
[TS-3140]: add test case for user privilege
上级
db0ad956
6b35a4ae
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
121 addition
and
0 deletion
+121
-0
tests/parallel_test/cases.task
tests/parallel_test/cases.task
+1
-0
tests/system-test/0-others/user_privilege.py
tests/system-test/0-others/user_privilege.py
+120
-0
未找到文件。
tests/parallel_test/cases.task
浏览文件 @
c88516e0
...
...
@@ -136,6 +136,7 @@
,,y,system-test,./pytest.sh python3 ./test.py -f 0-others/sysinfo.py
,,y,system-test,./pytest.sh python3 ./test.py -f 0-others/user_control.py
,,y,system-test,./pytest.sh python3 ./test.py -f 0-others/user_manage.py
,,y,system-test,./pytest.sh python3 ./test.py -f 0-others/user_privilege.py
,,y,system-test,./pytest.sh python3 ./test.py -f 0-others/fsync.py
,,y,system-test,./pytest.sh python3 ./test.py -f 0-others/multilevel.py
,,n,system-test,python3 ./test.py -f 0-others/compatibility.py
...
...
tests/system-test/0-others/user_privilege.py
0 → 100644
浏览文件 @
c88516e0
###################################################################
# Copyright (c) 2016 by TAOS Technologies, Inc.
# All rights reserved.
#
# This file is proprietary and confidential to TAOS Technologies.
# No part of this file may be reproduced, stored, transmitted,
# disclosed or used in any form or by any means other than as
# expressly provided by the written permission from Jianhui Tao
#
###################################################################
# -*- coding: utf-8 -*-
import
taos
from
taos.tmq
import
*
from
util.cases
import
*
from
util.common
import
*
from
util.log
import
*
from
util.sql
import
*
from
util.sqlset
import
*
class
TDTestCase
:
def
init
(
self
,
conn
,
logSql
,
replicaVar
=
1
):
self
.
replicaVar
=
int
(
replicaVar
)
tdLog
.
debug
(
"start to execute %s"
%
__file__
)
tdSql
.
init
(
conn
.
cursor
())
self
.
setsql
=
TDSetSql
()
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
.
column_dict
=
{
'ts'
:
'timestamp'
,
'col1'
:
'float'
,
'col2'
:
'int'
,
'col3'
:
'float'
,
}
self
.
tag_dict
=
{
't1'
:
'int'
,
't2'
:
f
'binary(
{
self
.
binary_length
}
)'
}
self
.
tag_list
=
[
f
'1, "Beijing"'
,
f
'2, "Shanghai"'
,
f
'3, "Guangzhou"'
,
f
'4, "Shenzhen"'
]
self
.
values_list
=
[
f
'now, 9.1, 200, 0.3'
]
self
.
tbnum
=
4
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
}
'
)
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
}
)'
)
def
user_privilege_check
(
self
):
testconn
=
taos
.
connect
(
user
=
'test'
,
password
=
'test'
)
expectErrNotOccured
=
False
try
:
sql
=
"select count(*) from db.stb where t2 = 'Beijing'"
res
=
testconn
.
query
(
sql
)
data
=
res
.
fetch_all
()
count
=
data
[
0
][
0
]
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"
)
elif
count
!=
1
:
tdLog
.
exit
(
f
"
{
sql
}
, expect result doesn't match"
)
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"
]
for
sql
in
sql_list
:
try
:
res
=
testconn
.
execute
(
sql
)
except
BaseException
:
expectErrNotOccured
=
True
if
expectErrNotOccured
:
pass
else
:
caller
=
inspect
.
getframeinfo
(
inspect
.
stack
()[
1
][
0
])
tdLog
.
exit
(
f
"
{
caller
.
filename
}
(
{
caller
.
lineno
}
) failed: sql:
{
sql
}
, expect error not occured"
)
pass
def
run
(
self
):
tdSql
.
prepare
()
self
.
prepare_data
()
self
.
create_user
()
self
.
user_privilege_check
()
self
.
user_privilege_error_check
()
def
stop
(
self
):
tdSql
.
close
()
tdLog
.
success
(
"%s successfully executed"
%
__file__
)
tdCases
.
addWindows
(
__file__
,
TDTestCase
())
tdCases
.
addLinux
(
__file__
,
TDTestCase
())
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录