未验证 提交 36602cd2 编写于 作者: O openharmony_ci 提交者: Gitee

!5968 新增电话接口xts覆盖

Merge pull request !5968 from 李昊/master
......@@ -161,7 +161,7 @@ export default function Telephony_NETMANAGER_TestDNSTest() {
it('Telephony_NETMANAGER_TestDNS_Test0900', 0, function(done){
let netHandle = netConnection.getDefaultNetSync();
console.info("Telephony_NETMANAGER_TestDNS_Test0900 " + JSON.stringify(netHandle));
expect(netHandle.netId).assertEqual(100);
expect(netHandle.netId >= 100).assertTrue();
done();
});
});
......
/**
* 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 net_Http from '@ohos.net.http';
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
export default function Http2Test() {
describe('Http2Test', function () {
/**
* @tc.number Telephony_NETSTACK_Http2TestBasicGet_0100
* @tc.name set usingCache to true
* @tc.desc usingCache test
*/
it('Telephony_NETSTACK_Http2TestBasicGet_0100', 0, async function (done) {
let http = net_Http.createHttp()
http.request("https://www.zhihu.com", {
usingProtocol: net_Http.HttpProtocol.HTTP1_1
}).then(function (data) {
console.info("Telephony_NETSTACK_Http2TestBasicGet_0100" + JSON.stringify(data));
expect(data.responseCode === net_Http.ResponseCode.OK).assertTrue();
done();
})
});
/**
* @tc.number Telephony_NETSTACK_Http2TestBasicGet_0200
* @tc.name set usingCache to true
* @tc.desc usingCache test
*/
it('Telephony_NETSTACK_Http2TestBasicGet_0200', 0, async function (done) {
let http = net_Http.createHttp()
http.request("https://www.zhihu.com", {
usingProtocol: net_Http.HttpProtocol.HTTP2
}).then(function (data) {
console.info("Telephony_NETSTACK_Http2TestBasicGet_0200" + JSON.stringify(data));
expect(data.responseCode === net_Http.ResponseCode.OK).assertTrue();
done();
})
});
/**
* @tc.number Telephony_NETSTACK_Http2TestBasicGet_0300
* @tc.name set usingCache to true
* @tc.desc usingCache test
*/
it('Telephony_NETSTACK_Http2TestBasicGet_0300', 0, async function (done) {
let http = net_Http.createHttp()
http.request("https://www.zhihu.com").then(function (data) {
console.info("Telephony_NETSTACK_Http2TestBasicGet_0300" + JSON.stringify(data));
expect(data.responseCode === net_Http.ResponseCode.OK).assertTrue();
done();
})
});
/**
* @tc.number Telephony_NETSTACK_Http2TestBasicGet_0400
* @tc.name set usingCache to true
* @tc.desc usingCache test
*/
it('Telephony_NETSTACK_Http2TestBasicGet_0400', 0, async function (done) {
expect(net_Http.HttpProtocol.HTTP1_1).assertEqual(0);
expect(net_Http.HttpProtocol.HTTP2).assertEqual(1);
done();
});
/**
* @tc.number Telephony_NETSTACK_Http2TestBasicGet_0500
* @tc.name set usingCache to true
* @tc.desc usingCache test
*/
it('Telephony_NETSTACK_Http2TestBasicGet_0500', 0, async function (done) {
expect(net_Http.HttpDataType.STRING).assertEqual(0);
expect(net_Http.HttpDataType.OBJECT).assertEqual(1);
expect(net_Http.HttpDataType.ARRAY_BUFFER).assertEqual(2);
done();
});
it('Telephony_http_HttpTestPriority_0100', 0, async function(done){
let CaseName = 'Telephony_http_HttpTestPriority_0100';
try {
let httpRequestOptions ={
method: net_http.RequestMethod.GET,
extraData: null,
header: "content-type': 'application/json",
readTimeout: 6000,
connectTimeout: 6000,
priority: 100
}
var httpRequest = net_http.createHttp();
httpRequest.request("https://httpbin/anything", httpRequestOptions, (err,data) => {
console.info(CaseName + Json.stringify(err)+ "data"+ Json.stringify(data));
expect(data.responseCode === net_http.ResponseCode.Ok).assertTrue();
done();
});
} catch(err){
console.info(CaseName+ "err=" + err)
done();
return;
}
})
});
}
\ 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 net_http from '@ohos.net.http';
import { describe, expect, it } from '@ohos/hypium'
export default function HttpCacheTest() {
describe('HttpCacheTest', function () {
/**
* @tc.number Telephony_NetStack_HttpTestBasicGet_0100
* @tc.name set usingCache to true
* @tc.desc usingCache test
*/
it('Telephony_NetStack_HttpTestBasicGet_0100', 0, async function(done){
let CaseName = 'Telephony_NetStack_HttpTestBasicGet_0100';
let http = net_http.createHttp();
http.request('https://httpbin.org/anything', {
usingCache : true
}).then(function(data){
console.info(CaseName + JSON.stringify(data));
expect(data.responseCode === net_http.ResponseCode.OK).assertTrue();
done();
return;
});
});
/**
* @tc.number Telephony_NetStack_HttpTestBasicGet_0200
* @tc.name set usingCache to false
* @tc.desc usingCache test
*/
it('Telephony_NetStack_HttpTestBasicGet_0200', 0, async function(done){
let CaseName = 'Telephony_NetStack_HttpTestBasicGet_0200';
let http = net_http.createHttp();
http.request('https://httpbin.org/anything', {
usingCache : false
}).then(function(data){
console.info(CaseName + JSON.stringify(data));
expect(data.responseCode === net_http.ResponseCode.OK).assertTrue();
done();
return;
});
});
/**
* @tc.number Telephony_NetStack_HttpTestCacheFlush_0100
* @tc.name use callback form test cache.flush
* @tc.desc cache flush test
*/
it('Telephony_NetStack_HttpTestCacheFlush_0100', 0, async function(done){
let CaseName = 'Telephony_NetStack_HttpTestCacheFlush_0100';
let http = net_http.createHttp();
let cache = net_http.createHttpResponseCache(10*1024*1024);
http.request('https://httpbin.org/anything',{
usingCache : true
}).then(function (){
cache.flush().then(function (data){
console.info(CaseName + JSON.stringify(data));
expect(data === undefined).assertTrue();
done();
return;
})
});
});
/**
* @tc.number Telephony_NetStack_HttpTestCacheFlush_0200
* @tc.name use promise form test cache.flush
* @tc.desc cache flush test
*/
it('Telephony_NetStack_HttpTestCacheFlush_0200', 0, async function(done){
let CaseName = 'Telephony_NetStack_HttpTestCacheFlush_0200';
let http = net_http.createHttp();
let cache = net_http.createHttpResponseCache(10*1024*1024);
http.request('https://httpbin.org/anything',{
usingCache : true
}).then(function (){
cache.flush(function (data){
console.info(CaseName + JSON.stringify(data));
expect(data === undefined).assertTrue();
done();
return;
})
});
});
/**
* @tc.number Telephony_NetStack_HttpTestCacheDelete_0100
* @tc.name use callback form test cache.delete
* @tc.desc cache flush test
*/
it('Telephony_NetStack_HttpTestCacheDelete_0100', 0, async function(done){
let CaseName = 'Telephony_NetStack_HttpTestCacheDelete_0100';
let http = net_http.createHttp();
let cache = net_http.createHttpResponseCache(10*1024*1024);
http.request('https://httpbin.org/anything',{
usingCache : true
}).then(function (){
cache.delete().then(function (data){
console.info(CaseName + JSON.stringify(data));
expect(data === undefined).assertTrue();
done();
return;
})
});
});
/**
* @tc.number Telephony_NetStack_HttpTestCacheDelete_0200
* @tc.name use callback form test cache.delete
* @tc.desc cache flush test
*/
it('Telephony_NetStack_HttpTestCacheDelete_0200', 0, async function(done){
let CaseName = 'Telephony_NetStack_HttpTestCacheDelete_0200';
let http = net_http.createHttp();
let cache = net_http.createHttpResponseCache(10*1024*1024);
http.request('https://httpbin.org/anything',{
usingCache : true
}).then(function (){
cache.delete(function (data){
console.info(CaseName + JSON.stringify(data));
expect(data === undefined).assertTrue();
done();
return;
})
});
});
});
};
\ No newline at end of file
......@@ -13,7 +13,11 @@
* limitations under the License.
*/
import Telephony_NETSTACK_HTTPTest from './NetworkManagerHttp.test.js'
import Http2Test from './Http2Test.js'
import HttpCacheTest from './HttpCacheTest.js'
export default function testsuite() {
Telephony_NETSTACK_HTTPTest()
Http2Test()
HttpCacheTest()
}
......@@ -18,6 +18,7 @@ import connectionJsunit from './ConnectionJsunit.test.ets';
import socketJsunit from './SocketJsunit.test.ets';
import webSocketJsunit from './WebSocketJsunit.test.ets';
import connectionSecondJsUnit from './ConnectionSecondJsUnit.test.ets';
import networkManagerSocketTest from './NetworkManagerSocket.test'
export default function testsuite() {
//other
......@@ -25,4 +26,5 @@ export default function testsuite() {
webSocketJsunit();
connectionJsunit();
connectionSecondJsUnit();
networkManagerSocketTest();
}
\ No newline at end of file
// @ts-nocheck
/*
* 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 { describe, it, expect, beforeAll, afterAll, afterEach, beforeEach } from 'hypium/index';
import socket from "@ohos.net.socket";
let sendData = "hello!";
let instance = undefined;
let options = {
ALPNProtocols: ["spdy/1", "http/1.1"],
address: {
address: "192.168.31.96",
port: 5555,
family: 1
},
secureOptions: {
key: "key",
cert: "cert",
ca: ["ca"],
passwd: "123456",
protocols: [socket.Protocol.TLSv12, socket.Protocol.TLSv13],
useRemoteCipherPrefer: true,
signatureAlgorithms: "rsa_pss_rsae_sha256:ECDSA+SHA256",
cipherSuites: "AES256-SHA256"
},
}
export default function networkManagerSocketTest() {
describe("Telephony_NetworkManager_SocketTest", function () {
beforeAll(async function () {
console.log('Telephony_NetworkManager_ActsNetworkManagerSocketTest beforeAll start')
console.log('Telephony_NetworkManager_ActsNetworkManagerSocketTest beforeAll end')
})
afterAll(async function () {
console.log('Telephony_NetworkManager_ActsNetworkManagerSocketTest afterAll start')
console.log('Telephony_NetworkManager_ActsNetworkManagerSocketTest afterAll end')
})
/**
* @tc.number Telephony_NetworkManager_constructTLSSocketInstance_0100
* @tc.name Test create TLSSocket object
* @tc.desc Function test
*/
it('Telephony_NetworkManager_constructTLSSocketInstance_0100', 0, async function (done) {
instance = socket.constructTLSSocketInstance()
if (instance != "") {
expect(instance).assertInstanceOf('Object');
done();
} else {
expect().assertFail();
done();
}
})
/**
* @tc.number Telephony_NetworkManager_connect_Async_0100
* @tc.name Test connect() interface
* @tc.desc Function test
*/
it('Telephony_NetworkManager_connect_Async_0100', 0, async function (done) {
instance = socket.constructTLSSocketInstance()
instance.connect(options, (err) => {
expect(options.ALPNProtocols != undefined).assertEqual(true);
expect(options.address != undefined).assertEqual(true);
expect(options.secureOptions != undefined).assertEqual(true);
expect(options.secureOptions.key != undefined).assertEqual(true);
expect(options.secureOptions.cert != undefined).assertEqual(true);
expect(options.secureOptions.ca != undefined).assertEqual(true);
expect(options.secureOptions.passwd != undefined).assertEqual(true);
expect(options.secureOptions.protocols != undefined).assertEqual(true);
expect(options.secureOptions.protocols[0] == "TLSv1.2").assertEqual(true);
expect(options.secureOptions.protocols[1] == "TLSv1.3").assertEqual(true);
expect(options.secureOptions.useRemoteCipherPrefer != undefined).assertEqual(true);
expect(options.secureOptions.signatureAlgorithms != undefined).assertEqual(true);
expect(options.secureOptions.cipherSuites != undefined).assertEqual(true);
expect(socket.X509CertRawData == undefined).assertEqual(true);
if (err == undefined) {
expect().assertFail();
done();
} else {
expect(err != undefined).assertEqual(true);
done();
}
})
})
/**
* @tc.number Telephony_NetworkManager_connect_Promise_0100
* @tc.name Test connect() interface
* @tc.desc Function test
*/
it('Telephony_NetworkManager_connect_Promise_0100', 0, async function (done) {
instance = socket.constructTLSSocketInstance()
instance.connect(options).then(() => {
expect().assertFail();
done();
}).catch((err) => {
expect(err != undefined).assertEqual(true);
done();
})
})
/**
* @tc.number Telephony_NetworkManager_close_Async_0100
* @tc.name Test close() interface
* @tc.desc Function test
*/
it('Telephony_NetworkManager_close_Async_0100', 0, async function (done) {
instance = socket.constructTLSSocketInstance()
instance.close((err) => {
if (err == undefined) {
expect().assertFail();
done();
} else {
expect(err != undefined).assertEqual(true);
done();
}
})
})
/**
* @tc.number Telephony_NetworkManager_close_Promise_0100
* @tc.name Test close() interface
* @tc.desc Function test
*/
it('Telephony_NetworkManager_close_Promise_0100', 0, async function (done) {
instance = socket.constructTLSSocketInstance()
instance.close().then(() => {
expect().assertFail();
done();
}).catch((err) => {
expect(err != undefined).assertEqual(true);
done();
})
})
/**
* @tc.number Telephony_NetworkManager_getCertificate_Async_0100
* @tc.name Test getCertificate() interface
* @tc.desc Function test
*/
it('Telephony_NetworkManager_getCertificate_Async_0100', 0, async function (done) {
instance = socket.constructTLSSocketInstance()
instance.getCertificate((err, data) => {
if (err == undefined) {
expect().assertFail();
done();
} else {
expect(data).assertEqual(undefined);
expect(err != undefined).assertEqual(true);
done();
}
})
})
/**
* @tc.number Telephony_NetworkManager_getCertificate_Promise_0100
* @tc.name Test getCertificate() interface
* @tc.desc Function test
*/
it('Telephony_NetworkManager_getCertificate_Promise_0100', 0, async function (done) {
instance = socket.constructTLSSocketInstance()
instance.getCertificate().then((data) => {
expect(data).assertEqual(undefined);
expect().assertFail();
done();
}).catch((err) => {
expect(err != undefined).assertEqual(true);
done();
})
})
/**
* @tc.number Telephony_NetworkManager_getRemoteCertificate_Async_0100
* @tc.name Test getRemoteCertificate() interface
* @tc.desc Function test
*/
it('Telephony_NetworkManager_getRemoteCertificate_Async_0100', 0, async function (done) {
instance = socket.constructTLSSocketInstance()
instance.getRemoteCertificate((err, data) => {
if (err == undefined) {
expect().assertFail();
done();
} else {
expect(data).assertEqual(undefined);
expect(err != undefined).assertEqual(true);
done();
}
})
})
/**
* @tc.number Telephony_NetworkManager_getRemoteCertificate_Promise_0100
* @tc.name Test getRemoteCertificate() interface
* @tc.desc Function test
*/
it('Telephony_NetworkManager_getRemoteCertificate_Promise_0100', 0, async function (done) {
instance = socket.constructTLSSocketInstance()
instance.getRemoteCertificate().then((data) => {
expect(data).assertEqual(undefined);
expect().assertFail();
done();
}).catch((err) => {
expect(err != undefined).assertEqual(true);
done();
})
})
/**
* @tc.number Telephony_NetworkManager_getProtocol_Async_0100
* @tc.name Test getProtocol() interface
* @tc.desc Function test
*/
it('Telephony_NetworkManager_getProtocol_Async_0100', 0, async function (done) {
instance = socket.constructTLSSocketInstance()
instance.getProtocol((err, data) => {
if (err == undefined) {
expect().assertFail();
done();
} else {
expect(data).assertEqual(undefined);
expect(err != undefined).assertEqual(true);
done();
}
})
})
/**
* @tc.number Telephony_NetworkManager_getProtocol_Promise_0100
* @tc.name Test getProtocol() interface
* @tc.desc Function test
*/
it('Telephony_NetworkManager_getProtocol_Promise_0100', 0, async function (done) {
instance = socket.constructTLSSocketInstance()
instance.getProtocol().then((data) => {
expect(data).assertEqual(undefined);
expect().assertFail();
done();
}).catch((err) => {
expect(err != undefined).assertEqual(true);
done();
})
})
/**
* @tc.number Telephony_NetworkManager_getCipherSuites_Async_0100
* @tc.name Test getCipherSuite() interface
* @tc.desc Function test
*/
it('Telephony_NetworkManager_getCipherSuites_Async_0100', 0, async function (done) {
instance = socket.constructTLSSocketInstance()
instance.getCipherSuite((err, data) => {
if (err == undefined) {
expect().assertFail();
done();
} else {
expect(data).assertEqual(undefined);
expect(err != undefined).assertEqual(true);
done();
}
})
})
/**
* @tc.number Telephony_NetworkManager_getCipherSuites_Promise_0100
* @tc.name Test getCipherSuite() interface
* @tc.desc Function test
*/
it('Telephony_NetworkManager_getCipherSuites_Promise_0100', 0, async function (done) {
instance = socket.constructTLSSocketInstance()
instance.getCipherSuite().then((data) => {
expect(data).assertEqual(undefined);
expect().assertFail();
done();
}).catch((err) => {
expect(err != undefined).assertEqual(true);
done();
})
})
/**
* @tc.number Telephony_NetworkManager_getSignatureAlgorithms_Async_0100
* @tc.name Test getSignatureAlgorithms() interface
* @tc.desc Function test
*/
it('Telephony_NetworkManager_getSignatureAlgorithms_Async_0100', 0, async function (done) {
instance = socket.constructTLSSocketInstance()
instance.getSignatureAlgorithms((err, data) => {
if (err == undefined) {
expect().assertFail();
done();
} else {
expect(data).assertEqual(undefined);
expect(err != undefined).assertEqual(true);
done();
}
})
})
/**
* @tc.number Telephony_NetworkManager_getSignatureAlgorithms_Promise_0100
* @tc.name Test getSignatureAlgorithms() interface
* @tc.desc Function test
*/
it('Telephony_NetworkManager_getSignatureAlgorithms_Promise_0100', 0, async function (done) {
instance = socket.constructTLSSocketInstance()
instance.getSignatureAlgorithms().then((data) => {
expect(data).assertEqual(undefined);
expect().assertFail();
done();
}).catch((err) => {
expect(err != undefined).assertEqual(true);
done();
})
})
/**
* @tc.number Telephony_NetworkManager_send_Async_0100
* @tc.name Test send() interface
* @tc.desc Function test
*/
it('Telephony_NetworkManager_send_Async_0100', 0, async function (done) {
instance = socket.constructTLSSocketInstance()
instance.send(sendData, (err) => {
if (err == undefined) {
expect().assertFail();
done();
} else {
expect(err != undefined).assertEqual(true);
done();
}
})
})
/**
* @tc.number Telephony_NetworkManager_send_Promise_0100
* @tc.name Test send() interface
* @tc.desc Function test
*/
it('Telephony_NetworkManager_send_Promise_0100', 0, async function (done) {
instance = socket.constructTLSSocketInstance()
instance.send(sendData).then(() => {
expect().assertFail();
done();
}).catch((err) => {
expect(err != undefined).assertEqual(true);
done();
})
})
})
}
\ No newline at end of file
......@@ -15,6 +15,6 @@ import("//test/xts/tools/build/suite.gni")
group("sms_mms") {
testonly = true
if (is_standard_system) {
deps = [ "sms_mms_error:ActSmsMmsErrorTest" ]
deps = [ "sms_mms_error:ActsSmsMmsErrorTest" ]
}
}
......@@ -13,14 +13,14 @@
import("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("ActSmsMmsErrorTest") {
ohos_js_hap_suite("ActsSmsMmsErrorTest") {
hap_profile = "./src/main/config.json"
deps = [
":hjs_demo_js_assets",
":hjs_demo_resources",
]
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "ActSmsMmsErrorTest"
hap_name = "ActsSmsMmsErrorTest"
part_name = "sms_mms"
subsystem_name = "telephony"
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册