@@ -2917,17 +2917,17 @@ func TestGeneratePolicies(t *testing.T) {
2917
2917
vsNamespace : "default" ,
2918
2918
vsName : "test" ,
2919
2919
}
2920
- ingressMTLSCertPath := "/etc/nginx/secrets/default-ingress-mtls-secret-ca.crt"
2921
- ingressMTLSCrlPath := "/etc/nginx/secrets/default-ingress-mtls-secret-ca.crl"
2922
- ingressMTLSCertAndCrlPath := fmt .Sprintf ("%s %s" , ingressMTLSCertPath , ingressMTLSCrlPath )
2920
+ mTLSCertPath := "/etc/nginx/secrets/default-ingress-mtls-secret-ca.crt"
2921
+ mTLSCrlPath := "/etc/nginx/secrets/default-ingress-mtls-secret-ca.crl"
2922
+ mTLSCertAndCrlPath := fmt .Sprintf ("%s %s" , mTLSCertPath , mTLSCrlPath )
2923
2923
policyOpts := policyOptions {
2924
2924
tls : true ,
2925
2925
secretRefs : map [string ]* secrets.SecretReference {
2926
2926
"default/ingress-mtls-secret" : {
2927
2927
Secret : & api_v1.Secret {
2928
2928
Type : secrets .SecretTypeCA ,
2929
2929
},
2930
- Path : ingressMTLSCertPath ,
2930
+ Path : mTLSCertPath ,
2931
2931
},
2932
2932
"default/ingress-mtls-secret-crl" : {
2933
2933
Secret : & api_v1.Secret {
@@ -2936,7 +2936,7 @@ func TestGeneratePolicies(t *testing.T) {
2936
2936
"ca.crl" : []byte ("base64crl" ),
2937
2937
},
2938
2938
},
2939
- Path : ingressMTLSCertAndCrlPath ,
2939
+ Path : mTLSCertAndCrlPath ,
2940
2940
},
2941
2941
"default/egress-mtls-secret" : {
2942
2942
Secret : & api_v1.Secret {
@@ -2950,6 +2950,12 @@ func TestGeneratePolicies(t *testing.T) {
2950
2950
},
2951
2951
Path : "/etc/nginx/secrets/default-egress-trusted-ca-secret" ,
2952
2952
},
2953
+ "default/egress-trusted-ca-secret-crl" : {
2954
+ Secret : & api_v1.Secret {
2955
+ Type : secrets .SecretTypeCA ,
2956
+ },
2957
+ Path : mTLSCertAndCrlPath ,
2958
+ },
2953
2959
"default/jwt-secret" : {
2954
2960
Secret : & api_v1.Secret {
2955
2961
Type : secrets .SecretTypeJWK ,
@@ -2984,7 +2990,6 @@ func TestGeneratePolicies(t *testing.T) {
2984
2990
tests := []struct {
2985
2991
policyRefs []conf_v1.PolicyReference
2986
2992
policies map [string ]* conf_v1.Policy
2987
- policyOpts policyOptions
2988
2993
context string
2989
2994
expected policiesCfg
2990
2995
msg string
@@ -3315,7 +3320,7 @@ func TestGeneratePolicies(t *testing.T) {
3315
3320
context : "spec" ,
3316
3321
expected : policiesCfg {
3317
3322
IngressMTLS : & version2.IngressMTLS {
3318
- ClientCert : ingressMTLSCertPath ,
3323
+ ClientCert : mTLSCertPath ,
3319
3324
VerifyClient : "off" ,
3320
3325
VerifyDepth : 1 ,
3321
3326
},
@@ -3346,8 +3351,8 @@ func TestGeneratePolicies(t *testing.T) {
3346
3351
context : "spec" ,
3347
3352
expected : policiesCfg {
3348
3353
IngressMTLS : & version2.IngressMTLS {
3349
- ClientCert : ingressMTLSCertPath ,
3350
- ClientCrl : ingressMTLSCrlPath ,
3354
+ ClientCert : mTLSCertPath ,
3355
+ ClientCrl : mTLSCrlPath ,
3351
3356
VerifyClient : "off" ,
3352
3357
VerifyDepth : 1 ,
3353
3358
},
@@ -3379,8 +3384,8 @@ func TestGeneratePolicies(t *testing.T) {
3379
3384
context : "spec" ,
3380
3385
expected : policiesCfg {
3381
3386
IngressMTLS : & version2.IngressMTLS {
3382
- ClientCert : ingressMTLSCertPath ,
3383
- ClientCrl : ingressMTLSCrlPath ,
3387
+ ClientCert : mTLSCertPath ,
3388
+ ClientCrl : mTLSCrlPath ,
3384
3389
VerifyClient : "off" ,
3385
3390
VerifyDepth : 1 ,
3386
3391
},
@@ -3423,6 +3428,42 @@ func TestGeneratePolicies(t *testing.T) {
3423
3428
},
3424
3429
msg : "egressMTLS reference" ,
3425
3430
},
3431
+ {
3432
+ policyRefs : []conf_v1.PolicyReference {
3433
+ {
3434
+ Name : "egress-mtls-policy" ,
3435
+ Namespace : "default" ,
3436
+ },
3437
+ },
3438
+ policies : map [string ]* conf_v1.Policy {
3439
+ "default/egress-mtls-policy" : {
3440
+ Spec : conf_v1.PolicySpec {
3441
+ EgressMTLS : & conf_v1.EgressMTLS {
3442
+ TLSSecret : "egress-mtls-secret" ,
3443
+ ServerName : true ,
3444
+ SessionReuse : createPointerFromBool (false ),
3445
+ TrustedCertSecret : "egress-trusted-ca-secret-crl" ,
3446
+ },
3447
+ },
3448
+ },
3449
+ },
3450
+ context : "route" ,
3451
+ expected : policiesCfg {
3452
+ EgressMTLS : & version2.EgressMTLS {
3453
+ Certificate : "/etc/nginx/secrets/default-egress-mtls-secret" ,
3454
+ CertificateKey : "/etc/nginx/secrets/default-egress-mtls-secret" ,
3455
+ Ciphers : "DEFAULT" ,
3456
+ Protocols : "TLSv1 TLSv1.1 TLSv1.2" ,
3457
+ ServerName : true ,
3458
+ SessionReuse : false ,
3459
+ VerifyDepth : 1 ,
3460
+ VerifyServer : false ,
3461
+ TrustedCert : mTLSCertPath ,
3462
+ SSLName : "$proxy_host" ,
3463
+ },
3464
+ },
3465
+ msg : "egressMTLS with crt and crl" ,
3466
+ },
3426
3467
{
3427
3468
policyRefs : []conf_v1.PolicyReference {
3428
3469
{
0 commit comments