提交 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",
] ]
} }
} }
...@@ -34,8 +34,8 @@ describe('AccessTokenTest',function(){ ...@@ -34,8 +34,8 @@ describe('AccessTokenTest',function(){
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");
...@@ -63,7 +63,8 @@ describe('AccessTokenTest',function(){ ...@@ -63,7 +63,8 @@ describe('AccessTokenTest',function(){
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,
PermissionFlag.PERMISSION_USER_SET);
console.log("Test_grantUserGrantedPermission_007 tokenID"+ tokenID + "-" + result) console.log("Test_grantUserGrantedPermission_007 tokenID"+ tokenID + "-" + result)
expect(result).assertEqual(RESULT_FAIL); expect(result).assertEqual(RESULT_FAIL);
...@@ -78,7 +79,8 @@ describe('AccessTokenTest',function(){ ...@@ -78,7 +79,8 @@ describe('AccessTokenTest',function(){
it('Test_revokeUserGrantedPermission_007', 0, async function(done){ it('Test_revokeUserGrantedPermission_007', 0, async function(done){
console.log("Test_revokeUserGrantedPermission_007 start"); console.log("Test_revokeUserGrantedPermission_007 start");
var atManager = abilityAccessCtrl.createAtManager(); var atManager = abilityAccessCtrl.createAtManager();
var result = await atManager.revokeUserGrantedPermission(tokenID, permissionNameUser, PermissionFlag.PERMISSION_USER_SET); var result = await atManager.revokeUserGrantedPermission(tokenID, permissionNameUser,
PermissionFlag.PERMISSION_USER_SET);
console.log("Test_revokeUserGrantedPermission_007 tokenID"+ tokenID + "-" + result) console.log("Test_revokeUserGrantedPermission_007 tokenID"+ tokenID + "-" + result)
expect(result).assertEqual(RESULT_FAIL); expect(result).assertEqual(RESULT_FAIL);
...@@ -91,6 +93,7 @@ describe('AccessTokenTest',function(){ ...@@ -91,6 +93,7 @@ describe('AccessTokenTest',function(){
* @tc.desc Get permission flag that has ohos.permission.GRANT_SENSITIVE_PERMISSIONS. * @tc.desc Get permission flag that has ohos.permission.GRANT_SENSITIVE_PERMISSIONS.
*/ */
it('Test_getPermissionFlags_005', 0, async function(done){ it('Test_getPermissionFlags_005', 0, async function(done){
console.log("Test_getPermissionFlags_005 start");
console.log("Test_getPermissionFlags_005 start"); console.log("Test_getPermissionFlags_005 start");
var atManager = abilityAccessCtrl.createAtManager(); var atManager = abilityAccessCtrl.createAtManager();
var result = await atManager.getPermissionFlags(tokenID, permissionNameUser); var result = await atManager.getPermissionFlags(tokenID, permissionNameUser);
......
...@@ -26,7 +26,7 @@ var PermissionFlag = { ...@@ -26,7 +26,7 @@ var PermissionFlag = {
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
...@@ -36,12 +36,13 @@ const DEFAULT_PERMISSION_FALG = 0 ...@@ -36,12 +36,13 @@ 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
+ ", bundleName:" + appInfo.bundleName)
// setTimeout(done(),TIMEOUT); // setTimeout(done(),TIMEOUT);
console.info("sleep begin"); console.info("sleep begin");
...@@ -49,13 +50,13 @@ describe('AccessTokenTest',function(){ ...@@ -49,13 +50,13 @@ describe('AccessTokenTest',function(){
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;
} }
...@@ -70,7 +71,7 @@ describe('AccessTokenTest',function(){ ...@@ -70,7 +71,7 @@ describe('AccessTokenTest',function(){
console.log("Test_verifyAccessToken_001 start"); console.log("Test_verifyAccessToken_001 start");
var atManager = abilityAccessCtrl.createAtManager(); var atManager = abilityAccessCtrl.createAtManager();
var result = await atManager.verifyAccessToken(tokenID, permissionNameUser); var result = await atManager.verifyAccessToken(tokenID, permissionNameUser);
console.log("Test_verifyAccessToken_001 tokenID"+ tokenID + "-" + result) console.log("Test_verifyAccessToken_001 tokenID" + tokenID + "-" + result)
expect(result).assertEqual(GrantStatus.PERMISSION_DENIED); expect(result).assertEqual(GrantStatus.PERMISSION_DENIED);
done(); done();
...@@ -85,7 +86,7 @@ describe('AccessTokenTest',function(){ ...@@ -85,7 +86,7 @@ describe('AccessTokenTest',function(){
console.log("Test_verifyAccessToken_002 start"); console.log("Test_verifyAccessToken_002 start");
var atManager = abilityAccessCtrl.createAtManager(); var atManager = abilityAccessCtrl.createAtManager();
var result = await atManager.verifyAccessToken(tokenID, permissionNameSystem); var result = await atManager.verifyAccessToken(tokenID, permissionNameSystem);
console.log("Test_verifyAccessToken_002 tokenID"+ tokenID + "-" + result) console.log("Test_verifyAccessToken_002 tokenID" + tokenID + "-" + result)
expect(result).assertEqual(GrantStatus.PERMISSION_GRANTED); expect(result).assertEqual(GrantStatus.PERMISSION_GRANTED);
done(); done();
...@@ -100,7 +101,7 @@ describe('AccessTokenTest',function(){ ...@@ -100,7 +101,7 @@ describe('AccessTokenTest',function(){
console.log("Test_verifyAccessToken_003 start"); console.log("Test_verifyAccessToken_003 start");
var atManager = abilityAccessCtrl.createAtManager(); var atManager = abilityAccessCtrl.createAtManager();
var result = await atManager.verifyAccessToken(0, permissionNameUser); var result = await atManager.verifyAccessToken(0, permissionNameUser);
console.log("Test_verifyAccessToken_003 tokenID"+ tokenID + "-" + result) console.log("Test_verifyAccessToken_003 tokenID" + tokenID + "-" + result)
expect(result).assertEqual(GrantStatus.PERMISSION_DENIED); expect(result).assertEqual(GrantStatus.PERMISSION_DENIED);
done(); done();
...@@ -115,7 +116,7 @@ describe('AccessTokenTest',function(){ ...@@ -115,7 +116,7 @@ describe('AccessTokenTest',function(){
console.log("Test_verifyAccessToken_004 start"); console.log("Test_verifyAccessToken_004 start");
var atManager = abilityAccessCtrl.createAtManager(); var atManager = abilityAccessCtrl.createAtManager();
var result = await atManager.verifyAccessToken(tokenID, ""); var result = await atManager.verifyAccessToken(tokenID, "");
console.log("Test_verifyAccessToken_004 tokenID"+ tokenID + "-" + result) console.log("Test_verifyAccessToken_004 tokenID" + tokenID + "-" + result)
expect(result).assertEqual(GrantStatus.PERMISSION_DENIED); expect(result).assertEqual(GrantStatus.PERMISSION_DENIED);
done(); done();
...@@ -129,10 +130,12 @@ describe('AccessTokenTest',function(){ ...@@ -129,10 +130,12 @@ describe('AccessTokenTest',function(){
it('Test_verifyAccessToken_005', 0, async function(done){ it('Test_verifyAccessToken_005', 0, async function(done){
console.log("Test_verifyAccessToken_005 start"); console.log("Test_verifyAccessToken_005 start");
var atManager = abilityAccessCtrl.createAtManager(); var atManager = abilityAccessCtrl.createAtManager();
var permissionName = "ohos.permission.testtesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttest"; var permissionName = "ohos.permission.testtesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttest"
+ "testtesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttest"
+ "testtesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttest";
var result = await atManager.verifyAccessToken(tokenID, permissionName); var result = await atManager.verifyAccessToken(tokenID, permissionName);
console.log("Test_verifyAccessToken_005 tokenID"+ tokenID + "-" + result) console.log("Test_verifyAccessToken_005 tokenID" + tokenID + "-" + result)
expect(result).assertEqual(GrantStatus.PERMISSION_DENIED); expect(result).assertEqual(GrantStatus.PERMISSION_DENIED);
done(); done();
...@@ -146,12 +149,13 @@ describe('AccessTokenTest',function(){ ...@@ -146,12 +149,13 @@ describe('AccessTokenTest',function(){
it('Test_grantUserGrantedPermission_001', 0, async function(done){ it('Test_grantUserGrantedPermission_001', 0, async function(done){
console.log("Test_grantUserGrantedPermission_001 start"); console.log("Test_grantUserGrantedPermission_001 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,
PermissionFlag.PERMISSION_USER_SET);
console.log("Test_grantUserGrantedPermission_001 tokenID" + tokenID + "-" + result); console.log("Test_grantUserGrantedPermission_001 tokenID" + tokenID + "-" + result);
expect(result).assertEqual(RESULT_SUCCESS); expect(result).assertEqual(RESULT_SUCCESS);
var result1 = await atManager.verifyAccessToken(tokenID, permissionNameUser); var result1 = await atManager.verifyAccessToken(tokenID, permissionNameUser);
console.log("Test_grantUserGrantedPermission_001 tokenID"+ tokenID + "-result1" + result1) console.log("Test_grantUserGrantedPermission_001 tokenID" + tokenID + "-result1" + result1)
expect(result1).assertEqual(GrantStatus.PERMISSION_GRANTED); expect(result1).assertEqual(GrantStatus.PERMISSION_GRANTED);
done(); done();
...@@ -165,7 +169,8 @@ describe('AccessTokenTest',function(){ ...@@ -165,7 +169,8 @@ describe('AccessTokenTest',function(){
it('Test_grantUserGrantedPermission_002', 0, async function(done){ it('Test_grantUserGrantedPermission_002', 0, async function(done){
console.log("Test_grantUserGrantedPermission_002 start"); console.log("Test_grantUserGrantedPermission_002 start");
var atManager = abilityAccessCtrl.createAtManager(); var atManager = abilityAccessCtrl.createAtManager();
var result = await atManager.grantUserGrantedPermission(tokenID, permissionNameSystem, PermissionFlag.PERMISSION_USER_SET); var result = await atManager.grantUserGrantedPermission(tokenID, permissionNameSystem,
PermissionFlag.PERMISSION_USER_SET);
console.log("Test_grantUserGrantedPermission_002 tokenID" + tokenID + "-" + result); console.log("Test_grantUserGrantedPermission_002 tokenID" + tokenID + "-" + result);
expect(result).assertEqual(RESULT_FAIL); expect(result).assertEqual(RESULT_FAIL);
...@@ -180,12 +185,13 @@ describe('AccessTokenTest',function(){ ...@@ -180,12 +185,13 @@ describe('AccessTokenTest',function(){
it('Test_grantUserGrantedPermission_003', 0, async function(done){ it('Test_grantUserGrantedPermission_003', 0, async function(done){
console.log("Test_grantUserGrantedPermission_003 start"); console.log("Test_grantUserGrantedPermission_003 start");
var atManager = abilityAccessCtrl.createAtManager(); var atManager = abilityAccessCtrl.createAtManager();
atManager.grantUserGrantedPermission(tokenID, permissionNameUser, PermissionFlag.PERMISSION_USER_SET,function(result){ atManager.grantUserGrantedPermission(tokenID, permissionNameUser, PermissionFlag.PERMISSION_USER_SET,
console.log("Test_grantUserGrantedPermission_003 tokenID"+ tokenID + "-" + result) function (result) {
console.log("Test_grantUserGrantedPermission_003 tokenID" + tokenID + "-" + result)
expect(result).assertEqual(RESULT_SUCCESS); expect(result).assertEqual(RESULT_SUCCESS);
atManager.verifyAccessToken(tokenID, permissionNameUser).then(function(result1){ atManager.verifyAccessToken(tokenID, permissionNameUser).then(function (result1) {
console.log("Test_grantUserGrantedPermission_003 tokenID"+ tokenID + "-result1" + result1) console.log("Test_grantUserGrantedPermission_003 tokenID" + tokenID + "-result1" + result1)
expect(result1).assertEqual(GrantStatus.PERMISSION_GRANTED); expect(result1).assertEqual(GrantStatus.PERMISSION_GRANTED);
}); });
done(); done();
...@@ -200,7 +206,8 @@ describe('AccessTokenTest',function(){ ...@@ -200,7 +206,8 @@ describe('AccessTokenTest',function(){
it('Test_grantUserGrantedPermission_004', 0, async function(done){ it('Test_grantUserGrantedPermission_004', 0, async function(done){
console.log("Test_grantUserGrantedPermission_004 start"); console.log("Test_grantUserGrantedPermission_004 start");
var atManager = abilityAccessCtrl.createAtManager(); var atManager = abilityAccessCtrl.createAtManager();
var result = await atManager.grantUserGrantedPermission(0, permissionNameUser, PermissionFlag.PERMISSION_USER_SET); var result = await atManager.grantUserGrantedPermission(0, permissionNameUser,
PermissionFlag.PERMISSION_USER_SET);
console.log("Test_grantUserGrantedPermission_004 tokenID" + tokenID + "-" + result); console.log("Test_grantUserGrantedPermission_004 tokenID" + tokenID + "-" + result);
expect(result).assertEqual(RESULT_FAIL); expect(result).assertEqual(RESULT_FAIL);
...@@ -230,8 +237,11 @@ describe('AccessTokenTest',function(){ ...@@ -230,8 +237,11 @@ describe('AccessTokenTest',function(){
it('Test_grantUserGrantedPermission_006', 0, async function(done){ it('Test_grantUserGrantedPermission_006', 0, async function(done){
console.log("Test_grantUserGrantedPermission_006 start"); console.log("Test_grantUserGrantedPermission_006 start");
var atManager = abilityAccessCtrl.createAtManager(); var atManager = abilityAccessCtrl.createAtManager();
var permissionName = "ohos.permission.testtesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttest"; var permissionName = "ohos.permission.testtesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttest"
var result = await atManager.grantUserGrantedPermission(tokenID, permissionName, PermissionFlag.PERMISSION_USER_SET); + "testtesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttest"
+ "testtesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttest";
var result = await atManager.grantUserGrantedPermission(tokenID, permissionName,
PermissionFlag.PERMISSION_USER_SET);
console.log("Test_grantUserGrantedPermission_006 tokenID" + tokenID + "-" + result); console.log("Test_grantUserGrantedPermission_006 tokenID" + tokenID + "-" + result);
expect(result).assertEqual(RESULT_FAIL); expect(result).assertEqual(RESULT_FAIL);
...@@ -246,12 +256,13 @@ describe('AccessTokenTest',function(){ ...@@ -246,12 +256,13 @@ describe('AccessTokenTest',function(){
it('Test_revokeUserGrantedPermission_001', 0, async function(done){ it('Test_revokeUserGrantedPermission_001', 0, async function(done){
console.log("Test_revokeUserGrantedPermission_001 start"); console.log("Test_revokeUserGrantedPermission_001 start");
var atManager = abilityAccessCtrl.createAtManager(); var atManager = abilityAccessCtrl.createAtManager();
var result = await atManager.revokeUserGrantedPermission(tokenID, permissionNameUser, PermissionFlag.PERMISSION_USER_SET); var result = await atManager.revokeUserGrantedPermission(tokenID, permissionNameUser,
PermissionFlag.PERMISSION_USER_SET);
console.log("Test_revokeUserGrantedPermission_001 tokenID" + tokenID + "-" + result); console.log("Test_revokeUserGrantedPermission_001 tokenID" + tokenID + "-" + result);
expect(result).assertEqual(RESULT_SUCCESS); expect(result).assertEqual(RESULT_SUCCESS);
var result1 = await atManager.verifyAccessToken(tokenID, permissionNameUser); var result1 = await atManager.verifyAccessToken(tokenID, permissionNameUser);
console.log("Test_revokeUserGrantedPermission_001 tokenID"+ tokenID + "-result1" + result1) console.log("Test_revokeUserGrantedPermission_001 tokenID" + tokenID + "-result1" + result1)
expect(result1).assertEqual(GrantStatus.PERMISSION_DENIED); expect(result1).assertEqual(GrantStatus.PERMISSION_DENIED);
done(); done();
...@@ -265,7 +276,8 @@ describe('AccessTokenTest',function(){ ...@@ -265,7 +276,8 @@ describe('AccessTokenTest',function(){
it('Test_revokeUserGrantedPermission_002', 0, async function(done){ it('Test_revokeUserGrantedPermission_002', 0, async function(done){
console.log("Test_revokeUserGrantedPermission_002 start"); console.log("Test_revokeUserGrantedPermission_002 start");
var atManager = abilityAccessCtrl.createAtManager(); var atManager = abilityAccessCtrl.createAtManager();
var result = await atManager.revokeUserGrantedPermission(tokenID, permissionNameSystem, PermissionFlag.PERMISSION_USER_SET); var result = await atManager.revokeUserGrantedPermission(tokenID, permissionNameSystem,
PermissionFlag.PERMISSION_USER_SET);
console.log("Test_revokeUserGrantedPermission_002 tokenID" + tokenID + "-" + result); console.log("Test_revokeUserGrantedPermission_002 tokenID" + tokenID + "-" + result);
expect(result).assertEqual(RESULT_FAIL); expect(result).assertEqual(RESULT_FAIL);
...@@ -280,12 +292,13 @@ describe('AccessTokenTest',function(){ ...@@ -280,12 +292,13 @@ describe('AccessTokenTest',function(){
it('Test_revokeUserGrantedPermission_003', 0, async function(done){ it('Test_revokeUserGrantedPermission_003', 0, async function(done){
console.log("Test_revokeUserGrantedPermission_003 start"); console.log("Test_revokeUserGrantedPermission_003 start");
var atManager = abilityAccessCtrl.createAtManager(); var atManager = abilityAccessCtrl.createAtManager();
atManager.revokeUserGrantedPermission(tokenID, permissionNameUser, PermissionFlag.PERMISSION_USER_SET,function(result){ atManager.revokeUserGrantedPermission(tokenID, permissionNameUser, PermissionFlag.PERMISSION_USER_SET,
console.log("Test_revokeUserGrantedPermission_003 tokenID"+ tokenID + "-" + result) function (result) {
console.log("Test_revokeUserGrantedPermission_003 tokenID" + tokenID + "-" + result)
expect(result).assertEqual(RESULT_SUCCESS); expect(result).assertEqual(RESULT_SUCCESS);
atManager.verifyAccessToken(tokenID, permissionNameUser).then(function(result1){ atManager.verifyAccessToken(tokenID, permissionNameUser).then(function (result1) {
console.log("Test_revokeUserGrantedPermission_003 tokenID"+ tokenID + "-result1" + result1) console.log("Test_revokeUserGrantedPermission_003 tokenID" + tokenID + "-result1" + result1)
expect(result1).assertEqual(GrantStatus.PERMISSION_DENIED); expect(result1).assertEqual(GrantStatus.PERMISSION_DENIED);
}); });
done(); done();
...@@ -300,7 +313,8 @@ describe('AccessTokenTest',function(){ ...@@ -300,7 +313,8 @@ describe('AccessTokenTest',function(){
it('Test_revokeUserGrantedPermission_004', 0, async function(done){ it('Test_revokeUserGrantedPermission_004', 0, async function(done){
console.log("Test_revokeUserGrantedPermission_004 start"); console.log("Test_revokeUserGrantedPermission_004 start");
var atManager = abilityAccessCtrl.createAtManager(); var atManager = abilityAccessCtrl.createAtManager();
var result = await atManager.revokeUserGrantedPermission(0, permissionNameUser, PermissionFlag.PERMISSION_USER_SET); var result = await atManager.revokeUserGrantedPermission(0, permissionNameUser,
PermissionFlag.PERMISSION_USER_SET);
console.log("Test_revokeUserGrantedPermission_004 tokenID" + tokenID + "-" + result); console.log("Test_revokeUserGrantedPermission_004 tokenID" + tokenID + "-" + result);
expect(result).assertEqual(RESULT_FAIL); expect(result).assertEqual(RESULT_FAIL);
...@@ -330,8 +344,11 @@ describe('AccessTokenTest',function(){ ...@@ -330,8 +344,11 @@ describe('AccessTokenTest',function(){
it('Test_revokeUserGrantedPermission_006', 0, async function(done){ it('Test_revokeUserGrantedPermission_006', 0, async function(done){
console.log("Test_revokeUserGrantedPermission_006 start"); console.log("Test_revokeUserGrantedPermission_006 start");
var atManager = abilityAccessCtrl.createAtManager(); var atManager = abilityAccessCtrl.createAtManager();
var permissionName = "ohos.permission.testtesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttest"; var permissionName = "ohos.permission.testtesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttest"
var result = await atManager.revokeUserGrantedPermission(tokenID, permissionName, PermissionFlag.PERMISSION_USER_SET); + "testtesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttest"
+ "testtesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttest";
var result = await atManager.revokeUserGrantedPermission(tokenID, permissionName,
PermissionFlag.PERMISSION_USER_SET);
console.log("Test_revokeUserGrantedPermission_006 tokenID" + tokenID + "-" + result); console.log("Test_revokeUserGrantedPermission_006 tokenID" + tokenID + "-" + result);
expect(result).assertEqual(RESULT_FAIL); expect(result).assertEqual(RESULT_FAIL);
...@@ -346,12 +363,13 @@ describe('AccessTokenTest',function(){ ...@@ -346,12 +363,13 @@ describe('AccessTokenTest',function(){
it('Test_getPermissionFlag_001', 0, async function(done){ it('Test_getPermissionFlag_001', 0, async function(done){
console.log("Test_getPermissionFlag_001 start"); console.log("Test_getPermissionFlag_001 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,
PermissionFlag.PERMISSION_USER_SET);
console.log("Test_getPermissionFlag_001 tokenID" + tokenID + "-" + result); console.log("Test_getPermissionFlag_001 tokenID" + tokenID + "-" + result);
expect(result).assertEqual(RESULT_SUCCESS); expect(result).assertEqual(RESULT_SUCCESS);
var result1 = await atManager.getPermissionFlags(tokenID, permissionNameUser); var result1 = await atManager.getPermissionFlags(tokenID, permissionNameUser);
console.log("Test_getPermissionFlag_001 tokenID"+ tokenID + "-result1" + result1) console.log("Test_getPermissionFlag_001 tokenID" + tokenID + "-result1" + result1)
expect(result1).assertEqual(PermissionFlag.PERMISSION_USER_SET); expect(result1).assertEqual(PermissionFlag.PERMISSION_USER_SET);
done(); done();
...@@ -395,7 +413,9 @@ describe('AccessTokenTest',function(){ ...@@ -395,7 +413,9 @@ describe('AccessTokenTest',function(){
it('Test_getPermissionFlag_004', 0, async function(done){ it('Test_getPermissionFlag_004', 0, async function(done){
console.log("Test_getPermissionFlag_004 start"); console.log("Test_getPermissionFlag_004 start");
var atManager = abilityAccessCtrl.createAtManager(); var atManager = abilityAccessCtrl.createAtManager();
var permissionName = "ohos.permission.testtesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttest"; var permissionName = "ohos.permission.testtesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttest"
+ "testtesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttest"
+ "testtesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttest";
var result = await atManager.getPermissionFlags(tokenID, permissionName); var result = await atManager.getPermissionFlags(tokenID, permissionName);
console.log("Test_getPermissionFlag_004 tokenID" + tokenID + "-" + result); console.log("Test_getPermissionFlag_004 tokenID" + tokenID + "-" + result);
expect(result).assertEqual(DEFAULT_PERMISSION_FALG); expect(result).assertEqual(DEFAULT_PERMISSION_FALG);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册