1+ import { AxiosError } from 'axios' ;
12import { readFileSync } from 'node:fs' ;
2- import { globalAgent as httpAgent } from 'node:http' ;
3+ import { globalAgent as httpGlobalAgent } from 'node:http' ;
34import {
45 Agent as httpsAgent ,
56 globalAgent as httpsGlobalAgent ,
@@ -15,7 +16,7 @@ describe('Ping', () => {
1516 server,
1617 token,
1718 cacheKey : 'default' ,
18- httpAgent,
19+ httpAgent : httpGlobalAgent ,
1920 httpsAgent : httpsGlobalAgent ,
2021 } ) ;
2122 await backend . ping ( ) ;
@@ -26,7 +27,7 @@ describe('Ping', () => {
2627 server : 'https://localhost:29180' ,
2728 token,
2829 cacheKey : 'default' ,
29- httpAgent,
30+ httpAgent : httpGlobalAgent ,
3031 httpsAgent : new httpsAgent ( {
3132 cert : readFileSync (
3233 join ( __dirname , 'assets/apisix_conf/mtls/client.cer' ) ,
@@ -48,7 +49,7 @@ describe('Ping', () => {
4849 server : 'http://0.0.0.0' ,
4950 token : '' ,
5051 cacheKey : 'default' ,
51- httpAgent,
52+ httpAgent : httpGlobalAgent ,
5253 httpsAgent : httpsGlobalAgent ,
5354 } ) ;
5455 await expect ( backend . ping ( ) ) . rejects . toThrow (
@@ -61,7 +62,7 @@ describe('Ping', () => {
6162 server : 'https://localhost:29180' ,
6263 token,
6364 cacheKey : 'default' ,
64- httpAgent,
65+ httpAgent : httpGlobalAgent ,
6566 httpsAgent : httpsGlobalAgent ,
6667 } ) ;
6768 await expect ( backend . ping ( ) ) . rejects . toThrow (
@@ -74,7 +75,7 @@ describe('Ping', () => {
7475 server : 'https://localhost:29180' ,
7576 token,
7677 cacheKey : 'default' ,
77- httpAgent,
78+ httpAgent : httpGlobalAgent ,
7879 httpsAgent : new httpsAgent ( {
7980 ca : readFileSync ( join ( __dirname , 'assets/apisix_conf/mtls/ca.cer' ) ) ,
8081 } ) ,
@@ -84,8 +85,10 @@ describe('Ping', () => {
8485 try {
8586 await backend . ping ( ) ;
8687 } catch ( err ) {
87- expect ( err . toString ( ) ) . toContain ( 'Request failed with status code 400' ) ;
88- expect ( err . response . data ) . toContain (
88+ expect ( ( err as AxiosError ) . toString ( ) ) . toContain (
89+ 'Request failed with status code 400' ,
90+ ) ;
91+ expect ( ( err as AxiosError ) . response ! . data ) . toContain (
8992 'No required SSL certificate was sent' ,
9093 ) ;
9194 }
0 commit comments