Skip to content

Commit 4809247

Browse files
committed
Use port from json body and go.mod replace
Signed-off-by: Daneyon Hansen <daneyon.hansen@solo.io>
1 parent 65299a3 commit 4809247

File tree

3 files changed

+21
-19
lines changed

3 files changed

+21
-19
lines changed

conformance/tests/gateway_following_epp_routing_dp.go

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -208,38 +208,37 @@ func assertTrafficOnlyReachesToExpectedPodsDP(
208208
if err := gwhttp.CompareRoundTrip(t, &r, cReq, cRes, expected); err != nil {
209209
return fmt.Errorf("expectation failed: %w", err)
210210
}
211-
// Enforce no leakage to non-selected pods (ports/ranks are internal).
211+
// Enforce no leakage to non-selected pods.
212212
if !slices.Contains(expectedPodNames, cReq.Pod) {
213213
return fmt.Errorf("unexpected pod %q (expected one of %v)", cReq.Pod, expectedPodNames)
214214
}
215215

216-
// Validate X-Echo-HTTP-Port vs EPP intent for the pod's IP.
217-
portHdr := getHeaderValue(cRes.Headers, "X-Echo-HTTP-Port") // Header set by backend echo server
218-
if portHdr == "" {
219-
return errors.New("missing X-Echo-HTTP-Port response header")
216+
// Validate httpPort from JSON response body vs EPP intent.
217+
if cReq.HTTPPort == "" {
218+
return errors.New("missing httpPort in echo JSON body response")
220219
}
221220
ip := podNameToIP[cReq.Pod]
222221
allowed, ok := ipToAllowedPorts[ip]
223222
if !ok {
224223
return fmt.Errorf("pod %q (IP %s) not present in EPP selection", cReq.Pod, ip)
225224
}
226225
if len(allowed) > 0 {
227-
if _, ok := allowed[portHdr]; !ok {
228-
return fmt.Errorf("unexpected X-Echo-HTTP-Port %q for IP %s (allowed: %v)", portHdr, ip, keys(allowed))
226+
if _, ok := allowed[cReq.HTTPPort]; !ok {
227+
return fmt.Errorf("unexpected httpPort %q for IP %s (allowed: %v)", cReq.HTTPPort, ip, keys(allowed))
229228
}
230229
} else {
231-
if _, ok := dpPorts[portHdr]; !ok {
232-
return fmt.Errorf("unexpected X-Echo-HTTP-Port %q for IP %s (expected one of DP ports %v)", portHdr, ip, keys(dpPorts))
230+
if _, ok := dpPorts[cReq.HTTPPort]; !ok {
231+
return fmt.Errorf("unexpected httpPort %q for IP %s (expected one of ports %v)", cReq.HTTPPort, ip, keys(dpPorts))
233232
}
234233
}
235234

236235
return nil
237236
})
238237
}
239238
if err := g.Wait(); err != nil {
240-
t.Fatalf("Requests were not confined to expected pods (DP) or failed port-header checks: %v", err)
239+
t.Fatalf("Requests were not confined to expected pods or failed port checks: %v", err)
241240
}
242-
t.Logf("DP traffic restricted to %v and port header validated against EPP selection", expectedPodNames)
241+
t.Logf("Traffic restricted to %v and httpPort validated against EPP selection", expectedPodNames)
243242
}
244243

245244
type portSet map[string]struct{}

go.mod

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,14 +108,14 @@ require (
108108
go.yaml.in/yaml/v3 v3.0.4 // indirect
109109
golang.org/x/crypto v0.43.0 // indirect
110110
golang.org/x/exp v0.0.0-20250808145144-a408d31f581a // indirect
111-
golang.org/x/mod v0.28.0 // indirect
111+
golang.org/x/mod v0.29.0 // indirect
112112
golang.org/x/net v0.46.0 // indirect
113113
golang.org/x/oauth2 v0.32.0 // indirect
114114
golang.org/x/sys v0.37.0 // indirect
115115
golang.org/x/term v0.36.0 // indirect
116116
golang.org/x/text v0.30.0 // indirect
117117
golang.org/x/time v0.13.0 // indirect
118-
golang.org/x/tools v0.37.0 // indirect
118+
golang.org/x/tools v0.38.0 // indirect
119119
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect
120120
google.golang.org/genproto/googleapis/api v0.0.0-20250929231259-57b25ae835d4 // indirect
121121
google.golang.org/genproto/googleapis/rpc v0.0.0-20250922171735-9219d122eba9 // indirect
@@ -131,3 +131,6 @@ require (
131131
sigs.k8s.io/json v0.0.0-20250730193827-2d320260d730 // indirect
132132
sigs.k8s.io/randfill v1.0.0 // indirect
133133
)
134+
135+
// Remove when https://github.com/kubernetes-sigs/gateway-api/pull/4230 is merged and this mod is bumped.
136+
replace sigs.k8s.io/gateway-api => github.com/danehans/gateway-api v0.0.0-20251105234232-3c6c58966376

go.sum

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XL
6767
github.com/cncf/xds/go v0.0.0-20250501225837-2ac532fd4443 h1:aQ3y1lwWyqYPiWZThqv1aFbZMiM9vblcSArJRf2Irls=
6868
github.com/cncf/xds/go v0.0.0-20250501225837-2ac532fd4443/go.mod h1:W+zGtBO5Y1IgJhy4+A9GOqVhqLpfZi+vwmdNXUehLA8=
6969
github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g=
70+
github.com/danehans/gateway-api v0.0.0-20251105234232-3c6c58966376 h1:D0LwQGjW4mhz4XlK3kc7qMZ2RsD69JM7ZqdX9P00oyk=
71+
github.com/danehans/gateway-api v0.0.0-20251105234232-3c6c58966376/go.mod h1:eEYVpDGr0WPqR/35ZTBIWWpwKL7uUzOqlT92mmv3fus=
7072
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
7173
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
7274
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
@@ -311,8 +313,8 @@ golang.org/x/exp v0.0.0-20250808145144-a408d31f581a h1:Y+7uR/b1Mw2iSXZ3G//1haIiS
311313
golang.org/x/exp v0.0.0-20250808145144-a408d31f581a/go.mod h1:rT6SFzZ7oxADUDx58pcaKFTcZ+inxAa9fTrYx/uVYwg=
312314
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
313315
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
314-
golang.org/x/mod v0.28.0 h1:gQBtGhjxykdjY9YhZpSlZIsbnaE2+PgjfLWUQTnoZ1U=
315-
golang.org/x/mod v0.28.0/go.mod h1:yfB/L0NOf/kmEbXjzCPOx1iK1fRutOydrCMsqRhEBxI=
316+
golang.org/x/mod v0.29.0 h1:HV8lRxZC4l2cr3Zq1LvtOsi/ThTgWnUk/y64QSs8GwA=
317+
golang.org/x/mod v0.29.0/go.mod h1:NyhrlYXJ2H4eJiRy/WDBO6HMqZQ6q9nk4JzS3NuCK+w=
316318
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
317319
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
318320
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
@@ -343,8 +345,8 @@ golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGm
343345
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
344346
golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
345347
golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
346-
golang.org/x/tools v0.37.0 h1:DVSRzp7FwePZW356yEAChSdNcQo6Nsp+fex1SUW09lE=
347-
golang.org/x/tools v0.37.0/go.mod h1:MBN5QPQtLMHVdvsbtarmTNukZDdgwdwlO5qGacAzF0w=
348+
golang.org/x/tools v0.38.0 h1:Hx2Xv8hISq8Lm16jvBZ2VQf+RLmbd7wVUsALibYI/IQ=
349+
golang.org/x/tools v0.38.0/go.mod h1:yEsQ/d/YK8cjh0L6rZlY8tgtlKiBNTL14pGDJPJpYQs=
348350
golang.org/x/tools/go/expect v0.1.1-deprecated h1:jpBZDwmgPhXsKZC6WhL20P4b/wmnpsEAGHaNy0n/rJM=
349351
golang.org/x/tools/go/expect v0.1.1-deprecated/go.mod h1:eihoPOH+FgIqa3FpoTwguz/bVUSGBlGQU67vpBeOrBY=
350352
golang.org/x/tools/go/packages/packagestest v0.1.1-deprecated h1:1h2MnaIAIXISqTFKdENegdpAgUXz6NrPEsbIeWaBRvM=
@@ -409,8 +411,6 @@ sigs.k8s.io/controller-runtime v0.22.4 h1:GEjV7KV3TY8e+tJ2LCTxUTanW4z/FmNB7l327U
409411
sigs.k8s.io/controller-runtime v0.22.4/go.mod h1:+QX1XUpTXN4mLoblf4tqr5CQcyHPAki2HLXqQMY6vh8=
410412
sigs.k8s.io/controller-tools v0.19.0 h1:OU7jrPPiZusryu6YK0jYSjPqg8Vhf8cAzluP9XGI5uk=
411413
sigs.k8s.io/controller-tools v0.19.0/go.mod h1:y5HY/iNDFkmFla2CfQoVb2AQXMsBk4ad84iR1PLANB0=
412-
sigs.k8s.io/gateway-api v1.4.0 h1:ZwlNM6zOHq0h3WUX2gfByPs2yAEsy/EenYJB78jpQfQ=
413-
sigs.k8s.io/gateway-api v1.4.0/go.mod h1:AR5RSqciWP98OPckEjOjh2XJhAe2Na4LHyXD2FUY7Qk=
414414
sigs.k8s.io/json v0.0.0-20250730193827-2d320260d730 h1:IpInykpT6ceI+QxKBbEflcR5EXP7sU1kvOlxwZh5txg=
415415
sigs.k8s.io/json v0.0.0-20250730193827-2d320260d730/go.mod h1:mdzfpAEoE6DHQEN0uh9ZbOCuHbLK5wOm7dK4ctXE9Tg=
416416
sigs.k8s.io/randfill v1.0.0 h1:JfjMILfT8A6RbawdsK2JXGBR5AQVfd+9TbzrlneTyrU=

0 commit comments

Comments
 (0)