Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
fdf70b98
X
Xts Acts
项目概览
OpenHarmony
/
Xts Acts
1 年多 前同步成功
通知
9
Star
22
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
X
Xts Acts
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
fdf70b98
编写于
1月 06, 2023
作者:
Z
zhangfuzhi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
网络用例整改,删除重复用例
Signed-off-by:
N
zhangfuzhi
<
zhangfuzhi1@huawei.com
>
上级
2eca517c
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
449 addition
and
546 deletion
+449
-546
telephony/telephonyjstest/netmanager_base/jshttp/src/main/js/test/Http2Test.js
...test/netmanager_base/jshttp/src/main/js/test/Http2Test.js
+32
-28
telephony/telephonyjstest/netmanager_base/jshttp/src/main/js/test/HttpCacheTest.js
.../netmanager_base/jshttp/src/main/js/test/HttpCacheTest.js
+6
-1
telephony/telephonyjstest/netmanager_base/jshttp/src/main/js/test/NetworkManagerHttp.test.js
...r_base/jshttp/src/main/js/test/NetworkManagerHttp.test.js
+123
-109
telephony/telephonyjstest/netmanager_base/system_fetch/src/main/js/test/Http.fetch.test.js
...ger_base/system_fetch/src/main/js/test/Http.fetch.test.js
+288
-408
未找到文件。
telephony/telephonyjstest/netmanager_base/jshttp/src/main/js/test/Http2Test.js
浏览文件 @
fdf70b98
...
...
@@ -14,7 +14,7 @@
*/
import
net_Http
from
'
@ohos.net.http
'
;
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expec
t
}
from
'
@ohos/hypium
'
import
{
describe
,
expect
,
i
t
}
from
'
@ohos/hypium
'
export
default
function
Http2Test
()
{
describe
(
'
Http2Test
'
,
function
()
{
...
...
@@ -25,10 +25,11 @@ export default function Http2Test() {
* @tc.desc usingCache test
*/
it
(
'
Telephony_NETSTACK_Http2TestBasicGet_0100
'
,
0
,
async
function
(
done
)
{
let
http
=
net_Http
.
createHttp
()
let
http
=
net_Http
.
createHttp
()
;
http
.
request
(
"
https://www.zhihu.com
"
,
{
usingProtocol
:
net_Http
.
HttpProtocol
.
HTTP1_1
}).
then
(
function
(
data
)
{
http
.
destroy
();
expect
(
data
.
responseCode
===
net_Http
.
ResponseCode
.
OK
).
assertTrue
();
done
();
});
...
...
@@ -40,10 +41,11 @@ export default function Http2Test() {
* @tc.desc usingCache test
*/
it
(
'
Telephony_NETSTACK_Http2TestBasicGet_0200
'
,
0
,
async
function
(
done
)
{
let
http
=
net_Http
.
createHttp
()
let
http
=
net_Http
.
createHttp
()
;
http
.
request
(
"
https://www.zhihu.com
"
,
{
usingProtocol
:
net_Http
.
HttpProtocol
.
HTTP2
}).
then
(
function
(
data
)
{
http
.
destroy
();
console
.
info
(
"
Telephony_NETSTACK_Http2TestBasicGet_0200
"
+
JSON
.
stringify
(
data
));
expect
(
data
.
responseCode
===
net_Http
.
ResponseCode
.
OK
).
assertTrue
();
done
();
...
...
@@ -56,8 +58,9 @@ export default function Http2Test() {
* @tc.desc usingCache test
*/
it
(
'
Telephony_NETSTACK_Http2TestBasicGet_0300
'
,
0
,
async
function
(
done
)
{
let
http
=
net_Http
.
createHttp
()
let
http
=
net_Http
.
createHttp
()
;
http
.
request
(
"
https://www.zhihu.com
"
).
then
(
function
(
data
)
{
http
.
destroy
();
console
.
info
(
"
Telephony_NETSTACK_Http2TestBasicGet_0300
"
+
JSON
.
stringify
(
data
));
expect
(
data
.
responseCode
===
net_Http
.
ResponseCode
.
OK
).
assertTrue
();
done
();
...
...
@@ -87,11 +90,11 @@ export default function Http2Test() {
done
();
});
it
(
'
Telephony_http_HttpTestPriority_0100
'
,
0
,
async
function
(
done
)
{
it
(
'
Telephony_http_HttpTestPriority_0100
'
,
0
,
async
function
(
done
)
{
let
CaseName
=
'
Telephony_http_HttpTestPriority_0100
'
;
try
{
let
httpRequestOptions
=
{
method
:
net_
h
ttp
.
RequestMethod
.
GET
,
let
httpRequestOptions
=
{
method
:
net_
H
ttp
.
RequestMethod
.
GET
,
extraData
:
null
,
expectDataType
:
net_Http
.
HttpDataType
.
STRING
,
header
:
"
content-type': 'application/json
"
,
...
...
@@ -99,15 +102,16 @@ export default function Http2Test() {
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
();
var
httpRequest
=
net_Http
.
createHttp
();
httpRequest
.
request
(
"
https://www.zhihu.com
"
,
httpRequestOptions
,
(
err
,
data
)
=>
{
httpRequest
.
destroy
();
console
.
info
(
CaseName
+
JSON
.
stringify
(
err
)
+
"
data
"
+
JSON
.
stringify
(
data
));
expect
(
data
.
responseCode
===
net_Http
.
ResponseCode
.
OK
).
assertTrue
();
expect
(
data
.
resultType
==
net_Http
.
HttpDataType
.
STRING
).
assertTrue
();
done
();
});
}
catch
(
err
)
{
console
.
info
(
CaseName
+
"
err=
"
+
err
)
}
catch
(
err
)
{
console
.
info
(
CaseName
+
"
err=
"
+
err
);
done
();
return
;
}
...
...
telephony/telephonyjstest/netmanager_base/jshttp/src/main/js/test/HttpCacheTest.js
浏览文件 @
fdf70b98
...
...
@@ -26,11 +26,11 @@ export default function HttpCacheTest() {
*/
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
){
http
.
destroy
();
expect
(
data
.
responseCode
===
net_http
.
ResponseCode
.
OK
).
assertTrue
();
done
();
return
;
...
...
@@ -49,6 +49,7 @@ export default function HttpCacheTest() {
http
.
request
(
'
https://httpbin.org/anything
'
,
{
usingCache
:
false
}).
then
(
function
(
data
){
http
.
destroy
();
console
.
info
(
CaseName
+
JSON
.
stringify
(
data
));
expect
(
data
.
responseCode
===
net_http
.
ResponseCode
.
OK
).
assertTrue
();
done
();
...
...
@@ -70,6 +71,7 @@ export default function HttpCacheTest() {
usingCache
:
true
}).
then
(
function
(){
cache
.
flush
().
then
(
function
(
data
){
http
.
destroy
();
console
.
info
(
CaseName
+
JSON
.
stringify
(
data
));
expect
(
data
===
undefined
).
assertTrue
();
done
();
...
...
@@ -92,6 +94,7 @@ export default function HttpCacheTest() {
usingCache
:
true
}).
then
(
function
(){
cache
.
flush
(
function
(
data
){
http
.
destroy
();
console
.
info
(
CaseName
+
JSON
.
stringify
(
data
));
expect
(
data
===
undefined
).
assertTrue
();
done
();
...
...
@@ -114,6 +117,7 @@ export default function HttpCacheTest() {
usingCache
:
true
}).
then
(
function
(){
cache
.
delete
().
then
(
function
(
data
){
http
.
destroy
();
console
.
info
(
CaseName
+
JSON
.
stringify
(
data
));
expect
(
data
===
undefined
).
assertTrue
();
done
();
...
...
@@ -136,6 +140,7 @@ export default function HttpCacheTest() {
usingCache
:
true
}).
then
(
function
(){
cache
.
delete
(
function
(
data
){
http
.
destroy
();
console
.
info
(
CaseName
+
JSON
.
stringify
(
data
));
expect
(
data
===
undefined
).
assertTrue
();
done
();
...
...
telephony/telephonyjstest/netmanager_base/jshttp/src/main/js/test/NetworkManagerHttp.test.js
浏览文件 @
fdf70b98
...
...
@@ -14,10 +14,11 @@
*/
import
netHttp
from
'
@ohos.net.http
'
;
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
@ohos/hypium
'
import
{
describe
,
expect
,
it
}
from
'
@ohos/hypium
'
export
default
function
Telephony_NETSTACK_HTTPTest
()
{
describe
(
'
Telephony_NETSTACK_HTTPTest
'
,
function
()
{
describe
(
'
Telephony_NETSTACK_HTTPTest
'
,
function
()
{
/**
* @tc.number Telephony_NETSTACK_HttpTestBasicGet_0100
...
...
@@ -25,9 +26,10 @@ describe('Telephony_NETSTACK_HTTPTest',function(){
* @tc.desc Function test`
*/
it
(
'
Telephony_NETSTACK_HttpTestBasicGet_0100
'
,
0
,
function
(
done
){
let
http
=
netHttp
.
createHttp
()
http
.
request
(
"
https://httpbin.org/anything
"
).
then
(
function
(
data
){
it
(
'
Telephony_NETSTACK_HttpTestBasicGet_0100
'
,
0
,
function
(
done
)
{
let
http
=
netHttp
.
createHttp
();
http
.
request
(
"
https://httpbin.org/anything
"
).
then
(
function
(
data
)
{
http
.
destroy
();
expect
(
data
.
responseCode
===
netHttp
.
ResponseCode
.
OK
).
assertTrue
();
done
();
});
...
...
@@ -39,12 +41,14 @@ describe('Telephony_NETSTACK_HTTPTest',function(){
* @tc.desc Function test`
*/
it
(
'
Telephony_NETSTACK_HttpTestUserAgent_0100
'
,
0
,
function
(
done
){
let
http
=
netHttp
.
createHttp
()
http
.
request
(
"
https://httpbin.org/user-agent
"
).
then
(
function
(
data
){
it
(
'
Telephony_NETSTACK_HttpTestUserAgent_0100
'
,
0
,
function
(
done
)
{
let
http
=
netHttp
.
createHttp
();
http
.
request
(
"
https://httpbin.org/user-agent
"
).
then
(
function
(
data
)
{
http
.
destroy
();
expect
(
data
.
responseCode
===
netHttp
.
ResponseCode
.
OK
).
assertTrue
();
console
.
info
(
JSON
.
stringify
(
data
));
expect
(
JSON
.
parse
(
data
.
result
)[
"
user-agent
"
]
===
"
libcurl-agent/1.0
"
).
assertTrue
();
expect
(
data
.
result
.
toString
().
search
(
"
user-agent
"
)
!=
-
1
).
assertTrue
();
expect
(
data
.
result
.
toString
().
search
(
"
libcurl-agent/1.0
"
)
!=
-
1
).
assertTrue
();
done
();
});
});
...
...
@@ -55,12 +59,14 @@ describe('Telephony_NETSTACK_HTTPTest',function(){
* @tc.desc Function test`
*/
it
(
'
Telephony_NETSTACK_HttpTestHeader_0100
'
,
0
,
function
(
done
)
{
it
(
'
Telephony_NETSTACK_HttpTestHeader_0100
'
,
0
,
function
(
done
)
{
let
http
=
netHttp
.
createHttp
();
http
.
request
(
"
https://httpbin.org/headers
"
).
then
(
function
(
data
){
expect
(
data
.
responseCode
===
netHttp
.
ResponseCode
.
OK
).
assertTrue
()
console
.
info
(
"
NETSTACK ####
"
+
JSON
.
stringify
(
JSON
.
parse
(
data
.
result
)))
expect
(
JSON
.
parse
(
data
.
result
)[
"
headers
"
][
"
Content-Type
"
]
===
"
application/json
"
).
assertTrue
()
http
.
request
(
"
https://httpbin.org/headers
"
).
then
(
function
(
data
)
{
http
.
destroy
();
expect
(
data
.
responseCode
===
netHttp
.
ResponseCode
.
OK
).
assertTrue
();
console
.
info
(
"
NETSTACK ####
"
+
JSON
.
stringify
(
data
.
result
));
expect
(
data
.
result
.
toString
().
search
(
"
Content-Type
"
)
!=
-
1
).
assertTrue
();
expect
(
data
.
result
.
toString
().
search
(
"
application/json
"
)
!=
-
1
).
assertTrue
();
done
()
});
});
...
...
@@ -71,14 +77,15 @@ describe('Telephony_NETSTACK_HTTPTest',function(){
* @tc.desc Function test`
*/
it
(
'
Telephony_NETSTACK_HttpTestPost_0100
'
,
0
,
function
(
done
){
let
http
=
netHttp
.
createHttp
()
http
.
request
(
"
https://httpbin.org/post
"
,{
method
:
netHttp
.
RequestMethod
.
POST
,
extraData
:
"
MineMine
"
}).
then
(
function
(
data
){
expect
(
data
.
responseCode
===
netHttp
.
ResponseCode
.
OK
).
assertTrue
()
expect
(
JSON
.
parse
(
data
.
result
)[
"
data
"
]
===
"
MineMine
"
).
assertTrue
()
it
(
'
Telephony_NETSTACK_HttpTestPost_0100
'
,
0
,
function
(
done
)
{
let
http
=
netHttp
.
createHttp
();
http
.
request
(
"
https://httpbin.org/post
"
,
{
method
:
netHttp
.
RequestMethod
.
POST
,
extraData
:
"
MineMine
"
}).
then
(
function
(
data
)
{
http
.
destroy
();
expect
(
data
.
responseCode
===
netHttp
.
ResponseCode
.
OK
).
assertTrue
();
expect
(
data
.
result
.
toString
().
search
(
"
MineMine
"
)
!=
-
1
).
assertTrue
()
done
();
});
});
...
...
@@ -89,14 +96,15 @@ describe('Telephony_NETSTACK_HTTPTest',function(){
* @tc.desc Function test`
*/
it
(
'
Telephony_NETSTACK_HttpTestPut_0100
'
,
0
,
function
(
done
){
let
http
=
netHttp
.
createHttp
()
http
.
request
(
"
https://httpbin.org/put
"
,{
method
:
netHttp
.
RequestMethod
.
PUT
,
extraData
:
"
MineMine
"
}).
then
(
function
(
data
){
expect
(
data
.
responseCode
===
netHttp
.
ResponseCode
.
OK
).
assertTrue
()
expect
(
JSON
.
parse
(
data
.
result
)[
"
data
"
]
===
"
MineMine
"
).
assertTrue
()
it
(
'
Telephony_NETSTACK_HttpTestPut_0100
'
,
0
,
function
(
done
)
{
let
http
=
netHttp
.
createHttp
();
http
.
request
(
"
https://httpbin.org/put
"
,
{
method
:
netHttp
.
RequestMethod
.
PUT
,
extraData
:
"
MineMine
"
}).
then
(
function
(
data
)
{
http
.
destroy
();
expect
(
data
.
responseCode
===
netHttp
.
ResponseCode
.
OK
).
assertTrue
();
expect
(
data
.
result
.
toString
().
search
(
"
MineMine
"
)
!=
-
1
).
assertTrue
()
done
();
});
});
...
...
@@ -107,11 +115,12 @@ describe('Telephony_NETSTACK_HTTPTest',function(){
* @tc.desc Function test`
*/
it
(
'
Telephony_NETSTACK_HttpTestCookies_0100
'
,
0
,
function
(
done
){
let
http
=
netHttp
.
createHttp
()
http
.
request
(
"
https://httpbin.org/cookies/set/name/value
"
).
then
(
function
(
data
){
expect
(
data
.
responseCode
===
netHttp
.
ResponseCode
.
OK
).
assertTrue
()
expect
(
data
.
cookies
!==
""
).
assertTrue
()
it
(
'
Telephony_NETSTACK_HttpTestCookies_0100
'
,
0
,
function
(
done
)
{
let
http
=
netHttp
.
createHttp
();
http
.
request
(
"
https://httpbin.org/cookies/set/name/value
"
).
then
(
function
(
data
)
{
http
.
destroy
();
expect
(
data
.
responseCode
===
netHttp
.
ResponseCode
.
OK
).
assertTrue
();
expect
(
data
.
cookies
!==
""
).
assertTrue
();
done
();
});
});
...
...
@@ -122,21 +131,26 @@ describe('Telephony_NETSTACK_HTTPTest',function(){
* @tc.desc Function test`
*/
it
(
'
Telephony_NETSTACK_HttpTestEncode_0100
'
,
0
,
function
(
done
)
{
let
http
=
netHttp
.
createHttp
()
http
.
request
(
"
https://httpbin.org/response-headers?key1=val1&key2=val2
"
,
{
extraData
:
{
"
name1
"
:
"
mine1
"
,
"
name2
"
:
"
mine2
"
,
it
(
'
Telephony_NETSTACK_HttpTestEncode_0100
'
,
0
,
function
(
done
)
{
let
http
=
netHttp
.
createHttp
();
http
.
request
(
"
https://httpbin.org/response-headers?key1=val1&key2=val2
"
,
{
extraData
:
{
"
name1
"
:
"
mine1
"
,
"
name2
"
:
"
mine2
"
,
}
}).
then
(
function
(
data
){
expect
(
data
.
responseCode
===
netHttp
.
ResponseCode
.
OK
).
assertTrue
()
expect
(
JSON
.
parse
(
data
.
result
)[
"
key1
"
]
===
"
val1
"
).
assertTrue
()
expect
(
JSON
.
parse
(
data
.
result
)[
"
key2
"
]
===
"
val2
"
).
assertTrue
()
expect
(
JSON
.
parse
(
data
.
result
)[
"
name1
"
]
===
"
mine1
"
).
assertTrue
()
expect
(
JSON
.
parse
(
data
.
result
)[
"
name2
"
]
===
"
mine2
"
).
assertTrue
()
}).
then
(
function
(
data
)
{
http
.
destroy
();
expect
(
data
.
responseCode
===
netHttp
.
ResponseCode
.
OK
).
assertTrue
();
expect
(
data
.
result
.
toString
().
search
(
"
key1
"
)
!=
-
1
).
assertTrue
()
expect
(
data
.
result
.
toString
().
search
(
"
val1
"
)
!=
-
1
).
assertTrue
()
expect
(
data
.
result
.
toString
().
search
(
"
key2
"
)
!=
-
1
).
assertTrue
()
expect
(
data
.
result
.
toString
().
search
(
"
val2
"
)
!=
-
1
).
assertTrue
()
expect
(
data
.
result
.
toString
().
search
(
"
name1
"
)
!=
-
1
).
assertTrue
()
expect
(
data
.
result
.
toString
().
search
(
"
mine1
"
)
!=
-
1
).
assertTrue
()
expect
(
data
.
result
.
toString
().
search
(
"
name2
"
)
!=
-
1
).
assertTrue
()
expect
(
data
.
result
.
toString
().
search
(
"
mine2
"
)
!=
-
1
).
assertTrue
()
done
();
});
});
});
});
}
telephony/telephonyjstest/netmanager_base/system_fetch/src/main/js/test/Http.fetch.test.js
浏览文件 @
fdf70b98
...
...
@@ -14,131 +14,11 @@
* limitations under the License.
*/
import
NetHttp
from
'
@ohos.net.http
'
;
import
fetch
from
'
@system.fetch
'
;
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
@ohos/hypium
'
import
{
describe
,
it
,
expect
}
from
'
@ohos/hypium
'
export
default
function
Telephony_NetStack_HttpFetchTest
()
{
describe
(
"
Telephony_NetStack_HttpFetchTest
"
,
function
()
{
/**
* @tc.number Telephony_NetStack_HttpTestBasicGet_0100
* @tc.name 基本场景,测试能否GET一个网址
* @tc.desc function test
*/
it
(
"
Telephony_NetStack_HttpTestBasicGet_0100
"
,
0
,
function
(
done
)
{
let
http
=
NetHttp
.
createHttp
()
http
.
request
(
"
https://httpbin.org/anything
"
).
then
(
function
(
data
){
console
.
info
(
"
NetStack
"
+
JSON
.
stringify
(
data
));
expect
(
data
.
responseCode
===
NetHttp
.
ResponseCode
.
OK
).
assertTrue
()
done
();
})
});
/**
* @tc.number Telephony_NetStack_HttpTestUserAgent_0100
* @tc.name 返回用户代理
* @tc.desc function test
*/
it
(
"
Telephony_NetStack_HttpTestUserAgent_0100
"
,
0
,
function
(
done
)
{
let
http
=
NetHttp
.
createHttp
()
http
.
request
(
"
https://httpbin.org/user-agent
"
).
then
(
function
(
data
){
console
.
info
(
"
NetStack
"
+
JSON
.
stringify
(
data
));
expect
(
data
.
responseCode
===
NetHttp
.
ResponseCode
.
OK
).
assertTrue
()
expect
(
JSON
.
parse
(
data
.
result
)[
"
user-agent
"
]
!=
undefined
).
assertTrue
();
done
();
})
});
/**
* @tc.number Telephony_NetStack_HttpTestHeader_0100
* @tc.name 返回Header
* @tc.desc function test
*/
it
(
"
Telephony_NetStack_HttpTestHeader_0100
"
,
0
,
function
(
done
)
{
let
http
=
NetHttp
.
createHttp
()
http
.
request
(
"
https://httpbin.org/headers
"
).
then
(
function
(
data
){
console
.
info
(
"
NetStack
"
+
JSON
.
stringify
(
data
));
expect
(
data
.
responseCode
===
NetHttp
.
ResponseCode
.
OK
).
assertTrue
()
console
.
info
(
"
NetStack
"
+
JSON
.
stringify
(
JSON
.
parse
(
data
.
result
)))
expect
(
JSON
.
parse
(
data
.
result
)[
"
headers
"
][
"
Content-Type
"
]
===
"
application/json
"
).
assertTrue
()
done
();
})
});
/**
* @tc.number Telephony_NetStack_HttpTestPost_0100
* @tc.name 返回Post内容
* @tc.desc function test
*/
it
(
"
Telephony_NetStack_HttpTestPost_0100
"
,
0
,
function
(
done
)
{
let
http
=
NetHttp
.
createHttp
()
http
.
request
(
"
https://httpbin.org/post
"
,{
method
:
NetHttp
.
RequestMethod
.
POST
,
extraData
:
"
MineMine
"
}).
then
(
function
(
data
){
console
.
info
(
"
NetStack
"
+
JSON
.
stringify
(
data
));
expect
(
data
.
responseCode
===
NetHttp
.
ResponseCode
.
OK
).
assertTrue
()
expect
(
JSON
.
parse
(
data
.
result
)[
"
data
"
]
===
"
MineMine
"
).
assertTrue
()
done
();
})
});
/**
* @tc.number Telephony_NetStack_HttpTestPut_0100
* @tc.name 返回Put内容
* @tc.desc function test
*/
it
(
"
Telephony_NetStack_HttpTestPut_0100
"
,
0
,
function
(
done
)
{
let
http
=
NetHttp
.
createHttp
()
http
.
request
(
"
https://httpbin.org/put
"
,{
method
:
NetHttp
.
RequestMethod
.
PUT
,
extraData
:
"
MineMine
"
}).
then
(
function
(
data
){
console
.
info
(
"
NetStack
"
+
JSON
.
stringify
(
data
));
expect
(
data
.
responseCode
===
NetHttp
.
ResponseCode
.
OK
).
assertTrue
()
expect
(
JSON
.
parse
(
data
.
result
)[
"
data
"
]
===
"
MineMine
"
).
assertTrue
()
done
();
})
});
/**
* @tc.number Telephony_NetStack_HttpTestCookies_0100
* @tc.name 返回Cookies内容
* @tc.desc function test
*/
it
(
"
Telephony_NetStack_HttpTestCookies_0100
"
,
0
,
function
(
done
)
{
let
http
=
NetHttp
.
createHttp
()
http
.
request
(
"
https://httpbin.org/cookies/set/name/value
"
).
then
(
function
(
data
){
console
.
info
(
"
NetStack
"
+
JSON
.
stringify
(
data
))
expect
(
data
.
responseCode
===
NetHttp
.
ResponseCode
.
OK
).
assertTrue
()
expect
(
data
.
cookies
!==
""
).
assertTrue
()
done
();
})
});
/**
* @tc.number Telephony_NetStack_HttpTestUrlEncode_0100
* @tc.name 返回Cookies内容
* @tc.desc function test
*/
it
(
"
Telephony_NetStack_HttpTestUrlEncode_0100
"
,
0
,
function
(
done
)
{
let
http
=
NetHttp
.
createHttp
()
http
.
request
(
"
https://httpbin.org/response-headers?key1=val1&key2=val2
"
,{
extraData
:
{
"
name1
"
:
"
mine1
"
,
"
name2
"
:
"
mine2
"
,
}
}).
then
(
function
(
data
){
console
.
info
(
"
NetStack
"
+
JSON
.
stringify
(
data
));
expect
(
data
.
responseCode
===
NetHttp
.
ResponseCode
.
OK
).
assertTrue
()
expect
(
JSON
.
parse
(
data
.
result
)[
"
key1
"
]
===
"
val1
"
).
assertTrue
()
expect
(
JSON
.
parse
(
data
.
result
)[
"
key2
"
]
===
"
val2
"
).
assertTrue
()
expect
(
JSON
.
parse
(
data
.
result
)[
"
name1
"
]
===
"
mine1
"
).
assertTrue
()
expect
(
JSON
.
parse
(
data
.
result
)[
"
name2
"
]
===
"
mine2
"
).
assertTrue
()
done
();
})
});
describe
(
"
Telephony_NetStack_HttpFetchTest
"
,
function
()
{
/**
* @tc.number Telephony_NetStack_HttpTestFetchBasicGet_0100
...
...
@@ -175,7 +55,7 @@ describe("Telephony_NetStack_HttpFetchTest", function () {
success
:
function
(
data
){
console
.
info
(
"
NetStack fetch success
"
+
JSON
.
stringify
(
data
))
expect
(
data
.
code
===
200
).
assertTrue
()
expect
(
JSON
.
parse
(
data
.
data
)[
"
user-agent
"
]
!=
undefined
).
assertTrue
();
expect
(
JSON
.
parse
(
data
.
data
.
toString
())[
"
user-agent
"
]
==
"
libcurl-agent/1.0
"
).
assertTrue
();
done
();
},
fail
:
function
(){
...
...
@@ -197,11 +77,11 @@ describe("Telephony_NetStack_HttpFetchTest", function () {
it
(
"
Telephony_NetStack_HttpTestFetchUserAgent_0200
"
,
0
,
function
(
done
)
{
fetch
.
fetch
({
url
:
"
https://httpbin.org/user-agent
"
,
responseType
:
"
JSON
"
,
responseType
:
"
json
"
,
success
:
function
(
data
){
console
.
info
(
"
NetStack fetch success
"
+
JSON
.
stringify
(
data
))
expect
(
data
.
code
===
200
).
assertTrue
()
expect
(
data
.
data
[
"
user-agent
"
]
!=
undefined
).
assertTrue
();
expect
(
data
.
data
[
"
user-agent
"
]
==
"
libcurl-agent/1.0
"
).
assertTrue
();
done
();
},
fail
:
function
(){
...
...
@@ -226,7 +106,7 @@ describe("Telephony_NetStack_HttpFetchTest", function () {
success
:
function
(
data
){
console
.
info
(
"
NetStack Fetch Success
"
+
JSON
.
stringify
(
data
))
expect
(
data
.
code
===
200
).
assertTrue
()
expect
(
JSON
.
parse
(
data
.
data
)[
"
headers
"
][
"
Content-Type
"
]
===
"
application/json
"
).
assertTrue
()
expect
(
JSON
.
parse
(
data
.
data
.
toString
()
)[
"
headers
"
][
"
Content-Type
"
]
===
"
application/json
"
).
assertTrue
()
done
();
},
fail
:
function
(){
...
...
@@ -248,7 +128,7 @@ describe("Telephony_NetStack_HttpFetchTest", function () {
it
(
"
Telephony_NetStack_HttpTestFetchHeader_0200
"
,
0
,
function
(
done
)
{
fetch
.
fetch
({
url
:
"
https://httpbin.org/headers
"
,
responseType
:
"
JSON
"
,
responseType
:
"
json
"
,
success
:
function
(
data
){
console
.
info
(
"
NetStack Fetch Success
"
+
JSON
.
stringify
(
data
))
expect
(
data
.
code
===
200
).
assertTrue
()
...
...
@@ -279,7 +159,7 @@ describe("Telephony_NetStack_HttpFetchTest", function () {
success
:
function
(
data
){
console
.
info
(
"
NetStack
"
+
JSON
.
stringify
(
data
))
expect
(
data
.
code
===
200
).
assertTrue
()
expect
(
JSON
.
parse
(
data
.
data
)[
"
data
"
]
===
"
MineMine
"
).
assertTrue
()
expect
(
JSON
.
parse
(
data
.
data
.
toString
()
)[
"
data
"
]
===
"
MineMine
"
).
assertTrue
()
done
();
},
fail
:
function
(){
...
...
@@ -303,7 +183,7 @@ describe("Telephony_NetStack_HttpFetchTest", function () {
url
:
"
https://httpbin.org/post
"
,
method
:
"
POST
"
,
data
:
"
MineMine
"
,
responseType
:
"
JSON
"
,
responseType
:
"
json
"
,
success
:
function
(
data
){
console
.
info
(
"
NetStack
"
+
JSON
.
stringify
(
data
))
expect
(
data
.
code
===
200
).
assertTrue
()
...
...
@@ -334,7 +214,7 @@ describe("Telephony_NetStack_HttpFetchTest", function () {
success
:
function
(
data
){
console
.
info
(
"
NetStack
"
+
JSON
.
stringify
(
data
))
expect
(
data
.
code
===
200
).
assertTrue
()
expect
(
JSON
.
parse
(
data
.
data
)[
"
data
"
]
===
"
MineMine
"
).
assertTrue
()
expect
(
JSON
.
parse
(
data
.
data
.
toString
()
)[
"
data
"
]
===
"
MineMine
"
).
assertTrue
()
done
();
},
fail
:
function
(){
...
...
@@ -358,7 +238,7 @@ describe("Telephony_NetStack_HttpFetchTest", function () {
url
:
"
https://httpbin.org/put
"
,
method
:
"
PUT
"
,
data
:
"
MineMine
"
,
responseType
:
"
JSON
"
,
responseType
:
"
json
"
,
success
:
function
(
data
){
console
.
info
(
"
NetStack
"
+
JSON
.
stringify
(
data
))
expect
(
data
.
code
===
200
).
assertTrue
()
...
...
@@ -391,10 +271,10 @@ describe("Telephony_NetStack_HttpFetchTest", function () {
success
:
function
(
data
){
console
.
info
(
"
NetStack
"
+
JSON
.
stringify
(
data
))
expect
(
data
.
code
===
200
).
assertTrue
()
expect
(
JSON
.
parse
(
data
.
data
)[
"
key1
"
]
===
"
val1
"
).
assertTrue
()
expect
(
JSON
.
parse
(
data
.
data
)[
"
key2
"
]
===
"
val2
"
).
assertTrue
()
expect
(
JSON
.
parse
(
data
.
data
)[
"
name1
"
]
===
"
mine1
"
).
assertTrue
()
expect
(
JSON
.
parse
(
data
.
data
)[
"
name2
"
]
===
"
mine2
"
).
assertTrue
()
expect
(
JSON
.
parse
(
data
.
data
.
toString
()
)[
"
key1
"
]
===
"
val1
"
).
assertTrue
()
expect
(
JSON
.
parse
(
data
.
data
.
toString
()
)[
"
key2
"
]
===
"
val2
"
).
assertTrue
()
expect
(
JSON
.
parse
(
data
.
data
.
toString
()
)[
"
name1
"
]
===
"
mine1
"
).
assertTrue
()
expect
(
JSON
.
parse
(
data
.
data
.
toString
()
)[
"
name2
"
]
===
"
mine2
"
).
assertTrue
()
done
();
},
fail
:
function
(){
...
...
@@ -420,7 +300,7 @@ describe("Telephony_NetStack_HttpFetchTest", function () {
"
name1
"
:
"
mine1
"
,
"
name2
"
:
"
mine2
"
,
},
responseType
:
"
JSON
"
,
responseType
:
"
json
"
,
success
:
function
(
data
){
console
.
info
(
"
NetStack
"
+
JSON
.
stringify
(
data
))
expect
(
data
.
code
===
200
).
assertTrue
()
...
...
@@ -440,5 +320,5 @@ describe("Telephony_NetStack_HttpFetchTest", function () {
}
})
});
});
});
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录