11import { jest } from '@jest/globals' ;
2- import ProxyServerConfigurationProvider from '../../../../src/net/proxy/ProxyServerConfigurationProvider.js' ;
2+ import ProxyServerConfigurationProvider , {
3+ ProxyServer ,
4+ SocksProxyServer ,
5+ } from '../../../../src/net/proxy/ProxyServerConfigurationProvider.js' ;
36import SentrySdk from '../../../../src/util/SentrySdk.js' ;
47
58describe ( 'ProxyServerConfigurationProvider' , ( ) => {
@@ -19,8 +22,24 @@ describe('ProxyServerConfigurationProvider', () => {
1922 displayName : 'test' ,
2023 username : '' ,
2124 password : '' ,
25+ ipv6Only : false ,
2226 } ,
23- ] ) ;
27+ ] satisfies ProxyServer [ ] ) ;
28+ expect ( configProvider . getSocksProxyServers ( ) ) . toEqual ( [ ] ) ;
29+ } ) ;
30+
31+ test ( 'Provide for proxy with ipv6only' , ( ) => {
32+ const configProvider = new ProxyServerConfigurationProvider ( [ 'https://proxy.example.com/?name=test&ipv6only=1' ] ) ;
33+
34+ expect ( configProvider . getProxyServers ( ) ) . toEqual ( [
35+ {
36+ simplifiedUri : 'https://proxy.example.com/' ,
37+ displayName : 'test' ,
38+ username : '' ,
39+ password : '' ,
40+ ipv6Only : true ,
41+ } ,
42+ ] satisfies ProxyServer [ ] ) ;
2443 expect ( configProvider . getSocksProxyServers ( ) ) . toEqual ( [ ] ) ;
2544 } ) ;
2645
@@ -33,20 +52,22 @@ describe('ProxyServerConfigurationProvider', () => {
3352 displayName : `${ protocol } ://proxy.example.com/` ,
3453 username : '' ,
3554 password : '' ,
55+ ipv6Only : false ,
3656 } ,
37- ] ) ;
57+ ] satisfies ProxyServer [ ] ) ;
3858 expect ( configProvider . getSocksProxyServers ( ) ) . toEqual ( [ ] ) ;
3959 } ) ;
4060
41- test . each ( [ 5 , 4 ] ) ( 'Provide for one socks%d proxy server' , ( socksVersion : number ) => {
61+ test . each ( [ 5 , 4 ] satisfies ( 4 | 5 ) [ ] ) ( 'Provide for one socks%d proxy server' , ( socksVersion : 4 | 5 ) => {
4262 const configProvider = new ProxyServerConfigurationProvider ( [ `socks${ socksVersion } ://user:pass@proxy.example.com:8899` ] ) ;
4363
44- const expectedProxies = [
64+ const expectedProxies : SocksProxyServer [ ] = [
4565 {
4666 simplifiedUri : `socks${ socksVersion } ://proxy.example.com:8899/` ,
4767 displayName : `socks${ socksVersion } ://proxy.example.com:8899/` ,
4868 username : 'user' ,
4969 password : 'pass' ,
70+ ipv6Only : false ,
5071 socksProxyOptions : {
5172 version : socksVersion ,
5273 host : 'proxy.example.com' ,
@@ -67,26 +88,29 @@ describe('ProxyServerConfigurationProvider', () => {
6788 'socks4://user:pass@proxy2.example.com:8899' ,
6889 ] ) ;
6990
70- const expectedHttpProxies = [
91+ const expectedHttpProxies : ProxyServer [ ] = [
7192 {
7293 simplifiedUri : 'http://proxy0.example.com:8080/' ,
7394 displayName : 'http://proxy0.example.com:8080/' ,
7495 username : '' ,
7596 password : '' ,
97+ ipv6Only : false ,
7698 } ,
7799 {
78100 simplifiedUri : 'https://proxy1.example.com/' ,
79101 displayName : 'https://proxy1.example.com/' ,
80102 username : '' ,
81103 password : '' ,
104+ ipv6Only : false ,
82105 } ,
83106 ] ;
84- const expectedSocksProxies = [
107+ const expectedSocksProxies : SocksProxyServer [ ] = [
85108 {
86109 simplifiedUri : 'socks5://[::1]:1234/' ,
87110 displayName : 'socks5://[::1]:1234/' ,
88111 username : '' ,
89112 password : '' ,
113+ ipv6Only : false ,
90114 socksProxyOptions : {
91115 version : 5 ,
92116 host : '::1' ,
@@ -99,6 +123,7 @@ describe('ProxyServerConfigurationProvider', () => {
99123 displayName : 'socks4://proxy2.example.com:8899/' ,
100124 username : 'user' ,
101125 password : 'pass' ,
126+ ipv6Only : false ,
102127 socksProxyOptions : {
103128 version : 4 ,
104129 host : 'proxy2.example.com' ,
@@ -155,8 +180,10 @@ describe('ProxyServerConfigurationProvider', () => {
155180 expect ( configProvider . getProxyServers ( ) . length ) . toBe ( 4 ) ;
156181
157182 expect ( SentrySdk . logAndCaptureWarning ) . toHaveBeenCalledTimes ( 2 ) ;
158- expect ( SentrySdk . logAndCaptureWarning ) . toHaveBeenNthCalledWith ( 1 , `Proxy server 'https://proxy1.example.com/' is configured multiple times` ) ;
159- expect ( SentrySdk . logAndCaptureWarning ) . toHaveBeenNthCalledWith ( 2 , `Proxy server 'https://proxy1.example.com/' is configured multiple times` ) ;
183+ expect ( SentrySdk . logAndCaptureWarning )
184+ . toHaveBeenNthCalledWith ( 1 , `Proxy server 'https://proxy1.example.com/' is configured multiple times` ) ;
185+ expect ( SentrySdk . logAndCaptureWarning )
186+ . toHaveBeenNthCalledWith ( 2 , `Proxy server 'https://proxy1.example.com/' is configured multiple times` ) ;
160187 } ) ;
161188
162189 test ( 'Warning is logged for duplicate proxy server names' , ( ) => {
@@ -171,7 +198,9 @@ describe('ProxyServerConfigurationProvider', () => {
171198 expect ( configProvider . getProxyServers ( ) . length ) . toBe ( 4 ) ;
172199
173200 expect ( SentrySdk . logAndCaptureWarning ) . toHaveBeenCalledTimes ( 2 ) ;
174- expect ( SentrySdk . logAndCaptureWarning ) . toHaveBeenNthCalledWith ( 1 , `Proxy server name 'test' is configured multiple times` ) ;
175- expect ( SentrySdk . logAndCaptureWarning ) . toHaveBeenNthCalledWith ( 2 , `Proxy server name 'test' is configured multiple times` ) ;
201+ expect ( SentrySdk . logAndCaptureWarning )
202+ . toHaveBeenNthCalledWith ( 1 , `Proxy server name 'test' is configured multiple times` ) ;
203+ expect ( SentrySdk . logAndCaptureWarning )
204+ . toHaveBeenNthCalledWith ( 2 , `Proxy server name 'test' is configured multiple times` ) ;
176205 } ) ;
177206} ) ;
0 commit comments