提交 acd88de1 编写于 作者: L liushuling

整改XTS用例

Signed-off-by: Nliushuling <liushuling1@huawei.com>
上级 29670233
......@@ -32,6 +32,7 @@ var GrantStatus = {
const RESULT_SUCCESS = 0;
const RESULT_FAIL = -1;
const TIMEOUT = 5000;
const ERR_PARAM_INVALID = 12100001;
const DEFAULT_PERMISSION_FALG = 0;
var permissionNameUser = "ohos.permission.ALPHA";
......@@ -176,10 +177,11 @@ describe('AccessTokenTest', function () {
*/
it('Test_verifyAccessTokenSync_002', 0, function(){
console.info("Test_verifyAccessTokenSync_002 start");
var atManager = abilityAccessCtrl.createAtManager();
var result = atManager.verifyAccessTokenSync(0, permissionNameUser);
console.info("Test_verifyAccessTokenSync_002 tokenID" + tokenID + "-" + result)
expect(result).assertEqual(GrantStatus.PERMISSION_DENIED);
try {
atManager.verifyAccessTokenSync(0, permissionNameUser);
} catch (error) {
expect(error.code).assertEqual(ERR_PARAM_INVALID);
}
})
/**
......@@ -189,10 +191,11 @@ describe('AccessTokenTest', function () {
*/
it('Test_verifyAccessTokenSync_003', 0, function(){
console.info("Test_verifyAccessTokenSync_003 start");
var atManager = abilityAccessCtrl.createAtManager();
var result = atManager.verifyAccessTokenSync(tokenID, "");
console.info("Test_verifyAccessTokenSync_003 tokenID" + tokenID + "-" + result)
expect(result).assertEqual(GrantStatus.PERMISSION_DENIED);
try {
atManager.verifyAccessTokenSync(tokenID, "");
} catch (error) {
expect(error.code).assertEqual(ERR_PARAM_INVALID);
}
})
/**
......@@ -207,9 +210,93 @@ describe('AccessTokenTest', function () {
+ "testtesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttest"
+ "testtesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttest";
var result = atManager.verifyAccessTokenSync(tokenID, permissionName);
console.info("Test_verifyAccessTokenSync_004 tokenID" + tokenID + "-" + result)
try {
atManager.verifyAccessTokenSync(tokenID, permissionName);
} catch (error) {
expect(error.code).assertEqual(ERR_PARAM_INVALID);
}
})
/**
* @tc.number Test_checkAccessToken_001
* @tc.name Test atManager.checkAccessToken.
* @tc.desc After the installation, user_grant permission is not granted by default(Promise).
*/
it('Test_checkAccessToken_001', 0, async function(done){
console.info("Test_verifyAccessToken_001 start");
var atManager = abilityAccessCtrl.createAtManager();
var result = await atManager.checkAccessToken(tokenID, permissionNameUser);
console.info("Test_checkAccessToken_001 tokenID" + tokenID + "-" + result)
expect(result).assertEqual(GrantStatus.PERMISSION_DENIED);
done();
})
/**
* @tc.number Test_checkAccessToken_002
* @tc.name Test atManager.checkAccessToken.
* @tc.desc After the installation, system_grant permission is granted by default(Promise).
*/
it('Test_checkAccessToken_002', 0, async function(done){
console.info("Test_checkAccessToken_002 start");
var atManager = abilityAccessCtrl.createAtManager();
var result = await atManager.checkAccessToken(tokenID, permissionNameSystem);
console.info("Test_checkAccessToken_002 tokenID" + tokenID + "-" + result)
expect(result).assertEqual(GrantStatus.PERMISSION_GRANTED);
done();
})
/**
* @tc.number Test_checkAccessToken_003
* @tc.name Test atManager.checkAccessToken.
* @tc.desc Test invalid TokenID(0)(Promise).
*/
it('Test_checkAccessToken_003', 0, async function(done){
console.info("Test_checkAccessToken_003 start");
var atManager = abilityAccessCtrl.createAtManager();
await atManager.checkAccessToken(0, permissionNameUser)
.catch((err) =>{
expect(err.code).assertEqual(ERR_PARAM_INVALID);
})
done();
})
/**
* @tc.number Test_checkAccessToken_004
* @tc.name Test atManager.checkAccessToken.
* @tc.desc Test invalid permission(empty)(Promise).
*/
it('Test_checkAccessToken_004', 0, async function(done){
console.info("Test_checkAccessToken_004 start");
var atManager = abilityAccessCtrl.createAtManager();
await atManager.checkAccessToken(tokenID, "")
.catch((err) =>{
expect(err.code).assertEqual(ERR_PARAM_INVALID);
})
done();
})
/**
* @tc.number Test_checkAccessToken_005
* @tc.name Test atManager.checkAccessToken.
* @tc.desc Test invalid permission(length exceeds 256)(Promise).
*/
it('Test_checkAccessToken_005', 0, async function(done){
console.info("Test_checkAccessToken_005 start");
var atManager = abilityAccessCtrl.createAtManager();
var permissionName = "ohos.permission.testtesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttest"
+ "testtesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttest"
+ "testtesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttest";
await atManager.checkAccessToken(tokenID, permissionName)
.catch((err) =>{
expect(err.code).assertEqual(ERR_PARAM_INVALID);
})
done();
})
})
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册