提交 5b5db901 编写于 作者: J jiyong_sd

Adapt to the new framework

Signed-off-by: Njiyong_sd <jiyong@huawei.com>
Change-Id: Ie0008df8d6ac327462ef88dfd3c5f0014c54187a
上级 1c57e4cb
...@@ -19,6 +19,7 @@ group("security") { ...@@ -19,6 +19,7 @@ group("security") {
deps = [ deps = [
"access_token/AccessTokenTest_Normal_js:ActsAccessTokenApiJSNormalTest", "access_token/AccessTokenTest_Normal_js:ActsAccessTokenApiJSNormalTest",
"cipher/datacipher:datacipher", "cipher/datacipher:datacipher",
"huks_standard",
"security_huks_basic", "security_huks_basic",
] ]
} }
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
# 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 permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
import("//test/xts/tools/build/suite.gni") import("//test/xts/tools/build/suite.gni")
...@@ -23,7 +23,9 @@ ohos_js_hap_suite("ActsAccessTokenApiJSNormalTest") { ...@@ -23,7 +23,9 @@ ohos_js_hap_suite("ActsAccessTokenApiJSNormalTest") {
hap_name = "ActsAccessTokenApiJSNormalTest" hap_name = "ActsAccessTokenApiJSNormalTest"
} }
ohos_js_assets("accesstoken_js_assets") { ohos_js_assets("accesstoken_js_assets") {
source_dir = "./src/main/js/default" js2abc = true
hap_profile = "./src/main/config.json"
source_dir = "./src/main/js"
} }
ohos_resources("accesstoken_resources") { ohos_resources("accesstoken_resources") {
sources = [ "./src/main/resources" ] sources = [ "./src/main/resources" ]
......
{ {
"description": "Configuration for osaccount js api Tests", "description": "Configuration for osaccount js api Tests",
"driver": { "driver": {
"type": "JSUnitTest", "type": "OHJSUnitTest",
"test-timeout": "600000", "test-timeout": "600000",
"package": "ohos.acts.security.access_token.normal", "shell-timeout": "600000",
"shell-timeout": "60000" "bundle-name": "ohos.acts.security.access_token.normal",
}, "package-name": "ohos.acts.security.access_token.normal",
"kits": [ "testcase-timeout": 10000
{ },
"test-file-name": [ "kits": [
"ActsAccessTokenApiJSNormalTest.hap" {
], "test-file-name": [
"type": "AppInstallKit", "ActsAccessTokenApiJSNormalTest.hap"
"cleanup-apps": true ],
} "type": "AppInstallKit",
] "cleanup-apps": true
}
]
} }
\ No newline at end of file
{ {
"app": { "app": {
"bundleName": "ohos.acts.security.access_token.normal", "bundleName": "ohos.acts.security.access_token.normal",
"vendor": "acts", "vendor": "acts",
"version": { "version": {
"code": 1000000, "code": 1000000,
"name": "1.0.0" "name": "1.0.0"
}, },
"apiVersion": { "apiVersion": {
"compatible": 4, "compatible": 4,
"target": 5, "target": 5,
"releaseType": "Release" "releaseType": "Release"
} }
}, },
"deviceConfig": {}, "deviceConfig": {},
"module": { "module": {
"package": "ohos.acts.security.access_token.normal", "package": "ohos.acts.security.access_token.normal",
"name": ".MyApplication", "name": ".entry",
"deviceType": [ "deviceType": [
"phone" "phone"
], ],
"distro": { "distro": {
"deliveryWithInstall": true, "deliveryWithInstall": true,
"moduleName": "entry", "moduleName": "entry",
"moduleType": "entry" "moduleType": "entry"
}, },
"definePermissions": [ "definePermissions": [
{ {
"name": "ohos.permission.ALPHA", "name": "ohos.permission.ALPHA",
"grantMode": "user_grant", "grantMode": "user_grant",
"availableLevel": "system_basic", "availableLevel": "system_basic",
"provisionEnable": true, "provisionEnable": true,
"distributedSceneEnable": true, "distributedSceneEnable": true,
"label": "ALPHA label", "label": "ALPHA label",
"description": "ALPHA description" "description": "ALPHA description"
}, },
{ {
"name": "ohos.permission.BETA", "name": "ohos.permission.BETA",
"grantMode": "system_grant", "grantMode": "system_grant",
"availableLevel": "system_basic", "availableLevel": "system_basic",
"provisionEnable": true, "provisionEnable": true,
"distributedSceneEnable": true, "distributedSceneEnable": true,
"label": "BETA label", "label": "BETA label",
"description": "BETA description" "description": "BETA description"
} }
], ],
"reqPermissions": [ "reqPermissions": [
{ {
"name": "ohos.permission.ALPHA", "name": "ohos.permission.ALPHA",
"reason": "use ohos.permission.ALPHA" "reason": "use ohos.permission.ALPHA"
}, },
{ {
"name": "ohos.permission.BETA", "name": "ohos.permission.BETA",
"reason": "use ohos.permission.BETA" "reason": "use ohos.permission.BETA"
}, },
{ {
"name": "ohos.permission.GRANT_SENSITIVE_PERMISSIONS", "name": "ohos.permission.GRANT_SENSITIVE_PERMISSIONS",
"reason": "use ohos.permission.GRANT_SENSITIVE_PERMISSIONS" "reason": "use ohos.permission.GRANT_SENSITIVE_PERMISSIONS"
}, },
{ {
"name": "ohos.permission.REVOKE_SENSITIVE_PERMISSIONS", "name": "ohos.permission.REVOKE_SENSITIVE_PERMISSIONS",
"reason": "use ohos.permission.REVOKE_SENSITIVE_PERMISSIONS" "reason": "use ohos.permission.REVOKE_SENSITIVE_PERMISSIONS"
}, },
{ {
"name": "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED" "name": "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED"
}, },
{ {
"name": "ohos.permission.GET_BUNDLE_INFO" "name": "ohos.permission.GET_BUNDLE_INFO"
} }
], ],
"abilities": [ "abilities": [
{ {
"visible":true, "skills": [
"skills": [ {
{ "entities": [
"entities": [ "entity.system.home"
"entity.system.home" ],
], "actions": [
"actions": [ "action.system.home"
"action.system.home" ]
] }
} ],
], "orientation": "unspecified",
"name": "ohos.acts.security.access_token.normal.MainAbility", "formsEnabled": false,
"icon": "$media:icon", "name": ".MainAbility",
"description": "$string:mainability_description", "srcLanguage": "js",
"label": "$string:app_name", "srcPath": "MainAbility",
"type": "page", "icon": "$media:icon",
"launchType": "standard" "description": "$string:MainAbility_desc",
} "label": "$string:MainAbility_label",
], "type": "page",
"js": [ "visible": true,
{ "launchType": "standard"
"pages": [ },
"pages/index/index" {
], "orientation": "unspecified",
"name": "default", "formsEnabled": false,
"window": { "name": ".TestAbility",
"designWidth": 720, "srcLanguage": "js",
"autoDesignWidth": false "srcPath": "TestAbility",
} "icon": "$media:icon",
} "description": "$string:TestAbility_desc",
] "label": "$string:TestAbility_label",
} "type": "page",
} "visible": true,
"launchType": "standard"
}
],
"js": [
{
"pages": [
"pages/index/index"
],
"name": "default",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
},
{
"pages": [
"pages/index/index"
],
"name": ".TestAbility",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
}
],
"testRunner": {
"name": "OpenHarmonyTestRunner",
"srcPath": "TestRunner"
},
"mainAbility": ".MainAbility",
"srcPath": ""
}
}
\ No newline at end of file
/* /*
* 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 in compliance with the License. * you may not use this file except in 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 permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
const injectRef = Object.getPrototypeOf(global) || global
import app from '@system.app' injectRef.regeneratorRuntime = require('@babel/runtime/regenerator')
import {Core, ExpectExtend} from 'deccjsunit/index' export default {
data: {
const injectRef = Object.getPrototypeOf(global) || global title: ''
injectRef.regeneratorRuntime = require('@babel/runtime/regenerator') },
onInit() {
export default { this.title = this.$t('strings.world');
data: { },
title: '' onShow() {
}, console.info('onShow finish')
onInit() { },
this.title = this.$t('strings.world'); onReady() {
}, },
onShow() { }
console.info('onShow finish')
const core = Core.getInstance()
const expectExtend = new ExpectExtend({
'id':'extend'
})
core.addService('expect',expectExtend)
core.init()
const configService = core.getDefaultService('config')
this.timeout = 10000
configService.setConfig(this)
require('../../test/List.test')
core.execute()
},
onReady() {
},
}
/* /*
* Copyright (C) 2021 Huawei Device Co., Ltd. * Copyright (c) 2022 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 in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
...@@ -13,28 +13,19 @@ ...@@ -13,28 +13,19 @@
* limitations under the License. * limitations under the License.
*/ */
import { Core, ExpectExtend } from 'deccjsunit/index'; import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import { Hypium } from '@ohos/hypium'
import testsuite from '../test/List.test'
export default { export default {
data: { onCreate() {
title: '', console.info('TestApplication onCreate')
}, var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
onInit() { var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
this.title = this.$t('strings.world'); console.info('start run testcase!!!')
}, Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
onShow() { },
const core = Core.getInstance(); onDestroy() {
const expectExtend = new ExpectExtend({ console.info("TestApplication onDestroy");
id: 'extend', }
});
core.addService('expect', expectExtend);
core.init();
const configService = core.getDefaultService('config');
this.timeout = 1500000;
configService.setConfig(this);
console.log('test start');
require('../../../test/List.test');
core.execute();
},
onReady() {},
}; };
{
"strings": {
"hello": "Hello",
"world": "World"
},
"Files": {
}
}
\ No newline at end of file
{
"strings": {
"hello": "您好",
"world": "世界"
},
"Files": {
}
}
\ No newline at end of file
.container {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
left: 0px;
top: 0px;
width: 100%;
height: 100%;
}
.title {
font-size: 60px;
text-align: center;
width: 100%;
height: 40%;
margin: 10px;
}
@media screen and (device-type: phone) and (orientation: landscape) {
.title {
font-size: 60px;
}
}
@media screen and (device-type: tablet) and (orientation: landscape) {
.title {
font-size: 100px;
}
}
\ No newline at end of file
<div class="container">
<text class="title">
{{ $t('strings.hello') }} {{ title }}
</text>
</div>
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export default {
data: {
title: ""
},
onInit() {
this.title = this.$t('strings.world');
}
}
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
function translateParamsToString(parameters) {
const keySet = new Set([
'-s class', '-s notClass', '-s suite', '-s itName',
'-s level', '-s testType', '-s size', '-s timeout',
'-s package', '-s dryRun'
])
let targetParams = '';
for (const key in parameters) {
if (keySet.has(key)) {
targetParams += ' ' + key + ' ' + parameters[key]
}
}
return targetParams.trim()
}
export default {
onPrepare() {
console.info('OpenHarmonyTestRunner OnPrepare')
},
onRun() {
console.log('OpenHarmonyTestRunner onRun run')
var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var testAbilityName = abilityDelegatorArguments.parameters['-p'] + '.TestAbility'
var cmd = 'aa start -d 0 -a ' + testAbilityName + ' -b ' + abilityDelegatorArguments.bundleName
cmd += ' ' + translateParamsToString(abilityDelegatorArguments.parameters)
var debug = abilityDelegatorArguments.parameters["-D"]
console.info('debug value : '+debug)
if (debug == 'true')
{
cmd += ' -D'
}
console.info('cmd : '+cmd)
abilityDelegator.executeShellCommand(cmd, (err, data) => {
console.info('executeShellCommand : err : ' + JSON.stringify(err));
console.info('executeShellCommand : data : ' + data.stdResult);
console.info('executeShellCommand : data : ' + data.exitCode);
})
}
};
/* /*
* 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, beforeAll, afterEach, it, expect} from 'deccjsunit/index' import {describe, beforeAll, afterEach, it, expect} from '@ohos/hypium'
import abilityAccessCtrl from '@ohos.abilityAccessCtrl' import abilityAccessCtrl from '@ohos.abilityAccessCtrl'
import bundle from '@ohos.bundle' import bundle from '@ohos.bundle'
import osAccount from '@ohos.account.osAccount' import osAccount from '@ohos.account.osAccount'
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 () { export default function AccessTokenTest() {
console.info('##########start AccessTokenTest'); describe('AccessTokenTest', function () {
beforeAll(async function (done){ console.info('##########start AccessTokenTest');
var accountManager = osAccount.getAccountManager(); beforeAll(async function (done){
var userId = await accountManager.getOsAccountLocalIdFromProcess(); var accountManager = osAccount.getAccountManager();
var appInfo = await bundle.getApplicationInfo('ohos.acts.security.access_token.normal', 0, userId); var userId = await accountManager.getOsAccountLocalIdFromProcess();
tokenID = appInfo.accessTokenId; var appInfo = await bundle.getApplicationInfo('ohos.acts.security.access_token.normal', 0, userId);
console.info("AccessTokenTest accessTokenId:" + appInfo.accessTokenId + ", name:" + appInfo.name tokenID = appInfo.accessTokenId;
+ ", bundleName:" + appInfo.bundleName) console.info("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) {
} next = (new Date()).getTime();
} }
}
/**
* @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.info("Test_verifyAccessToken_001 start"); it('Test_verifyAccessToken_001', 0, async function(done){
var atManager = abilityAccessCtrl.createAtManager(); console.info("Test_verifyAccessToken_001 start");
var result = await atManager.verifyAccessToken(tokenID, permissionNameUser); var atManager = abilityAccessCtrl.createAtManager();
console.info("Test_verifyAccessToken_001 tokenID" + tokenID + "-" + result) var result = await atManager.verifyAccessToken(tokenID, permissionNameUser);
expect(result).assertEqual(GrantStatus.PERMISSION_DENIED); console.info("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 granted by default(Promise). * @tc.name Test atManager.verifyAccessToken.
*/ * @tc.desc After the installation, system_grant permission is granted by default(Promise).
it('Test_verifyAccessToken_002', 0, async function(done){ */
console.info("Test_verifyAccessToken_002 start"); it('Test_verifyAccessToken_002', 0, async function(done){
var atManager = abilityAccessCtrl.createAtManager(); console.info("Test_verifyAccessToken_002 start");
var result = await atManager.verifyAccessToken(tokenID, permissionNameSystem); var atManager = abilityAccessCtrl.createAtManager();
console.info("Test_verifyAccessToken_002 tokenID" + tokenID + "-" + result) var result = await atManager.verifyAccessToken(tokenID, permissionNameSystem);
expect(result).assertEqual(GrantStatus.PERMISSION_GRANTED); console.info("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.info("Test_verifyAccessToken_003 start"); it('Test_verifyAccessToken_003', 0, async function(done){
var atManager = abilityAccessCtrl.createAtManager(); console.info("Test_verifyAccessToken_003 start");
var result = await atManager.verifyAccessToken(0, permissionNameUser); var atManager = abilityAccessCtrl.createAtManager();
console.info("Test_verifyAccessToken_003 tokenID" + tokenID + "-" + result) var result = await atManager.verifyAccessToken(0, permissionNameUser);
expect(result).assertEqual(GrantStatus.PERMISSION_DENIED); console.info("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.info("Test_verifyAccessToken_004 start"); it('Test_verifyAccessToken_004', 0, async function(done){
var atManager = abilityAccessCtrl.createAtManager(); console.info("Test_verifyAccessToken_004 start");
var result = await atManager.verifyAccessToken(tokenID, ""); var atManager = abilityAccessCtrl.createAtManager();
console.info("Test_verifyAccessToken_004 tokenID" + tokenID + "-" + result) var result = await atManager.verifyAccessToken(tokenID, "");
expect(result).assertEqual(GrantStatus.PERMISSION_DENIED); console.info("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.info("Test_verifyAccessToken_005 start"); it('Test_verifyAccessToken_005', 0, async function(done){
var atManager = abilityAccessCtrl.createAtManager(); console.info("Test_verifyAccessToken_005 start");
var permissionName = "ohos.permission.testtesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttest" var atManager = abilityAccessCtrl.createAtManager();
+ "testtesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttest" var permissionName = "ohos.permission.testtesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttest"
+ "testtesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttest"; + "testtesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttest"
+ "testtesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttest";
var result = await atManager.verifyAccessToken(tokenID, permissionName);
console.info("Test_verifyAccessToken_005 tokenID" + tokenID + "-" + result) var result = await atManager.verifyAccessToken(tokenID, permissionName);
expect(result).assertEqual(GrantStatus.PERMISSION_DENIED); console.info("Test_verifyAccessToken_005 tokenID" + tokenID + "-" + result)
expect(result).assertEqual(GrantStatus.PERMISSION_DENIED);
done();
}) done();
})
/**
* @tc.number Test_verifyAccessTokenSync_0000 /**
* @tc.name Test_verifyAccessTokenSync_000. * @tc.number Test_verifyAccessTokenSync_0000
* @tc.desc Test verifyAccessTokenSync, After the installation, user_grant permission is not granted by default. * @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"); it('Test_verifyAccessTokenSync_000', 0, function(){
var atManager = abilityAccessCtrl.createAtManager(); console.info("Test_verifyAccessTokenSync_000 start");
var result = atManager.verifyAccessTokenSync(tokenID, permissionNameUser); var atManager = abilityAccessCtrl.createAtManager();
console.info("Test_verifyAccessTokenSync_000 tokenID" + tokenID + "-" + result) var result = atManager.verifyAccessTokenSync(tokenID, permissionNameUser);
expect(result).assertEqual(GrantStatus.PERMISSION_DENIED); 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.number Test_verifyAccessTokenSync_0100
* @tc.desc Test verifyAccessTokenSync, After the installation, system_grant permission is granted by default. * @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"); it('Test_verifyAccessTokenSync_001', 0, function(){
var atManager = abilityAccessCtrl.createAtManager(); console.info("Test_verifyAccessTokenSync_001 start");
var result = atManager.verifyAccessTokenSync(tokenID, permissionNameSystem); var atManager = abilityAccessCtrl.createAtManager();
console.info("Test_verifyAccessTokenSync_001 tokenID" + tokenID + "-" + result) var result = atManager.verifyAccessTokenSync(tokenID, permissionNameSystem);
expect(result).assertEqual(GrantStatus.PERMISSION_GRANTED); 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.number Test_verifyAccessTokenSync_0200
* @tc.desc Test verifyAccessTokenSync, invalid TokenID(0). * @tc.name Test_verifyAccessTokenSync_002.
*/ * @tc.desc Test verifyAccessTokenSync, invalid TokenID(0).
it('Test_verifyAccessTokenSync_002', 0, function(){ */
console.info("Test_verifyAccessTokenSync_002 start"); it('Test_verifyAccessTokenSync_002', 0, function(){
var atManager = abilityAccessCtrl.createAtManager(); console.info("Test_verifyAccessTokenSync_002 start");
var result = atManager.verifyAccessTokenSync(0, permissionNameUser); var atManager = abilityAccessCtrl.createAtManager();
console.info("Test_verifyAccessTokenSync_002 tokenID" + tokenID + "-" + result) var result = atManager.verifyAccessTokenSync(0, permissionNameUser);
expect(result).assertEqual(GrantStatus.PERMISSION_DENIED); 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.number Test_verifyAccessTokenSync_0300
* @tc.desc Test verifyAccessTokenSync, invalid permission(empty). * @tc.name Test_verifyAccessTokenSync_003.
*/ * @tc.desc Test verifyAccessTokenSync, invalid permission(empty).
it('Test_verifyAccessTokenSync_003', 0, function(){ */
console.info("Test_verifyAccessTokenSync_003 start"); it('Test_verifyAccessTokenSync_003', 0, function(){
var atManager = abilityAccessCtrl.createAtManager(); console.info("Test_verifyAccessTokenSync_003 start");
var result = atManager.verifyAccessTokenSync(tokenID, ""); var atManager = abilityAccessCtrl.createAtManager();
console.info("Test_verifyAccessTokenSync_003 tokenID" + tokenID + "-" + result) var result = atManager.verifyAccessTokenSync(tokenID, "");
expect(result).assertEqual(GrantStatus.PERMISSION_DENIED); 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.number Test_verifyAccessTokenSync_0400
* @tc.desc Test verifyAccessTokenSync, invalid permission(length exceeds 256). * @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"); it('Test_verifyAccessTokenSync_004', 0, function(){
var atManager = abilityAccessCtrl.createAtManager(); console.info("Test_verifyAccessTokenSync_004 start");
var permissionName = "ohos.permission.testtesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttest" var atManager = abilityAccessCtrl.createAtManager();
+ "testtesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttest" var permissionName = "ohos.permission.testtesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttest"
+ "testtesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttest"; + "testtesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttest"
+ "testtesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttest";
var result = atManager.verifyAccessTokenSync(tokenID, permissionName);
console.info("Test_verifyAccessTokenSync_004 tokenID" + tokenID + "-" + result) var result = atManager.verifyAccessTokenSync(tokenID, permissionName);
expect(result).assertEqual(GrantStatus.PERMISSION_DENIED); console.info("Test_verifyAccessTokenSync_004 tokenID" + tokenID + "-" + result)
}) expect(result).assertEqual(GrantStatus.PERMISSION_DENIED);
}) })
})
}
...@@ -12,5 +12,7 @@ ...@@ -12,5 +12,7 @@
* 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.
*/ */
import AccessTokenTest from './AccessToken.test.js'
require('./AccessToken.test.js') export default function testsuite() {
\ No newline at end of file AccessTokenTest()
}
{ {
"string": [ "string": [
{ {
"name": "app_name", "name": "app_name",
"value": "AccessTokenJsTestNormal" "value": "AccessTokenJsTestNormal"
}, },
{ {
"name": "mainability_description", "name": "mainability_description",
"value": "JS_Phone_Empty Feature Ability" "value": "JS_Phone_Empty Feature Ability"
} },
] {
"name": "MainAbility_desc",
"value": "description"
},
{
"name": "MainAbility_label",
"value": "label"
},
{
"name": "TestAbility_desc",
"value": "description"
},
{
"name": "TestAbility_label",
"value": "label"
}
]
} }
\ No newline at end of file
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
import("//test/xts/tools/build/suite.gni") import("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("ActsSecurityCipherTest") { ohos_js_hap_suite("ActsSecurityCipherTest") {
hap_profile = "./entry/src/main/config.json" hap_profile = "./src/main/config.json"
deps = [ deps = [
":huks_js_assets", ":huks_js_assets",
":huks_js_resources", ":huks_js_resources",
...@@ -22,9 +22,11 @@ ohos_js_hap_suite("ActsSecurityCipherTest") { ...@@ -22,9 +22,11 @@ ohos_js_hap_suite("ActsSecurityCipherTest") {
hap_name = "ActsSecurityCipherTest" hap_name = "ActsSecurityCipherTest"
} }
ohos_js_assets("huks_js_assets") { ohos_js_assets("huks_js_assets") {
source_dir = "./entry/src/main/js/MainAbility" js2abc = true
hap_profile = "./src/main/config.json"
source_dir = "./src/main/js"
} }
ohos_resources("huks_js_resources") { ohos_resources("huks_js_resources") {
sources = [ "./entry/src/main/js/resources" ] sources = [ "./src/main/resources" ]
hap_profile = "./entry/src/main/config.json" hap_profile = "./src/main/config.json"
} }
{ {
"description": "Configuration for keystoretest js api Tests", "description": "Configuration for keystoretest js api Tests",
"driver": { "driver": {
"type": "JSUnitTest", "type": "OHJSUnitTest",
"test-timeout": "300000", "test-timeout": "300000",
"package": "com.huawei.keystoretest", "shell-timeout": "300000",
"shell-timeout": "60000" "bundle-name": "com.huawei.keystoretest",
}, "package-name": "com.huawei.keystoretest",
"kits": [ "testcase-timeout": 1500000
{ },
"test-file-name": [ "kits": [
"ActsSecurityCipherTest.hap" {
], "test-file-name": [
"type": "AppInstallKit", "ActsSecurityCipherTest.hap"
"cleanup-apps": true ],
} "type": "AppInstallKit",
] "cleanup-apps": true
}
]
} }
\ No newline at end of file
{
"app": {
"bundleName": "com.huawei.keystoretest",
"vendor": "huawei",
"version": {
"code": 1,
"name": "1.0.0"
},
"apiVersion": {
"compatible": 6,
"target": 6,
"releaseType": "Beta1"
}
},
"deviceConfig": {},
"module": {
"package": "com.huawei.keystoretest",
"name": ".MyApplication",
"mainAbility": "com.huawei.keystoretest.MainAbility",
"deviceType": [
"phone"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry",
"installationFree": true
},
"abilities": [
{
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"name": "com.huawei.keystoretest.MainAbility",
"icon": "$media:icon",
"description": "$string:mainability_description",
"label": "$string:entry_MainAbility",
"type": "page",
"launchType": "standard",
"visible": true,
"isVisible": "true"
}
],
"js": [
{
"pages": [
"pages/index/index"
],
"name": "default",
"window": {
"designWidth": 720,
"autoDesignWidth": true
}
}
]
}
}
\ No newline at end of file
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { Core, ExpectExtend } from 'deccjsunit/index';
export default {
data: {
title: '',
},
onInit() {
this.title = this.$t('strings.world');
},
onShow() {
const core = Core.getInstance();
const expectExtend = new ExpectExtend({
id: 'extend',
});
core.addService('expect', expectExtend);
core.init();
const configService = core.getDefaultService('config');
this.timeout = 1500000;
configService.setConfig(this);
console.log('test start');
require('../../../test/List.test');
core.execute();
},
onReady() {},
};
{
"app": {
"bundleName": "com.huawei.keystoretest",
"vendor": "huawei",
"version": {
"code": 1,
"name": "1.0.0"
},
"apiVersion": {
"compatible": 6,
"target": 6,
"releaseType": "Beta1"
}
},
"deviceConfig": {},
"module": {
"package": "com.huawei.keystoretest",
"name": ".entry",
"mainAbility": ".MainAbility",
"deviceType": [
"phone"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry",
"installationFree": true
},
"abilities": [
{
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"orientation": "unspecified",
"formsEnabled": false,
"name": ".MainAbility",
"srcLanguage": "js",
"srcPath": "MainAbility",
"icon": "$media:icon",
"description": "$string:MainAbility_desc",
"label": "$string:MainAbility_label",
"type": "page",
"visible": true,
"launchType": "standard"
},
{
"orientation": "unspecified",
"formsEnabled": false,
"name": ".TestAbility",
"srcLanguage": "js",
"srcPath": "TestAbility",
"icon": "$media:icon",
"description": "$string:TestAbility_desc",
"label": "$string:TestAbility_label",
"type": "page",
"visible": true,
"launchType": "standard"
}
],
"js": [
{
"pages": [
"pages/index/index"
],
"name": "default",
"window": {
"designWidth": 720,
"autoDesignWidth": true
}
},
{
"pages": [
"pages/index/index"
],
"name": ".TestAbility",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
}
],
"testRunner": {
"name": "OpenHarmonyTestRunner",
"srcPath": "TestRunner"
},
"srcPath": ""
}
}
\ No newline at end of file
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export default {
data: {
title: '',
},
onInit() {
this.title = this.$t('strings.world');
},
onShow() {
},
onReady() {},
};
/* /*
* Copyright (C) 2021 Huawei Device Co., Ltd. * Copyright (c) 2022 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 in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
...@@ -13,28 +13,19 @@ ...@@ -13,28 +13,19 @@
* limitations under the License. * limitations under the License.
*/ */
import { Core, ExpectExtend } from 'deccjsunit/index'; import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import { Hypium } from '@ohos/hypium'
import testsuite from '../test/List.test'
export default { export default {
data: { onCreate() {
title: '', console.info('TestApplication onCreate')
}, var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
onInit() { var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
this.title = this.$t('strings.world'); console.info('start run testcase!!!')
}, Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
onShow() { },
const core = Core.getInstance(); onDestroy() {
const expectExtend = new ExpectExtend({ console.info("TestApplication onDestroy");
id: 'extend', }
});
core.addService('expect', expectExtend);
core.init();
const configService = core.getDefaultService('config');
this.timeout = 1500000;
configService.setConfig(this);
console.log('test start');
require('../../../test/List.test');
core.execute();
},
onReady() {},
}; };
{
"strings": {
"hello": "Hello",
"world": "World"
},
"Files": {
}
}
\ No newline at end of file
{
"strings": {
"hello": "您好",
"world": "世界"
},
"Files": {
}
}
\ No newline at end of file
.container {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
left: 0px;
top: 0px;
width: 100%;
height: 100%;
}
.title {
font-size: 60px;
text-align: center;
width: 100%;
height: 40%;
margin: 10px;
}
@media screen and (device-type: phone) and (orientation: landscape) {
.title {
font-size: 60px;
}
}
@media screen and (device-type: tablet) and (orientation: landscape) {
.title {
font-size: 100px;
}
}
\ No newline at end of file
<div class="container">
<text class="title">
{{ $t('strings.hello') }} {{ title }}
</text>
</div>
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export default {
data: {
title: ""
},
onInit() {
this.title = this.$t('strings.world');
}
}
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
function translateParamsToString(parameters) {
const keySet = new Set([
'-s class', '-s notClass', '-s suite', '-s itName',
'-s level', '-s testType', '-s size', '-s timeout',
'-s package', '-s dryRun'
])
let targetParams = '';
for (const key in parameters) {
if (keySet.has(key)) {
targetParams += ' ' + key + ' ' + parameters[key]
}
}
return targetParams.trim()
}
export default {
onPrepare() {
console.info('OpenHarmonyTestRunner OnPrepare')
},
onRun() {
console.log('OpenHarmonyTestRunner onRun run')
var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var testAbilityName = abilityDelegatorArguments.parameters['-p'] + '.TestAbility'
var cmd = 'aa start -d 0 -a ' + testAbilityName + ' -b ' + abilityDelegatorArguments.bundleName
cmd += ' ' + translateParamsToString(abilityDelegatorArguments.parameters)
var debug = abilityDelegatorArguments.parameters["-D"]
console.info('debug value : '+debug)
if (debug == 'true')
{
cmd += ' -D'
}
console.info('cmd : '+cmd)
abilityDelegator.executeShellCommand(cmd, (err, data) => {
console.info('executeShellCommand : err : ' + JSON.stringify(err));
console.info('executeShellCommand : data : ' + data.stdResult);
console.info('executeShellCommand : data : ' + data.exitCode);
})
}
};
...@@ -12,9 +12,10 @@ ...@@ -12,9 +12,10 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index' import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
import cipher from '@system.cipher'; import cipher from '@system.cipher';
describe('cipher1.test.js', function () { export default function cipher1_test() {
describe('cipher1_test', function () {
let plainTextRsa; let plainTextRsa;
let cipherTextRsa; let cipherTextRsa;
let rsaPublicKey; let rsaPublicKey;
...@@ -433,4 +434,4 @@ describe('cipher1.test.js', function () { ...@@ -433,4 +434,4 @@ describe('cipher1.test.js', function () {
} }
}); });
}); });
}); });}
\ No newline at end of file
...@@ -12,9 +12,10 @@ ...@@ -12,9 +12,10 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index' import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
import cipher from '@system.cipher'; import cipher from '@system.cipher';
describe('cipher2.test.js', function () { export default function cipher2_test() {
describe('cipher2_test', function () {
let plainTextRsa; let plainTextRsa;
let cipherTextRsa; let cipherTextRsa;
let rsaPublicKey; let rsaPublicKey;
...@@ -415,4 +416,4 @@ describe('cipher2.test.js', function () { ...@@ -415,4 +416,4 @@ describe('cipher2.test.js', function () {
} }
}); });
}); });
}); });}
\ No newline at end of file
...@@ -12,9 +12,10 @@ ...@@ -12,9 +12,10 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index' import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
import cipher from '@system.cipher'; import cipher from '@system.cipher';
describe('hitscipher.test.js', function () { export default function hitscipher_test() {
describe('hitscipher_test', function () {
let plainTextRsa; let plainTextRsa;
let cipherTextRsa; let cipherTextRsa;
let rsaPublicKey; let rsaPublicKey;
...@@ -237,4 +238,4 @@ describe('hitscipher.test.js', function () { ...@@ -237,4 +238,4 @@ describe('hitscipher.test.js', function () {
expect(cipherResultFail).assertTrue(); expect(cipherResultFail).assertTrue();
console.log(`cipher.rsa performance time: ${timestamp2-timestamp1}`); console.log(`cipher.rsa performance time: ${timestamp2-timestamp1}`);
}); });
}); });}
\ No newline at end of file
/* /*
* Copyright (C) 2021 Huawei Device Co., Ltd. * Copyright (C) 2022 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 in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
...@@ -13,7 +13,11 @@ ...@@ -13,7 +13,11 @@
* limitations under the License. * limitations under the License.
*/ */
require('./Cipher/securityHuksExportSupportJsunit.test.js'); import cipher1_test from './Agree/cipher1.test.js'
require('./Cipher/SecurityHuksAESBasicCallbackJsunit.test.js'); import cipher2_test from './Agree/cipher2.test.js'
require('./Cipher/SecurityHuksRSABasicCallbackJsunit.test.js'); import hitscipher_test from './Agree/hitscipher.test.js'
require('./Cipher/SecurityHuksSM4BasicCallbackJsunit.test.js'); export default function testsuite() {
cipher1_test()
cipher2_test()
hitscipher_test()
}
...@@ -7,6 +7,22 @@ ...@@ -7,6 +7,22 @@
{ {
"name": "mainability_description", "name": "mainability_description",
"value": "JS_Empty Ability" "value": "JS_Empty Ability"
} },
{
"name": "MainAbility_desc",
"value": "description"
},
{
"name": "MainAbility_label",
"value": "label"
},
{
"name": "TestAbility_desc",
"value": "description"
},
{
"name": "TestAbility_label",
"value": "label"
}
] ]
} }
\ No newline at end of file
...@@ -9,12 +9,12 @@ ...@@ -9,12 +9,12 @@
# 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 permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
import("//test/xts/tools/build/suite.gni") import("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("ActsHuksAbnormalTest") { ohos_js_hap_suite("ActsHuksAbnormalTest") {
hap_profile = "./entry/src/main/config.json" hap_profile = "./src/main/config.json"
deps = [ deps = [
":hjs_demo_js_assets", ":hjs_demo_js_assets",
":hjs_demo_resources", ":hjs_demo_resources",
...@@ -23,9 +23,11 @@ ohos_js_hap_suite("ActsHuksAbnormalTest") { ...@@ -23,9 +23,11 @@ ohos_js_hap_suite("ActsHuksAbnormalTest") {
hap_name = "ActsHuksAbnormalTest" hap_name = "ActsHuksAbnormalTest"
} }
ohos_js_assets("hjs_demo_js_assets") { ohos_js_assets("hjs_demo_js_assets") {
source_dir = "./entry/src/main/js/default" js2abc = true
hap_profile = "./src/main/config.json"
source_dir = "./src/main/js"
} }
ohos_resources("hjs_demo_resources") { ohos_resources("hjs_demo_resources") {
sources = [ "./entry/src/main/js/resources" ] sources = [ "./src/main/resources" ]
hap_profile = "./entry/src/main/config.json" hap_profile = "./src/main/config.json"
} }
{ {
"description": "Configuration for algorithm completion test", "description": "Configuration for algorithm completion test",
"driver": { "driver": {
"type": "JSUnitTest", "type": "OHJSUnitTest",
"test-timeout": "7200000", "test-timeout": "7200000",
"package": "com.example.err", "shell-timeout": "7200000",
"shell-timeout": "60000" "bundle-name": "com.example.err",
}, "package-name": "com.example.err",
"kits": [ "testcase-timeout": 1000000
{ },
"test-file-name": [ "kits": [
"ActsHuksAbnormalTest.hap" {
], "test-file-name": [
"type": "AppInstallKit", "ActsHuksAbnormalTest.hap"
"cleanup-apps": true ],
} "type": "AppInstallKit",
] "cleanup-apps": true
} }
]
}
\ No newline at end of file
{
"app": {
"bundleName": "com.example.err",
"vendor": "example",
"version": {
"code": 1,
"name": "1.0.0"
},
"apiVersion": {
"compatible": 4,
"target": 5,
"releaseType": "Beta1"
}
},
"deviceConfig": {},
"module": {
"package": "com.example.err",
"name": ".MyApplication",
"mainAbility": "com.example.err.MainAbility",
"deviceType": [
"phone"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry",
"installationFree": true
},
"abilities": [
{
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"name": "com.example.err.MainAbility",
"icon": "$media:icon",
"description": "$string:mainability_description",
"label": "$string:entry_MainAbility",
"type": "page",
"launchType": "singleton",
"visible": true,
"isVisible": "true"
}
],
"js": [
{
"pages": [
"pages/index/index"
],
"name": "default",
"window": {
"designWidth": 720,
"autoDesignWidth": true
}
}
]
}
}
\ No newline at end of file
/*
* Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import file from '@system.file';
import {Core, ExpectExtend, ReportExtend} from 'deccjsunit/index';
export default {
data: {
title: ""
},
onInit() {
this.title = this.$t('strings.world');
},
onShow() {
const core = Core.getInstance();
const expectExtend = new ExpectExtend({
'id': 'extend'
});
const reportExtend = new ReportExtend(file);
core.addService('expect', expectExtend);
core.addService('report', reportExtend);
core.init();
const configService = core.getDefaultService('config');
this.timeout = 1000000;
configService.setConfig(this);
require('../../../test/hks_abnormal_testList.test.js');
core.execute();
}
}
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
require('./hks_abnormal_promise_part1.test.js');
require('./hks_abnormal_promise_part2.test');
require('./hks_abnormal_promise_part3.test');
require('./hks_abnormal_promise_part4.test');
require('./hks_abnormal_promise_part5.test');
require('./hks_abnormal_promise_part6.test');
require('./hks_abnormal_callback_part1.test.js');
require('./hks_abnormal_callback_part2.test');
require('./hks_abnormal_callback_part3.test');
require('./hks_abnormal_callback_part4.test');
require('./hks_abnormal_callback_part5.test');
require('./hks_abnormal_callback_part6.test');
{
"app": {
"bundleName": "com.example.err",
"vendor": "example",
"version": {
"code": 1,
"name": "1.0.0"
},
"apiVersion": {
"compatible": 4,
"target": 5,
"releaseType": "Beta1"
}
},
"deviceConfig": {},
"module": {
"package": "com.example.err",
"name": ".entry",
"mainAbility": ".MainAbility",
"deviceType": [
"phone"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry",
"installationFree": true
},
"abilities": [
{
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"orientation": "unspecified",
"formsEnabled": false,
"name": ".MainAbility",
"srcLanguage": "js",
"srcPath": "MainAbility",
"icon": "$media:icon",
"description": "$string:MainAbility_desc",
"label": "$string:MainAbility_label",
"type": "page",
"visible": true,
"launchType": "standard"
},
{
"orientation": "unspecified",
"formsEnabled": false,
"name": ".TestAbility",
"srcLanguage": "js",
"srcPath": "TestAbility",
"icon": "$media:icon",
"description": "$string:TestAbility_desc",
"label": "$string:TestAbility_label",
"type": "page",
"visible": true,
"launchType": "standard"
}
],
"js": [
{
"pages": [
"pages/index/index"
],
"name": "default",
"window": {
"designWidth": 720,
"autoDesignWidth": true
}
},
{
"pages": [
"pages/index/index"
],
"name": ".TestAbility",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
}
],
"testRunner": {
"name": "OpenHarmonyTestRunner",
"srcPath": "TestRunner"
},
"srcPath": ""
}
}
\ No newline at end of file
...@@ -12,7 +12,13 @@ ...@@ -12,7 +12,13 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
export default {
require('./Agree/hitscipher.test.js'); data: {
require('./Agree/cipher1.test.js'); title: ""
require('./Agree/cipher2.test.js'); },
onInit() {
this.title = this.$t('strings.world');
},
onShow() {
}
}
/* /*
* Copyright (C) 2021 Huawei Device Co., Ltd. * Copyright (c) 2022 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 in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
...@@ -13,28 +13,19 @@ ...@@ -13,28 +13,19 @@
* limitations under the License. * limitations under the License.
*/ */
import { Core, ExpectExtend } from 'deccjsunit/index'; import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import { Hypium } from '@ohos/hypium'
import testsuite from '../test/List.test'
export default { export default {
data: { onCreate() {
title: '', console.info('TestApplication onCreate')
}, var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
onInit() { var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
this.title = this.$t('strings.world'); console.info('start run testcase!!!')
}, Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
onShow() { },
const core = Core.getInstance(); onDestroy() {
const expectExtend = new ExpectExtend({ console.info("TestApplication onDestroy");
id: 'extend', }
});
core.addService('expect', expectExtend);
core.init();
const configService = core.getDefaultService('config');
this.timeout = 1500000;
configService.setConfig(this);
console.log('test start');
require('../../../test/List.test');
core.execute();
},
onReady() {},
}; };
{
"strings": {
"hello": "Hello",
"world": "World"
},
"Files": {
}
}
\ No newline at end of file
{
"strings": {
"hello": "您好",
"world": "世界"
},
"Files": {
}
}
\ No newline at end of file
.container {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
left: 0px;
top: 0px;
width: 100%;
height: 100%;
}
.title {
font-size: 60px;
text-align: center;
width: 100%;
height: 40%;
margin: 10px;
}
@media screen and (device-type: phone) and (orientation: landscape) {
.title {
font-size: 60px;
}
}
@media screen and (device-type: tablet) and (orientation: landscape) {
.title {
font-size: 100px;
}
}
\ No newline at end of file
<div class="container">
<text class="title">
{{ $t('strings.hello') }} {{ title }}
</text>
</div>
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export default {
data: {
title: ""
},
onInit() {
this.title = this.$t('strings.world');
}
}
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
function translateParamsToString(parameters) {
const keySet = new Set([
'-s class', '-s notClass', '-s suite', '-s itName',
'-s level', '-s testType', '-s size', '-s timeout',
'-s package', '-s dryRun'
])
let targetParams = '';
for (const key in parameters) {
if (keySet.has(key)) {
targetParams += ' ' + key + ' ' + parameters[key]
}
}
return targetParams.trim()
}
export default {
onPrepare() {
console.info('OpenHarmonyTestRunner OnPrepare')
},
onRun() {
console.log('OpenHarmonyTestRunner onRun run')
var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var testAbilityName = abilityDelegatorArguments.parameters['-p'] + '.TestAbility'
var cmd = 'aa start -d 0 -a ' + testAbilityName + ' -b ' + abilityDelegatorArguments.bundleName
cmd += ' ' + translateParamsToString(abilityDelegatorArguments.parameters)
var debug = abilityDelegatorArguments.parameters["-D"]
console.info('debug value : '+debug)
if (debug == 'true')
{
cmd += ' -D'
}
console.info('cmd : '+cmd)
abilityDelegator.executeShellCommand(cmd, (err, data) => {
console.info('executeShellCommand : err : ' + JSON.stringify(err));
console.info('executeShellCommand : data : ' + data.stdResult);
console.info('executeShellCommand : data : ' + data.exitCode);
})
}
};
...@@ -12,16 +12,29 @@ ...@@ -12,16 +12,29 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import Hks_Abnormal_Callback_Part1 from './hks_abnormal_callback_part1.test.js'
require('./Agree/SecurityHuksDHBasicFinish63KBCallbackJsunit.test.js'); import Hks_Abnormal_Callback_Part2 from './hks_abnormal_callback_part2.test.js'
require('./Agree/SecurityHuksDHBasicFinish65KBCallbackJsunit.test.js'); import Hks_Abnormal_Callback_Part3 from './hks_abnormal_callback_part3.test.js'
require('./Agree/SecurityHuksDHBasicAbort63KBCallbackJsunit.test.js'); import Hks_Abnormal_Callback_Part4 from './hks_abnormal_callback_part4.test.js'
require('./Agree/SecurityHuksDHBasicAbort65KBCallbackJsunit.test.js'); import Hks_Abnormal_Callback_Part5 from './hks_abnormal_callback_part5.test.js'
require('./Agree/SecurityHuksECDHBasicFinish63KBCallbackJsunit.test.js'); import Hks_Abnormal_Callback_Part6 from './hks_abnormal_callback_part6.test.js'
require('./Agree/SecurityHuksECDHBasicFinish65KBCallbackJsunit.test.js'); import Hks_Abnormal_Promise_Part1 from './hks_abnormal_promise_part1.test.js'
require('./Agree/SecurityHuksECDHBasicAbort63KBCallbackJsunit.test.js'); import Hks_Abnormal_Promise_Part2 from './hks_abnormal_promise_part2.test.js'
require('./Agree/SecurityHuksECDHBasicAbort65KBCallbackJsunit.test.js'); import Hks_Abnormal_Promise_Part3 from './hks_abnormal_promise_part3.test.js'
require('./Agree/SecurityHuksX25519BasicFinish63KBCallbackJsunit.test.js'); import Hks_Abnormal_Promise_Part4 from './hks_abnormal_promise_part4.test.js'
require('./Agree/SecurityHuksX25519BasicFinish65KBCallbackJsunit.test.js'); import Hks_Abnormal_Promise_Part5 from './hks_abnormal_promise_part5.test.js'
require('./Agree/SecurityHuksX25519BasicAbort63KBCallbackJsunit.test.js'); import Hks_Abnormal_Promise_Part6 from './hks_abnormal_promise_part6.test.js'
require('./Agree/SecurityHuksX25519BasicAbort65KBCallbackJsunit.test.js'); export default function testsuite() {
Hks_Abnormal_Callback_Part1()
Hks_Abnormal_Callback_Part2()
Hks_Abnormal_Callback_Part3()
Hks_Abnormal_Callback_Part4()
Hks_Abnormal_Callback_Part5()
Hks_Abnormal_Callback_Part6()
Hks_Abnormal_Promise_Part1()
Hks_Abnormal_Promise_Part2()
Hks_Abnormal_Promise_Part3()
Hks_Abnormal_Promise_Part4()
Hks_Abnormal_Promise_Part5()
Hks_Abnormal_Promise_Part6()
}
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
*/ */
import hks from '@ohos.security.huks' import hks from '@ohos.security.huks'
import { describe, it, expect } from 'deccjsunit/index' import { describe, it, expect } from '@ohos/hypium'
import { import {
alias, alias,
aliasEmpty, aliasEmpty,
...@@ -40,6 +40,7 @@ import { ...@@ -40,6 +40,7 @@ import {
invalidValueUint8Array invalidValueUint8Array
} from './hks_abnormal_common.test.js' } from './hks_abnormal_common.test.js'
export default function Hks_Abnormal_Callback_Part1() {
describe('Hks_Abnormal_Callback_Part1', function () { describe('Hks_Abnormal_Callback_Part1', function () {
async function generateAesKey(mode) { async function generateAesKey(mode) {
...@@ -1629,4 +1630,4 @@ describe('Hks_Abnormal_Callback_Part1', function () { ...@@ -1629,4 +1630,4 @@ describe('Hks_Abnormal_Callback_Part1', function () {
deleteKeyCallback(alias, done); deleteKeyCallback(alias, done);
}); });
}); });
}); });}
\ No newline at end of file
...@@ -14,10 +14,10 @@ ...@@ -14,10 +14,10 @@
*/ */
import hks from '@ohos.security.huks' import hks from '@ohos.security.huks'
import { describe, it, expect } from 'deccjsunit/index' import { describe, it, expect } from '@ohos/hypium'
import { import {
alias, alias,
} from '../../../../../../hks_xts_common.test' } from '../../../../../hks_xts_common.test'
import { import {
generateRSAKeyOption, generateRSAKeyOption,
...@@ -36,6 +36,7 @@ import { ...@@ -36,6 +36,7 @@ import {
rsaDecryptInvalidSizeOption, rsaDecryptInvalidSizeOption,
} from './hks_abnormal_common.test.js' } from './hks_abnormal_common.test.js'
export default function Hks_Abnormal_Callback_Part3() {
describe('Hks_Abnormal_Callback_Part3', function () { describe('Hks_Abnormal_Callback_Part3', function () {
var cipherText = []; var cipherText = [];
...@@ -1481,4 +1482,4 @@ describe('Hks_Abnormal_Callback_Part3', function () { ...@@ -1481,4 +1482,4 @@ describe('Hks_Abnormal_Callback_Part3', function () {
done(); done();
}); });
}); });
}); });}
\ No newline at end of file
...@@ -14,10 +14,10 @@ ...@@ -14,10 +14,10 @@
*/ */
import hks from '@ohos.security.huks' import hks from '@ohos.security.huks'
import { describe, it, expect } from 'deccjsunit/index' import { describe, it, expect } from '@ohos/hypium'
import { import {
alias, alias,
} from '../../../../../../hks_xts_common.test' } from '../../../../../hks_xts_common.test'
import { import {
plainTextSize64, plainTextSize64,
signOrVerifyGenerateKeyOption, signOrVerifyGenerateKeyOption,
...@@ -26,6 +26,7 @@ import { ...@@ -26,6 +26,7 @@ import {
signOrVerifyInvalidPaddingOption, signOrVerifyInvalidPaddingOption,
} from './hks_abnormal_common.test.js' } from './hks_abnormal_common.test.js'
export default function Hks_Abnormal_Callback_Part4() {
describe('Hks_Abnormal_Callback_Part4', function () { describe('Hks_Abnormal_Callback_Part4', function () {
async function generateKey() { async function generateKey() {
...@@ -565,4 +566,4 @@ describe('Hks_Abnormal_Callback_Part4', function () { ...@@ -565,4 +566,4 @@ describe('Hks_Abnormal_Callback_Part4', function () {
done(); done();
}); });
}); });
}); });}
\ No newline at end of file
...@@ -19,7 +19,7 @@ import { ...@@ -19,7 +19,7 @@ import {
makeImportOption, makeImportOption,
makeEncryptAndDecryptOption, makeEncryptAndDecryptOption,
makeSignAndVerifyOption makeSignAndVerifyOption
} from '../../../../../../hks_xts_common.test' } from '../../../../../hks_xts_common.test'
export var alias = 'alias'; export var alias = 'alias';
export var aliasEmpty = ''; export var aliasEmpty = '';
export var aliasTooLong = '01234567890123456789012345678901234567890123456789012345678901234'; export var aliasTooLong = '01234567890123456789012345678901234567890123456789012345678901234';
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
*/ */
import hks from '@ohos.security.huks' import hks from '@ohos.security.huks'
import { describe, it, expect } from 'deccjsunit/index' import { describe, it, expect } from '@ohos/hypium'
import { import {
alias, alias,
aliasEmpty, aliasEmpty,
...@@ -40,6 +40,7 @@ import { ...@@ -40,6 +40,7 @@ import {
invalidValueUint8Array invalidValueUint8Array
} from './hks_abnormal_common.test.js' } from './hks_abnormal_common.test.js'
export default function Hks_Abnormal_Promise_Part1() {
describe('Hks_Abnormal_Promise_Part1', function () { describe('Hks_Abnormal_Promise_Part1', function () {
async function generateAesKey(mode) { async function generateAesKey(mode) {
...@@ -1522,4 +1523,4 @@ describe('Hks_Abnormal_Promise_Part1', function () { ...@@ -1522,4 +1523,4 @@ describe('Hks_Abnormal_Promise_Part1', function () {
expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT); expect(ret.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_ARGUMENT);
await deleteKeyPromise(alias, done); await deleteKeyPromise(alias, done);
}); });
}); });}
\ No newline at end of file
...@@ -14,10 +14,10 @@ ...@@ -14,10 +14,10 @@
*/ */
import hks from '@ohos.security.huks' import hks from '@ohos.security.huks'
import { describe, it, expect } from 'deccjsunit/index' import { describe, it, expect } from '@ohos/hypium'
import { import {
alias, alias,
} from '../../../../../../hks_xts_common.test' } from '../../../../../hks_xts_common.test'
import { import {
aesGenerateKeyInvalidSizeOption, aesGenerateKeyInvalidSizeOption,
aesGenerateKeyInvalidModeOption, aesGenerateKeyInvalidModeOption,
...@@ -41,6 +41,7 @@ import { ...@@ -41,6 +41,7 @@ import {
dhGenerateKeyInvalidPurposeOption, dhGenerateKeyInvalidPurposeOption,
} from './hks_abnormal_common.test.js' } from './hks_abnormal_common.test.js'
export default function Hks_Abnormal_Promise_Part2() {
describe('Hks_Abnormal_Promise_Part2', function () { describe('Hks_Abnormal_Promise_Part2', function () {
var errHmacKeySizeA = 0; var errHmacKeySizeA = 0;
var errHmacKeySizeB = 9; var errHmacKeySizeB = 9;
...@@ -1844,4 +1845,4 @@ describe('Hks_Abnormal_Promise_Part2', function () { ...@@ -1844,4 +1845,4 @@ describe('Hks_Abnormal_Promise_Part2', function () {
expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE); expect(result.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PURPOSE);
done(); done();
}); });
}); });}
\ No newline at end of file
...@@ -14,10 +14,10 @@ ...@@ -14,10 +14,10 @@
*/ */
import hks from '@ohos.security.huks' import hks from '@ohos.security.huks'
import { describe, it, expect } from 'deccjsunit/index' import { describe, it, expect } from '@ohos/hypium'
import { import {
alias, alias,
} from '../../../../../../hks_xts_common.test' } from '../../../../../hks_xts_common.test'
import { import {
generateRSAKeyOption, generateRSAKeyOption,
...@@ -36,6 +36,7 @@ import { ...@@ -36,6 +36,7 @@ import {
rsaDecryptInvalidSizeOption, rsaDecryptInvalidSizeOption,
} from './hks_abnormal_common.test.js' } from './hks_abnormal_common.test.js'
export default function Hks_Abnormal_Promise_Part3() {
describe('Hks_Abnormal_Promise_Part3', function () { describe('Hks_Abnormal_Promise_Part3', function () {
var cipherText = []; var cipherText = [];
...@@ -1559,3 +1560,4 @@ describe('Hks_Abnormal_Promise_Part3', function () { ...@@ -1559,3 +1560,4 @@ describe('Hks_Abnormal_Promise_Part3', function () {
}); });
}); });
}
...@@ -14,10 +14,10 @@ ...@@ -14,10 +14,10 @@
*/ */
import hks from '@ohos.security.huks' import hks from '@ohos.security.huks'
import { describe, it, expect } from 'deccjsunit/index' import { describe, it, expect } from '@ohos/hypium'
import { import {
alias, alias,
} from '../../../../../../hks_xts_common.test' } from '../../../../../hks_xts_common.test'
import { import {
plainTextSize64, plainTextSize64,
signOrVerifyGenerateKeyOption, signOrVerifyGenerateKeyOption,
...@@ -26,6 +26,7 @@ import { ...@@ -26,6 +26,7 @@ import {
signOrVerifyInvalidPaddingOption, signOrVerifyInvalidPaddingOption,
} from './hks_abnormal_common.test.js' } from './hks_abnormal_common.test.js'
export default function Hks_Abnormal_Promise_Part4() {
describe('Hks_Abnormal_Promise_Part4', function () { describe('Hks_Abnormal_Promise_Part4', function () {
/** /**
...@@ -597,4 +598,4 @@ describe('Hks_Abnormal_Promise_Part4', function () { ...@@ -597,4 +598,4 @@ describe('Hks_Abnormal_Promise_Part4', function () {
expect(verifyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PADDING); expect(verifyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PADDING);
done(); done();
}); });
}); });}
\ No newline at end of file
...@@ -14,10 +14,10 @@ ...@@ -14,10 +14,10 @@
*/ */
import hks from '@ohos.security.huks' import hks from '@ohos.security.huks'
import { describe, it, expect } from 'deccjsunit/index' import { describe, it, expect } from '@ohos/hypium'
import { import {
alias, alias,
} from '../../../../../../hks_xts_common.test' } from '../../../../../hks_xts_common.test'
import { import {
generateAgreeKeyOption, generateAgreeKeyOption,
hmacGenerateKeyOption, hmacGenerateKeyOption,
...@@ -25,6 +25,7 @@ import { ...@@ -25,6 +25,7 @@ import {
hmacInvalidPurposeOption, hmacInvalidPurposeOption,
} from './hks_abnormal_common.test.js' } from './hks_abnormal_common.test.js'
export default function Hks_Abnormal_Promise_Part5() {
describe('Hks_Abnormal_Promise_Part5', function () { describe('Hks_Abnormal_Promise_Part5', function () {
/** /**
...@@ -342,4 +343,4 @@ describe('Hks_Abnormal_Promise_Part5', function () { ...@@ -342,4 +343,4 @@ describe('Hks_Abnormal_Promise_Part5', function () {
expect(macRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_DIGEST); expect(macRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_DIGEST);
done(); done();
}); });
}); });}
\ No newline at end of file
...@@ -14,11 +14,11 @@ ...@@ -14,11 +14,11 @@
*/ */
import hks from '@ohos.security.huks' import hks from '@ohos.security.huks'
import { describe, it, expect } from 'deccjsunit/index' import { describe, it, expect } from '@ohos/hypium'
import { import {
aliasA, aliasA,
aliasB, aliasB,
} from '../../../../../../hks_xts_common.test' } from '../../../../../hks_xts_common.test'
import { import {
generateImportKeyOption, generateImportKeyOption,
eccGenerateKeyOption, eccGenerateKeyOption,
...@@ -27,6 +27,7 @@ import { ...@@ -27,6 +27,7 @@ import {
importOptionsInvalidPurposeOrPaddingOption, importOptionsInvalidPurposeOrPaddingOption,
} from './hks_abnormal_common.test.js' } from './hks_abnormal_common.test.js'
export default function Hks_Abnormal_Promise_Part6() {
describe('Hks_Abnormal_Promise_Part6', function () { describe('Hks_Abnormal_Promise_Part6', function () {
var publicKey = []; var publicKey = [];
...@@ -666,4 +667,4 @@ describe('Hks_Abnormal_Promise_Part6', function () { ...@@ -666,4 +667,4 @@ describe('Hks_Abnormal_Promise_Part6', function () {
expect(importKeyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PADDING); expect(importKeyRet.errorCode).assertEqual(hks.HuksErrorCode.HUKS_ERROR_INVALID_PADDING);
done(); done();
}); });
}); });}
\ No newline at end of file
...@@ -7,6 +7,22 @@ ...@@ -7,6 +7,22 @@
{ {
"name": "mainability_description", "name": "mainability_description",
"value": "JS_Empty Ability" "value": "JS_Empty Ability"
} },
{
"name": "MainAbility_desc",
"value": "description"
},
{
"name": "MainAbility_label",
"value": "label"
},
{
"name": "TestAbility_desc",
"value": "description"
},
{
"name": "TestAbility_label",
"value": "label"
}
] ]
} }
\ No newline at end of file
...@@ -9,12 +9,12 @@ ...@@ -9,12 +9,12 @@
# 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 permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
import("//test/xts/tools/build/suite.gni") import("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("ActsHuksAlgCompletionTest") { ohos_js_hap_suite("ActsHuksAlgCompletionTest") {
hap_profile = "./entry/src/main/config.json" hap_profile = "./src/main/config.json"
deps = [ deps = [
":hjs_demo_js_assets", ":hjs_demo_js_assets",
":hjs_demo_resources", ":hjs_demo_resources",
...@@ -23,9 +23,11 @@ ohos_js_hap_suite("ActsHuksAlgCompletionTest") { ...@@ -23,9 +23,11 @@ ohos_js_hap_suite("ActsHuksAlgCompletionTest") {
hap_name = "ActsHuksAlgCompletionTest" hap_name = "ActsHuksAlgCompletionTest"
} }
ohos_js_assets("hjs_demo_js_assets") { ohos_js_assets("hjs_demo_js_assets") {
source_dir = "./entry/src/main/js/default" js2abc = true
hap_profile = "./src/main/config.json"
source_dir = "./src/main/js"
} }
ohos_resources("hjs_demo_resources") { ohos_resources("hjs_demo_resources") {
sources = [ "./entry/src/main/js/resources" ] sources = [ "./src/main/resources" ]
hap_profile = "./entry/src/main/config.json" hap_profile = "./src/main/config.json"
} }
{ {
"description": "Configuration for algorithm completion test", "description": "Configuration for algorithm completion test",
"driver": { "driver": {
"type": "JSUnitTest", "type": "OHJSUnitTest",
"test-timeout": "26000000", "test-timeout": "4200000",
"package": "com.example.hksxtstest", "shell-timeout": "4200000",
"shell-timeout": "60000" "bundle-name": "com.example.hksxtstest",
}, "package-name": "com.example.hksxtstest",
"kits": [ "testcase-timeout": 7200000
{ },
"test-file-name": [ "kits": [
"ActsHuksAlgCompletionTest.hap" {
], "test-file-name": [
"type": "AppInstallKit", "ActsHuksAlgCompletionTest.hap"
"cleanup-apps": true ],
} "type": "AppInstallKit",
] "cleanup-apps": true
} }
]
}
\ No newline at end of file
{
"app": {
"bundleName": "com.example.hksxtstest",
"vendor": "example",
"version": {
"code": 1,
"name": "1.0.0"
},
"apiVersion": {
"compatible": 4,
"target": 5,
"releaseType": "Beta1"
}
},
"deviceConfig": {},
"module": {
"package": "com.example.hksxtstest",
"name": ".MyApplication",
"mainAbility": "com.example.hksxtstest.MainAbility",
"deviceType": [
"phone"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry",
"installationFree": true
},
"abilities": [
{
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"name": "com.example.hksxtstest.MainAbility",
"icon": "$media:icon",
"description": "$string:mainability_description",
"label": "$string:entry_MainAbility",
"type": "page",
"launchType": "singleton",
"visible": true,
"isVisible": "true"
}
],
"js": [
{
"pages": [
"pages/index/index"
],
"name": "default",
"window": {
"designWidth": 720,
"autoDesignWidth": true
}
}
]
}
}
\ No newline at end of file
/*
* Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import file from '@system.file';
import {Core, ExpectExtend, ReportExtend} from 'deccjsunit/index';
export default {
data: {
title: ''
},
onInit() {
this.title = this.$t('strings.world');
},
onShow() {
const core = Core.getInstance();
const expectExtend = new ExpectExtend({
'id': 'extend'
});
const reportExtend = new ReportExtend(file);
core.addService('expect', expectExtend);
core.addService('report', reportExtend);
core.init();
const configService = core.getDefaultService('config');
this.timeout = 7200000;
configService.setConfig(this);
require('../../../test/hks_xtsTestList_algCompletion.test.js');
core.execute();
}
}
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
require('./hks_xtsTest_algCompletion_encryptAndDecrypt_aes.test.js');
require('./hks_xtsTest_algCompletion_encryptAndDecrypt_rsa.test.js');
require ('./hks_xtsTest_algCompletion_signAndVerify_promise.test.js');
require ('./hks_xtsTest_algCompletion_signAndVerify_callback.test.js');
require('./hks_xtsTest_algCompletion_agree.test.js');
require('./hks_xtsTest_algCompletion_mac.test.js');
require('./hks_jsApi_ca.test.js');
require('./hks_jsApi_deriveKey.test.js');
require('./hks_jsApi_generateKey.test.js');
require('./hks_jsApi_getKeyProperties.test.js');
require('./hks_jsApi_getSdkVersion.test.js');
\ No newline at end of file
{
"app": {
"bundleName": "com.example.hksxtstest",
"vendor": "example",
"version": {
"code": 1,
"name": "1.0.0"
},
"apiVersion": {
"compatible": 4,
"target": 5,
"releaseType": "Beta1"
}
},
"deviceConfig": {},
"module": {
"package": "com.example.hksxtstest",
"name": ".entry",
"mainAbility": ".MainAbility",
"deviceType": [
"phone"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry",
"installationFree": true
},
"abilities": [
{
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"orientation": "unspecified",
"formsEnabled": false,
"name": ".MainAbility",
"srcLanguage": "js",
"srcPath": "MainAbility",
"icon": "$media:icon",
"description": "$string:MainAbility_desc",
"label": "$string:MainAbility_label",
"type": "page",
"visible": true,
"launchType": "standard"
},
{
"orientation": "unspecified",
"formsEnabled": false,
"name": ".TestAbility",
"srcLanguage": "js",
"srcPath": "TestAbility",
"icon": "$media:icon",
"description": "$string:TestAbility_desc",
"label": "$string:TestAbility_label",
"type": "page",
"visible": true,
"launchType": "standard"
}
],
"js": [
{
"pages": [
"pages/index/index"
],
"name": "default",
"window": {
"designWidth": 720,
"autoDesignWidth": true
}
},
{
"pages": [
"pages/index/index"
],
"name": ".TestAbility",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
}
],
"testRunner": {
"name": "OpenHarmonyTestRunner",
"srcPath": "TestRunner"
},
"srcPath": ""
}
}
\ No newline at end of file
/*
* Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import file from '@system.file';
export default {
data: {
title: ''
},
onInit() {
this.title = this.$t('strings.world');
},
onShow() {
}
}
/* /*
* Copyright (C) 2021 Huawei Device Co., Ltd. * Copyright (c) 2022 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 in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
...@@ -13,28 +13,19 @@ ...@@ -13,28 +13,19 @@
* limitations under the License. * limitations under the License.
*/ */
import { Core, ExpectExtend } from 'deccjsunit/index'; import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import { Hypium } from '@ohos/hypium'
import testsuite from '../test/List.test'
export default { export default {
data: { onCreate() {
title: '', console.info('TestApplication onCreate')
}, var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
onInit() { var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
this.title = this.$t('strings.world'); console.info('start run testcase!!!')
}, Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
onShow() { },
const core = Core.getInstance(); onDestroy() {
const expectExtend = new ExpectExtend({ console.info("TestApplication onDestroy");
id: 'extend', }
});
core.addService('expect', expectExtend);
core.init();
const configService = core.getDefaultService('config');
this.timeout = 1500000;
configService.setConfig(this);
console.log('test start');
require('../../../test/List.test');
core.execute();
},
onReady() {},
}; };
{
"strings": {
"hello": "Hello",
"world": "World"
},
"Files": {
}
}
\ No newline at end of file
{
"strings": {
"hello": "您好",
"world": "世界"
},
"Files": {
}
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册