@@ -60,7 +60,7 @@ func TestServer_HandleHealth_CORS(t *testing.T) {
6060 server := & Server {
6161 allowedOrigins : []string {"http://allowed.com" },
6262 registry : & Registry {providers : make (map [string ]AIProvider )},
63- kubectl : & kube.KubectlProxy { config : & api.Config {}} ,
63+ kubectl : kube .NewTestKubectlProxy ( & api.Config {}) ,
6464 }
6565
6666 // Case 1: Allowed Origin
@@ -90,7 +90,7 @@ func TestServer_HandleStatus(t *testing.T) {
9090 },
9191 }
9292 server := & Server {
93- kubectl : & kube.KubectlProxy { config : config } ,
93+ kubectl : kube .NewTestKubectlProxy ( config ) ,
9494 allowedOrigins : []string {"http://allowed.com" },
9595 agentToken : "test-token" ,
9696 tokenExplicit : true ,
@@ -225,7 +225,7 @@ func TestServer_HandleClustersHTTP(t *testing.T) {
225225 "c1" : {Server : "https://c1.com" },
226226 },
227227 }
228- mockProxy := & kube.KubectlProxy { config : config }
228+ mockProxy := kube .NewTestKubectlProxy ( config )
229229 server := & Server {
230230 kubectl : mockProxy ,
231231 allowedOrigins : []string {"*" },
@@ -271,10 +271,7 @@ func TestServer_HandleRenameContextHTTP(t *testing.T) {
271271 execCommandContext = fakeExecCommandContext
272272
273273 // Setup proxy
274- proxy := & kube.KubectlProxy {
275- kubeconfig : "/tmp/config" ,
276- config : & api.Config {},
277- }
274+ proxy := kube .NewTestKubectlProxy (& api.Config {})
278275
279276 server := & Server {
280277 kubectl : proxy ,
@@ -323,10 +320,7 @@ func TestServer_ResourceHandlers(t *testing.T) {
323320 config := & api.Config {
324321 CurrentContext : "ctx-1" ,
325322 }
326- proxy := & kube.KubectlProxy {
327- config : config ,
328- kubeconfig : "/tmp/config" ,
329- }
323+ proxy := kube .NewTestKubectlProxy (config )
330324
331325 // Create mock k8s client
332326 k8sClient , _ := k8s .NewMultiClusterClient ("" )
@@ -973,7 +967,7 @@ func TestMatchOrigin(t *testing.T) {
973967
974968func TestServer_HandleClustersHTTP_Unauthorized (t * testing.T ) {
975969 server := & Server {
976- kubectl : & kube.KubectlProxy { config : & api.Config {}} ,
970+ kubectl : kube .NewTestKubectlProxy ( & api.Config {}) ,
977971 agentToken : "secret" , // require token
978972 allowedOrigins : []string {"*" },
979973 }
@@ -992,7 +986,7 @@ func TestServer_HandleClustersHTTP_Unauthorized(t *testing.T) {
992986
993987func TestServer_HandleClustersHTTP_OPTIONS (t * testing.T ) {
994988 server := & Server {
995- kubectl : & kube.KubectlProxy { config : & api.Config {}} ,
989+ kubectl : kube .NewTestKubectlProxy ( & api.Config {}) ,
996990 allowedOrigins : []string {"http://allowed.com" },
997991 }
998992
@@ -1434,7 +1428,7 @@ func (fakeFileInfo) Sys() interface{} { return nil }
14341428
14351429func TestServer_HandleRenameContextHTTP_Unauthorized (t * testing.T ) {
14361430 server := & Server {
1437- kubectl : & kube.KubectlProxy { config : & api.Config {}} ,
1431+ kubectl : kube .NewTestKubectlProxy ( & api.Config {}) ,
14381432 agentToken : "secret" ,
14391433 allowedOrigins : []string {"*" },
14401434 }
@@ -1452,7 +1446,7 @@ func TestServer_HandleRenameContextHTTP_Unauthorized(t *testing.T) {
14521446
14531447func TestServer_HandleRenameContextHTTP_WrongMethod (t * testing.T ) {
14541448 server := & Server {
1455- kubectl : & kube.KubectlProxy { config : & api.Config {}} ,
1449+ kubectl : kube .NewTestKubectlProxy ( & api.Config {}) ,
14561450 allowedOrigins : []string {"*" },
14571451 }
14581452
@@ -1472,10 +1466,7 @@ func TestServer_HandleRenameContextHTTP_MissingNames(t *testing.T) {
14721466 execCommandContext = fakeExecCommandContext
14731467
14741468 server := & Server {
1475- kubectl : & kube.KubectlProxy {
1476- config : & api.Config {},
1477- kubeconfig : "/tmp/config" ,
1478- },
1469+ kubectl : kube .NewTestKubectlProxy (& api.Config {}),
14791470 allowedOrigins : []string {"*" },
14801471 }
14811472
@@ -1499,10 +1490,7 @@ func TestServer_HandleRenameContextHTTP_FlagInjection(t *testing.T) {
14991490 execCommandContext = fakeExecCommandContext
15001491
15011492 server := & Server {
1502- kubectl : & kube.KubectlProxy {
1503- config : & api.Config {},
1504- kubeconfig : "/tmp/config" ,
1505- },
1493+ kubectl : kube .NewTestKubectlProxy (& api.Config {}),
15061494 allowedOrigins : []string {"*" },
15071495 }
15081496
@@ -2130,7 +2118,7 @@ func TestServer_ValidateAPIKeyValue_EmptyKey(t *testing.T) {
21302118
21312119func TestServer_HandleHealth_OPTIONS (t * testing.T ) {
21322120 server := & Server {
2133- kubectl : & kube.KubectlProxy { config : & api.Config {}} ,
2121+ kubectl : kube .NewTestKubectlProxy ( & api.Config {}) ,
21342122 registry : & Registry {providers : make (map [string ]AIProvider )},
21352123 allowedOrigins : []string {"http://localhost" },
21362124 }
@@ -3417,7 +3405,7 @@ func TestCheckPingHealth_AllScenarios(t *testing.T) {
34173405
34183406func TestServer_HandleLocalClusterTools_GET (t * testing.T ) {
34193407 server := & Server {
3420- localClusters : NewLocalClusterManager (nil ),
3408+ localClusters : kube . NewLocalClusterManager (nil ),
34213409 allowedOrigins : []string {"*" },
34223410 }
34233411
@@ -3433,7 +3421,7 @@ func TestServer_HandleLocalClusterTools_GET(t *testing.T) {
34333421
34343422func TestServer_HandleLocalClusters_GET (t * testing.T ) {
34353423 server := & Server {
3436- localClusters : NewLocalClusterManager (nil ),
3424+ localClusters : kube . NewLocalClusterManager (nil ),
34373425 allowedOrigins : []string {"*" },
34383426 }
34393427
@@ -3449,7 +3437,7 @@ func TestServer_HandleLocalClusters_GET(t *testing.T) {
34493437
34503438func TestServer_HandleLocalClusters_WrongMethod (t * testing.T ) {
34513439 server := & Server {
3452- localClusters : NewLocalClusterManager (nil ),
3440+ localClusters : kube . NewLocalClusterManager (nil ),
34533441 allowedOrigins : []string {"*" },
34543442 }
34553443
@@ -3464,7 +3452,7 @@ func TestServer_HandleLocalClusters_WrongMethod(t *testing.T) {
34643452
34653453func TestServer_HandleLocalClusterTools_WrongMethod (t * testing.T ) {
34663454 server := & Server {
3467- localClusters : NewLocalClusterManager (nil ),
3455+ localClusters : kube . NewLocalClusterManager (nil ),
34683456 allowedOrigins : []string {"*" },
34693457 }
34703458
0 commit comments