Skip to content

Commit 949c08e

Browse files
committed
Add additional test case
1 parent 42af02a commit 949c08e

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

internal/mode/static/state/change_processor.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,9 @@ func NewChangeProcessorImpl(cfg ChangeProcessorConfig) *ChangeProcessorImpl {
231231
// belong to the NGINX Gateway Fabric or an HTTPRoute that doesn't belong to any of the Gateways of the
232232
// NGINX Gateway Fabric. Find a way to ignore changes that don't affect the configuration and/or statuses of
233233
// the resources.
234+
// Tracking issues: https://github.com/nginxinc/nginx-gateway-fabric/issues/1123,
235+
// https://github.com/nginxinc/nginx-gateway-fabric/issues/1124,
236+
// https://github.com/nginxinc/nginx-gateway-fabric/issues/1577
234237

235238
// FIXME(pleshakov)
236239
// Remove CaptureUpsertChange() and CaptureDeleteChange() from ChangeProcessor and pass all changes directly to

internal/mode/static/state/graph/backend_tls_policy.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,11 @@ func validateBackendTLSPolicy(
8888
valid = false
8989
conds = append(conds, staticConds.NewBackendTLSPolicyInvalid(fmt.Sprintf("invalid hostname: %s", err.Error())))
9090
}
91-
if backendTLSPolicy.Spec.TLS.CACertRefs != nil && len(backendTLSPolicy.Spec.TLS.CACertRefs) > 0 {
91+
if backendTLSPolicy.Spec.TLS.CACertRefs != nil && backendTLSPolicy.Spec.TLS.WellKnownCACerts != nil {
92+
valid = false
93+
msg := "CACertRefs and WellKnownCACerts are mutually exclusive"
94+
conds = append(conds, staticConds.NewBackendTLSPolicyInvalid(msg))
95+
} else if backendTLSPolicy.Spec.TLS.CACertRefs != nil && len(backendTLSPolicy.Spec.TLS.CACertRefs) > 0 {
9296
if err := validateBackendTLSCACertRef(backendTLSPolicy, configMapResolver); err != nil {
9397
valid = false
9498
conds = append(conds, staticConds.NewBackendTLSPolicyInvalid(

internal/mode/static/state/graph/backend_tls_policy_test.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,23 @@ func TestValidateBackendTLSPolicy(t *testing.T) {
323323
},
324324
},
325325
},
326+
{
327+
name: "invalid case with too both ca cert refs and wellknowncerts",
328+
tlsPolicy: &v1alpha2.BackendTLSPolicy{
329+
ObjectMeta: metav1.ObjectMeta{
330+
Name: "tls-policy",
331+
Namespace: "test",
332+
},
333+
Spec: v1alpha2.BackendTLSPolicySpec{
334+
TargetRef: *targetRefNormalCase,
335+
TLS: v1alpha2.BackendTLSPolicyConfig{
336+
CACertRefs: localObjectRefNormalCase,
337+
Hostname: "foo.test.com",
338+
WellKnownCACerts: (helpers.GetPointer(v1alpha2.WellKnownCACertSystem)),
339+
},
340+
},
341+
},
342+
},
326343
{
327344
name: "invalid case with too many ancestors",
328345
tlsPolicy: &v1alpha2.BackendTLSPolicy{

0 commit comments

Comments
 (0)