@@ -11,6 +11,7 @@ import { CoreV1Api } from './api';
11
11
import { bufferFromFileOrString , findHomeDir , findObject , KubeConfig , makeAbsolutePath } from './config' ;
12
12
import { Cluster , newClusters , newContexts , newUsers , User , ActionOnInvalid } from './config_types' ;
13
13
import { ExecAuth } from './exec_auth' ;
14
+ import { request } from 'http' ;
14
15
15
16
const kcFileName = 'testdata/kubeconfig.yaml' ;
16
17
const kc2FileName = 'testdata/kubeconfig-2.yaml' ;
@@ -240,6 +241,44 @@ describe('KubeConfig', () => {
240
241
} ) ;
241
242
242
243
describe ( 'applyHTTPSOptions' , ( ) => {
244
+ it ( 'should apply tls-server-name to https.RequestOptions' , async ( ) => {
245
+ const kc = new KubeConfig ( ) ;
246
+ kc . loadFromFile ( kcTlsServerNameFileName ) ;
247
+
248
+ const opts : https . RequestOptions = { } ;
249
+ await kc . applytoHTTPSOptions ( opts ) ;
250
+
251
+ expect ( opts ) . to . deep . equal ( {
252
+ headers : { } ,
253
+ ca : new Buffer ( 'CADATA2' , 'utf-8' ) ,
254
+ cert : new Buffer ( 'USER_CADATA' , 'utf-8' ) ,
255
+ key : new Buffer ( 'USER_CKDATA' , 'utf-8' ) ,
256
+ rejectUnauthorized : false ,
257
+ servername : 'kube.example2.com' ,
258
+ } ) ;
259
+ } ) ;
260
+ it ( 'should apply tls-server-name to request.Options' , async ( ) => {
261
+ const kc = new KubeConfig ( ) ;
262
+ kc . loadFromFile ( kcTlsServerNameFileName ) ;
263
+
264
+ const opts : requestlib . Options = {
265
+ url : 'https://company.com' ,
266
+ } ;
267
+ await kc . applyToRequest ( opts ) ;
268
+
269
+ expect ( opts ) . to . deep . equal ( {
270
+ url : 'https://company.com' ,
271
+ headers : { } ,
272
+ ca : new Buffer ( 'CADATA2' , 'utf-8' ) ,
273
+ cert : new Buffer ( 'USER_CADATA' , 'utf-8' ) ,
274
+ key : new Buffer ( 'USER_CKDATA' , 'utf-8' ) ,
275
+ rejectUnauthorized : false ,
276
+ strictSSL : false ,
277
+ agentOptions : {
278
+ servername : 'kube.example2.com' ,
279
+ } ,
280
+ } ) ;
281
+ } ) ;
243
282
it ( 'should apply cert configs' , ( ) => {
244
283
const kc = new KubeConfig ( ) ;
245
284
kc . loadFromFile ( kcFileName ) ;
0 commit comments