From 252b8618f86b5400fa96703a9b1f9bc10c5b801d Mon Sep 17 00:00:00 2001 From: jinhaihw Date: Mon, 11 Jul 2022 15:20:27 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90security=E3=80=91=E3=80=90master?= =?UTF-8?q?=E3=80=91=E5=A2=9E=E5=8A=A0=20access=5Ftoken=20=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E5=A5=97verifyAccessTokenSync=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E7=94=A8=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: jinhaihw Change-Id: I16f380fe6a58ebd75595e3c3934c0b7004e29311 --- .../main/js/default/test/AccessToken.test.js | 69 +++++++++++++++++++ 1 file changed, 69 insertions(+) mode change 100755 => 100644 security/access_token/AccessTokenTest_Normal_js/src/main/js/default/test/AccessToken.test.js diff --git a/security/access_token/AccessTokenTest_Normal_js/src/main/js/default/test/AccessToken.test.js b/security/access_token/AccessTokenTest_Normal_js/src/main/js/default/test/AccessToken.test.js old mode 100755 new mode 100644 index e1aba5080..276ba4689 --- a/security/access_token/AccessTokenTest_Normal_js/src/main/js/default/test/AccessToken.test.js +++ b/security/access_token/AccessTokenTest_Normal_js/src/main/js/default/test/AccessToken.test.js @@ -142,4 +142,73 @@ describe('AccessTokenTest', function () { done(); }) + + /** + * @tc.number Test_verifyAccessTokenSync_0000 + * @tc.name Test_verifyAccessTokenSync_000. + * @tc.desc Test verifyAccessTokenSync, After the installation, user_grant permission is not granted by default. + */ + it('Test_verifyAccessTokenSync_000', 0, function(){ + console.info("Test_verifyAccessTokenSync_000 start"); + var atManager = abilityAccessCtrl.createAtManager(); + var result = atManager.verifyAccessTokenSync(tokenID, permissionNameUser); + console.info("Test_verifyAccessTokenSync_000 tokenID" + tokenID + "-" + result) + expect(result).assertEqual(GrantStatus.PERMISSION_DENIED); + }) + + /** + * @tc.number Test_verifyAccessTokenSync_0100 + * @tc.name Test_verifyAccessTokenSync_001. + * @tc.desc Test verifyAccessTokenSync, After the installation, system_grant permission is granted by default. + */ + it('Test_verifyAccessTokenSync_001', 0, function(){ + console.info("Test_verifyAccessTokenSync_001 start"); + var atManager = abilityAccessCtrl.createAtManager(); + var result = atManager.verifyAccessTokenSync(tokenID, permissionNameSystem); + console.info("Test_verifyAccessTokenSync_001 tokenID" + tokenID + "-" + result) + expect(result).assertEqual(GrantStatus.PERMISSION_GRANTED); + }) + + /** + * @tc.number Test_verifyAccessTokenSync_0200 + * @tc.name Test_verifyAccessTokenSync_002. + * @tc.desc Test verifyAccessTokenSync, invalid TokenID(0). + */ + 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); + }) + + /** + * @tc.number Test_verifyAccessTokenSync_0300 + * @tc.name Test_verifyAccessTokenSync_003. + * @tc.desc Test verifyAccessTokenSync, invalid permission(empty). + */ + 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); + }) + + /** + * @tc.number Test_verifyAccessTokenSync_0400 + * @tc.name Test_verifyAccessTokenSync_004. + * @tc.desc Test verifyAccessTokenSync, invalid permission(length exceeds 256). + */ + it('Test_verifyAccessTokenSync_004', 0, function(){ + console.info("Test_verifyAccessTokenSync_004 start"); + var atManager = abilityAccessCtrl.createAtManager(); + var permissionName = "ohos.permission.testtesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttest" + + "testtesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttest" + + "testtesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttest"; + + var result = atManager.verifyAccessTokenSync(tokenID, permissionName); + console.info("Test_verifyAccessTokenSync_004 tokenID" + tokenID + "-" + result) + expect(result).assertEqual(GrantStatus.PERMISSION_DENIED); + }) }) -- GitLab