提交 9b9090cf 编写于 作者: Y yuanyuhang1

useriamshangku

Signed-off-by: Nyuanyuhang1 <yuanyuhang1@huawei.com>
上级 8a3f2c56
......@@ -18,6 +18,7 @@ group("useriam") {
if (is_standard_system) {
deps = [
"face_auth/js_api_test/function_test/userauth:ActsUserauthTest",
"face_auth/js_api_test/function_test/userauthnopermission:ActsUserauthnopermissionTest",
"face_auth/js_api_test/function_test/userauthpart2:ActsUserauthTwoTest",
]
}
......
# 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("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("ActsUserauthnopermissionTest") {
hap_profile = "./src/main/config.json"
deps = [
":hjs_demo_js_assets",
":hjs_demo_resources",
]
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "ActsUserauthnopermissionTest"
subsystem_name = "useriam"
part_name = "face_auth"
}
ohos_js_assets("hjs_demo_js_assets") {
js2abc = true
hap_profile = "./src/main/config.json"
source_dir = "./src/main/js"
}
ohos_resources("hjs_demo_resources") {
sources = [ "./src/main/resources" ]
hap_profile = "./src/main/config.json"
}
{
"description": "Configuration for hjunit demo Tests",
"driver": {
"type": "OHJSUnitTest",
"test-timeout": "600000",
"shell-timeout": "600000",
"bundle-name": "com.example.myapplication101",
"package-name": "com.example.myapplication101"
},
"kits": [
{
"test-file-name": [
"ActsUserauthnopermissionTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
},
{
"type": "ShellKit",
"run-command": [
"remount",
"mkdir /data/test"
]
},
{
"type": "PushKit",
"push": [
"ActsUserauthnopermissionTest.hap->/data/test/ActsUserauthnopermissionTest.hap"
]
},
{
"type": "ShellKit",
"run-command": [
"chmod 644 /data/test/*.hap",
"chmod 777 -R data"
]
}
]
}
{
"app": {
"bundleName": "com.example.myapplication101",
"vendor": "example",
"version": {
"code": 12,
"name": "1.0.0"
},
"apiVersion": {
"compatible": 4,
"target": 5,
"releaseType": "Beta1"
}
},
"deviceConfig": {},
"module": {
"package": "com.example.myapplication101",
"name": ".entry",
"mainAbility": ".MainAbility",
"deviceType": [
"tablet",
"default",
"phone",
"tablet",
"tv",
"wearable"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry",
"installationFree": false
},
"abilities": [
{
"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"
},
{
"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"
}
],
"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": ""
}
}
/*
* 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'
import { Hypium } from '@ohos/hypium'
import testsuite from '../test/List.Test'
export default {
onCreate() {
console.info('TestApplication onCreate')
var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
console.info('start run testcase!!!')
Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
},
onDestroy() {
console.info("TestApplication onDestroy");
}
};
{
"strings": {
"hello": "Hello",
"world": "World"
}
}
\ No newline at end of file
{
"strings": {
"hello": "您好",
"world": "世界"
}
}
\ 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.
*/
.container {
flex-direction: column;
justify-content: center;
align-items: center;
width: 100%;
height: 100%;
}
.title {
font-size: 40px;
color: #000000;
opacity: 0.9;
}
@media screen and (device-type: tablet) and (orientation: landscape) {
.title {
font-size: 100px;
}
}
@media screen and (device-type: wearable) {
.title {
font-size: 28px;
color: #FFFFFF;
}
}
@media screen and (device-type: tv) {
.container {
background-image: url("/common/images/Wallpaper.png");
background-size: cover;
background-repeat: no-repeat;
background-position: center;
}
.title {
font-size: 100px;
color: #FFFFFF;
}
}
@media screen and (device-type: phone) and (orientation: landscape) {
.title {
font-size: 60px;
}
}
/*
* 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.
*/
<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.
*/
import fileio from '@ohos.fileio'
export default {
data: {
title: ""
},
onInit() {
this.title = this.$t('strings.world');
},
onShow() {
console.info('onShow start')
},
onReady() {
},
fileSave(caseNum, codeNum, ...code) {
console.log(caseNum + ' fileSave start');
var path = "/data/config.dat"
let fd = fileio.openSync(path, 0o102, 0o666);
var message = caseNum + "\r\n" + codeNum + "\r\n";
for(var i = 0; i < code.length; i++){
message = message + code[i] + "\r\n";
}
fileio.writeSync(fd, message);
fileio.closeSync(fd);
console.log(caseNum + ' fileSave end');
},
fileSaveB(caseNum, code) {
console.log(caseNum + ' fileSave start');
var path = "/data/config.dat"
let fd = fileio.openSync(path, 0o102, 0o666);
var message = code;
fileio.writeSync(fd, message);
fileio.closeSync(fd);
console.log(caseNum + ' fileSave end');
},
saveNull() {
console.log('JSAPI null file faceid.dat start');
var path = "/data/faceId.dat"
let fd = fileio.openSync(path, 0o102, 0o666);
var message = "";
fileio.writeSync(fd, message);
fileio.closeSync(fd);
console.log('JSAPI null file faceid.dat end');
},
}
/*
* 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 {
onCreate() {
console.info('AceApplication onCreate');
},
onDestroy() {
console.info('AceApplication onDestroy');
}
};
{
"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'] + '.MainAbility'
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) 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 userAuthTestNopermission from './nopermisson.js'
export default function testsuite() {
userAuthTestNopermission()
}
/*
* 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 userAuth from '@ohos.userIAM.userAuth'
let UserAuthKit = new userAuth.UserAuth()
var index = require('../MainAbility/pages/index/index.js');
var waitFlag = false;
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
/**
* test case
*/
export default function userAuthTestExecute() {
describe('userAuthTestExecute', function () {
beforeEach(function(done) {
let waitTime = 1000;
if (waitFlag) {
waitTime = 30000;
}
setTimeout(function() {
done();
}, waitTime);
})
afterEach(function() {
})
/**
* @tc.name execute_authentication_promise_Type_is_null
* @tc.number JSAPI_Function_Execute_2100
* @tc.size MEDIUM
* @tc.type FUNC
* @tc.level Level2
*/
it('JSAPI_Function_Nopermission_2100', 0, function (done) {
console.log("JSAPI_Function_Nopermission_2100 start");
const auth = userAuth.getAuthenticator();
auth.execute("FACE_ONLY", "S1").catch(function(data) {
console.log("JSAPI_Function_Nopermission_2100 auth.execute:" + data);
// general error
expect(data).assertEqual(100);
setTimeout(function() {
done();
}, 1);
});
console.log("JSAPI_Function_Nopermission_2100 end");
})
/**
* @tc.name execute_authentication_callback_Type_is_null
* @tc.number JSAPI_Function_Execute_1800
* @tc.size MEDIUM
* @tc.type FUNC
* @tc.level Level2
*/
it('JSAPI_Function_Nopermission_1800', 0, function (done) {
console.log("JSAPI_Function_Nopermission_1800 start");
const auth = userAuth.getAuthenticator();
auth.execute("FACE_ONLY", "S1", function(data) {
console.log("JSAPI_Function_Nopermission_1800 auth.execute:" + data);
// general error
expect(data).assertEqual(100);
setTimeout(function() {
done();
}, 1);
});
console.log("JSAPI_Function_Nopermission_1800 end");
})
/*
* @tc.number : Security_IAM_Nopermission_API8_Func_0101
* @tc.name : Kit interface get version
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 0
*/
it('Security_IAM_Nopermission_API8_Func_0101', 0, async function (done) {
try {
let getversionresult = null;
getversionresult = UserAuthKit.getVersion();
console.info('Security_IAM_Nopermission_API8_Func_0101 getversionresult = ' + getversionresult);
//mini version 0
expect(getversionresult).assertEqual(0);
done();
} catch (e) {
console.log("testFace Security_IAM_Nopermission_API8_Func_0101 fail " + e.code);
expect(null).assertFail();
done();
}
})
/*
* @tc.number : Security_IAM_Nopermission_API8_Func_0112
* @tc.name : Kit interface get AvailabeStatus
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 0
*/
it('Security_IAM_Nopermission_API8_Func_0112', 0, async function (done) {
console.info('testFace Security_IAM_Nopermission_API8_Func_0112 start');
try {
let AvailabeStatus = null
AvailabeStatus = UserAuthKit.getAvailableStatus(2, 10000);
console.info('testFace Security_IAM_Nopermission_API8_Func_0112,2,10000 result = ' + JSON.stringify(AvailabeStatus));
// 100:general error
expect(1005).assertEqual(AvailabeStatus);
done()
} catch (e) {
console.log("Security_IAM_Nopermission_API8_Func_0112 fail " + e.code);
expect(100).assertEqual(e.code);
done()
}
})
/*
* @tc.number : Security_IAM_Nopermission_API8_Func_0103
* @tc.name : Kit interface auth & cancel auth
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 0
*/
it('Security_IAM_Nopermission_API8_Func_0103', 0, async function (done) {
let contextID1 = null
let challenge = new Uint8Array([253, 19, 58, 160, 67, 200, 247, 37])
let onresult = {
authresult: null,
authextr: null,
}
let onacquireinfo = {
authmodule : null,
authacquire : null,
authextr : null
}
console.log("Security_IAM_Nopermission_API8_Func_0103 2,10000");
contextID1 = UserAuthKit.auth(challenge, userAuth.UserAuthType.FACE,userAuth.AuthTrustLevel.ATL1, {
onResult: function(result,extraInfo){
console.log("Security_IAM_Nopermission_API8_Func_0103 auth result = " + result);
onresult.authresult = result;
//100:general error
expect(1005).assertEqual(result);
console.info('Security_IAM_Nopermission_API8_Func_0103 contextID1 = ' + contextID1);
let cancelResult = UserAuthKit.cancelAuth(contextID1);
console.info('Security_IAM_Nopermission_API8_Func_0103 cancelResult = ' + cancelResult);
done();
},
onAcquireInfo: function (modulea,acquire,extr){
console.info('faceTest publicauth auth onAcquireInfo in');
onacquireinfo.authmodule = modulea;
onacquireinfo.authacquire = acquire;
onacquireinfo.authextr = extr;
console.log("testFace faceDemo auth module = " + JSON.stringify(modulea));
console.info('testFace publicauth auth onAcquireInfo = ' + JSON.stringify(onacquireinfo));
}
});
})
/*
* @tc.number : Security_IAM_Nopermission_API9_Func_0101
* @tc.name : Kit interface get version
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 0
*/
it('Security_IAM_Nopermission_API9_Func_0101', 0, async function (done) {
try {
let getversionresult = userAuth.getVersion();
console.info('Security_IAM_Nopermission_API9_Func_0101 getversionresult = ' + getversionresult);
// no permission
expect(getversionresult).assertEqual(201);
done();
} catch (e) {
console.log("testFace GetVersionTest_0101 fail " + e.code);
expect(e.code).assertEqual(201);
done();
}
})
/*
* @tc.number : Security_IAM_Nopermisson_Func_0104
* @tc.name : getAvailabeStatus invalid parameters
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 0
*/
it('Security_IAM_Nopermisson_API9_Func_0104', 0, async function (done) {
console.info('testFace Security_IAM_Nopermisson_API9_Func_0104 start');
try {
userAuth.getAvailableStatus(userAuth.UserAuthType.FACE, userAuth.AuthTrustLevel.ATL1);
console.log("Security_IAM_Nopermisson_API9_Func_0104 success " );
done()
} catch (e) {
console.log("Security_IAM_Nopermisson_API9_Func_0104 fail " + e.code);
expect(e.code).assertEqual(201);
done()
}
})
/*
* @tc.number : Security_IAM_Nopermission_API9_Func_0110
* @tc.name : getAuthInstance faceType ATL4
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 0
*/
it('Security_IAM_Nopermission_API9_Func_0110', 0, async function (done) {
let challenge = new Uint8Array([253, 19, 58, 160, 67, 200, 247, 37])
let authType = userAuth.UserAuthType.FACE;
let authTrustLevel = userAuth.AuthTrustLevel.ATL1;
try {
var authInstance = userAuth.getAuthInstance(challenge, authType, authTrustLevel);
console.log("Security_IAM_Nopermission_API9_Func_0110 FACE ATL1 success");
done();
} catch (e) {
console.log("Security_IAM_Nopermission_API9_Func_0110 FACE ATL1 fail" + e.code);
expect(e.code).assertEqual(201);
done();
}
})
/*
* @tc.number : Security_IAM_Nopermission_API9_Func_0103
* @tc.name : Kit interface auth & cancel auth
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 0
*/
it('Security_IAM_Nopermission_API9_Func_0103', 0, async function (done) {
let challenge = new Uint8Array([253, 19, 58, 160, 67, 200, 247, 37])
let authType = userAuth.UserAuthType.FACE;
let authTrustLevel = userAuth.AuthTrustLevel.ATL1;
try {
var authInstance = userAuth.getAuthInstance(challenge, authType, authTrustLevel);
// register result and tip
authInstance.on("result", {
callback: (result) => {
console.log("authV9 result " + result.result);
console.log("authV9 token " + result.token);
console.log("authV9 remainAttempts " + result.remainAttempts);
console.log("authV9 lockoutDuration " + result.lockoutDuration);
expect(result.result).assertEqual(userAuth.ResultCodeV9.NOT_ENROLLED);
}
});
authInstance.on("tip", {
callback: (result) => {
console.log("authV9 module " + result.module);
console.log("authV9 tip " + result.tip);
}
});
//start auth
authInstance.start();
} catch (e) {
console.log("Security_IAM_Nopermission_API9_Func_0103 fail " + e.code);
expect(e.code).assertEqual(201);
}
// cancel auth
try {
authInstance.cancel();
} catch (e) {
console.log("Security_IAM_Nopermission_API9_Func_0103 cancel fail " + e.code);
expect(e.code).assertEqual(201);
}
// unregister result and tip
try {
authInstance.off("result");
authInstance.off("tip");
done();
} catch (e) {
console.log("Security_IAM_Nopermission_API9_Func_0103 fail " + e.code);
done();
}
})
})
}
{
"string": [
{
"name": "entry_MainAbility",
"value": "entry_MainAbility"
},
{
"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,491 +13,582 @@
* limitations under the License.
*/
import {describe, it, expect} from '@ohos/hypium'
import { describe, it, expect } from '@ohos/hypium'
import userAuthNorth from '@ohos.userIAM.userAuth'
export default function userauthTest() {
describe('userauthTest_API9', function () {
describe('userauthTest_API9', function () {
/*
* @tc.number : Security_IAM_Func_0101
* @tc.name : Kit interface get version
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 0
*/
it('Security_IAM_Func_0101', 0, async function (done) {
try {
let getversionresult = null;
getversionresult = userAuthNorth.getVersion();
console.info('GetVersionTest_0101 getversionresult = ' + getversionresult);
done();
} catch (e) {
console.log("testFace GetVersionTest_0101 fail " + e);
expect(null).assertFail();
}
})
/*
* @tc.number : Security_IAM_Func_0101
* @tc.name : Kit interface get version
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 0
*/
it('Security_IAM_Func_0101', 0, async function (done) {
try {
let getversionresult = userAuthNorth.getVersion();
console.info('GetVersionTest_0101 getversionresult = ' + getversionresult);
expect(getversionresult).assertEqual(0);
done();
} catch (e) {
console.log("testFace GetVersionTest_0101 fail " + e.code);
expect(null).assertFail();
}
})
/*
* @tc.number : Security_IAM_Func_0102
* @tc.name : Kit interface get AvailabeStatus
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 0
*/
it('Security_IAM_Func_0102', 0, async function (done) {
console.info('testFace GetAvailabeStatusTest0102 start');
try {
userAuthNorth.getAvailableStatus(userAuthNorth.UserAuthType.FACE,
userAuthNorth.AuthTrustLevel.ATL1);
} catch (e) {
console.log("GetAvailabeStatusTest0102 fail " + e);
expect(e.code).assertEqual(userAuthNorth.ResultCodeV9.NOT_ENROLLED);
done();
}
})
/*
/*
* @tc.number : Security_IAM_Func_0102
* @tc.name : Kit interface get AvailabeStatus
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 0
*/
it('Security_IAM_Func_0102', 0, async function (done) {
console.info('testFace GetAvailabeStatusTest0102 start');
let authType = userAuthNorth.UserAuthType.FACE
let level = [userAuthNorth.AuthTrustLevel.ATL1, userAuthNorth.AuthTrustLevel.ATL2, userAuthNorth.AuthTrustLevel.ATL3, userAuthNorth.AuthTrustLevel.ATL4]
for (let idx1 = 0; idx1 < level.length; idx1++) {
try {
console.info('GetAvailabeStatusTest0102 authtype:' + authType + 'trustlevel:' + level[idx1])
userAuthNorth.getAvailableStatus(authType, level[idx1]);
} catch (e) {
console.log("GetAvailabeStatusTest0102 fail " + 'authType:' + authType + 'trustlevel:' + level[idx1] + 'e.code:' + e.code);
expect(e.code).assertEqual(userAuthNorth.ResultCodeV9.NOT_ENROLLED);
done();
}
}
})
/*
* @tc.number : Security_IAM_Func_0104
* @tc.name : getAvailabeStatus invalid parameters
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 0
*/
it('Security_IAM_Func_0104', 0, async function (done) {
console.info('testFace GetAvailabeStatusTest0104 start');
//No AuthType
try {
userAuthNorth.getAvailableStatus(userAuthNorth.AuthTrustLevel.ATL1);
} catch (e) {
console.log("GetAvailabeStatusTest0104 noAuthType fail " + e.code);
expect(e.code).assertEqual(401);
}
//No AuthTrustLevel
try {
userAuthNorth.getAvailableStatus(userAuthNorth.UserAuthType.FACE);
} catch (e) {
console.log("GetAvailabeStatusTest0104 no AuthTrustLevel fail " + e.code);
expect(e.code).assertEqual(401);
}
//No authtype and AuthTrustLevel
try {
userAuthNorth.getAvailableStatus();
} catch (e) {
console.log("GetAvailabeStatusTest0104 no authtype and AuthTrustLevel fail " + e.code);
expect(e.code).assertEqual(401);
}
//more param 2
try {
userAuthNorth.getAvailableStatus(userAuthNorth.UserAuthType.FACE, userAuthNorth.AuthTrustLevel.ATL1, 2);
} catch (e) {
console.log("GetAvailabeStatusTest0104 more param 2 fail " + e.code);
expect(e.code).assertEqual(401);
}
let invalidauthType = [-1, 0, 1, 3, 5]
for (let idx = 0; idx < invalidauthType.length; idx++) {
//authType invalid
try {
console.log("GetAvailabeStatusTest0104 authType invalid: " + invalidauthType[idx]);
userAuthNorth.getAvailableStatus(invalidauthType[idx], userAuthNorth.AuthTrustLevel.ATL1);
} catch (e) {
console.log("GetAvailabeStatusTest0104 authType invalid:" + e.code);
expect(e.code).assertEqual(userAuthNorth.ResultCodeV9.TYPE_NOT_SUPPORT);
}
}
let invalidtrustLevel = [5000, 15000, 50000]
for (let idx = 0; idx < invalidtrustLevel.length; idx++) {
//trustlevel invalid
try {
console.log("GetAvailabeStatusTest0104 trustLevel invalid " + invalidtrustLevel[idx]);
userAuthNorth.getAvailableStatus(2, invalidtrustLevel[idx]);
} catch (e) {
console.log("GetAvailabeStatusTest0104 trustLevel invalid :1 " + e.code);
expect(e.code).assertEqual(userAuthNorth.ResultCodeV9.TRUST_LEVEL_NOT_SUPPORT);
}
}
done()
})
/*
* @tc.number : Security_IAM_Func_0111
* @tc.name : Kit interface get AvailabeStatus
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 0
*/
it('Security_IAM_Func_0111', 0, async function (done) {
console.info('testFace Security_IAM_Func_0111 start');
try {
userAuthNorth.getAvailableStatus(userAuthNorth.UserAuthType.FACE,
userAuthNorth.AuthTrustLevel.ATL4);
} catch (e) {
console.log("Security_IAM_Func_0111 fail " + e);
expect(e.code).assertEqual(userAuthNorth.ResultCodeV9.NOT_ENROLLED);
done();
}
})
/*
* @tc.number : Security_IAM_Func_0104
* @tc.name : getAvailabeStatus invalid parameters
* @tc.name : Kit interface get getAuthInstance
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 0
*/
it('Security_IAM_Func_0104', 0, async function (done) {
console.info('testFace GetAvailabeStatusTest0104 start');
//No AuthType
try {
userAuthNorth.getAvailableStatus(userAuthNorth.AuthTrustLevel.ATL1);
} catch (e) {
console.log("GetAvailabeStatusTest0104 noAuthType fail " + e);
expect(e.code).assertEqual(userAuthNorth.ResultCodeV9.INVALID_PARAMETERS);
}
//No AuthTrustLevel
try {
userAuthNorth.getAvailableStatus(userAuthNorth.UserAuthType.FACE);
} catch (e) {
console.log("GetAvailabeStatusTest0104 no AuthTrustLevel fail " + e);
expect(e.code).assertEqual(userAuthNorth.ResultCodeV9.INVALID_PARAMETERS);
}
//authType invalid
try {
userAuthNorth.getAvailableStatus(1, userAuthNorth.AuthTrustLevel.ATL1);
} catch (e) {
console.log("GetAvailabeStatusTest0104 authType invalid :1 " + e);
expect(e.code).assertEqual(userAuthNorth.ResultCodeV9.INVALID_PARAMETERS);
}
//authType invalid
try {
userAuthNorth.getAvailableStatus(5, userAuthNorth.AuthTrustLevel.ATL1);
} catch (e) {
console.log("GetAvailabeStatusTest0104 authType invalid :5 " + e);
expect(e.code).assertEqual(userAuthNorth.ResultCodeV9.INVALID_PARAMETERS);
}
//AuthTrustLevel invalid
try {
userAuthNorth.getAvailableStatus(userAuthNorth.UserAuthType.FACE, 15000);
} catch (e) {
console.log("GetAvailabeStatusTest0104 AuthTrustLevel invalid 15000 " + e);
expect(e.code).assertEqual(userAuthNorth.ResultCodeV9.INVALID_PARAMETERS);
}
//AuthTrustLevel invalid
try {
userAuthNorth.getAvailableStatus(userAuthNorth.UserAuthType.FACE, 50000);
} catch (e) {
console.log("GetAvailabeStatusTest0104 AuthTrustLevel invalid 50000 " + e);
expect(e.code).assertEqual(userAuthNorth.ResultCodeV9.INVALID_PARAMETERS);
done();
}
})
*/
it('Security_IAM_Func_0111', 0, async function (done) {
console.info('testFace getAuthInstance start');
let challenge = new Uint8Array([253, 19, 58, 160, 67, 200, 247, 37])
let authType = userAuthNorth.UserAuthType.FACE
let level = [userAuthNorth.AuthTrustLevel.ATL1, userAuthNorth.AuthTrustLevel.ATL2, userAuthNorth.AuthTrustLevel.ATL3, userAuthNorth.AuthTrustLevel.ATL4]
var authInstance
/*
* @tc.number : Security_IAM_Func_0105
* @tc.name : getAuthInstance invalid parameters
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 0
*/
it('Security_IAM_Func_0105', 0, async function (done) {
console.info('testFace Security_IAM_Func_0105 start');
let challenge = new Uint8Array([253, 19, 58, 160, 67, 200, 247, 37])
let authType = userAuthNorth.UserAuthType.FACE;
let authTrustLevel = userAuthNorth.AuthTrustLevel.ATL1;
// no challenge
try {
var authInstance = userAuthNorth.getAuthInstance(authType, authTrustLevel);
} catch (e) {
console.log("Security_IAM_Func_0105 noAuthType fail " + e);
expect(e.code).assertEqual(userAuthNorth.ResultCodeV9.INVALID_PARAMETERS);
}
// no authType
try {
var authInstance = userAuthNorth.getAuthInstance(challenge, authTrustLevel);
} catch (e) {
console.log("Security_IAM_Func_0105 noAuthType fail " + e);
expect(e.code).assertEqual(userAuthNorth.ResultCodeV9.INVALID_PARAMETERS);
}
// no AuthTrustLevel
try {
var authInstance = userAuthNorth.getAuthInstance(challenge,authType);
} catch (e) {
console.log("Security_IAM_Func_0105 noAuthType fail " + e);
expect(e.code).assertEqual(userAuthNorth.ResultCodeV9.INVALID_PARAMETERS);
}
//authType invalid
try {
var authInstance = userAuthNorth.getAuthInstance(challenge, 1, authTrustLevel);
} catch (e) {
console.log("Security_IAM_Func_0105 authType invalid :1 " + e);
expect(e.code).assertEqual(userAuthNorth.ResultCodeV9.INVALID_PARAMETERS);
}
//authType invalid
try {
var authInstance = userAuthNorth.getAuthInstance(challenge, 5, authTrustLevel);
} catch (e) {
console.log("Security_IAM_Func_0105 authType invalid :5 " + e);
expect(e.code).assertEqual(userAuthNorth.ResultCodeV9.INVALID_PARAMETERS);
}
//AuthTrustLevel invalid
try {
var authInstance = userAuthNorth.getAuthInstance(challenge, authType, 15000);
} catch (e) {
console.log("Security_IAM_Func_0105 AuthTrustLevel invalid 15000 " + e);
expect(e.code).assertEqual(userAuthNorth.ResultCodeV9.INVALID_PARAMETERS);
}
//AuthTrustLevel invalid
try {
var authInstance = userAuthNorth.getAuthInstance(challenge, authType, 50000);
} catch (e) {
console.log("Security_IAM_Func_0105 AuthTrustLevel invalid 50000 " + e);
expect(e.code).assertEqual(userAuthNorth.ResultCodeV9.INVALID_PARAMETERS);
done();
}
})
/*
* @tc.number : Security_IAM_Func_0106
* @tc.name : on,off invalid parameters
for (let idx2 = 0; idx2 < level.length; idx2++) {
try {
console.info('getAuthInstance authtype:' + authType + 'trustlevel:' + level[idx2])
authInstance = userAuthNorth.getAuthInstance(challenge, authType, level[idx2]);
authInstance.on("result", {
callback: (result) => {
console.log("authV9 result " + result.result);
expect(result.result).assertEqual(userAuthNorth.ResultCodeV9.NOT_ENROLLED);
}
});
//start auth
authInstance.start();
} catch (e) {
console.log("getAuthInstance/start fail " + e.code + 'authType:' + authType + 'trustlevel:' + level[idx2] + 'e.code:' + e.code);
expect(e.code).assertEqual(userAuthNorth.ResultCodeV9.NOT_ENROLLED);
}
}
done()
})
/*
* @tc.number : Security_IAM_Func_0105
* @tc.name : getAuthInstance invalid parameters
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 0
*/
it('Security_IAM_Func_0105', 0, async function (done) {
console.info('testFace Security_IAM_Func_0105 start');
let challenge = new Uint8Array([253, 19, 58, 160, 67, 200, 247, 37])
let authType = userAuthNorth.UserAuthType.FACE;
let authTrustLevel = userAuthNorth.AuthTrustLevel.ATL1;
// no challenge
try {
var authInstance = userAuthNorth.getAuthInstance(authType, authTrustLevel);
} catch (e) {
console.log("Security_IAM_Func_0105 no challenge fail " + e.code);
expect(e.code).assertEqual(401);
}
// no authType
try {
var authInstance = userAuthNorth.getAuthInstance(challenge, authTrustLevel);
} catch (e) {
console.log("Security_IAM_Func_0105 noAuthType fail " + e.code);
expect(e.code).assertEqual(401);
}
// no AuthTrustLevel
try {
var authInstance = userAuthNorth.getAuthInstance(challenge, authType);
} catch (e) {
console.log("Security_IAM_Func_0105 noAuthTrustLevel fail " + e.code);
expect(e.code).assertEqual(401);
}
// no param
try {
var authInstance = userAuthNorth.getAuthInstance();
} catch (e) {
console.log("Security_IAM_Func_0105 noAuthType fail " + e.code);
expect(e.code).assertEqual(401);
}
// more param
try {
var authInstance = userAuthNorth.getAuthInstance(challenge, 2, 10000, 10000);
} catch (e) {
console.log("Security_IAM_Func_0105 more param fail " + e.code);
expect(e.code).assertEqual(401);
}
let invalidauthType = [-1, 0, 1, 3, 5]
for (let idx = 0; idx < invalidauthType.length; idx++) {
//authType invalid
try {
console.log("getAuthInstance authType invalid " + invalidauthType[idx]);
var authInstance = userAuthNorth.getAuthInstance(challenge, invalidauthType[idx], userAuthNorth.AuthTrustLevel.ATL1);
} catch (e) {
console.log("getAuthInstance authType invalid : " + "invalidauthType[idx]" + invalidauthType[idx] + e.code);
expect(e.code).assertEqual(userAuthNorth.ResultCodeV9.TYPE_NOT_SUPPORT);
}
}
let invalidtrustLevel = [5000, 15000, 50000]
for (let idx = 0; idx < invalidtrustLevel.length; idx++) {
//trustlevel invalid
try {
console.log("getAuthInstance trustLevel invalid " + invalidtrustLevel[idx]);
var authInstance = userAuthNorth.getAuthInstance(challenge, 2, invalidtrustLevel[idx]);
} catch (e) {
console.log("getAuthInstance trustLevel invalid : " + "invalidtrustLevel[idx]" + invalidtrustLevel[idx] + e.code);
expect(e.code).assertEqual(userAuthNorth.ResultCodeV9.TRUST_LEVEL_NOT_SUPPORT);
}
}
done()
})
/*
* @tc.number : Security_IAM_Func_0106
* @tc.name : on,off invalid parameters
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 0
*/
it('Security_IAM_Func_0106', 0, async function (done) {
console.info('testFace Security_IAM_Func_0106 start');
let challenge = new Uint8Array([253, 19, 58, 160, 67, 200, 247, 37])
let authType = userAuthNorth.UserAuthType.FACE;
let authTrustLevel = userAuthNorth.AuthTrustLevel.ATL1;
//on: invalid parameter
try {
var authInstance = userAuthNorth.getAuthInstance(challenge, authType, authTrustLevel);
authInstance.on("results", {
callback: function (result) {
if (result.result != userAuthNorth.ResultCodeV9.SUCCESS) {
console.log("Security_IAM_Func_0106 on result = " + result.result);
}
}
});
} catch (e) {
console.log("Security_IAM_Func_0106 invalid results fail " + e.code);
expect(e.code).assertEqual(401);
}
//on: invalid parameter
try {
var authInstance = userAuthNorth.getAuthInstance(challenge, authType, authTrustLevel);
authInstance.on("tips", {
callback: function (result) {
if (result.result != userAuthNorth.ResultCodeV9.SUCCESS) {
console.log("Security_IAM_Func_0106 on result = " + result.result);
}
}
});
} catch (e) {
console.log("Security_IAM_Func_0106 invalid tips fail " + e.code);
expect(e.code).assertEqual(401);
}
//on: more parameter
try {
var authInstance = userAuthNorth.getAuthInstance(challenge, authType, authTrustLevel);
authInstance.on("tip", "result", {
callback: function (result) {
if (result.result != userAuthNorth.ResultCodeV9.SUCCESS) {
console.log("Security_IAM_Func_0106 on result = " + result.result);
}
}
});
} catch (e) {
console.log("Security_IAM_Func_0106 more param fail " + e.code);
expect(e.code).assertEqual(401);
}
//on: invalid parameter
try {
var authInstance = userAuthNorth.getAuthInstance(challenge, authType, authTrustLevel);
authInstance.on("", {
callback: function (result) {
if (result.result != userAuthNorth.ResultCodeV9.SUCCESS) {
console.log("Security_IAM_Func_0106 on result = " + result.result);
}
}
});
} catch (e) {
console.log("Security_IAM_Func_0106 invalid fail " + e.code);
expect(e.code).assertEqual(401);
}
//on: invalid parameter
try {
var authInstance = userAuthNorth.getAuthInstance(challenge, authType, authTrustLevel);
authInstance.on("result");
} catch (e) {
console.log("Security_IAM_Func_0106 no callback fail " + e.code);
expect(e.code).assertEqual(401);
}
//off: invalid parameter
try {
var authInstance = userAuthNorth.getAuthInstance(challenge, authType, authTrustLevel);
authInstance.off("results");
} catch (e) {
console.log("Security_IAM_Func_0106 invalid results fail " + e.code);
expect(e.code).assertEqual(401);
}
//off: more parameter
try {
var authInstance = userAuthNorth.getAuthInstance(challenge, authType, authTrustLevel);
authInstance.off("result", "tip");
} catch (e) {
console.log("Security_IAM_Func_0106 more param fail " + e.code);
expect(e.code).assertEqual(401);
}
//off: invalid parameter
try {
var authInstance = userAuthNorth.getAuthInstance(challenge, authType, authTrustLevel);
authInstance.off("tips");
} catch (e) {
console.log("Security_IAM_Func_0106 invalid tips fail " + e.code);
expect(e.code).assertEqual(401);
}
//off: invalid parameter
try {
var authInstance = userAuthNorth.getAuthInstance(challenge, authType, authTrustLevel);
authInstance.off("");
} catch (e) {
console.log("Security_IAM_Func_0106 invalid param fail " + e.code);
expect(e.code).assertEqual(401);
done();
}
})
/*
* @tc.number : Security_IAM_Func_0103
* @tc.name : Kit interface auth & cancel auth
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 0
*/
it('Security_IAM_Func_0106', 0, async function (done) {
console.info('testFace Security_IAM_Func_0106 start');
let challenge = new Uint8Array([253, 19, 58, 160, 67, 200, 247, 37])
let authType = userAuthNorth.UserAuthType.FACE;
let authTrustLevel = userAuthNorth.AuthTrustLevel.ATL1;
//on: invalid parameter
try {
var authInstance = userAuthNorth.getAuthInstance(challenge, authType, authTrustLevel);
authInstance.on("results", {
callback: function(result) {
if (result.result != userAuthNorth.ResultCodeV9.SUCCESS) {
console.log("Security_IAM_Func_0106 on result = " + result.result);
}
}
});
} catch (e) {
console.log("Security_IAM_Func_0106 noAuthType fail " + e);
expect(e.code).assertEqual(userAuthNorth.ResultCodeV9.INVALID_PARAMETERS);
}
//on: invalid parameter
try {
var authInstance = userAuthNorth.getAuthInstance(challenge, authType, authTrustLevel);
authInstance.on("", {
callback: function(result) {
if (result.result != userAuthNorth.ResultCodeV9.SUCCESS) {
console.log("Security_IAM_Func_0106 on result = " + result.result);
}
}
});
} catch (e) {
console.log("Security_IAM_Func_0106 noAuthType fail " + e);
expect(e.code).assertEqual(userAuthNorth.ResultCodeV9.INVALID_PARAMETERS);
}
//on: invalid parameter
try {
var authInstance = userAuthNorth.getAuthInstance(challenge, authType, authTrustLevel);
authInstance.on("result");
} catch (e) {
console.log("Security_IAM_Func_0106 noAuthType fail " + e);
expect(e.code).assertEqual(userAuthNorth.ResultCodeV9.INVALID_PARAMETERS);
}
//off: invalid parameter
try {
var authInstance = userAuthNorth.getAuthInstance(challenge, authType, authTrustLevel);
authInstance.off("results");
} catch (e) {
console.log("Security_IAM_Func_0106 noAuthType fail " + e);
expect(e.code).assertEqual(userAuthNorth.ResultCodeV9.INVALID_PARAMETERS);
}
//off: invalid parameter
try {
var authInstance = userAuthNorth.getAuthInstance(challenge, authType, authTrustLevel);
authInstance.off("");
} catch (e) {
console.log("Security_IAM_Func_0106 noAuthType fail " + e);
expect(e.code).assertEqual(userAuthNorth.ResultCodeV9.INVALID_PARAMETERS);
done();
}
})
/*
* @tc.number : Security_IAM_Func_0103
* @tc.name : Kit interface auth & cancel auth
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 0
*/
it('Security_IAM_Func_0103', 0, async function (done) {
let challenge = new Uint8Array([253, 19, 58, 160, 67, 200, 247, 37])
let authType = userAuthNorth.UserAuthType.FACE;
let authTrustLevel = userAuthNorth.AuthTrustLevel.ATL1;
try {
var authInstance = userAuthNorth.getAuthInstance(challenge, authType, authTrustLevel);
// register result and tip
authInstance.on("result", {
callback: (result) => {
console.log("authV9 result " + result.result);
console.log("authV9 token " + result.token);
console.log("authV9 remainAttempts " + result.remainAttempts);
console.log("authV9 lockoutDuration " + result.lockoutDuration);
expect(result.result).assertEqual(userAuthNorth.ResultCodeV9.NOT_ENROLLED);
*/
it('Security_IAM_Func_0103', 0, async function (done) {
let challenge = new Uint8Array([253, 19, 58, 160, 67, 200, 247, 37])
let authType = userAuthNorth.UserAuthType.FACE;
let authTrustLevel = userAuthNorth.AuthTrustLevel.ATL1;
try {
var authInstance = userAuthNorth.getAuthInstance(challenge, authType, authTrustLevel);
// register result and tip
authInstance.on("result", {
callback: (result) => {
console.log("authV9 result " + result.result);
console.log("authV9 token " + result.token);
console.log("authV9 remainAttempts " + result.remainAttempts);
console.log("authV9 lockoutDuration " + result.lockoutDuration);
expect(result.result).assertEqual(userAuthNorth.ResultCodeV9.NOT_ENROLLED);
}
});
authInstance.on("tip", {
callback: (result) => {
console.log("authV9 module " + result.module);
console.log("authV9 tip " + result.tip);
}
});
//start auth
authInstance.start();
} catch (e) {
console.log("Security_IAM_Func_0103 fail " + e);
}
});
authInstance.on("tip", {
callback: (result) => {
console.log("authV9 module " + result.module);
console.log("authV9 tip " + result.tip);
// cancel auth
try {
authInstance.cancel();
} catch (e) {
console.log("Security_IAM_Func_0103 cancel fail " + e);
expect(e.code).assertEqual(userAuthNorth.ResultCodeV9.GENERAL_ERROR);
}
});
//start auth
authInstance.start();
} catch (e) {
console.log("Security_IAM_Func_0103 fail " + e);
}
// cancel auth
try {
authInstance.cancel();
} catch (e) {
console.log("Security_IAM_Func_0103 cancel fail " + e);
expect(e.code).assertEqual(userAuthNorth.ResultCodeV9.GENERAL_ERROR);
}
// unregister result and tip
try {
// unregister result and tip
try {
authInstance.off("result");
authInstance.off("tip");
done();
} catch (e) {
console.log("Security_IAM_Func_0103 fail " + e);
expect(e.code).assertEqual(userAuthNorth.ResultCodeV9.GENERAL_ERROR);
done();
}
})
} catch (e) {
console.log("Security_IAM_Func_0103 fail " + e);
expect(e.code).assertEqual(userAuthNorth.ResultCodeV9.GENERAL_ERROR);
done();
}
})
/*
* @tc.number : Security_IAM_Func_0108
* @tc.name : off direct
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 0
*/
it('Security_IAM_Func_0108', 0, async function (done) {
let challenge = new Uint8Array([253, 19, 58, 160, 67, 200, 247, 37])
let authType = userAuthNorth.UserAuthType.FACE;
let authTrustLevel = userAuthNorth.AuthTrustLevel.ATL1;
try {
var authInstance = userAuthNorth.getAuthInstance(challenge, authType, authTrustLevel);
authInstance.off("result");
done();
} catch (e) {
console.log("Security_IAM_Func_0108 fail " + e);
expect(e.code).assertEqual(userAuthNorth.ResultCodeV9.GENERAL_ERROR);
done();
}
})
/*
* @tc.number : Security_IAM_Func_0108
* @tc.name : off direct
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 0
*/
it('Security_IAM_Func_0108', 0, async function (done) {
let challenge = new Uint8Array([253, 19, 58, 160, 67, 200, 247, 37])
let authType = userAuthNorth.UserAuthType.FACE;
let authTrustLevel = userAuthNorth.AuthTrustLevel.ATL1;
/*
* @tc.number : Security_IAM_Func_0109
* @tc.name : cancel direct
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 0
*/
it('Security_IAM_Func_0109', 0, async function (done) {
let challenge = new Uint8Array([253, 19, 58, 160, 67, 200, 247, 37])
let authType = userAuthNorth.UserAuthType.FACE;
let authTrustLevel = userAuthNorth.AuthTrustLevel.ATL1;
try {
var authInstance = userAuthNorth.getAuthInstance(challenge, authType, authTrustLevel);
authInstance.cancel();
} catch (e) {
console.log("Security_IAM_Func_0109 fail " + e);
expect(e.code).assertEqual(userAuthNorth.ResultCodeV9.GENERAL_ERROR);
done();
}
})
/*
* @tc.number : Security_IAM_Func_0110
* @tc.name : getAuthInstance faceType ATL4
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 0
*/
it('Security_IAM_Func_0110', 0, async function (done) {
let challenge = new Uint8Array([253, 19, 58, 160, 67, 200, 247, 37])
let authType = userAuthNorth.UserAuthType.FACE;
let authTrustLevel = userAuthNorth.AuthTrustLevel.ATL4;
try {
var authInstance = userAuthNorth.getAuthInstance(challenge, authType, authTrustLevel);
done();
} catch (e) {
console.log("Security_IAM_Func_0110 FACE ATL4 fail" + e);
expect(null).assertFail();
try {
var authInstance = userAuthNorth.getAuthInstance(challenge, authType, authTrustLevel);
authInstance.off("result");
done();
} catch (e) {
console.log("Security_IAM_Func_0108 fail " + e.code);
expect(e.code).assertEqual(userAuthNorth.ResultCodeV9.GENERAL_ERROR);
done();
}
})
/*
* @tc.number : Security_IAM_Func_0109
* @tc.name : cancel direct
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 0
*/
it('Security_IAM_Func_0109', 0, async function (done) {
let challenge = new Uint8Array([253, 19, 58, 160, 67, 200, 247, 37])
let authType = userAuthNorth.UserAuthType.FACE;
let authTrustLevel = userAuthNorth.AuthTrustLevel.ATL1;
try {
var authInstance = userAuthNorth.getAuthInstance(challenge, authType, authTrustLevel);
authInstance.cancel();
} catch (e) {
console.log("Security_IAM_Func_0109 fail " + e);
expect(e.code).assertEqual(userAuthNorth.ResultCodeV9.GENERAL_ERROR);
done();
}
})
/*
* @tc.number : Security_IAM_Func_0110
* @tc.name : getAuthInstance faceType ATL4
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 0
*/
it('Security_IAM_Func_0110', 0, async function (done) {
let challenge = new Uint8Array([253, 19, 58, 160, 67, 200, 247, 37])
let authType = userAuthNorth.UserAuthType.FACE;
let authTrustLevel = userAuthNorth.AuthTrustLevel.ATL4;
try {
var authInstance = userAuthNorth.getAuthInstance(challenge, authType, authTrustLevel);
done();
} catch (e) {
console.log("Security_IAM_Func_0110 FACE ATL4 fail" + e);
expect(null).assertFail();
done();
}
})
/*
* @tc.number : Security_IAM_PIN_Kit_Func_0104
* @tc.name : Kit interface enum AuthTrustLevel
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 0
*/
it('Security_IAM_PIN_Kit_Func_0104', 0, async function (done) {
console.info('testFace Security_IAM_PIN_Kit_Func_0104 start');
expect(10000).assertEqual(userAuthNorth.AuthTrustLevel.ATL1);
expect(20000).assertEqual(userAuthNorth.AuthTrustLevel.ATL2);
expect(30000).assertEqual(userAuthNorth.AuthTrustLevel.ATL3);
expect(40000).assertEqual(userAuthNorth.AuthTrustLevel.ATL4);
console.info('testFace Security_IAM_PIN_Kit_Func_0104 end');
done();
}
})
})
/*
* @tc.number : Security_IAM_PIN_Kit_Func_0104
* @tc.name : Kit interface enum AuthTrustLevel
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 0
*/
it('Security_IAM_PIN_Kit_Func_0104', 0, async function (done) {
console.info('testFace Security_IAM_PIN_Kit_Func_0104 start');
expect(10000).assertEqual(userAuthNorth.AuthTrustLevel.ATL1);
expect(20000).assertEqual(userAuthNorth.AuthTrustLevel.ATL2);
expect(30000).assertEqual(userAuthNorth.AuthTrustLevel.ATL3);
expect(40000).assertEqual(userAuthNorth.AuthTrustLevel.ATL4);
console.info('testFace Security_IAM_PIN_Kit_Func_0104 end');
done();
})
/*
* @tc.number : Security_IAM_PIN_Kit_Func_0105
* @tc.name : Kit interface enum FaceTips
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 0
*/
it('Security_IAM_PIN_Kit_Func_0105', 0, async function (done) {
console.info('testFace Security_IAM_PIN_Kit_Func_0105 start');
expect(1).assertEqual(userAuthNorth.FaceTips.FACE_AUTH_TIP_TOO_BRIGHT);
expect(2).assertEqual(userAuthNorth.FaceTips.FACE_AUTH_TIP_TOO_DARK);
expect(3).assertEqual(userAuthNorth.FaceTips.FACE_AUTH_TIP_TOO_CLOSE);
expect(4).assertEqual(userAuthNorth.FaceTips.FACE_AUTH_TIP_TOO_FAR);
expect(5).assertEqual(userAuthNorth.FaceTips.FACE_AUTH_TIP_TOO_HIGH);
expect(6).assertEqual(userAuthNorth.FaceTips.FACE_AUTH_TIP_TOO_LOW);
expect(7).assertEqual(userAuthNorth.FaceTips.FACE_AUTH_TIP_TOO_RIGHT);
expect(8).assertEqual(userAuthNorth.FaceTips.FACE_AUTH_TIP_TOO_LEFT);
expect(9).assertEqual(userAuthNorth.FaceTips.FACE_AUTH_TIP_TOO_MUCH_MOTION);
expect(10).assertEqual(userAuthNorth.FaceTips.FACE_AUTH_TIP_POOR_GAZE);
expect(11).assertEqual(userAuthNorth.FaceTips.FACE_AUTH_TIP_NOT_DETECTED);
console.info('testFace Security_IAM_PIN_Kit_Func_0105 end');
done();
})
/*
* @tc.number : Security_IAM_PIN_Kit_Func_0105
* @tc.name : Kit interface enum FaceTips
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 0
*/
it('Security_IAM_PIN_Kit_Func_0105', 0, async function (done) {
console.info('testFace Security_IAM_PIN_Kit_Func_0105 start');
expect(1).assertEqual(userAuthNorth.FaceTips.FACE_AUTH_TIP_TOO_BRIGHT);
expect(2).assertEqual(userAuthNorth.FaceTips.FACE_AUTH_TIP_TOO_DARK);
expect(3).assertEqual(userAuthNorth.FaceTips.FACE_AUTH_TIP_TOO_CLOSE);
expect(4).assertEqual(userAuthNorth.FaceTips.FACE_AUTH_TIP_TOO_FAR);
expect(5).assertEqual(userAuthNorth.FaceTips.FACE_AUTH_TIP_TOO_HIGH);
expect(6).assertEqual(userAuthNorth.FaceTips.FACE_AUTH_TIP_TOO_LOW);
expect(7).assertEqual(userAuthNorth.FaceTips.FACE_AUTH_TIP_TOO_RIGHT);
expect(8).assertEqual(userAuthNorth.FaceTips.FACE_AUTH_TIP_TOO_LEFT);
expect(9).assertEqual(userAuthNorth.FaceTips.FACE_AUTH_TIP_TOO_MUCH_MOTION);
expect(10).assertEqual(userAuthNorth.FaceTips.FACE_AUTH_TIP_POOR_GAZE);
expect(11).assertEqual(userAuthNorth.FaceTips.FACE_AUTH_TIP_NOT_DETECTED);
console.info('testFace Security_IAM_PIN_Kit_Func_0105 end');
done();
})
/*
* @tc.number : Security_IAM_PIN_Kit_Func_0106
* @tc.name : Kit interface enum UserAuthType
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 0
*/
it('Security_IAM_PIN_Kit_Func_0106', 0, async function (done) {
console.info('testFace Security_IAM_PIN_Kit_Func_0106 start');
expect(2).assertEqual(userAuthNorth.UserAuthType.FACE);
expect(4).assertEqual(userAuthNorth.UserAuthType.FINGERPRINT);
console.info('testFace Security_IAM_PIN_Kit_Func_0106 end');
done();
})
/*
* @tc.number : Security_IAM_PIN_Kit_Func_0106
* @tc.name : Kit interface enum UserAuthType
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 0
*/
it('Security_IAM_PIN_Kit_Func_0106', 0, async function (done) {
console.info('testFace Security_IAM_PIN_Kit_Func_0106 start');
expect(2).assertEqual(userAuthNorth.UserAuthType.FACE);
expect(4).assertEqual(userAuthNorth.UserAuthType.FINGERPRINT);
console.info('testFace Security_IAM_PIN_Kit_Func_0106 end');
done();
})
/*
* @tc.number : Security_IAM_Func_0107
* @tc.name : Kit interface enum ResultCode
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 0
*/
it('Security_IAM_Func_0107', 0, async function (done) {
console.info('testFace Security_IAM_Func_0107 start');
expect(12500000).assertEqual(userAuthNorth.ResultCodeV9.SUCCESS);
expect(12500001).assertEqual(userAuthNorth.ResultCodeV9.FAIL);
expect(12500002).assertEqual(userAuthNorth.ResultCodeV9.GENERAL_ERROR);
expect(12500003).assertEqual(userAuthNorth.ResultCodeV9.CANCELED);
expect(12500004).assertEqual(userAuthNorth.ResultCodeV9.TIMEOUT);
expect(12500005).assertEqual(userAuthNorth.ResultCodeV9.TYPE_NOT_SUPPORT);
expect(12500006).assertEqual(userAuthNorth.ResultCodeV9.TRUST_LEVEL_NOT_SUPPORT);
expect(12500007).assertEqual(userAuthNorth.ResultCodeV9.BUSY);
expect(12500009).assertEqual(userAuthNorth.ResultCodeV9.LOCKED);
expect(12500010).assertEqual(userAuthNorth.ResultCodeV9.NOT_ENROLLED);
console.info('testFace Security_IAM_Func_0107 end');
done();
})
/*
* @tc.number : Security_IAM_Func_0107
* @tc.name : Kit interface enum ResultCode
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 0
*/
it('Security_IAM_Func_0107', 0, async function (done) {
console.info('testFace Security_IAM_Func_0107 start');
expect(12500000).assertEqual(userAuthNorth.ResultCodeV9.SUCCESS);
expect(12500001).assertEqual(userAuthNorth.ResultCodeV9.FAIL);
expect(12500002).assertEqual(userAuthNorth.ResultCodeV9.GENERAL_ERROR);
expect(12500003).assertEqual(userAuthNorth.ResultCodeV9.CANCELED);
expect(12500004).assertEqual(userAuthNorth.ResultCodeV9.TIMEOUT);
expect(12500005).assertEqual(userAuthNorth.ResultCodeV9.TYPE_NOT_SUPPORT);
expect(12500006).assertEqual(userAuthNorth.ResultCodeV9.TRUST_LEVEL_NOT_SUPPORT);
expect(12500007).assertEqual(userAuthNorth.ResultCodeV9.BUSY);
expect(12500008).assertEqual(userAuthNorth.ResultCodeV9.INVALID_PARAMETERS);
expect(12500009).assertEqual(userAuthNorth.ResultCodeV9.LOCKED);
expect(12500010).assertEqual(userAuthNorth.ResultCodeV9.NOT_ENROLLED);
console.info('testFace Security_IAM_Func_0107 end');
done();
})
/*
* @tc.number : Security_IAM_PIN_Kit_Func_0108
* @tc.name : Kit interface enum FingerprintTips
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 0
*/
it('Security_IAM_PIN_Kit_Func_0108', 0, async function (done) {
console.info('testFace Security_IAM_PIN_Kit_Func_0108 start');
expect(0).assertEqual(userAuthNorth.FingerprintTips.FINGERPRINT_AUTH_TIP_GOOD);
expect(1).assertEqual(userAuthNorth.FingerprintTips.FINGERPRINT_AUTH_TIP_DIRTY);
expect(2).assertEqual(userAuthNorth.FingerprintTips.FINGERPRINT_AUTH_TIP_INSUFFICIENT);
expect(3).assertEqual(userAuthNorth.FingerprintTips.FINGERPRINT_AUTH_TIP_PARTIAL);
expect(4).assertEqual(userAuthNorth.FingerprintTips.FINGERPRINT_AUTH_TIP_TOO_FAST);
expect(5).assertEqual(userAuthNorth.FingerprintTips.FINGERPRINT_AUTH_TIP_TOO_SLOW);
console.info('testFace Security_IAM_PIN_Kit_Func_0108 end');
done();
})
/*
* @tc.number : Security_IAM_PIN_Kit_Func_0108
* @tc.name : Kit interface enum FingerprintTips
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 0
*/
it('Security_IAM_PIN_Kit_Func_0108', 0, async function (done) {
console.info('testFace Security_IAM_PIN_Kit_Func_0108 start');
expect(0).assertEqual(userAuthNorth.FingerprintTips.FINGERPRINT_AUTH_TIP_GOOD);
expect(1).assertEqual(userAuthNorth.FingerprintTips.FINGERPRINT_AUTH_TIP_DIRTY);
expect(2).assertEqual(userAuthNorth.FingerprintTips.FINGERPRINT_AUTH_TIP_INSUFFICIENT);
expect(3).assertEqual(userAuthNorth.FingerprintTips.FINGERPRINT_AUTH_TIP_PARTIAL);
expect(4).assertEqual(userAuthNorth.FingerprintTips.FINGERPRINT_AUTH_TIP_TOO_FAST);
expect(5).assertEqual(userAuthNorth.FingerprintTips.FINGERPRINT_AUTH_TIP_TOO_SLOW);
console.info('testFace Security_IAM_PIN_Kit_Func_0108 end');
done();
})
})
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册