@@ -194,6 +194,7 @@ describe('KubeConfig', () => {
194194 ca : new Buffer ( 'CADATA2' , 'utf-8' ) ,
195195 cert : new Buffer ( 'USER2_CADATA' , 'utf-8' ) ,
196196 key : new Buffer ( 'USER2_CKDATA' , 'utf-8' ) ,
197+ rejectUnauthorized : false ,
197198 } ) ;
198199 } ) ;
199200 } ) ;
@@ -592,6 +593,46 @@ describe('KubeConfig', () => {
592593 }
593594 } ) ;
594595
596+ it ( 'should populate rejectUnauthorized=false when skipTLSVerify is set' , ( ) => {
597+ const config = new KubeConfig ( ) ;
598+ const token = 'token' ;
599+ config . loadFromClusterAndUser (
600+ { skipTLSVerify : true } as Cluster ,
601+ {
602+ authProvider : {
603+ name : 'azure' ,
604+ config : {
605+ 'access-token' : token ,
606+ } ,
607+ } ,
608+ } as User ) ;
609+ const opts = { } as requestlib . Options ;
610+
611+ config . applyToRequest ( opts ) ;
612+ expect ( opts . rejectUnauthorized ) . to . equal ( false ) ;
613+ } ) ;
614+
615+ it ( 'should not set rejectUnauthorized if skipTLSVerify is not set' , ( ) => {
616+ // This test is just making 100% sure we validate certs unless we explictly set
617+ // skipTLSVerify = true
618+ const config = new KubeConfig ( ) ;
619+ const token = 'token' ;
620+ config . loadFromClusterAndUser (
621+ { } as Cluster ,
622+ {
623+ authProvider : {
624+ name : 'azure' ,
625+ config : {
626+ 'access-token' : token ,
627+ } ,
628+ } ,
629+ } as User ) ;
630+ const opts = { } as requestlib . Options ;
631+
632+ config . applyToRequest ( opts ) ;
633+ expect ( opts . rejectUnauthorized ) . to . equal ( undefined ) ;
634+ } ) ;
635+
595636 it ( 'should throw with expired token and no cmd' , ( ) => {
596637 const config = new KubeConfig ( ) ;
597638 config . loadFromClusterAndUser (
0 commit comments