@@ -24,8 +24,8 @@ func TestGenerateNginxCfg(t *testing.T) {
24
24
isPlus := false
25
25
expected := createExpectedConfigForCafeIngressEx (isPlus )
26
26
27
- apRes := make ( map [ string ] string )
28
- result , warnings := generateNginxCfg (& cafeIngressEx , apRes , false , configParams , isPlus , false , & StaticConfigParams {}, false )
27
+ apRes := AppProtectResources {}
28
+ result , warnings := generateNginxCfg (& cafeIngressEx , apRes , false , configParams , false , false , & StaticConfigParams {}, false )
29
29
30
30
if diff := cmp .Diff (expected , result ); diff != "" {
31
31
t .Errorf ("generateNginxCfg() returned unexpected result (-want +got):\n %s" , diff )
@@ -66,8 +66,8 @@ func TestGenerateNginxCfgForJWT(t *testing.T) {
66
66
},
67
67
}
68
68
69
- apRes := make ( map [ string ] string )
70
- result , warnings := generateNginxCfg (& cafeIngressEx , apRes , false , configParams , isPlus , false , & StaticConfigParams {}, false )
69
+ apRes := AppProtectResources {}
70
+ result , warnings := generateNginxCfg (& cafeIngressEx , apRes , false , configParams , true , false , & StaticConfigParams {}, false )
71
71
72
72
if ! reflect .DeepEqual (result .Servers [0 ].JWTAuth , expected .Servers [0 ].JWTAuth ) {
73
73
t .Errorf ("generateNginxCfg returned \n %v, but expected \n %v" , result .Servers [0 ].JWTAuth , expected .Servers [0 ].JWTAuth )
@@ -85,7 +85,7 @@ func TestGenerateNginxCfgWithMissingTLSSecret(t *testing.T) {
85
85
cafeIngressEx .SecretRefs ["cafe-secret" ].Error = errors .New ("secret doesn't exist" )
86
86
configParams := NewDefaultConfigParams ()
87
87
88
- apRes := make ( map [ string ] string )
88
+ apRes := AppProtectResources {}
89
89
result , resultWarnings := generateNginxCfg (& cafeIngressEx , apRes , false , configParams , false , false , & StaticConfigParams {}, false )
90
90
91
91
expectedSSLRejectHandshake := true
@@ -109,7 +109,7 @@ func TestGenerateNginxCfgWithWildcardTLSSecret(t *testing.T) {
109
109
cafeIngressEx .Ingress .Spec .TLS [0 ].SecretName = ""
110
110
configParams := NewDefaultConfigParams ()
111
111
112
- apRes := make ( map [ string ] string )
112
+ apRes := AppProtectResources {}
113
113
result , warnings := generateNginxCfg (& cafeIngressEx , apRes , false , configParams , false , false , & StaticConfigParams {}, true )
114
114
115
115
resultServer := result .Servers [0 ]
@@ -352,8 +352,8 @@ func TestGenerateNginxCfgForMergeableIngresses(t *testing.T) {
352
352
353
353
configParams := NewDefaultConfigParams ()
354
354
355
- masterApRes := make ( map [ string ] string )
356
- result , warnings := generateNginxCfgForMergeableIngresses (mergeableIngresses , masterApRes , configParams , isPlus , false , & StaticConfigParams {}, false )
355
+ masterApRes := AppProtectResources {}
356
+ result , warnings := generateNginxCfgForMergeableIngresses (mergeableIngresses , masterApRes , configParams , false , false , & StaticConfigParams {}, false )
357
357
358
358
if diff := cmp .Diff (expected , result ); diff != "" {
359
359
t .Errorf ("generateNginxCfgForMergeableIngresses() returned unexpected result (-want +got):\n %s" , diff )
@@ -377,7 +377,7 @@ func TestGenerateNginxConfigForCrossNamespaceMergeableIngresses(t *testing.T) {
377
377
expected := createExpectedConfigForCrossNamespaceMergeableCafeIngress ()
378
378
configParams := NewDefaultConfigParams ()
379
379
380
- emptyApResources := make ( map [ string ] string )
380
+ emptyApResources := AppProtectResources {}
<
38B3
/tr>381
381
result , warnings := generateNginxCfgForMergeableIngresses (mergeableIngresses , emptyApResources , configParams , false , false , & StaticConfigParams {}, false )
382
382
383
383
if diff := cmp .Diff (expected , result ); diff != "" {
@@ -442,7 +442,7 @@ func TestGenerateNginxCfgForMergeableIngressesForJWT(t *testing.T) {
442
442
minionJwtKeyFileNames [objectMetaToFileName (& mergeableIngresses .Minions [0 ].Ingress .ObjectMeta )] = "/etc/nginx/secrets/default-coffee-jwk"
443
443
configParams := NewDefaultConfigParams ()
444
444
445
- masterApRes := make ( map [ string ] string )
445
+ masterApRes := AppProtectResources {}
446
446
result , warnings := generateNginxCfgForMergeableIngresses (mergeableIngresses , masterApRes , configParams , isPlus , false , & StaticConfigParams {}, false )
447
447
448
448
if ! reflect .DeepEqual (result .Servers [0 ].JWTAuth , expected .Servers [0 ].JWTAuth ) {
@@ -837,8 +837,8 @@ func TestGenerateNginxCfgForSpiffe(t *testing.T) {
837
837
expected .Servers [0 ].Locations [i ].SSL = true
838
838
}
839
839
840
- apResources := make ( map [ string ] string )
841
- result , warnings := generateNginxCfg (& cafeIngressEx , apResources , false , configParams , isPlus , false ,
840
+ apResources := AppProtectResources {}
841
+ result , warnings := generateNginxCfg (& cafeIngressEx , apResources , false , configParams , false , false ,
842
842
& StaticConfigParams {NginxServiceMesh : true }, false )
843
843
844
844
if diff := cmp .Diff (expected , result ); diff != "" {
@@ -861,8 +861,8 @@ func TestGenerateNginxCfgForInternalRoute(t *testing.T) {
861
861
expected .Servers [0 ].SpiffeCerts = true
862
862
expected .Ingress .Annotations [internalRouteAnnotation ] = "true"
863
863
864
- apResources := make ( map [ string ] string )
865
- result , warnings := generateNginxCfg (& cafeIngressEx , apResources , false , configParams , isPlus , false ,
864
+ apResources := AppProtectResources {}
865
+ result , warnings := generateNginxCfg (& cafeIngressEx , apResources , false , configParams , false , false ,
866
866
& StaticConfigParams {NginxServiceMesh : true , EnableInternalRoutes : true }, false )
867
867
868
868
if diff := cmp .Diff (expected , result ); diff != "" {
@@ -1311,19 +1311,20 @@ func TestGenerateNginxCfgForAppProtect(t *testing.T) {
1311
1311
},
1312
1312
},
1313
1313
}
1314
- cafeIngressEx .AppProtectLogConf = & unstructured.Unstructured {
1315
- Object : map [string ]interface {}{
1314
+ cafeIngressEx .AppProtectLogConf = [] * unstructured.Unstructured {
1315
+ { Object : map [string ]interface {}{
1316
1316
"metadata" : map [string ]interface {}{
1317
1317
"namespace" : "default" ,
1318
1318
"name" : "logconf" ,
1319
1319
},
1320
1320
},
1321
+ },
1321
1322
}
1322
1323
1323
1324
configParams := NewDefaultConfigParams ()
1324
- apRes := map [ string ] string {
1325
- appProtectPolicyKey : "/etc/nginx/waf/nac-policies/default_dataguard-alarm" ,
1326
- appProtectLogConfKey : "/etc/nginx/waf/nac-logconfs/default_logconf syslog:server=127.0.0.1:514" ,
1325
+ apRes := AppProtectResources {
1326
+ AppProtectPolicy : "/etc/nginx/waf/nac-policies/default_dataguard-alarm" ,
1327
+ AppProtectLogconfs : [] string { "/etc/nginx/waf/nac-logconfs/default_logconf syslog:server=127.0.0.1:514" } ,
1327
1328
}
1328
1329
staticCfgParams := & StaticConfigParams {
1329
1330
MainAppProtectLoadModule : true ,
@@ -1334,7 +1335,7 @@ func TestGenerateNginxCfgForAppProtect(t *testing.T) {
1334
1335
expected := createExpectedConfigForCafeIngressEx (isPlus )
1335
1336
expected .Servers [0 ].AppProtectEnable = "on"
1336
1337
expected .Servers [0 ].AppProtectPolicy = "/etc/nginx/waf/nac-policies/default_dataguard-alarm"
1337
- expected .Servers [0 ].AppProtectLogConf = "/etc/nginx/waf/nac-logconfs/default_logconf syslog:server=127.0.0.1:514"
1338
+ expected .Servers [0 ].AppProtectLogConfs = [] string { "/etc/nginx/waf/nac-logconfs/default_logconf syslog:server=127.0.0.1:514" }
1338
1339
expected .Servers [0 ].AppProtectLogEnable = "on"
1339
1340
expected .Ingress .Annotations = cafeIngressEx .Ingress .Annotations
1340
1341
@@ -1359,19 +1360,20 @@ func TestGenerateNginxCfgForMergeableIngressesForAppProtect(t *testing.T) {
1359
1360
},
1360
1361
},
1361
1362
}
1362
- mergeableIngresses .Master .AppProtectLogConf = & unstructured.Unstructured {
1363
- Object : map [string ]interface {}{
1363
+ mergeableIngresses .Master .AppProtectLogConf = [] * unstructured.Unstructured {
1364
+ { Object : map [string ]interface {}{
1364
1365
"metadata" : map [string ]interface {}{
1365
1366
"namespace" : "default" ,
1366
1367
"name" : "logconf" ,
1367
1368
},
1368
1369
},
1370
+ },
1369
1371
}
1370
1372
1371
1373
configParams := NewDefaultConfigParams ()
1372
- apRes := map [ string ] string {
1373
- appProtectPolicyKey : "/etc/nginx/waf/nac-policies/default_dataguard-alarm" ,
1374
- appProtectLogConfKey : "/etc/nginx/waf/nac-logconfs/default_logconf syslog:server=127.0.0.1:514" ,
1374
+ apRes := AppProtectResources {
1375
+ AppProtectPolicy : "/etc/nginx/waf/nac-policies/default_dataguard-alarm" ,
1376
+ AppProtectLogconfs : [] string { "/etc/nginx/waf/nac-logconfs/default_logconf syslog:server=127.0.0.1:514" } ,
1375
1377
}
1376
1378
staticCfgParams := & StaticConfigParams {
1377
1379
MainAppProtectLoadModule : true ,
@@ -1382,7 +1384,7 @@ func TestGenerateNginxCfgForMergeableIngressesForAppProtect(t *testing.T) {
1382
1384
expected := createExpectedConfigForMergeableCafeIngress (isPlus )
1383
1385
expected .Servers [0 ].AppProtectEnable = "on"
1384
1386
expected .Servers [0 ].AppProtectPolicy = "/etc/nginx/waf/nac-policies/default_dataguard-alarm"
1385
- expected .Servers [0 ].AppProtectLogConf = "/etc/nginx/waf/nac-logconfs/default_logconf syslog:server=127.0.0.1:514"
1387
+ expected .Servers [0 ].AppProtectLogConfs = [] string { "/etc/nginx/waf/nac-logconfs/default_logconf syslog:server=127.0.0.1:514" }
1386
1388
expected .Servers [0 ].AppProtectLogEnable = "on"
1387
1389
expected .Ingress .Annotations = mergeableIngresses .Master .Ingress .Annotations
1388
1390
0 commit comments