From 869db973e9f95aa084fcacc66dbbe92d41d3b2c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B4=94=E8=B6=85?= Date: Fri, 17 Mar 2023 01:25:12 +0000 Subject: [PATCH] =?UTF-8?q?[xts-acts][access=5Ftoken][master]=E8=A1=A5?= =?UTF-8?q?=E5=85=85xts=E7=94=A8=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 崔超 --- .../src/main/js/test/AccessToken.test.js | 128 +++++++++++++++++- 1 file changed, 126 insertions(+), 2 deletions(-) diff --git a/security/access_token/AccessTokenTest_Normal_js/src/main/js/test/AccessToken.test.js b/security/access_token/AccessTokenTest_Normal_js/src/main/js/test/AccessToken.test.js index f908a0913..0381566d1 100644 --- a/security/access_token/AccessTokenTest_Normal_js/src/main/js/test/AccessToken.test.js +++ b/security/access_token/AccessTokenTest_Normal_js/src/main/js/test/AccessToken.test.js @@ -65,7 +65,7 @@ describe('AccessTokenTest', function () { } } - /** + /** * @tc.number Test_verifyAccessToken_001 * @tc.name Test atManager.verifyAccessToken. * @tc.desc After the installation, user_grant permission is not granted by default(Promise). @@ -143,6 +143,39 @@ describe('AccessTokenTest', function () { done(); }) + /** + * @tc.number Test_verifyAccessToken_006 + * @tc.name Test atManager.verifyAccessToken. + * @tc.desc Test Error tokenID(Promise). + */ + it('Test_verifyAccessToken_006', 0, async function(done){ + console.info("Test_verifyAccessToken_006 start"); + var atManager = abilityAccessCtrl.createAtManager(); + var permissionName = "ohos.permission.GRANT_SENSITIVE_PERMISSIONS"; + + var result = await atManager.verifyAccessToken(1111111111, permissionName); + console.info("Test_verifyAccessToken_006 tokenID" + tokenID + "-" + result) + expect(result).assertEqual(GrantStatus.PERMISSION_DENIED); + + done(); + }) + + /** + * @tc.number Test_verifyAccessToken_007 + * @tc.name Test atManager.verifyAccessToken. + * @tc.desc Test Error permission(Promise). + */ + it('Test_verifyAccessToken_007', 0, async function(done){ + console.info("Test_verifyAccessToken_007 start"); + var atManager = abilityAccessCtrl.createAtManager(); + var permissionName = "ohos.permission.GRANT_SENSITIVE_PERMISSIO"; + + var result = await atManager.verifyAccessToken(tokenID, permissionName); + console.info("Test_verifyAccessToken_007 tokenID" + tokenID + "-" + result) + expect(result).assertEqual(GrantStatus.PERMISSION_DENIED); + + done(); + }) /** * @tc.number Test_verifyAccessTokenSync_0000 @@ -222,6 +255,42 @@ describe('AccessTokenTest', function () { } }) + /** + * @tc.number Test_verifyAccessTokenSync_0500 + * @tc.name Test_verifyAccessTokenSync_005. + * @tc.desc Test Error tokenID(Promise). + */ + it('Test_verifyAccessTokenSync_005', 0, function(){ + console.info("Test_verifyAccessTokenSync_005 start"); + var atManager = abilityAccessCtrl.createAtManager(); + var permissionName = "ohos.permission.GRANT_SENSITIVE_PERMISSIONS"; + + try { + atManager.verifyAccessTokenSync(1111111111, permissionName); + } catch (error) { + console.info("Test_verifyAccessTokenSync_005 tokenID" + JSON.stringify(error)) + expect(error.code).assertEqual(ERR_PARAM_INVALID); + } + }) + + /** + * @tc.number Test_verifyAccessTokenSync_0600 + * @tc.name Test_verifyAccessTokenSync_006. + * @tc.desc Test Error permission(Promise). + */ + it('Test_verifyAccessTokenSync_006', 0, function(){ + console.info("Test_verifyAccessTokenSync_006 start"); + var atManager = abilityAccessCtrl.createAtManager(); + var permissionName = "ohos.permission.GRANT_SENSITIVE_PERMISSIO"; + + try { + atManager.verifyAccessTokenSync(tokenID, permissionName); + } catch (error) { + console.info("Test_verifyAccessTokenSync_006 tokenID" + JSON.stringify(error)) + expect(error.code).assertEqual(ERR_PARAM_INVALID); + } + }) + /** * @tc.number Test_checkAccessToken_001 * @tc.name Test atManager.checkAccessToken. @@ -314,6 +383,61 @@ describe('AccessTokenTest', function () { }) /** + * @tc.number Test_checkAccessToken_006 + * @tc.name Test atManager.checkAccessToken. + * @tc.desc After the installation, user_grant permission is not granted by default(Promise). + */ + it('Test_checkAccessToken_006', 0, async function(done){ + console.info("Test_checkAccessToken_006 start"); + var atManager = abilityAccessCtrl.createAtManager(); + try { + atManager.checkAccessToken(tokenID, permissionNameUser); + } catch(error) { + console.info("Test_checkAccessToken_006 tokenID" + JSON.stringify(error)) + expect(error.code).assertEqual(GrantStatus.PERMISSION_DENIED); + } + done(); + }) + + /** + * @tc.number Test_checkAccessToken_007 + * @tc.name Test atManager.checkAccessToken. + * @tc.desc Test Error tokenID(Promise). + */ + it('Test_checkAccessToken_007', 0, async function(done){ + console.info("Test_checkAccessToken_007 start"); + var atManager = abilityAccessCtrl.createAtManager(); + var permissionName = "ohos.permission.GRANT_SENSITIVE_PERMISSIONS"; + + try { + atManager.checkAccessToken(1111111111, permissionName) + } catch (err) { + expect(err.code).assertEqual(ERR_PARAM_INVALID); + } + + done(); + }) + + /** + * @tc.number Test_checkAccessToken_008 + * @tc.name Test atManager.checkAccessToken. + * @tc.desc Test Error permission(Promise). + */ + it('Test_checkAccessToken_008', 0, async function(done){ + console.info("Test_checkAccessToken_008 start"); + var atManager = abilityAccessCtrl.createAtManager(); + var permissionName = "ohos.permission.GRANT_SENSITIVE_PERMISSIO"; + + try { + atManager.checkAccessToken(tokenID, permissionName) + } catch (err) { + expect(err.code).assertEqual(ERR_PARAM_INVALID); + } + + done(); + }) + + /** * @tc.number Test_requestPermissionsFromUser_0100 * @tc.name Test_requestPermissionsFromUser_001. * @tc.desc RequestPermissionsFromUser normal scenario(Promise). @@ -402,6 +526,6 @@ describe('AccessTokenTest', function () { } done(); }) - + }) } -- GitLab