Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
af495f20
X
Xts Acts
项目概览
OpenHarmony
/
Xts Acts
大约 1 年 前同步成功
通知
9
Star
22
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
X
Xts Acts
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
af495f20
编写于
5月 23, 2022
作者:
O
openharmony_ci
提交者:
Gitee
5月 23, 2022
浏览文件
操作
浏览文件
下载
差异文件
!3227 update securitylabel xts
Merge pull request !3227 from zhangxingxia/master
上级
a60b075e
cb625329
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
238 addition
and
81 deletion
+238
-81
storage/storagesecuritylabeljstest/src/main/js/default/test/securitylabel.test.js
...abeljstest/src/main/js/default/test/securitylabel.test.js
+238
-81
未找到文件。
storage/storagesecuritylabeljstest/src/main/js/default/test/securitylabel.test.js
浏览文件 @
af495f20
...
@@ -19,6 +19,115 @@ import {
...
@@ -19,6 +19,115 @@ import {
describe
(
'
securitylabel
'
,
function
()
{
describe
(
'
securitylabel
'
,
function
()
{
/**
* @tc.number SUB_DF_SECURITYLABEL_SET_SECURITY_LABEL_SYNC_0000
* @tc.name securitylabel_test_set_security_label_sync_000
* @tc.desc Test the setSecurityLabelSync() interface,and the getSecurityLabelSync() interface to get the data label.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it
(
'
securitylabel_test_set_security_label_sync_000
'
,
0
,
async
function
()
{
try
{
let
dataLevel
=
[
"
s0
"
,
"
s1
"
,
"
s2
"
,
"
s3
"
,
"
s4
"
];
for
(
let
i
=
0
;
i
<
dataLevel
.
length
;
i
++
){
let
fpath
=
await
nextFileName
(
"
test
"
+
dataLevel
[
i
]
+
'
.txt
'
);
fileio
.
openSync
(
fpath
,
0o102
,
0o666
);
securityLabel
.
setSecurityLabelSync
(
fpath
,
dataLevel
[
i
]);
let
level
=
securityLabel
.
getSecurityLabelSync
(
fpath
);
expect
(
level
==
dataLevel
[
i
]).
assertTrue
();
fileio
.
unlinkSync
(
fpath
);
}
}
catch
(
e
)
{
console
.
log
(
'
securitylabel_test_set_security_label_sync_000 has failed for
'
+
e
);
expect
(
null
).
assertFail
();
}
});
/**
* @tc.number SUB_DF_SECURITYLABEL_SET_SECURITY_LABEL_SYNC_0010
* @tc.name securitylabel_test_set_security_label_sync_001
* @tc.desc Test the setSecurityLabelSync() interface, When the dataLevel is wrong.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it
(
'
securitylabel_test_set_security_label_sync_001
'
,
0
,
async
function
()
{
let
fpath
=
await
nextFileName
(
"
test.txt
"
);
fileio
.
openSync
(
fpath
,
0o102
,
0o666
);
try
{
securityLabel
.
setSecurityLabelSync
(
fpath
,
"
abc
"
);
}
catch
(
err
)
{
console
.
log
(
'
securitylabel_test_set_security_label_sync_001 has failed for
'
+
err
);
expect
(
err
.
message
==
"
Invalid Argument of dataLevelEnum
"
).
assertTrue
();
fileio
.
unlinkSync
(
fpath
);
}
});
/**
* @tc.number SUB_DF_SECURITYLABEL_SET_SECURITY_LABEL_SYNC_0020
* @tc.name securitylabel_test_set_security_label_sync_002
* @tc.desc Test the setSecurityLabelSync() interface,When the path does not exist.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it
(
'
securitylabel_test_set_security_label_sync_002
'
,
0
,
async
function
()
{
try
{
let
result
=
securityLabel
.
setSecurityLabelSync
(
"
/data/aaa.txt
"
,
"
s0
"
);
expect
(
result
.
code
==
-
1
).
assertTrue
();
}
catch
(
e
)
{
console
.
log
(
'
securitylabel_test_set_security_label_sync_002 has failed for
'
+
err
);
}
});
/**
* @tc.number SUB_DF_SECURITYLABEL_SET_SECURITY_LABEL_SYNC_0030
* @tc.name securitylabel_test_set_security_label_sync_003
* @tc.desc Test the setSecurityLabelSync() interface,When the dataLevel type is wrong.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it
(
'
securitylabel_test_set_security_label_sync_003
'
,
0
,
async
function
()
{
let
fpath
=
await
nextFileName
(
"
test.txt
"
);
fileio
.
openSync
(
fpath
,
0o102
,
0o666
);
try
{
securityLabel
.
setSecurityLabelSync
(
fpath
,
1
);
}
catch
(
err
)
{
console
.
log
(
'
securitylabel_test_set_security_label_sync_003 has failed for
'
+
err
);
expect
(
err
.
message
==
"
Invalid dataLevel
"
).
assertTrue
();
fileio
.
unlinkSync
(
fpath
);
}
});
/**
* @tc.number SUB_DF_SECURITYLABEL_SET_SECURITY_LABEL_SYNC_0040
* @tc.name securitylabel_test_set_security_label_sync_004
* @tc.desc Test the setSecurityLabelSync() interface,When there is no datalevel parameter.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it
(
'
securitylabel_test_set_security_label_sync_004
'
,
0
,
async
function
()
{
let
fpath
=
await
nextFileName
(
"
test.txt
"
);
fileio
.
openSync
(
fpath
,
0o102
,
0o666
);
try
{
securityLabel
.
setSecurityLabelSync
(
fpath
);
}
catch
(
err
)
{
console
.
log
(
'
securitylabel_test_set_security_label_sync_004 has failed for
'
+
err
);
expect
(
err
.
message
==
"
Number of arguments unmatched
"
).
assertTrue
();
fileio
.
unlinkSync
(
fpath
);
}
});
/**
/**
* @tc.number SUB_DF_SECURITYLABEL_SET_SECURITY_LABEL_0000
* @tc.number SUB_DF_SECURITYLABEL_SET_SECURITY_LABEL_0000
* @tc.name securitylabel_test_set_security_label_async_000
* @tc.name securitylabel_test_set_security_label_async_000
...
@@ -36,7 +145,7 @@ describe('securitylabel', function () {
...
@@ -36,7 +145,7 @@ describe('securitylabel', function () {
securityLabel
.
setSecurityLabel
(
fpath
,
'
s0
'
,
function
(
err
)
{
securityLabel
.
setSecurityLabel
(
fpath
,
'
s0
'
,
function
(
err
)
{
securityLabel
.
getSecurityLabel
(
fpath
,
function
(
err
,
dataLevel
)
{
securityLabel
.
getSecurityLabel
(
fpath
,
function
(
err
,
dataLevel
)
{
expect
(
dataLevel
==
'
s0
'
).
assertTrue
();
expect
(
dataLevel
==
'
s0
'
).
assertTrue
();
expect
(
fileio
.
unlinkSync
(
fpath
)
==
null
).
assertTrue
(
);
fileio
.
unlinkSync
(
fpath
);
done
();
done
();
})
})
})
})
...
@@ -63,7 +172,7 @@ describe('securitylabel', function () {
...
@@ -63,7 +172,7 @@ describe('securitylabel', function () {
securityLabel
.
setSecurityLabel
(
fpath
,
'
s1
'
,
async
function
(
err
)
{
securityLabel
.
setSecurityLabel
(
fpath
,
'
s1
'
,
async
function
(
err
)
{
let
dataLevel
=
await
securityLabel
.
getSecurityLabel
(
fpath
);
let
dataLevel
=
await
securityLabel
.
getSecurityLabel
(
fpath
);
expect
(
dataLevel
==
'
s1
'
).
assertTrue
();
expect
(
dataLevel
==
'
s1
'
).
assertTrue
();
expect
(
fileio
.
unlinkSync
(
fpath
)
==
null
).
assertTrue
(
);
fileio
.
unlinkSync
(
fpath
);
done
();
done
();
})
})
}
catch
(
e
)
{
}
catch
(
e
)
{
...
@@ -89,7 +198,7 @@ describe('securitylabel', function () {
...
@@ -89,7 +198,7 @@ describe('securitylabel', function () {
await
securityLabel
.
setSecurityLabel
(
fpath
,
'
s2
'
);
await
securityLabel
.
setSecurityLabel
(
fpath
,
'
s2
'
);
securityLabel
.
getSecurityLabel
(
fpath
,
function
(
err
,
dataLevel
)
{
securityLabel
.
getSecurityLabel
(
fpath
,
function
(
err
,
dataLevel
)
{
expect
(
dataLevel
==
'
s2
'
).
assertTrue
();
expect
(
dataLevel
==
'
s2
'
).
assertTrue
();
expect
(
fileio
.
unlinkSync
(
fpath
)
==
null
).
assertTrue
(
);
fileio
.
unlinkSync
(
fpath
);
done
();
done
();
})
})
}
catch
(
e
)
{
}
catch
(
e
)
{
...
@@ -115,7 +224,7 @@ describe('securitylabel', function () {
...
@@ -115,7 +224,7 @@ describe('securitylabel', function () {
await
securityLabel
.
setSecurityLabel
(
fpath
,
'
s3
'
);
await
securityLabel
.
setSecurityLabel
(
fpath
,
'
s3
'
);
let
dataLevel
=
await
securityLabel
.
getSecurityLabel
(
fpath
);
let
dataLevel
=
await
securityLabel
.
getSecurityLabel
(
fpath
);
expect
(
dataLevel
==
'
s3
'
).
assertTrue
();
expect
(
dataLevel
==
'
s3
'
).
assertTrue
();
expect
(
fileio
.
unlinkSync
(
fpath
)
==
null
).
assertTrue
(
);
fileio
.
unlinkSync
(
fpath
);
done
();
done
();
}
catch
(
e
)
{
}
catch
(
e
)
{
console
.
log
(
'
securitylabel_test_set_security_label_async_003 has failed for
'
+
e
);
console
.
log
(
'
securitylabel_test_set_security_label_async_003 has failed for
'
+
e
);
...
@@ -140,7 +249,7 @@ describe('securitylabel', function () {
...
@@ -140,7 +249,7 @@ describe('securitylabel', function () {
await
securityLabel
.
setSecurityLabel
(
fpath
,
'
s4
'
);
await
securityLabel
.
setSecurityLabel
(
fpath
,
'
s4
'
);
let
dataLevel
=
await
securityLabel
.
getSecurityLabel
(
fpath
);
let
dataLevel
=
await
securityLabel
.
getSecurityLabel
(
fpath
);
expect
(
dataLevel
==
'
s4
'
).
assertTrue
();
expect
(
dataLevel
==
'
s4
'
).
assertTrue
();
expect
(
fileio
.
unlinkSync
(
fpath
)
==
null
).
assertTrue
(
);
fileio
.
unlinkSync
(
fpath
);
done
();
done
();
}
catch
(
e
)
{
}
catch
(
e
)
{
console
.
log
(
'
securitylabel_test_set_security_label_async_004 has failed for
'
+
e
);
console
.
log
(
'
securitylabel_test_set_security_label_async_004 has failed for
'
+
e
);
...
@@ -151,7 +260,7 @@ describe('securitylabel', function () {
...
@@ -151,7 +260,7 @@ describe('securitylabel', function () {
/**
/**
* @tc.number SUB_DF_SECURITYLABEL_SET_SECURITY_LABEL_0050
* @tc.number SUB_DF_SECURITYLABEL_SET_SECURITY_LABEL_0050
* @tc.name securitylabel_test_set_security_label_async_005
* @tc.name securitylabel_test_set_security_label_async_005
* @tc.desc Test setSecurityLabel() interfaces
. return false when path is empty stri
ng.
* @tc.desc Test setSecurityLabel() interfaces
,When the path type is wro
ng.
* @tc.size MEDIUM
* @tc.size MEDIUM
* @tc.type Function
* @tc.type Function
* @tc.level Level 0
* @tc.level Level 0
...
@@ -159,13 +268,10 @@ describe('securitylabel', function () {
...
@@ -159,13 +268,10 @@ describe('securitylabel', function () {
*/
*/
it
(
'
securitylabel_test_set_security_label_async_005
'
,
0
,
async
function
(
done
)
{
it
(
'
securitylabel_test_set_security_label_async_005
'
,
0
,
async
function
(
done
)
{
try
{
try
{
securityLabel
.
setSecurityLabel
(
''
,
'
s0
'
,
function
(
err
)
{
await
securityLabel
.
setSecurityLabel
(
123
,
'
s0
'
);
expect
(
err
.
code
==
'
-1
'
).
assertTrue
();
}
catch
(
err
)
{
done
();
console
.
log
(
'
securitylabel_test_set_security_label_async_005 has failed for
'
+
err
);
});
expect
(
err
.
message
==
"
Invalid path
"
).
assertTrue
();
}
catch
(
e
)
{
console
.
log
(
'
securitylabel_test_set_security_label_async_005 has failed for
'
+
e
);
expect
(
null
).
assertFail
();
done
();
done
();
}
}
});
});
...
@@ -173,7 +279,7 @@ describe('securitylabel', function () {
...
@@ -173,7 +279,7 @@ describe('securitylabel', function () {
/**
/**
* @tc.number SUB_DF_SECURITYLABEL_SET_SECURITY_LABEL_0060
* @tc.number SUB_DF_SECURITYLABEL_SET_SECURITY_LABEL_0060
* @tc.name securitylabel_test_set_security_label_async_006
* @tc.name securitylabel_test_set_security_label_async_006
* @tc.desc Test setSecurityLabel() interfaces
.
return false when the path is invalid.
* @tc.desc Test setSecurityLabel() interfaces
,
return false when the path is invalid.
* @tc.size MEDIUM
* @tc.size MEDIUM
* @tc.type Function
* @tc.type Function
* @tc.level Level 0
* @tc.level Level 0
...
@@ -181,13 +287,10 @@ describe('securitylabel', function () {
...
@@ -181,13 +287,10 @@ describe('securitylabel', function () {
*/
*/
it
(
'
securitylabel_test_set_security_label_async_006
'
,
0
,
async
function
(
done
)
{
it
(
'
securitylabel_test_set_security_label_async_006
'
,
0
,
async
function
(
done
)
{
try
{
try
{
securityLabel
.
setSecurityLabel
(
'
/data/test.txt
'
,
'
s0
'
,
function
(
err
)
{
await
securityLabel
.
setSecurityLabel
(
'
/data/test.txt
'
,
'
s0
'
);
expect
(
err
.
code
==
'
-1
'
).
assertTrue
();
}
catch
(
err
)
{
done
();
console
.
log
(
'
securitylabel_test_set_security_label_async_006 has failed for
'
+
err
);
});
expect
(
err
.
code
==
-
1
).
assertTrue
();
}
catch
(
e
)
{
console
.
log
(
'
securitylabel_test_set_security_label_async_006 has failed for
'
+
e
);
expect
(
null
).
assertFail
();
done
();
done
();
}
}
});
});
...
@@ -195,7 +298,7 @@ describe('securitylabel', function () {
...
@@ -195,7 +298,7 @@ describe('securitylabel', function () {
/**
/**
* @tc.number SUB_DF_SECURITYLABEL_SET_SECURITY_LABEL_0070
* @tc.number SUB_DF_SECURITYLABEL_SET_SECURITY_LABEL_0070
* @tc.name securitylabel_test_set_security_label_async_007
* @tc.name securitylabel_test_set_security_label_async_007
* @tc.desc Test setSecurityLabel() interfaces
.
Throw exception when path is empty.
* @tc.desc Test setSecurityLabel() interfaces
,
Throw exception when path is empty.
* @tc.size MEDIUM
* @tc.size MEDIUM
* @tc.type Function
* @tc.type Function
* @tc.level Level 0
* @tc.level Level 0
...
@@ -204,11 +307,9 @@ describe('securitylabel', function () {
...
@@ -204,11 +307,9 @@ describe('securitylabel', function () {
it
(
'
securitylabel_test_set_security_label_async_007
'
,
0
,
async
function
(
done
)
{
it
(
'
securitylabel_test_set_security_label_async_007
'
,
0
,
async
function
(
done
)
{
try
{
try
{
await
securityLabel
.
setSecurityLabel
(
'
s0
'
);
await
securityLabel
.
setSecurityLabel
(
'
s0
'
);
expect
(
null
).
assertFail
();
}
catch
(
err
)
{
done
();
console
.
log
(
'
securitylabel_test_set_security_label_async_007 has failed for
'
+
err
);
}
catch
(
e
)
{
expect
(
err
.
message
==
"
Number of arguments unmatched
"
).
assertTrue
();
console
.
log
(
'
securitylabel_test_set_security_label_async_007 has failed for
'
+
e
);
expect
(
!!
e
).
assertTrue
();
done
();
done
();
}
}
});
});
...
@@ -216,7 +317,7 @@ describe('securitylabel', function () {
...
@@ -216,7 +317,7 @@ describe('securitylabel', function () {
/**
/**
* @tc.number SUB_DF_SECURITYLABEL_SET_SECURITY_LABEL_0080
* @tc.number SUB_DF_SECURITYLABEL_SET_SECURITY_LABEL_0080
* @tc.name securitylabel_test_set_security_label_async_008
* @tc.name securitylabel_test_set_security_label_async_008
* @tc.desc Test setSecurityLabel() interfaces
. return false when dataLevel is empty stri
ng.
* @tc.desc Test setSecurityLabel() interfaces
,When the dataLevel type is wro
ng.
* @tc.size MEDIUM
* @tc.size MEDIUM
* @tc.type Function
* @tc.type Function
* @tc.level Level 0
* @tc.level Level 0
...
@@ -227,16 +328,10 @@ describe('securitylabel', function () {
...
@@ -227,16 +328,10 @@ describe('securitylabel', function () {
fileio
.
openSync
(
fpath
,
0o102
,
0o666
);
fileio
.
openSync
(
fpath
,
0o102
,
0o666
);
try
{
try
{
securityLabel
.
setSecurityLabel
(
fpath
,
''
,
async
function
(
err
)
{
await
securityLabel
.
setSecurityLabel
(
fpath
,
1
)
expect
(
err
.
code
==
'
-1
'
).
assertTrue
();
}
catch
(
err
)
{
let
dataLevel
=
await
securityLabel
.
getSecurityLabel
(
fpath
);
console
.
log
(
'
securitylabel_test_set_security_label_async_008 has failed for
'
+
err
);
expect
(
dataLevel
==
''
).
assertTrue
();
expect
(
err
.
message
==
"
Invalid dataLevel
"
).
assertTrue
();
expect
(
fileio
.
unlinkSync
(
fpath
)
==
null
).
assertTrue
();
done
();
});
}
catch
(
e
)
{
console
.
log
(
'
securitylabel_test_set_security_label_async_008 has failed for
'
+
e
);
expect
(
null
).
assertFail
();
done
();
done
();
}
}
});
});
...
@@ -244,7 +339,7 @@ describe('securitylabel', function () {
...
@@ -244,7 +339,7 @@ describe('securitylabel', function () {
/**
/**
* @tc.number SUB_DF_SECURITYLABEL_SET_SECURITY_LABEL_0090
* @tc.number SUB_DF_SECURITYLABEL_SET_SECURITY_LABEL_0090
* @tc.name securitylabel_test_set_security_label_async_009
* @tc.name securitylabel_test_set_security_label_async_009
* @tc.desc Test setSecurityLabel() interfaces
.
return false when the dataLevel is invalid.
* @tc.desc Test setSecurityLabel() interfaces
,
return false when the dataLevel is invalid.
* @tc.size MEDIUM
* @tc.size MEDIUM
* @tc.type Function
* @tc.type Function
* @tc.level Level 0
* @tc.level Level 0
...
@@ -255,16 +350,10 @@ describe('securitylabel', function () {
...
@@ -255,16 +350,10 @@ describe('securitylabel', function () {
fileio
.
openSync
(
fpath
,
0o102
,
0o666
);
fileio
.
openSync
(
fpath
,
0o102
,
0o666
);
try
{
try
{
securityLabel
.
setSecurityLabel
(
fpath
,
'
ss
'
,
async
function
(
err
)
{
await
securityLabel
.
setSecurityLabel
(
fpath
,
'
ss
'
);
expect
(
err
.
code
==
'
-1
'
).
assertTrue
();
}
catch
(
err
)
{
let
dataLevel
=
await
securityLabel
.
getSecurityLabel
(
fpath
);
console
.
log
(
'
securitylabel_test_set_security_label_async_009 has failed for
'
+
err
);
expect
(
dataLevel
==
''
).
assertTrue
();
expect
(
err
.
message
==
"
Invalid Argument of dataLevelEnum
"
).
assertTrue
();
expect
(
fileio
.
unlinkSync
(
fpath
)
==
null
).
assertTrue
();
done
();
});
}
catch
(
e
)
{
console
.
log
(
'
securitylabel_test_set_security_label_async_009 has failed for
'
+
e
);
expect
(
null
).
assertFail
();
done
();
done
();
}
}
});
});
...
@@ -272,7 +361,7 @@ describe('securitylabel', function () {
...
@@ -272,7 +361,7 @@ describe('securitylabel', function () {
/**
/**
* @tc.number SUB_DF_SECURITYLABEL_SET_SECURITY_LABEL_0100
* @tc.number SUB_DF_SECURITYLABEL_SET_SECURITY_LABEL_0100
* @tc.name securitylabel_test_set_security_label_async_010
* @tc.name securitylabel_test_set_security_label_async_010
* @tc.desc Test setSecurityLabel() interfaces
.
Throw exception when dataLevel is empty.
* @tc.desc Test setSecurityLabel() interfaces
,
Throw exception when dataLevel is empty.
* @tc.size MEDIUM
* @tc.size MEDIUM
* @tc.type Function
* @tc.type Function
* @tc.level Level 0
* @tc.level Level 0
...
@@ -284,12 +373,10 @@ describe('securitylabel', function () {
...
@@ -284,12 +373,10 @@ describe('securitylabel', function () {
try
{
try
{
await
securityLabel
.
setSecurityLabel
(
fpath
);
await
securityLabel
.
setSecurityLabel
(
fpath
);
expect
(
null
).
assertFail
();
}
catch
(
err
)
{
done
();
console
.
log
(
'
securitylabel_test_set_security_label_async_010 has failed for
'
+
err
);
}
catch
(
e
)
{
fileio
.
unlinkSync
(
fpath
);
console
.
log
(
'
securitylabel_test_set_security_label_async_010 has failed for
'
+
e
);
expect
(
err
.
message
==
"
Number of arguments unmatched
"
).
assertTrue
();
expect
(
fileio
.
unlinkSync
(
fpath
)
==
null
).
assertTrue
();
expect
(
!!
e
).
assertTrue
();
done
();
done
();
}
}
});
});
...
@@ -297,7 +384,7 @@ describe('securitylabel', function () {
...
@@ -297,7 +384,7 @@ describe('securitylabel', function () {
/**
/**
* @tc.number SUB_DF_SECURITYLABEL_SET_SECURITY_LABEL_0110
* @tc.number SUB_DF_SECURITYLABEL_SET_SECURITY_LABEL_0110
* @tc.name securitylabel_test_set_security_label_async_011
* @tc.name securitylabel_test_set_security_label_async_011
* @tc.desc Test setSecurityLabel() interfaces
.
Throws an exception when passing multiple parameters.
* @tc.desc Test setSecurityLabel() interfaces
,
Throws an exception when passing multiple parameters.
* @tc.size MEDIUM
* @tc.size MEDIUM
* @tc.type Function
* @tc.type Function
* @tc.level Level 0
* @tc.level Level 0
...
@@ -311,31 +398,103 @@ describe('securitylabel', function () {
...
@@ -311,31 +398,103 @@ describe('securitylabel', function () {
securityLabel
.
setSecurityLabel
(
fpath
,
'
s0
'
,
''
,
function
(
err
)
{
securityLabel
.
setSecurityLabel
(
fpath
,
'
s0
'
,
''
,
function
(
err
)
{
done
();
done
();
})
})
}
catch
(
e
)
{
}
catch
(
e
rr
)
{
console
.
log
(
'
securitylabel_test_set_security_label_async_011 has failed for
'
+
e
);
console
.
log
(
'
securitylabel_test_set_security_label_async_011 has failed for
'
+
e
rr
);
expect
(
fileio
.
unlinkSync
(
fpath
)
==
null
).
assertTrue
(
);
fileio
.
unlinkSync
(
fpath
);
expect
(
!!
e
).
assertTrue
();
expect
(
err
.
message
==
"
Number of arguments unmatched
"
).
assertTrue
();
done
();
done
();
}
}
});
});
/**
/**
* @tc.number SUB_DF_SECURITYLABEL_GET_SECURITY_LABEL_0000
* @tc.number SUB_DF_SECURITYLABEL_GET_SECURITY_LABEL_
SYNC_
0000
* @tc.name securitylabel_test_get_security_label_
a
sync_000
* @tc.name securitylabel_test_get_security_label_sync_000
* @tc.desc Test getSecurityLabel
() interfaces.
return empty when path is empty string.
* @tc.desc Test getSecurityLabel
Sync() interfaces,
return empty when path is empty string.
* @tc.size MEDIUM
* @tc.size MEDIUM
* @tc.type Function
* @tc.type Function
* @tc.level Level 0
* @tc.level Level 0
* @tc.require
* @tc.require
*/
*/
it
(
'
securitylabel_test_get_security_label_async_000
'
,
0
,
async
function
(
done
)
{
it
(
'
securitylabel_test_get_security_label_sync_000
'
,
0
,
function
(
)
{
try
{
try
{
let
dataLevel
=
await
securityLabel
.
getSecurityLabel
(
''
);
let
dataLevel
=
securityLabel
.
getSecurityLabelSync
(
''
);
expect
(
dataLevel
==
''
).
assertTrue
();
expect
(
dataLevel
==
''
).
assertTrue
();
done
();
}
catch
(
e
)
{
}
catch
(
e
)
{
console
.
log
(
'
securitylabel_test_get_security_label_
a
sync_000 has failed for
'
+
e
);
console
.
log
(
'
securitylabel_test_get_security_label_sync_000 has failed for
'
+
e
);
expect
(
null
).
assertFail
();
expect
(
null
).
assertFail
();
}
});
/**
* @tc.number SUB_DF_SECURITYLABEL_GET_SECURITY_LABEL_SYNC_0010
* @tc.name securitylabel_test_get_security_label_sync_001
* @tc.desc Test getSecurityLabelSync() interfaces,return empty when the path is invalid.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it
(
'
securitylabel_test_get_security_label_sync_001
'
,
0
,
function
()
{
try
{
let
dataLevel
=
securityLabel
.
getSecurityLabelSync
(
'
/data/test.txt
'
);
expect
(
dataLevel
==
''
).
assertTrue
();
}
catch
(
e
)
{
console
.
log
(
'
securitylabel_test_get_security_label_sync_001 has failed for
'
+
e
);
expect
(
null
).
assertFail
();
}
});
/**
* @tc.number SUB_DF_SECURITYLABEL_GET_SECURITY_LABEL_SYNC_0020
* @tc.name securitylabel_test_get_security_label_sync_002
* @tc.desc Test getSecurityLabelSync() interfaces,When there are no parameters.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it
(
'
securitylabel_test_get_security_label_sync_002
'
,
0
,
function
()
{
try
{
securityLabel
.
getSecurityLabelSync
();
}
catch
(
err
)
{
console
.
log
(
'
securitylabel_test_get_security_label_sync_002 has failed for
'
+
err
);
expect
(
err
.
message
==
"
Number of arguments unmatched
"
).
assertTrue
();
}
});
/**
* @tc.number SUB_DF_SECURITYLABEL_GET_SECURITY_LABEL_SYNC_0030
* @tc.name securitylabel_test_get_security_label_sync_003
* @tc.desc Test getSecurityLabelSync() interfaces,When the path type is wrong.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it
(
'
securitylabel_test_get_security_label_sync_003
'
,
0
,
function
()
{
try
{
securityLabel
.
getSecurityLabelSync
(
123
);
}
catch
(
err
)
{
console
.
log
(
'
securitylabel_test_get_security_label_sync_003 has failed for
'
+
err
);
expect
(
err
.
message
==
"
Invalid path
"
).
assertTrue
();
}
});
/**
* @tc.number SUB_DF_SECURITYLABEL_GET_SECURITY_LABEL_0000
* @tc.name securitylabel_test_get_security_label_async_000
* @tc.desc Test getSecurityLabel() interfaces,When the path type is wrong.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it
(
'
securitylabel_test_get_security_label_async_000
'
,
0
,
async
function
(
done
)
{
try
{
await
securityLabel
.
getSecurityLabel
(
123
);
}
catch
(
err
)
{
console
.
log
(
'
securitylabel_test_get_security_label_async_000 has failed for
'
+
err
);
expect
(
err
.
message
==
"
Invalid path
"
).
assertTrue
();
done
();
done
();
}
}
});
});
...
@@ -343,7 +502,7 @@ describe('securitylabel', function () {
...
@@ -343,7 +502,7 @@ describe('securitylabel', function () {
/**
/**
* @tc.number SUB_DF_SECURITYLABEL_GET_SECURITY_LABEL_0010
* @tc.number SUB_DF_SECURITYLABEL_GET_SECURITY_LABEL_0010
* @tc.name securitylabel_test_get_security_label_async_001
* @tc.name securitylabel_test_get_security_label_async_001
* @tc.desc Test getSecurityLabel() interfaces
.
return empty when the path is invalid.
* @tc.desc Test getSecurityLabel() interfaces
,
return empty when the path is invalid.
* @tc.size MEDIUM
* @tc.size MEDIUM
* @tc.type Function
* @tc.type Function
* @tc.level Level 0
* @tc.level Level 0
...
@@ -360,11 +519,12 @@ describe('securitylabel', function () {
...
@@ -360,11 +519,12 @@ describe('securitylabel', function () {
done
();
done
();
}
}
});
});
/**
/**
* @tc.number SUB_DF_SECURITYLABEL_GET_SECURITY_LABEL_0020
* @tc.number SUB_DF_SECURITYLABEL_GET_SECURITY_LABEL_0020
* @tc.name securitylabel_test_get_security_label_async_002
* @tc.name securitylabel_test_get_security_label_async_002
* @tc.desc Test getSecurityLabel() interfaces
.
Throw exception when path is empty.
* @tc.desc Test getSecurityLabel() interfaces
,
Throw exception when path is empty.
* @tc.size MEDIUM
* @tc.size MEDIUM
* @tc.type Function
* @tc.type Function
* @tc.level Level 0
* @tc.level Level 0
...
@@ -373,11 +533,9 @@ describe('securitylabel', function () {
...
@@ -373,11 +533,9 @@ describe('securitylabel', function () {
it
(
'
securitylabel_test_get_security_label_async_002
'
,
0
,
async
function
(
done
)
{
it
(
'
securitylabel_test_get_security_label_async_002
'
,
0
,
async
function
(
done
)
{
try
{
try
{
await
securityLabel
.
getSecurityLabel
();
await
securityLabel
.
getSecurityLabel
();
expect
(
null
).
assertFail
();
}
catch
(
err
)
{
done
();
console
.
log
(
'
securitylabel_test_get_security_label_async_002 has failed for
'
+
err
);
}
catch
(
e
)
{
expect
(
err
.
message
==
"
Number of arguments unmatched
"
).
assertTrue
();
console
.
log
(
'
securitylabel_test_get_security_label_async_002 has failed for
'
+
e
);
expect
(
!!
e
).
assertTrue
();
done
();
done
();
}
}
});
});
...
@@ -385,7 +543,7 @@ describe('securitylabel', function () {
...
@@ -385,7 +543,7 @@ describe('securitylabel', function () {
/**
/**
* @tc.number SUB_DF_SECURITYLABEL_GET_SECURITY_LABEL_0030
* @tc.number SUB_DF_SECURITYLABEL_GET_SECURITY_LABEL_0030
* @tc.name securitylabel_test_get_security_label_async_003
* @tc.name securitylabel_test_get_security_label_async_003
* @tc.desc Test getSecurityLabel() interfaces
.
Throws an exception when passing multiple parameters.
* @tc.desc Test getSecurityLabel() interfaces
,
Throws an exception when passing multiple parameters.
* @tc.size MEDIUM
* @tc.size MEDIUM
* @tc.type Function
* @tc.type Function
* @tc.level Level 0
* @tc.level Level 0
...
@@ -394,15 +552,14 @@ describe('securitylabel', function () {
...
@@ -394,15 +552,14 @@ describe('securitylabel', function () {
it
(
'
securitylabel_test_get_security_label_async_003
'
,
0
,
async
function
(
done
)
{
it
(
'
securitylabel_test_get_security_label_async_003
'
,
0
,
async
function
(
done
)
{
let
fpath
=
await
nextFileName
(
'
test9.txt
'
);
let
fpath
=
await
nextFileName
(
'
test9.txt
'
);
fileio
.
openSync
(
fpath
,
0o102
,
0o666
);
fileio
.
openSync
(
fpath
,
0o102
,
0o666
);
try
{
try
{
securityLabel
.
getSecurityLabel
(
fpath
,
''
,
function
(
err
,
dataLevel
)
{
securityLabel
.
getSecurityLabel
(
fpath
,
''
,
function
(
err
,
dataLevel
)
{
done
();
done
();
});
});
}
catch
(
e
)
{
}
catch
(
e
rr
)
{
console
.
log
(
'
securitylabel_test_get_security_label_async_003 has failed for
'
+
e
);
console
.
log
(
'
securitylabel_test_get_security_label_async_003 has failed for
'
+
e
rr
);
expect
(
fileio
.
unlinkSync
(
fpath
)
==
null
).
assertTrue
(
);
fileio
.
unlinkSync
(
fpath
);
expect
(
!!
e
).
assertTrue
();
expect
(
err
.
message
==
"
Number of arguments unmatched
"
).
assertTrue
();
done
();
done
();
}
}
});
});
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录