@@ -18,6 +18,7 @@ const kc2FileName = 'testdata/kubeconfig-2.yaml';
1818const kcDupeCluster = 'testdata/kubeconfig-dupe-cluster.yaml' ;
1919const kcDupeContext = 'testdata/kubeconfig-dupe-context.yaml' ;
2020const kcDupeUser = 'testdata/kubeconfig-dupe-user.yaml' ;
21+ const kcProxyUrl = 'testdata/kubeconfig-proxy-url.yaml' ;
2122
2223const kcNoUserFileName = 'testdata/empty-user-kubeconfig.yaml' ;
2324const kcInvalidContextFileName = 'testdata/empty-context-kubeconfig.yaml' ;
@@ -36,6 +37,7 @@ function validateFileLoad(kc: KubeConfig) {
3637 expect ( cluster1 . name ) . to . equal ( 'cluster1' ) ;
3738 expect ( cluster1 . caData ) . to . equal ( 'Q0FEQVRB' ) ;
3839 expect ( cluster1 . server ) . to . equal ( 'http://example.com' ) ;
40+ expect ( cluster1 . proxyUrl ) . to . equal ( 'socks5://localhost:1181' ) ;
3941 expect ( cluster2 . name ) . to . equal ( 'cluster2' ) ;
4042 expect ( cluster2 . caData ) . to . equal ( 'Q0FEQVRBMg==' ) ;
4143 expect ( cluster2 . server ) . to . equal ( 'http://example2.com' ) ;
@@ -403,6 +405,30 @@ describe('KubeConfig', () => {
403405 rejectUnauthorized : false ,
404406 } ) ;
405407 } ) ;
408+ it ( 'should apply proxy to request.Options' , async ( ) => {
409+ const kc = new KubeConfig ( ) ;
410+ kc . loadFromFile ( kc2FileName ) ;
411+
412+ const opts = { } as requestlib . Options ;
413+
414+ await kc . applyToRequest ( opts ) ;
415+
416+ expect ( opts ) . to . deep . equal ( {
417+ headers : { } ,
418+ ca : Buffer . from ( 'CADAT@' , 'utf-8' ) ,
419+ cert : Buffer . from ( ']SER_CADATA' , 'utf-8' ) ,
420+ key : Buffer . from ( ']SER_CKDATA' , 'utf-8' ) ,
421+ proxy : 'https://localhost:1181' ,
422+ } ) ;
423+ } ) ;
424+ it ( 'should apply agent to request.Options' , async ( ) => {
425+ const kc = new KubeConfig ( ) ;
426+ kc . loadFromFile ( kcProxyUrl ) ;
427+
428+ const opts = { } as requestlib . Options ;
429+ await kc . applyToRequest ( opts ) ;
430+ expect ( opts . agent ) . to . exist ;
431+ } ) ;
406432 } ) ;
407433
408434 describe ( 'loadClusterConfigObjects' , ( ) => {
0 commit comments