Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
8b4ea1d4
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看板
提交
8b4ea1d4
编写于
6月 28, 2022
作者:
J
jinhaihw
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
【security】【master】修改access_token用例localled获取方式
Signed-off-by:
N
jinhaihw
<
jinhai2@huawei.com
>
上级
ea531873
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
16 addition
and
13 deletion
+16
-13
security/access_token/AccessTokenTest_Normal_js/src/main/js/default/test/AccessToken.test.js
...st_Normal_js/src/main/js/default/test/AccessToken.test.js
+16
-13
未找到文件。
security/access_token/AccessTokenTest_Normal_js/src/main/js/default/test/AccessToken.test.js
浏览文件 @
8b4ea1d4
...
...
@@ -17,6 +17,7 @@
import
{
describe
,
beforeEach
,
afterEach
,
it
,
expect
}
from
'
deccjsunit/index
'
import
abilityAccessCtrl
from
'
@ohos.abilityAccessCtrl
'
import
bundle
from
'
@ohos.bundle
'
import
osAccount
from
'
@ohos.account.osAccount
'
var
PermissionFlag
=
{
PERMISSION_USER_SET
:
1
,
...
...
@@ -37,11 +38,13 @@ var permissionNameUser = "ohos.permission.ALPHA";
var
permissionNameSystem
=
"
ohos.permission.BETA
"
;
var
tokenID
=
undefined
describe
(
'
AccessTokenTest
'
,
function
()
{
console
.
log
(
'
##########start AccessTokenTest
'
);
console
.
info
(
'
##########start AccessTokenTest
'
);
beforeAll
(
async
function
(
done
){
var
appInfo
=
await
bundle
.
getApplicationInfo
(
'
ohos.acts.security.access_token.normal
'
,
0
,
100
);
var
accountManager
=
osAccount
.
getAccountManager
();
var
localled
=
await
accountManager
.
getOsAccountTypeFromProcess
();
var
appInfo
=
await
bundle
.
getApplicationInfo
(
'
ohos.acts.security.access_token.normal
'
,
0
,
localled
);
tokenID
=
appInfo
.
accessTokenId
;
console
.
log
(
"
AccessTokenTest accessTokenId:
"
+
appInfo
.
accessTokenId
+
"
, name:
"
+
appInfo
.
name
console
.
info
(
"
AccessTokenTest accessTokenId:
"
+
appInfo
.
accessTokenId
+
"
, name:
"
+
appInfo
.
name
+
"
, bundleName:
"
+
appInfo
.
bundleName
)
// setTimeout(done(),TIMEOUT);
...
...
@@ -67,10 +70,10 @@ describe('AccessTokenTest', function () {
* @tc.desc After the installation, user_grant permission is not granted by default(Promise).
*/
it
(
'
Test_verifyAccessToken_001
'
,
0
,
async
function
(
done
){
console
.
log
(
"
Test_verifyAccessToken_001 start
"
);
console
.
info
(
"
Test_verifyAccessToken_001 start
"
);
var
atManager
=
abilityAccessCtrl
.
createAtManager
();
var
result
=
await
atManager
.
verifyAccessToken
(
tokenID
,
permissionNameUser
);
console
.
log
(
"
Test_verifyAccessToken_001 tokenID
"
+
tokenID
+
"
-
"
+
result
)
console
.
info
(
"
Test_verifyAccessToken_001 tokenID
"
+
tokenID
+
"
-
"
+
result
)
expect
(
result
).
assertEqual
(
GrantStatus
.
PERMISSION_DENIED
);
done
();
...
...
@@ -82,10 +85,10 @@ describe('AccessTokenTest', function () {
* @tc.desc After the installation, system_grant permission is not granted by default(Promise).
*/
it
(
'
Test_verifyAccessToken_002
'
,
0
,
async
function
(
done
){
console
.
log
(
"
Test_verifyAccessToken_002 start
"
);
console
.
info
(
"
Test_verifyAccessToken_002 start
"
);
var
atManager
=
abilityAccessCtrl
.
createAtManager
();
var
result
=
await
atManager
.
verifyAccessToken
(
tokenID
,
permissionNameSystem
);
console
.
log
(
"
Test_verifyAccessToken_002 tokenID
"
+
tokenID
+
"
-
"
+
result
)
console
.
info
(
"
Test_verifyAccessToken_002 tokenID
"
+
tokenID
+
"
-
"
+
result
)
expect
(
result
).
assertEqual
(
GrantStatus
.
PERMISSION_GRANTED
);
done
();
...
...
@@ -97,10 +100,10 @@ describe('AccessTokenTest', function () {
* @tc.desc Test invalid TokenID(0)(Promise).
*/
it
(
'
Test_verifyAccessToken_003
'
,
0
,
async
function
(
done
){
console
.
log
(
"
Test_verifyAccessToken_003 start
"
);
console
.
info
(
"
Test_verifyAccessToken_003 start
"
);
var
atManager
=
abilityAccessCtrl
.
createAtManager
();
var
result
=
await
atManager
.
verifyAccessToken
(
0
,
permissionNameUser
);
console
.
log
(
"
Test_verifyAccessToken_003 tokenID
"
+
tokenID
+
"
-
"
+
result
)
console
.
info
(
"
Test_verifyAccessToken_003 tokenID
"
+
tokenID
+
"
-
"
+
result
)
expect
(
result
).
assertEqual
(
GrantStatus
.
PERMISSION_DENIED
);
done
();
...
...
@@ -112,10 +115,10 @@ describe('AccessTokenTest', function () {
* @tc.desc Test invalid permission(empty)(Promise).
*/
it
(
'
Test_verifyAccessToken_004
'
,
0
,
async
function
(
done
){
console
.
log
(
"
Test_verifyAccessToken_004 start
"
);
console
.
info
(
"
Test_verifyAccessToken_004 start
"
);
var
atManager
=
abilityAccessCtrl
.
createAtManager
();
var
result
=
await
atManager
.
verifyAccessToken
(
tokenID
,
""
);
console
.
log
(
"
Test_verifyAccessToken_004 tokenID
"
+
tokenID
+
"
-
"
+
result
)
console
.
info
(
"
Test_verifyAccessToken_004 tokenID
"
+
tokenID
+
"
-
"
+
result
)
expect
(
result
).
assertEqual
(
GrantStatus
.
PERMISSION_DENIED
);
done
();
...
...
@@ -127,14 +130,14 @@ describe('AccessTokenTest', function () {
* @tc.desc Test invalid permission(length exceeds 256)(Promise).
*/
it
(
'
Test_verifyAccessToken_005
'
,
0
,
async
function
(
done
){
console
.
log
(
"
Test_verifyAccessToken_005 start
"
);
console
.
info
(
"
Test_verifyAccessToken_005 start
"
);
var
atManager
=
abilityAccessCtrl
.
createAtManager
();
var
permissionName
=
"
ohos.permission.testtesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttest
"
+
"
testtesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttest
"
+
"
testtesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttest
"
;
var
result
=
await
atManager
.
verifyAccessToken
(
tokenID
,
permissionName
);
console
.
log
(
"
Test_verifyAccessToken_005 tokenID
"
+
tokenID
+
"
-
"
+
result
)
console
.
info
(
"
Test_verifyAccessToken_005 tokenID
"
+
tokenID
+
"
-
"
+
result
)
expect
(
result
).
assertEqual
(
GrantStatus
.
PERMISSION_DENIED
);
done
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录