@@ -3,6 +3,7 @@ import { deepEqual, deepStrictEqual, notStrictEqual, rejects, strictEqual, throw
3
3
import child_process from 'node:child_process' ;
4
4
import { readFileSync } from 'node:fs' ;
5
5
import https from 'node:https' ;
6
+ import http from 'node:http' ;
6
7
import { Agent , RequestOptions } from 'node:https' ;
7
8
import path , { dirname , join } from 'node:path' ;
8
9
import { fileURLToPath } from 'node:url' ;
@@ -298,7 +299,7 @@ describe('KubeConfig', () => {
298
299
} ) ;
299
300
} ) ;
300
301
301
- describe ( 'applyHTTPSOptions' , ( ) => {
302
+ describe . only ( 'applyHTTPSOptions' , ( ) => {
302
303
it ( 'should apply tls-server-name to https.RequestOptions' , async ( ) => {
303
304
const kc = new KubeConfig ( ) ;
304
305
kc . loadFromFile ( kcTlsServerNameFileName ) ;
@@ -448,6 +449,30 @@ describe('KubeConfig', () => {
448
449
message : 'Unsupported proxy type' ,
449
450
} ) ;
450
451
} ) ;
452
+ it ( 'should apply http agent if cluster.server starts with http and no proxy-url is provided' , async ( ) => {
453
+ const kc = new KubeConfig ( ) ;
454
+ kc . loadFromFile ( kcProxyUrl ) ;
455
+ kc . setCurrentContext ( 'contextE' ) ;
456
+
457
+ const testServerName = 'http://example.com' ;
458
+ const rc = new RequestContext ( testServerName , HttpMethod . GET ) ;
459
+
460
+ await kc . applySecurityAuthentication ( rc ) ;
461
+
462
+ strictEqual ( rc . getAgent ( ) instanceof http . Agent , true ) ;
463
+ } ) ;
464
+ it ( 'should apply https agent if cluster.server starts with https and no proxy-url is provided' , async ( ) => {
465
+ const kc = new KubeConfig ( ) ;
466
+ kc . loadFromFile ( kcProxyUrl ) ;
467
+ kc . setCurrentContext ( 'contextF' ) ;
468
+
469
+ const testServerName = 'https://example.com' ;
470
+ const rc = new RequestContext ( testServerName , HttpMethod . GET ) ;
471
+
472
+ await kc . applySecurityAuthentication ( rc ) ;
473
+
474
+ strictEqual ( rc . getAgent ( ) instanceof https . Agent , true ) ;
475
+ } ) ;
451
476
} ) ;
452
477
453
478
describe ( 'loadClusterConfigObjects' , ( ) => {
0 commit comments