Skip to content

Commit 99e7eac

Browse files
committed
1 parent 6d9ab9e commit 99e7eac

File tree

5 files changed

+45
-40
lines changed

5 files changed

+45
-40
lines changed

conformance/base/manifests.yaml

+32-33
Original file line numberDiff line numberDiff line change
@@ -740,9 +740,9 @@ spec:
740740
selector:
741741
app: backendtlspolicy-test
742742
ports:
743-
- protocol: TCP
744-
port: 443
745-
targetPort: 8443
743+
- protocol: TCP
744+
port: 443
745+
targetPort: 8443
746746
---
747747
apiVersion: apps/v1
748748
kind: Deployment
@@ -762,34 +762,33 @@ spec:
762762
app: backendtlspolicy-test
763763
spec:
764764
containers:
765-
- name: backendtlspolicy-test
766-
image: gcr.io/k8s-staging-gateway-api/echo-basic:v20240412-v1.0.0-394-g40c666fd
767-
volumeMounts:
768-
- name: secret-volume
769-
mountPath: /etc/secret-volume
770-
env:
771-
- name: POD_NAME
772-
valueFrom:
773-
fieldRef:
774-
fieldPath: metadata.name
775-
- name: NAMESPACE
776-
valueFrom:
777-
fieldRef:
778-
fieldPath: metadata.namespace
779-
- name: CA_CERT
780-
value: /etc/secret-volume/crt
781-
- name: CA_CERT_KEY
782-
value: /etc/secret-volume/key
783-
resources:
784-
requests:
785-
cpu: 10m
786-
volumes:
765+
- name: backendtlspolicy-test
766+
image: gcr.io/k8s-staging-gateway-api/echo-basic:v20240412-v1.0.0-394-g40c666fd
767+
volumeMounts:
787768
- name: secret-volume
788-
secret:
789-
secretName: backend-tls-checks-certificate
790-
items:
791-
- key: tls.crt
792-
path: crt
793-
- key: tls.key
794-
path: key
795-
---
769+
mountPath: /etc/secret-volume
770+
env:
771+
- name: POD_NAME
772+
valueFrom:
773+
fieldRef:
774+
fieldPath: metadata.name
775+
- name: NAMESPACE
776+
valueFrom:
777+
fieldRef:
778+
fieldPath: metadata.namespace
779+
- name: CA_CERT
780+
value: /etc/secret-volume/crt
781+
- name: CA_CERT_KEY
782+
value: /etc/secret-volume/key
783+
resources:
784+
requests:
785+
cpu: 10m
786+
volumes:
787+
- name: secret-volume
788+
secret:
789+
secretName: backend-tls-checks-certificate
790+
items:
791+
- key: tls.crt
792+
path: crt
793+
- key: tls.key
794+
path: key

conformance/echo-basic/.go.mod

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ module sigs.k8s.io/gateway-api/conformance/echo-basic
33
go 1.21
44

55
require (
6+
github.com/paultag/sniff v0.0.0-20200207005214-cf7e4d167732
67
golang.org/x/net v0.21.0
78
google.golang.org/grpc v1.53.0
89
google.golang.org/protobuf v1.28.1

conformance/echo-basic/.go.sum

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiu
44
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
55
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
66
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
7+
github.com/paultag/sniff v0.0.0-20200207005214-cf7e4d167732 h1:nkseUkzjazCNyGhkRwnJ1OiHSwMXazsJQx+Ci+oVLEM=
8+
github.com/paultag/sniff v0.0.0-20200207005214-cf7e4d167732/go.mod h1:J3XXNGJINXLa4yIivdUT0Ad/srv2q0pSOWbbm6El2EY=
79
golang.org/x/net v0.21.0 h1:AQyQV4dYCvJ7vGmJyKki9+PBdyvhkSd8EIx/qb0AYv4=
810
golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44=
911
golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y=

conformance/echo-basic/echo-basic.go

+6-3
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,9 @@ func echoHandler(w http.ResponseWriter, r *http.Request) {
226226
if strings.Contains(r.RequestURI, "backendTLS") {
227227
sni, err = sniffForSNI(r.RemoteAddr)
228228
if err != nil {
229-
// Todo: research if for some test cases there won't be one
229+
// TODO: research if for some test cases there won't be SNI available.
230+
processError(w, err, http.StatusBadRequest)
231+
return
230232
}
231233
}
232234

@@ -340,14 +342,15 @@ func sniffForSNI(addr string) (string, error) {
340342
return "", fmt.Errorf("could not read socket: %v", err)
341343
}
342344
// Take an incoming TLS Client Hello and return the SNI name.
343-
sni, err = parser.GetHostname(data[:])
345+
sni, err = parser.GetHostname(data)
344346
if err != nil {
345347
return "", fmt.Errorf("error getting SNI: %v", err)
346348
}
347349
if sni == "" {
348350
return "", fmt.Errorf("no server name indication found")
351+
} else { //nolint:revive
352+
return sni, nil
349353
}
350-
return sni, nil
351354
}
352355
}
353356

conformance/tests/backendtlspolicy-normative.yaml

+4-4
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ metadata:
2323
namespace: gateway-conformance-infra
2424
spec:
2525
targetRefs:
26-
- group: ""
27-
kind: Service
28-
name: "backendtlspolicy-test"
26+
- group: ""
27+
kind: Service
28+
name: "backendtlspolicy-test"
2929
validation:
3030
caCertificateRefs:
3131
group: ""
3232
kind: Secret
3333
name: "backend-tls-checks-certificate"
34-
hostname: "abc.example.com"
34+
hostname: "abc.example.com"

0 commit comments

Comments
 (0)