未验证 提交 1f1ebe51 编写于 作者: O openharmony_ci 提交者: Gitee

!4118 security】【xts_m0614】修改access_token用例userId获取方式

Merge pull request !4118 from 金海/monthly_20220614
...@@ -41,8 +41,8 @@ describe('AccessTokenTest', function () { ...@@ -41,8 +41,8 @@ describe('AccessTokenTest', function () {
console.info('##########start AccessTokenTest'); console.info('##########start AccessTokenTest');
beforeAll(async function (done){ beforeAll(async function (done){
var accountManager = osAccount.getAccountManager(); var accountManager = osAccount.getAccountManager();
var localled = await accountManager.getOsAccountTypeFromProcess(); var userId = await accountManager.getOsAccountLocalIdFromProcess();
var appInfo = await bundle.getApplicationInfo('ohos.acts.security.access_token.normal', 0, localled); var appInfo = await bundle.getApplicationInfo('ohos.acts.security.access_token.normal', 0, userId);
tokenID = appInfo.accessTokenId; tokenID = appInfo.accessTokenId;
console.info("AccessTokenTest accessTokenId:" + appInfo.accessTokenId + ", name:" + appInfo.name console.info("AccessTokenTest accessTokenId:" + appInfo.accessTokenId + ", name:" + appInfo.name
+ ", bundleName:" + appInfo.bundleName) + ", bundleName:" + appInfo.bundleName)
...@@ -70,10 +70,10 @@ describe('AccessTokenTest', function () { ...@@ -70,10 +70,10 @@ describe('AccessTokenTest', function () {
* @tc.desc After the installation, user_grant permission is not granted by default(Promise). * @tc.desc After the installation, user_grant permission is not granted by default(Promise).
*/ */
it('Test_verifyAccessToken_001', 0, async function(done){ it('Test_verifyAccessToken_001', 0, async function(done){
console.log("Test_verifyAccessToken_001 start"); console.info("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.info("Test_verifyAccessToken_001 tokenID" + tokenID + "-" + result)
expect(result).assertEqual(GrantStatus.PERMISSION_DENIED); expect(result).assertEqual(GrantStatus.PERMISSION_DENIED);
done(); done();
...@@ -85,10 +85,10 @@ describe('AccessTokenTest', function () { ...@@ -85,10 +85,10 @@ describe('AccessTokenTest', function () {
* @tc.desc After the installation, system_grant permission is granted by default(Promise). * @tc.desc After the installation, system_grant permission is granted by default(Promise).
*/ */
it('Test_verifyAccessToken_002', 0, async function(done){ it('Test_verifyAccessToken_002', 0, async function(done){
console.log("Test_verifyAccessToken_002 start"); console.info("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.info("Test_verifyAccessToken_002 tokenID" + tokenID + "-" + result)
expect(result).assertEqual(GrantStatus.PERMISSION_GRANTED); expect(result).assertEqual(GrantStatus.PERMISSION_GRANTED);
done(); done();
...@@ -100,10 +100,10 @@ describe('AccessTokenTest', function () { ...@@ -100,10 +100,10 @@ describe('AccessTokenTest', function () {
* @tc.desc Test invalid TokenID(0)(Promise). * @tc.desc Test invalid TokenID(0)(Promise).
*/ */
it('Test_verifyAccessToken_003', 0, async function(done){ it('Test_verifyAccessToken_003', 0, async function(done){
console.log("Test_verifyAccessToken_003 start"); console.info("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.info("Test_verifyAccessToken_003 tokenID" + tokenID + "-" + result)
expect(result).assertEqual(GrantStatus.PERMISSION_DENIED); expect(result).assertEqual(GrantStatus.PERMISSION_DENIED);
done(); done();
...@@ -115,10 +115,10 @@ describe('AccessTokenTest', function () { ...@@ -115,10 +115,10 @@ describe('AccessTokenTest', function () {
* @tc.desc Test invalid permission(empty)(Promise). * @tc.desc Test invalid permission(empty)(Promise).
*/ */
it('Test_verifyAccessToken_004', 0, async function(done){ it('Test_verifyAccessToken_004', 0, async function(done){
console.log("Test_verifyAccessToken_004 start"); console.info("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.info("Test_verifyAccessToken_004 tokenID" + tokenID + "-" + result)
expect(result).assertEqual(GrantStatus.PERMISSION_DENIED); expect(result).assertEqual(GrantStatus.PERMISSION_DENIED);
done(); done();
...@@ -130,14 +130,14 @@ describe('AccessTokenTest', function () { ...@@ -130,14 +130,14 @@ describe('AccessTokenTest', function () {
* @tc.desc Test invalid permission(length exceeds 256)(Promise). * @tc.desc Test invalid permission(length exceeds 256)(Promise).
*/ */
it('Test_verifyAccessToken_005', 0, async function(done){ it('Test_verifyAccessToken_005', 0, async function(done){
console.log("Test_verifyAccessToken_005 start"); console.info("Test_verifyAccessToken_005 start");
var atManager = abilityAccessCtrl.createAtManager(); var atManager = abilityAccessCtrl.createAtManager();
var permissionName = "ohos.permission.testtesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttest" var permissionName = "ohos.permission.testtesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttest"
+ "testtesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttest" + "testtesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttest"
+ "testtesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttest"; + "testtesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttest";
var result = await atManager.verifyAccessToken(tokenID, permissionName); var result = await atManager.verifyAccessToken(tokenID, permissionName);
console.log("Test_verifyAccessToken_005 tokenID" + tokenID + "-" + result) console.info("Test_verifyAccessToken_005 tokenID" + tokenID + "-" + result)
expect(result).assertEqual(GrantStatus.PERMISSION_DENIED); expect(result).assertEqual(GrantStatus.PERMISSION_DENIED);
done(); done();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册