提交 64c05803 编写于 作者: T teacher-dong

【security】【mastere】access_token部件测试用例代码修改

Signed-off-by: Nteacher-dong <dongwang.wangdong@huawei.com>
Change-Id: I191aa66a3b28112e9a0b613e091fd7495764634f
上级 ac6ef494
...@@ -17,10 +17,9 @@ group("security") { ...@@ -17,10 +17,9 @@ group("security") {
testonly = true testonly = true
if (is_standard_system) { if (is_standard_system) {
deps = [ deps = [
#"user_iam/face_auth/js_api_test/function_test/userauth:ActsUserauthTest",
#"user_iam/face_auth/js_api_test/performance_test/performance:ActsUserauthPerformanceTest",
"access_token/AccessTokenTest_NoPermission_js:ActsAccessTokenJSApiTestNoPermission", "access_token/AccessTokenTest_NoPermission_js:ActsAccessTokenJSApiTestNoPermission",
"access_token/AccessTokenTest_Normal_js:ActsAccessTokenJSApiTestNormal", "access_token/AccessTokenTest_Normal_js:ActsAccessTokenJSApiTestNormal",
"huks_standard",
] ]
} }
} }
/* /*
* Copyright (C) 2021 Huawei Device Co., Ltd. * Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except compliance with the License. * you may not use this file except compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing,software * Unless required by applicable law or agreed to in writing,software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permission and * See the License for the specific language governing permission and
* limitations under the License. * limitations under the License.
*/ */
// @ts-nocheck // @ts-nocheck
import {describe, beforeEach, afterEach, it, expect} from 'deccjsunit/index' import {describe, beforeEach, afterEach, it, expect} from 'deccjsunit/index'
import abilityAccessCtrl from '@ohos.abilityAccessCtrl' import abilityAccessCtrl from '@ohos.abilityAccessCtrl'
import bundle from '@ohos.bundle' import bundle from '@ohos.bundle'
var PermissionFlag = { var PermissionFlag = {
PERMISSION_USER_SET: 1, PERMISSION_USER_SET: 1,
PERMISSION_USER_FIXED: 2, PERMISSION_USER_FIXED: 2,
PERMISSION_SYSTEM_FIXED: 3 PERMISSION_SYSTEM_FIXED: 3
}; };
const RESULT_FAIL = -1 const RESULT_FAIL = -1
const TIMEOUT = 1000; const TIMEOUT = 1000;
const DEFAULT_PERMISSION_FALG = 0 const DEFAULT_PERMISSION_FALG = 0
var permissionNameUser = "ohos.permission.ALPHA"; var permissionNameUser = "ohos.permission.ALPHA";
var tokenID = undefined var tokenID = undefined
describe('AccessTokenTest',function(){ describe('AccessTokenTest',function(){
console.log('##########start AccessTokenTests'); console.log('##########start AccessTokenTests');
beforeAll(async function (done){ beforeAll(async function (done){
var appInfo = await bundle.getApplicationInfo('ohos.acts.security.access_token.nopermission',0 ,100); var appInfo = await bundle.getApplicationInfo('ohos.acts.security.access_token.nopermission',0 ,100);
tokenID = appInfo.accessTokenId; tokenID = appInfo.accessTokenId;
console.log("AccessTokenTest accessTokenId:" + appInfo.accessTokenId + ", name:"+ appInfo.name + ", bundleName:" + appInfo.bundleName) console.log("AccessTokenTest accessTokenId:" + appInfo.accessTokenId + ", name:"+ appInfo.name
// setTimeout(done(),TIMEOUT); + ", bundleName:" + appInfo.bundleName)
console.info("sleep begin"); console.info("sleep begin");
sleep(TIMEOUT); sleep(TIMEOUT);
console.info("sleep end"); console.info("sleep end");
done(); done();
}) })
afterEach(function(){ afterEach(function(){
}) })
function sleep(delay){ function sleep(delay){
var start = (new Date()).getTime(); var start = (new Date()).getTime();
var next = (new Date()).getTime(); var next = (new Date()).getTime();
while (next - start < delay){ while (next - start < delay){
next = (new Date()).getTime(); next = (new Date()).getTime();
continue; continue;
} }
} }
/** /**
* @tc.number Test_grantUserGrantedPermission_007 * @tc.number Test_grantUserGrantedPermission_007
* @tc.name Test atManager.grantUserGrantedPermission. * @tc.name Test atManager.grantUserGrantedPermission.
* @tc.desc Grant permission that has ohos.permission.GRANT_SENSITIVE_PERMISSIONS. * @tc.desc Grant permission that has ohos.permission.GRANT_SENSITIVE_PERMISSIONS.
*/ */
it('Test_grantUserGrantedPermission_007', 0, async function(done){ it('Test_grantUserGrantedPermission_007', 0, async function(done){
console.info("sleep begin"); console.info("sleep begin");
sleep(1000); sleep(1000);
console.info("sleep end"); console.info("sleep end");
console.log("Test_grantUserGrantedPermission_007 start"); console.log("Test_grantUserGrantedPermission_007 start");
var atManager = abilityAccessCtrl.createAtManager(); var atManager = abilityAccessCtrl.createAtManager();
var result = await atManager.grantUserGrantedPermission(tokenID, permissionNameUser, PermissionFlag.PERMISSION_USER_SET); var result = await atManager.grantUserGrantedPermission(tokenID, permissionNameUser,
console.log("Test_grantUserGrantedPermission_007 tokenID"+ tokenID + "-" + result) PermissionFlag.PERMISSION_USER_SET);
expect(result).assertEqual(RESULT_FAIL); console.log("Test_grantUserGrantedPermission_007 tokenID"+ tokenID + "-" + result)
expect(result).assertEqual(RESULT_FAIL);
done();
}) done();
})
/**
* @tc.number Test_revokeUserGrantedPermission_007 /**
* @tc.name Test atManager.grantUserGrantedPermission. * @tc.number Test_revokeUserGrantedPermission_007
* @tc.desc Revoke permission that has ohos.permission.GRANT_SENSITIVE_PERMISSIONS. * @tc.name Test atManager.grantUserGrantedPermission.
*/ * @tc.desc Revoke permission that has ohos.permission.GRANT_SENSITIVE_PERMISSIONS.
it('Test_revokeUserGrantedPermission_007', 0, async function(done){ */
console.log("Test_revokeUserGrantedPermission_007 start"); it('Test_revokeUserGrantedPermission_007', 0, async function(done){
var atManager = abilityAccessCtrl.createAtManager(); console.log("Test_revokeUserGrantedPermission_007 start");
var result = await atManager.revokeUserGrantedPermission(tokenID, permissionNameUser, PermissionFlag.PERMISSION_USER_SET); var atManager = abilityAccessCtrl.createAtManager();
console.log("Test_revokeUserGrantedPermission_007 tokenID"+ tokenID + "-" + result) var result = await atManager.revokeUserGrantedPermission(tokenID, permissionNameUser,
expect(result).assertEqual(RESULT_FAIL); PermissionFlag.PERMISSION_USER_SET);
console.log("Test_revokeUserGrantedPermission_007 tokenID"+ tokenID + "-" + result)
done(); expect(result).assertEqual(RESULT_FAIL);
})
done();
/** })
* @tc.number Test_getPermissionFlags_005
* @tc.name Test atManager.getPermissionFlags. /**
* @tc.desc Get permission flag that has ohos.permission.GRANT_SENSITIVE_PERMISSIONS. * @tc.number Test_getPermissionFlags_005
*/ * @tc.name Test atManager.getPermissionFlags.
it('Test_getPermissionFlags_005', 0, async function(done){ * @tc.desc Get permission flag that has ohos.permission.GRANT_SENSITIVE_PERMISSIONS.
console.log("Test_getPermissionFlags_005 start"); */
var atManager = abilityAccessCtrl.createAtManager(); it('Test_getPermissionFlags_005', 0, async function(done){
var result = await atManager.getPermissionFlags(tokenID, permissionNameUser); console.log("Test_getPermissionFlags_005 start");
console.log("Test_getPermissionFlags_005 tokenID"+ tokenID + "-" + result) console.log("Test_getPermissionFlags_005 start");
expect(result).assertEqual(DEFAULT_PERMISSION_FALG); var atManager = abilityAccessCtrl.createAtManager();
var result = await atManager.getPermissionFlags(tokenID, permissionNameUser);
done(); console.log("Test_getPermissionFlags_005 tokenID"+ tokenID + "-" + result)
}) expect(result).assertEqual(DEFAULT_PERMISSION_FALG);
})
\ No newline at end of file done();
})
})
/* /*
* Copyright (C) 2021 Huawei Device Co., Ltd. * Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except compliance with the License. * you may not use this file except compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing,software * Unless required by applicable law or agreed to in writing,software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permission and * See the License for the specific language governing permission and
* limitations under the License. * limitations under the License.
*/ */
// @ts-nocheck // @ts-nocheck
import {describe, beforeEach, afterEach, it, expect} from 'deccjsunit/index' import {describe, beforeEach, afterEach, it, expect} from 'deccjsunit/index'
import abilityAccessCtrl from '@ohos.abilityAccessCtrl' import abilityAccessCtrl from '@ohos.abilityAccessCtrl'
import bundle from '@ohos.bundle' import bundle from '@ohos.bundle'
var PermissionFlag = { var PermissionFlag = {
PERMISSION_USER_SET: 1, PERMISSION_USER_SET: 1,
PERMISSION_USER_FIXED: 2, PERMISSION_USER_FIXED: 2,
PERMISSION_SYSTEM_FIXED: 3 PERMISSION_SYSTEM_FIXED: 3
}; };
var GrantStatus = { var GrantStatus = {
PERMISSION_DENIED: -1, PERMISSION_DENIED: -1,
PERMISSION_GRANTED:0, PERMISSION_GRANTED: 0,
}; };
const RESULT_SUCCESS = 0 const RESULT_SUCCESS = 0
const RESULT_FAIL = -1 const RESULT_FAIL = -1
const TIMEOUT = 5000; const TIMEOUT = 5000;
const DEFAULT_PERMISSION_FALG = 0 const DEFAULT_PERMISSION_FALG = 0
var permissionNameUser = "ohos.permission.ALPHA"; var permissionNameUser = "ohos.permission.ALPHA";
var permissionNameSystem = "ohos.permission.BETA"; var permissionNameSystem = "ohos.permission.BETA";
var tokenID = undefined var tokenID = undefined
describe('AccessTokenTest',function(){ describe('AccessTokenTest', function () {
console.log('##########start AccessTokenTest'); console.log('##########start AccessTokenTest');
beforeAll(async function (done){ beforeAll(async function (done){
var appInfo = await bundle.getApplicationInfo('ohos.acts.security.access_token.normal', 0, 100); var appInfo = await bundle.getApplicationInfo('ohos.acts.security.access_token.normal', 0, 100);
tokenID = appInfo.accessTokenId; tokenID = appInfo.accessTokenId;
console.log("AccessTokenTest accessTokenId:"+appInfo.accessTokenId + ", name:"+ appInfo.name + ", bundleName:" + appInfo.bundleName) console.log("AccessTokenTest accessTokenId:" + appInfo.accessTokenId + ", name:" + appInfo.name
// setTimeout(done(),TIMEOUT); + ", bundleName:" + appInfo.bundleName)
// setTimeout(done(),TIMEOUT);
console.info("sleep begin");
sleep(TIMEOUT); console.info("sleep begin");
console.info("sleep end"); sleep(TIMEOUT);
done(); console.info("sleep end");
}) done();
afterEach(function(){ })
}) afterEach(function () {
})
function sleep(delay){
var start = (new Date()).getTime(); function sleep(delay) {
var next = (new Date()).getTime(); var start = (new Date()).getTime();
while (next - start < delay){ var next = (new Date()).getTime();
next = (new Date()).getTime(); while (next - start < delay) {
continue; next = (new Date()).getTime();
} continue;
} }
}
/**
* @tc.number Test_verifyAccessToken_001 /**
* @tc.name Test atManager.verifyAccessToken. * @tc.number Test_verifyAccessToken_001
* @tc.desc After the installation, user_grant permission is not granted by default(Promise). * @tc.name Test atManager.verifyAccessToken.
*/ * @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"); it('Test_verifyAccessToken_001', 0, async function(done){
var atManager = abilityAccessCtrl.createAtManager(); console.log("Test_verifyAccessToken_001 start");
var result = await atManager.verifyAccessToken(tokenID, permissionNameUser); var atManager = abilityAccessCtrl.createAtManager();
console.log("Test_verifyAccessToken_001 tokenID"+ tokenID + "-" + result) var result = await atManager.verifyAccessToken(tokenID, permissionNameUser);
expect(result).assertEqual(GrantStatus.PERMISSION_DENIED); console.log("Test_verifyAccessToken_001 tokenID" + tokenID + "-" + result)
expect(result).assertEqual(GrantStatus.PERMISSION_DENIED);
done();
}) done();
})
/**
* @tc.number Test_verifyAccessToken_002 /**
* @tc.name Test atManager.verifyAccessToken. * @tc.number Test_verifyAccessToken_002
* @tc.desc After the installation, system_grant permission is not granted by default(Promise). * @tc.name Test atManager.verifyAccessToken.
*/ * @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"); it('Test_verifyAccessToken_002', 0, async function(done){
var atManager = abilityAccessCtrl.createAtManager(); console.log("Test_verifyAccessToken_002 start");
var result = await atManager.verifyAccessToken(tokenID, permissionNameSystem); var atManager = abilityAccessCtrl.createAtManager();
console.log("Test_verifyAccessToken_002 tokenID"+ tokenID + "-" + result) var result = await atManager.verifyAccessToken(tokenID, permissionNameSystem);
expect(result).assertEqual(GrantStatus.PERMISSION_GRANTED); console.log("Test_verifyAccessToken_002 tokenID" + tokenID + "-" + result)
expect(result).assertEqual(GrantStatus.PERMISSION_GRANTED);
done();
}) done();
})
/**
* @tc.number Test_verifyAccessToken_003 /**
* @tc.name Test atManager.verifyAccessToken. * @tc.number Test_verifyAccessToken_003
* @tc.desc Test invalid TokenID(0)(Promise). * @tc.name Test atManager.verifyAccessToken.
*/ * @tc.desc Test invalid TokenID(0)(Promise).
it('Test_verifyAccessToken_003', 0, async function(done){ */
console.log("Test_verifyAccessToken_003 start"); it('Test_verifyAccessToken_003', 0, async function(done){
var atManager = abilityAccessCtrl.createAtManager(); console.log("Test_verifyAccessToken_003 start");
var result = await atManager.verifyAccessToken(0, permissionNameUser); var atManager = abilityAccessCtrl.createAtManager();
console.log("Test_verifyAccessToken_003 tokenID"+ tokenID + "-" + result) var result = await atManager.verifyAccessToken(0, permissionNameUser);
expect(result).assertEqual(GrantStatus.PERMISSION_DENIED); console.log("Test_verifyAccessToken_003 tokenID" + tokenID + "-" + result)
expect(result).assertEqual(GrantStatus.PERMISSION_DENIED);
done();
}) done();
})
/**
* @tc.number Test_verifyAccessToken_004 /**
* @tc.name Test atManager.verifyAccessToken. * @tc.number Test_verifyAccessToken_004
* @tc.desc Test invalid permission(empty)(Promise). * @tc.name Test atManager.verifyAccessToken.
*/ * @tc.desc Test invalid permission(empty)(Promise).
it('Test_verifyAccessToken_004', 0, async function(done){ */
console.log("Test_verifyAccessToken_004 start"); it('Test_verifyAccessToken_004', 0, async function(done){
var atManager = abilityAccessCtrl.createAtManager(); console.log("Test_verifyAccessToken_004 start");
var result = await atManager.verifyAccessToken(tokenID, ""); var atManager = abilityAccessCtrl.createAtManager();
console.log("Test_verifyAccessToken_004 tokenID"+ tokenID + "-" + result) var result = await atManager.verifyAccessToken(tokenID, "");
expect(result).assertEqual(GrantStatus.PERMISSION_DENIED); console.log("Test_verifyAccessToken_004 tokenID" + tokenID + "-" + result)
expect(result).assertEqual(GrantStatus.PERMISSION_DENIED);
done();
}) done();
})
/**
* @tc.number Test_verifyAccessToken_005 /**
* @tc.name Test atManager.verifyAccessToken. * @tc.number Test_verifyAccessToken_005
* @tc.desc Test invalid permission(length exceeds 256)(Promise). * @tc.name Test atManager.verifyAccessToken.
*/ * @tc.desc Test invalid permission(length exceeds 256)(Promise).
it('Test_verifyAccessToken_005', 0, async function(done){ */
console.log("Test_verifyAccessToken_005 start"); it('Test_verifyAccessToken_005', 0, async function(done){
var atManager = abilityAccessCtrl.createAtManager(); console.log("Test_verifyAccessToken_005 start");
var permissionName = "ohos.permission.testtesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttest"; var atManager = abilityAccessCtrl.createAtManager();
var permissionName = "ohos.permission.testtesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttest"
var result = await atManager.verifyAccessToken(tokenID, permissionName); + "testtesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttest"
console.log("Test_verifyAccessToken_005 tokenID"+ tokenID + "-" + result) + "testtesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttest";
expect(result).assertEqual(GrantStatus.PERMISSION_DENIED);
var result = await atManager.verifyAccessToken(tokenID, permissionName);
done(); console.log("Test_verifyAccessToken_005 tokenID" + tokenID + "-" + result)
}) expect(result).assertEqual(GrantStatus.PERMISSION_DENIED);
/** done();
* @tc.number Test_grantUserGrantedPermission_001 })
* @tc.name Test atManager.grantUserGrantedPermission.
* @tc.desc Test grant user_grant permission(Promise). /**
*/ * @tc.number Test_grantUserGrantedPermission_001
it('Test_grantUserGrantedPermission_001', 0, async function(done){ * @tc.name Test atManager.grantUserGrantedPermission.
console.log("Test_grantUserGrantedPermission_001 start"); * @tc.desc Test grant user_grant permission(Promise).
var atManager = abilityAccessCtrl.createAtManager(); */
var result = await atManager.grantUserGrantedPermission(tokenID, permissionNameUser, PermissionFlag.PERMISSION_USER_SET); it('Test_grantUserGrantedPermission_001', 0, async function(done){
console.log("Test_grantUserGrantedPermission_001 tokenID" + tokenID + "-" + result); console.log("Test_grantUserGrantedPermission_001 start");
expect(result).assertEqual(RESULT_SUCCESS); var atManager = abilityAccessCtrl.createAtManager();
var result = await atManager.grantUserGrantedPermission(tokenID, permissionNameUser,
var result1 = await atManager.verifyAccessToken(tokenID, permissionNameUser); PermissionFlag.PERMISSION_USER_SET);
console.log("Test_grantUserGrantedPermission_001 tokenID"+ tokenID + "-result1" + result1) console.log("Test_grantUserGrantedPermission_001 tokenID" + tokenID + "-" + result);
expect(result1).assertEqual(GrantStatus.PERMISSION_GRANTED); expect(result).assertEqual(RESULT_SUCCESS);
done(); var result1 = await atManager.verifyAccessToken(tokenID, permissionNameUser);
}) console.log("Test_grantUserGrantedPermission_001 tokenID" + tokenID + "-result1" + result1)
expect(result1).assertEqual(GrantStatus.PERMISSION_GRANTED);
/**
* @tc.number Test_grantUserGrantedPermission_002 done();
* @tc.name Test atManager.grantUserGrantedPermission. })
* @tc.desc Test grant user_grant permission(Promise).
*/ /**
it('Test_grantUserGrantedPermission_002', 0, async function(done){ * @tc.number Test_grantUserGrantedPermission_002
console.log("Test_grantUserGrantedPermission_002 start"); * @tc.name Test atManager.grantUserGrantedPermission.
var atManager = abilityAccessCtrl.createAtManager(); * @tc.desc Test grant user_grant permission(Promise).
var result = await atManager.grantUserGrantedPermission(tokenID, permissionNameSystem, PermissionFlag.PERMISSION_USER_SET); */
console.log("Test_grantUserGrantedPermission_002 tokenID" + tokenID + "-" + result); it('Test_grantUserGrantedPermission_002', 0, async function(done){
expect(result).assertEqual(RESULT_FAIL); console.log("Test_grantUserGrantedPermission_002 start");
var atManager = abilityAccessCtrl.createAtManager();
done(); var result = await atManager.grantUserGrantedPermission(tokenID, permissionNameSystem,
}) PermissionFlag.PERMISSION_USER_SET);
console.log("Test_grantUserGrantedPermission_002 tokenID" + tokenID + "-" + result);
/** expect(result).assertEqual(RESULT_FAIL);
* @tc.number Test_grantUserGrantedPermission_003
* @tc.name Test atManager.grantUserGrantedPermission. done();
* @tc.desc Test grant user_grant permission(Promise). })
*/
it('Test_grantUserGrantedPermission_003', 0, async function(done){ /**
console.log("Test_grantUserGrantedPermission_003 start"); * @tc.number Test_grantUserGrantedPermission_003
var atManager = abilityAccessCtrl.createAtManager(); * @tc.name Test atManager.grantUserGrantedPermission.
atManager.grantUserGrantedPermission(tokenID, permissionNameUser, PermissionFlag.PERMISSION_USER_SET,function(result){ * @tc.desc Test grant user_grant permission(Promise).
console.log("Test_grantUserGrantedPermission_003 tokenID"+ tokenID + "-" + result) */
expect(result).assertEqual(RESULT_SUCCESS); it('Test_grantUserGrantedPermission_003', 0, async function(done){
console.log("Test_grantUserGrantedPermission_003 start");
atManager.verifyAccessToken(tokenID, permissionNameUser).then(function(result1){ var atManager = abilityAccessCtrl.createAtManager();
console.log("Test_grantUserGrantedPermission_003 tokenID"+ tokenID + "-result1" + result1) atManager.grantUserGrantedPermission(tokenID, permissionNameUser, PermissionFlag.PERMISSION_USER_SET,
expect(result1).assertEqual(GrantStatus.PERMISSION_GRANTED); function (result) {
}); console.log("Test_grantUserGrantedPermission_003 tokenID" + tokenID + "-" + result)
done(); expect(result).assertEqual(RESULT_SUCCESS);
});
}) atManager.verifyAccessToken(tokenID, permissionNameUser).then(function (result1) {
console.log("Test_grantUserGrantedPermission_003 tokenID" + tokenID + "-result1" + result1)
/** expect(result1).assertEqual(GrantStatus.PERMISSION_GRANTED);
* @tc.number Test_grantUserGrantedPermission_004 });
* @tc.name Test atManager.grantUserGrantedPermission. done();
* @tc.desc Test invalid TokenID(0)(Promise). });
*/ })
it('Test_grantUserGrantedPermission_004', 0, async function(done){
console.log("Test_grantUserGrantedPermission_004 start"); /**
var atManager = abilityAccessCtrl.createAtManager(); * @tc.number Test_grantUserGrantedPermission_004
var result = await atManager.grantUserGrantedPermission(0, permissionNameUser, PermissionFlag.PERMISSION_USER_SET); * @tc.name Test atManager.grantUserGrantedPermission.
console.log("Test_grantUserGrantedPermission_004 tokenID" + tokenID + "-" + result); * @tc.desc Test invalid TokenID(0)(Promise).
expect(result).assertEqual(RESULT_FAIL); */
it('Test_grantUserGrantedPermission_004', 0, async function(done){
done(); console.log("Test_grantUserGrantedPermission_004 start");
}) var atManager = abilityAccessCtrl.createAtManager();
var result = await atManager.grantUserGrantedPermission(0, permissionNameUser,
/** PermissionFlag.PERMISSION_USER_SET);
* @tc.number Test_grantUserGrantedPermission_005 console.log("Test_grantUserGrantedPermission_004 tokenID" + tokenID + "-" + result);
* @tc.name Test atManager.grantUserGrantedPermission. expect(result).assertEqual(RESULT_FAIL);
* @tc.desc Test invalid permission(empty)(Promise).
*/ done();
it('Test_grantUserGrantedPermission_005', 0, async function(done){ })
console.log("Test_grantUserGrantedPermission_005 start");
var atManager = abilityAccessCtrl.createAtManager(); /**
var result = await atManager.grantUserGrantedPermission(tokenID, "", PermissionFlag.PERMISSION_USER_SET); * @tc.number Test_grantUserGrantedPermission_005
console.log("Test_grantUserGrantedPermission_005 tokenID" + tokenID + "-" + result); * @tc.name Test atManager.grantUserGrantedPermission.
expect(result).assertEqual(RESULT_FAIL); * @tc.desc Test invalid permission(empty)(Promise).
*/
done(); it('Test_grantUserGrantedPermission_005', 0, async function(done){
}) console.log("Test_grantUserGrantedPermission_005 start");
var atManager = abilityAccessCtrl.createAtManager();
/** var result = await atManager.grantUserGrantedPermission(tokenID, "", PermissionFlag.PERMISSION_USER_SET);
* @tc.number Test_grantUserGrantedPermission_006 console.log("Test_grantUserGrantedPermission_005 tokenID" + tokenID + "-" + result);
* @tc.name Test atManager.grantUserGrantedPermission. expect(result).assertEqual(RESULT_FAIL);
* @tc.desc Test invalid permission(length exceeds 256)(Promise).
*/ done();
it('Test_grantUserGrantedPermission_006', 0, async function(done){ })
console.log("Test_grantUserGrantedPermission_006 start");
var atManager = abilityAccessCtrl.createAtManager(); /**
var permissionName = "ohos.permission.testtesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttest"; * @tc.number Test_grantUserGrantedPermission_006
var result = await atManager.grantUserGrantedPermission(tokenID, permissionName, PermissionFlag.PERMISSION_USER_SET); * @tc.name Test atManager.grantUserGrantedPermission.
console.log("Test_grantUserGrantedPermission_006 tokenID" + tokenID + "-" + result); * @tc.desc Test invalid permission(length exceeds 256)(Promise).
expect(result).assertEqual(RESULT_FAIL); */
it('Test_grantUserGrantedPermission_006', 0, async function(done){
done(); console.log("Test_grantUserGrantedPermission_006 start");
}) var atManager = abilityAccessCtrl.createAtManager();
var permissionName = "ohos.permission.testtesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttest"
/** + "testtesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttest"
* @tc.number Test_revokeUserGrantedPermission_001 + "testtesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttest";
* @tc.name Test atManager.revokeUserGrantedPermission. var result = await atManager.grantUserGrantedPermission(tokenID, permissionName,
* @tc.desc Test revoke user_grant permission(Promise). PermissionFlag.PERMISSION_USER_SET);
*/ console.log("Test_grantUserGrantedPermission_006 tokenID" + tokenID + "-" + result);
it('Test_revokeUserGrantedPermission_001', 0, async function(done){ expect(result).assertEqual(RESULT_FAIL);
console.log("Test_revokeUserGrantedPermission_001 start");
var atManager = abilityAccessCtrl.createAtManager(); done();
var result = await atManager.revokeUserGrantedPermission(tokenID, permissionNameUser, PermissionFlag.PERMISSION_USER_SET); })
console.log("Test_revokeUserGrantedPermission_001 tokenID" + tokenID + "-" + result);
expect(result).assertEqual(RESULT_SUCCESS); /**
* @tc.number Test_revokeUserGrantedPermission_001
var result1 = await atManager.verifyAccessToken(tokenID, permissionNameUser); * @tc.name Test atManager.revokeUserGrantedPermission.
console.log("Test_revokeUserGrantedPermission_001 tokenID"+ tokenID + "-result1" + result1) * @tc.desc Test revoke user_grant permission(Promise).
expect(result1).assertEqual(GrantStatus.PERMISSION_DENIED); */
it('Test_revokeUserGrantedPermission_001', 0, async function(done){
done(); console.log("Test_revokeUserGrantedPermission_001 start");
}) var atManager = abilityAccessCtrl.createAtManager();
var result = await atManager.revokeUserGrantedPermission(tokenID, permissionNameUser,
/** PermissionFlag.PERMISSION_USER_SET);
* @tc.number Test_revokeUserGrantedPermission_002 console.log("Test_revokeUserGrantedPermission_001 tokenID" + tokenID + "-" + result);
* @tc.name Test atManager.revokeUserGrantedPermission. expect(result).assertEqual(RESULT_SUCCESS);
* @tc.desc Test revoke system_grant permission(Promise).
*/ var result1 = await atManager.verifyAccessToken(tokenID, permissionNameUser);
it('Test_revokeUserGrantedPermission_002', 0, async function(done){ console.log("Test_revokeUserGrantedPermission_001 tokenID" + tokenID + "-result1" + result1)
console.log("Test_revokeUserGrantedPermission_002 start"); expect(result1).assertEqual(GrantStatus.PERMISSION_DENIED);
var atManager = abilityAccessCtrl.createAtManager();
var result = await atManager.revokeUserGrantedPermission(tokenID, permissionNameSystem, PermissionFlag.PERMISSION_USER_SET); done();
console.log("Test_revokeUserGrantedPermission_002 tokenID" + tokenID + "-" + result); })
expect(result).assertEqual(RESULT_FAIL);
/**
done(); * @tc.number Test_revokeUserGrantedPermission_002
}) * @tc.name Test atManager.revokeUserGrantedPermission.
* @tc.desc Test revoke system_grant permission(Promise).
/** */
* @tc.number Test_revokeUserGrantedPermission_003 it('Test_revokeUserGrantedPermission_002', 0, async function(done){
* @tc.name Test atManager.revokeUserGrantedPermission. console.log("Test_revokeUserGrantedPermission_002 start");
* @tc.desc Test revoke user_grant permission(AsyncCallback). var atManager = abilityAccessCtrl.createAtManager();
*/ var result = await atManager.revokeUserGrantedPermission(tokenID, permissionNameSystem,
it('Test_revokeUserGrantedPermission_003', 0, async function(done){ PermissionFlag.PERMISSION_USER_SET);
console.log("Test_revokeUserGrantedPermission_003 start"); console.log("Test_revokeUserGrantedPermission_002 tokenID" + tokenID + "-" + result);
var atManager = abilityAccessCtrl.createAtManager(); expect(result).assertEqual(RESULT_FAIL);
atManager.revokeUserGrantedPermission(tokenID, permissionNameUser, PermissionFlag.PERMISSION_USER_SET,function(result){
console.log("Test_revokeUserGrantedPermission_003 tokenID"+ tokenID + "-" + result) done();
expect(result).assertEqual(RESULT_SUCCESS); })
atManager.verifyAccessToken(tokenID, permissionNameUser).then(function(result1){ /**
console.log("Test_revokeUserGrantedPermission_003 tokenID"+ tokenID + "-result1" + result1) * @tc.number Test_revokeUserGrantedPermission_003
expect(result1).assertEqual(GrantStatus.PERMISSION_DENIED); * @tc.name Test atManager.revokeUserGrantedPermission.
}); * @tc.desc Test revoke user_grant permission(AsyncCallback).
done(); */
}); it('Test_revokeUserGrantedPermission_003', 0, async function(done){
}) console.log("Test_revokeUserGrantedPermission_003 start");
var atManager = abilityAccessCtrl.createAtManager();
/** atManager.revokeUserGrantedPermission(tokenID, permissionNameUser, PermissionFlag.PERMISSION_USER_SET,
* @tc.number Test_revokeUserGrantedPermission_004 function (result) {
* @tc.name Test atManager.revokeUserGrantedPermission. console.log("Test_revokeUserGrantedPermission_003 tokenID" + tokenID + "-" + result)
* @tc.desc Test invalid TokenID(0)(Promise). expect(result).assertEqual(RESULT_SUCCESS);
*/
it('Test_revokeUserGrantedPermission_004', 0, async function(done){ atManager.verifyAccessToken(tokenID, permissionNameUser).then(function (result1) {
console.log("Test_revokeUserGrantedPermission_004 start"); console.log("Test_revokeUserGrantedPermission_003 tokenID" + tokenID + "-result1" + result1)
var atManager = abilityAccessCtrl.createAtManager(); expect(result1).assertEqual(GrantStatus.PERMISSION_DENIED);
var result = await atManager.revokeUserGrantedPermission(0, permissionNameUser, PermissionFlag.PERMISSION_USER_SET); });
console.log("Test_revokeUserGrantedPermission_004 tokenID" + tokenID + "-" + result); done();
expect(result).assertEqual(RESULT_FAIL); });
})
done();
}) /**
* @tc.number Test_revokeUserGrantedPermission_004
/** * @tc.name Test atManager.revokeUserGrantedPermission.
* @tc.number Test_revokeUserGrantedPermission_005 * @tc.desc Test invalid TokenID(0)(Promise).
* @tc.name Test atManager.revokeUserGrantedPermission. */
* @tc.desc Test invalid permission(empty)(Promise). it('Test_revokeUserGrantedPermission_004', 0, async function(done){
*/ console.log("Test_revokeUserGrantedPermission_004 start");
it('Test_revokeUserGrantedPermission_005', 0, async function(done){ var atManager = abilityAccessCtrl.createAtManager();
console.log("Test_revokeUserGrantedPermission_005 start"); var result = await atManager.revokeUserGrantedPermission(0, permissionNameUser,
var atManager = abilityAccessCtrl.createAtManager(); PermissionFlag.PERMISSION_USER_SET);
var result = await atManager.revokeUserGrantedPermission(tokenID, "", PermissionFlag.PERMISSION_USER_SET); console.log("Test_revokeUserGrantedPermission_004 tokenID" + tokenID + "-" + result);
console.log("Test_revokeUserGrantedPermission_005 tokenID" + tokenID + "-" + result); expect(result).assertEqual(RESULT_FAIL);
expect(result).assertEqual(RESULT_FAIL);
done();
done(); })
})
/**
/** * @tc.number Test_revokeUserGrantedPermission_005
* @tc.number Test_revokeUserGrantedPermission_006 * @tc.name Test atManager.revokeUserGrantedPermission.
* @tc.name Test atManager.revokeUserGrantedPermission. * @tc.desc Test invalid permission(empty)(Promise).
* @tc.desc Test invalid permission(length exceeds 256)(Promise). */
*/ it('Test_revokeUserGrantedPermission_005', 0, async function(done){
it('Test_revokeUserGrantedPermission_006', 0, async function(done){ console.log("Test_revokeUserGrantedPermission_005 start");
console.log("Test_revokeUserGrantedPermission_006 start"); var atManager = abilityAccessCtrl.createAtManager();
var atManager = abilityAccessCtrl.createAtManager(); var result = await atManager.revokeUserGrantedPermission(tokenID, "", PermissionFlag.PERMISSION_USER_SET);
var permissionName = "ohos.permission.testtesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttest"; console.log("Test_revokeUserGrantedPermission_005 tokenID" + tokenID + "-" + result);
var result = await atManager.revokeUserGrantedPermission(tokenID, permissionName, PermissionFlag.PERMISSION_USER_SET); expect(result).assertEqual(RESULT_FAIL);
console.log("Test_revokeUserGrantedPermission_006 tokenID" + tokenID + "-" + result);
expect(result).assertEqual(RESULT_FAIL); done();
})
done();
}) /**
* @tc.number Test_revokeUserGrantedPermission_006
/** * @tc.name Test atManager.revokeUserGrantedPermission.
* @tc.number Test_getPermissionFlag_001 * @tc.desc Test invalid permission(length exceeds 256)(Promise).
* @tc.name Test atManager.getPermissionFlags. */
* @tc.desc Test get permission flag(Promise). it('Test_revokeUserGrantedPermission_006', 0, async function(done){
*/ console.log("Test_revokeUserGrantedPermission_006 start");
it('Test_getPermissionFlag_001', 0, async function(done){ var atManager = abilityAccessCtrl.createAtManager();
console.log("Test_getPermissionFlag_001 start"); var permissionName = "ohos.permission.testtesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttest"
var atManager = abilityAccessCtrl.createAtManager(); + "testtesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttest"
var result = await atManager.grantUserGrantedPermission(tokenID, permissionNameUser, PermissionFlag.PERMISSION_USER_SET); + "testtesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttest";
console.log("Test_getPermissionFlag_001 tokenID" + tokenID + "-" + result); var result = await atManager.revokeUserGrantedPermission(tokenID, permissionName,
expect(result).assertEqual(RESULT_SUCCESS); PermissionFlag.PERMISSION_USER_SET);
console.log("Test_revokeUserGrantedPermission_006 tokenID" + tokenID + "-" + result);
var result1 = await atManager.getPermissionFlags(tokenID, permissionNameUser); expect(result).assertEqual(RESULT_FAIL);
console.log("Test_getPermissionFlag_001 tokenID"+ tokenID + "-result1" + result1)
expect(result1).assertEqual(PermissionFlag.PERMISSION_USER_SET); done();
})
done();
}) /**
* @tc.number Test_getPermissionFlag_001
/** * @tc.name Test atManager.getPermissionFlags.
* @tc.number Test_getPermissionFlag_002 * @tc.desc Test get permission flag(Promise).
* @tc.name Test atManager.getPermissionFlags. */
* @tc.desc Test invalid TokenID(0)(Promise). it('Test_getPermissionFlag_001', 0, async function(done){
*/ console.log("Test_getPermissionFlag_001 start");
it('Test_getPermissionFlag_002', 0, async function(done){ var atManager = abilityAccessCtrl.createAtManager();
console.log("Test_getPermissionFlag_002 start"); var result = await atManager.grantUserGrantedPermission(tokenID, permissionNameUser,
var atManager = abilityAccessCtrl.createAtManager(); PermissionFlag.PERMISSION_USER_SET);
var result = await atManager.getPermissionFlags(0, permissionNameUser); console.log("Test_getPermissionFlag_001 tokenID" + tokenID + "-" + result);
console.log("Test_getPermissionFlag_002 tokenID" + tokenID + "-" + result); expect(result).assertEqual(RESULT_SUCCESS);
expect(result).assertEqual(DEFAULT_PERMISSION_FALG);
var result1 = await atManager.getPermissionFlags(tokenID, permissionNameUser);
done(); console.log("Test_getPermissionFlag_001 tokenID" + tokenID + "-result1" + result1)
}) expect(result1).assertEqual(PermissionFlag.PERMISSION_USER_SET);
/** done();
* @tc.number Test_getPermissionFlag_003 })
* @tc.name Test atManager.getPermissionFlags.
* @tc.desc Test invalid permission(empty)(Promise). /**
*/ * @tc.number Test_getPermissionFlag_002
it('Test_getPermissionFlag_003', 0, async function(done){ * @tc.name Test atManager.getPermissionFlags.
console.log("Test_getPermissionFlag_003 start"); * @tc.desc Test invalid TokenID(0)(Promise).
var atManager = abilityAccessCtrl.createAtManager(); */
var result = await atManager.getPermissionFlags(tokenID, ""); it('Test_getPermissionFlag_002', 0, async function(done){
console.log("Test_getPermissionFlag_003 tokenID" + tokenID + "-" + result); console.log("Test_getPermissionFlag_002 start");
expect(result).assertEqual(DEFAULT_PERMISSION_FALG); var atManager = abilityAccessCtrl.createAtManager();
var result = await atManager.getPermissionFlags(0, permissionNameUser);
done(); console.log("Test_getPermissionFlag_002 tokenID" + tokenID + "-" + result);
}) expect(result).assertEqual(DEFAULT_PERMISSION_FALG);
/** done();
* @tc.number Test_getPermissionFlag_004 })
* @tc.name Test atManager.getPermissionFlags.
* @tc.desc Test invalid permission(length exceeds 256)(Promise). /**
*/ * @tc.number Test_getPermissionFlag_003
it('Test_getPermissionFlag_004', 0, async function(done){ * @tc.name Test atManager.getPermissionFlags.
console.log("Test_getPermissionFlag_004 start"); * @tc.desc Test invalid permission(empty)(Promise).
var atManager = abilityAccessCtrl.createAtManager(); */
var permissionName = "ohos.permission.testtesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttest"; it('Test_getPermissionFlag_003', 0, async function(done){
var result = await atManager.getPermissionFlags(tokenID, permissionName); console.log("Test_getPermissionFlag_003 start");
console.log("Test_getPermissionFlag_004 tokenID" + tokenID + "-" + result); var atManager = abilityAccessCtrl.createAtManager();
expect(result).assertEqual(DEFAULT_PERMISSION_FALG); var result = await atManager.getPermissionFlags(tokenID, "");
console.log("Test_getPermissionFlag_003 tokenID" + tokenID + "-" + result);
done(); expect(result).assertEqual(DEFAULT_PERMISSION_FALG);
})
}) done();
\ No newline at end of file })
/**
* @tc.number Test_getPermissionFlag_004
* @tc.name Test atManager.getPermissionFlags.
* @tc.desc Test invalid permission(length exceeds 256)(Promise).
*/
it('Test_getPermissionFlag_004', 0, async function(done){
console.log("Test_getPermissionFlag_004 start");
var atManager = abilityAccessCtrl.createAtManager();
var permissionName = "ohos.permission.testtesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttest"
+ "testtesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttest"
+ "testtesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttest";
var result = await atManager.getPermissionFlags(tokenID, permissionName);
console.log("Test_getPermissionFlag_004 tokenID" + tokenID + "-" + result);
expect(result).assertEqual(DEFAULT_PERMISSION_FALG);
done();
})
})
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册