1
1
import * as https from 'https' ;
2
+ import * as tls from 'tls' ;
2
3
import * as assert from 'assert' ;
4
+ import * as fs from 'fs' ;
5
+ import * as path from 'path' ;
3
6
import * as vpa from '../../..' ;
4
7
import { createPacProxyAgent } from '../../../src/agent' ;
5
- import { testRequest , ca , unusedCa , proxiedProxyAgentParamsV1 } from './utils' ;
8
+ import { testRequest , ca , unusedCa , proxiedProxyAgentParamsV1 , tlsProxiedProxyAgentParamsV1 } from './utils' ;
6
9
7
10
describe ( 'Proxied client' , function ( ) {
8
11
it ( 'should use HTTP proxy for HTTPS connection' , function ( ) {
@@ -14,6 +17,27 @@ describe('Proxied client', function () {
14
17
} ) ;
15
18
} ) ;
16
19
20
+ it ( 'should use HTTPS proxy for HTTPS connection' , function ( ) {
21
+ const { resolveProxyWithRequest : resolveProxy } = vpa . createProxyResolver ( tlsProxiedProxyAgentParamsV1 ) ;
22
+ const patchedHttps : typeof https = {
23
+ ...https ,
24
+ ...vpa . createHttpPatch ( tlsProxiedProxyAgentParamsV1 , https , resolveProxy ) ,
25
+ } as any ;
26
+ return testRequest ( patchedHttps , {
27
+ hostname : 'test-https-server' ,
28
+ path : '/test-path' ,
29
+ _vscodeTestReplaceCaCerts : true ,
30
+ } ) ;
31
+ } ) ;
32
+
33
+ it ( 'should use HTTPS proxy for HTTPS connection (fetch)' , async function ( ) {
34
+ const { resolveProxyURL } = vpa . createProxyResolver ( tlsProxiedProxyAgentParamsV1 ) ;
35
+ const patchedFetch = vpa . createFetchPatch ( tlsProxiedProxyAgentParamsV1 , globalThis . fetch , resolveProxyURL ) ;
36
+ const res = await patchedFetch ( 'https://test-https-server/test-path' ) ;
37
+ assert . strictEqual ( res . status , 200 ) ;
38
+ assert . strictEqual ( ( await res . json ( ) ) . status , 'OK!' ) ;
39
+ } ) ;
40
+
17
41
it ( 'should support basic auth' , function ( ) {
18
42
return testRequest ( https , {
19
43
hostname : 'test-https-server' ,
0 commit comments