Skip to content

Commit 0fb183c

Browse files
committed
review fixes
1 parent b2c36fe commit 0fb183c

File tree

3 files changed

+91
-9
lines changed

3 files changed

+91
-9
lines changed

conformance/tests/backendtlspolicy.go

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import (
2020
"testing"
2121

2222
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
23-
2423
"k8s.io/apimachinery/pkg/types"
2524

2625
gatewayv1 "sigs.k8s.io/gateway-api/apis/v1"
@@ -75,6 +74,9 @@ var BackendTLSPolicy = suite.ConformanceTest{
7574
validSanPolicyNN := types.NamespacedName{Name: "backendtlspolicy-san", Namespace: ns}
7675
kubernetes.BackendTLSPolicyMustHaveCondition(t, suite.Client, suite.TimeoutConfig, validSanPolicyNN, gwNN, policyCond)
7776

77+
validMultiSanPolicyNN := types.NamespacedName{Name: "backendtlspolicy-multiple-sans-test", Namespace: ns}
78+
kubernetes.BackendTLSPolicyMustHaveCondition(t, suite.Client, suite.TimeoutConfig, validMultiSanPolicyNN, gwNN, policyCond)
79+
7880
serverStr := "abc.example.com"
7981

8082
// Verify that the request sent to Service with valid BackendTLSPolicy should succeed.
@@ -145,7 +147,19 @@ var BackendTLSPolicy = suite.ConformanceTest{
145147
Request: h.Request{
146148
Host: serverStr,
147149
Path: "/backendTLSSan",
148-
SNI: serverStr,
150+
},
151+
Response: h.Response{StatusCode: 200},
152+
})
153+
})
154+
155+
// Verify that the request sent to Service with BackendTLSPolicy configured with multiple SANs should succeed.
156+
t.Run("HTTP request sent to Service with BackendTLSPolicy configured with multiple SANs should succeed", func(t *testing.T) {
157+
h.MakeRequestAndExpectEventuallyConsistentResponse(t, suite.RoundTripper, suite.TimeoutConfig, gwAddr,
158+
h.ExpectedResponse{
159+
Namespace: ns,
160+
Request: h.Request{
161+
Host: serverStr,
162+
Path: "/backendTLSMultiSans",
149163
},
150164
Response: h.Response{StatusCode: 200},
151165
})
@@ -159,7 +173,6 @@ var BackendTLSPolicy = suite.ConformanceTest{
159173
Request: h.Request{
160174
Host: serverStr,
161175
Path: "/backendTLSSanMismatch",
162-
SNI: serverStr,
163176
},
164177
})
165178
})

conformance/tests/backendtlspolicy.yaml

Lines changed: 73 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,15 @@ spec:
8888
- path:
8989
type: Exact
9090
value: /backendTLSSan
91+
- backendRefs:
92+
- group: ""
93+
kind: Service
94+
name: backendtlspolicy-multiple-sans-test
95+
port: 443
96+
matches:
97+
- path:
98+
type: Exact
99+
value: /backendTLSMultiSans
91100
---
92101
apiVersion: v1
93102
kind: Service
@@ -163,6 +172,21 @@ spec:
163172
port: 443
164173
targetPort: 8443
165174
---
175+
apiVersion: v1
176+
kind: Service
177+
metadata:
178+
name: backendtlspolicy-multiple-sans-test
179+
namespace: gateway-conformance-infra
180+
spec:
181+
selector:
182+
app: backendtlspolicy-test
183+
ports:
184+
- name: "btls"
185+
protocol: TCP
186+
appProtocol: HTTPS
187+
port: 443
188+
targetPort: 8443
189+
---
166190
# Deployment must not be applied until after the secret is generated.
167191
apiVersion: apps/v1
168192
kind: Deployment
@@ -269,6 +293,25 @@ spec:
269293
---
270294
apiVersion: gateway.networking.k8s.io/v1alpha3
271295
kind: BackendTLSPolicy
296+
metadata:
297+
name: backendtlspolicy-cert-mismatch
298+
namespace: gateway-conformance-infra
299+
spec:
300+
targetRefs:
301+
- group: ""
302+
kind: Service
303+
name: "backendtlspolicy-cert-mismatch-test"
304+
sectionName: "btls"
305+
validation:
306+
caCertificateRefs:
307+
- group: ""
308+
kind: ConfigMap
309+
# This secret is generated dynamically by the test suite.
310+
name: "backend-tls-mismatch-certificate"
311+
hostname: "abc.example.com"
312+
---
313+
apiVersion: gateway.networking.k8s.io/v1alpha3
314+
kind: BackendTLSPolicy
272315
metadata:
273316
name: backendtlspolicy-san
274317
namespace: gateway-conformance-infra
@@ -283,11 +326,37 @@ spec:
283326
- group: ""
284327
kind: ConfigMap
285328
# This secret is generated dynamically by the test suite.
286-
name: "backend-tls-certificate"
329+
name: "backend-tls-checks-certificate"
330+
hostname: "abc.example.com"
287331
subjectAltNames:
288332
- type: Hostname
289333
hostname: abc.example.com
290-
hostname: "mismatch.example.com"
334+
---
335+
apiVersion: gateway.networking.k8s.io/v1alpha3
336+
kind: BackendTLSPolicy
337+
metadata:
338+
name: backendtlspolicy-multiple-sans
339+
namespace: gateway-conformance-infra
340+
spec:
341+
targetRefs:
342+
- group: ""
343+
kind: Service
344+
name: "backendtlspolicy-multiple-sans-test"
345+
sectionName: "btls"
346+
validation:
347+
caCertificateRefs:
348+
- group: ""
349+
kind: ConfigMap
350+
# This secret is generated dynamically by the test suite.
351+
name: "backend-tls-checks-certificate"
352+
hostname: "abc.example.com"
353+
subjectAltNames:
354+
- type: Hostname
355+
hostname: abc.example.com
356+
- type: Hostname
357+
hostname: efg.example.com
358+
- type: Hostname
359+
hostname: yjh.example.com
291360
---
292361
apiVersion: gateway.networking.k8s.io/v1alpha3
293362
kind: BackendTLSPolicy
@@ -305,8 +374,8 @@ spec:
305374
- group: ""
306375
kind: ConfigMap
307376
# This secret is generated dynamically by the test suite.
308-
name: "backend-tls-certificate"
377+
name: "backend-tls-checks-certificate"
378+
hostname: "abc.example.com"
309379
subjectAltNames:
310380
- type: Hostname
311381
hostname: cde.example.com
312-
hostname: "mismatch.example.com"

conformance/utils/kubernetes/helpers.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1003,7 +1003,7 @@ func BackendTLSPolicyMustHaveCondition(t *testing.T, client client.Client, timeo
10031003
policy := &v1alpha3.BackendTLSPolicy{}
10041004
err := client.Get(ctx, policyNN, policy)
10051005
if err != nil {
1006-
return false, fmt.Errorf("error fetching BackendTLSPolicy: %w", err)
1006+
return false, fmt.Errorf("error fetching BackendTLSPolicy %v err: %w", policyNN, err)
10071007
}
10081008

10091009
for _, parent := range policy.Status.Ancestors {
@@ -1024,5 +1024,5 @@ func BackendTLSPolicyMustHaveCondition(t *testing.T, client client.Client, timeo
10241024
return false, nil
10251025
})
10261026

1027-
require.NoErrorf(t, waitErr, "error waiting for BackendTLSPolicy status to have a Condition %v", condition)
1027+
require.NoErrorf(t, waitErr, "error waiting for BackendTLSPolicy %v status to have a Condition %v", policyNN, condition)
10281028
}

0 commit comments

Comments
 (0)