Skip to content

Commit 0369aa8

Browse files
committed
update test files
Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com>
1 parent f244b01 commit 0369aa8

2 files changed

Lines changed: 105 additions & 6 deletions

File tree

internal/gatewayapi/testdata/httproute-with-urlrewrite-hostname-filter-invalid.in.yaml

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,36 @@ httpRoutes:
186186
group: gateway.envoyproxy.io
187187
kind: HTTPRouteFilter
188188
name: valid-header
189+
- apiVersion: gateway.networking.k8s.io/v1
190+
kind: HTTPRoute
191+
metadata:
192+
namespace: default
193+
name: httproute-header-and-pathregex-host-rewrites
194+
spec:
195+
hostnames:
196+
- gateway.envoyproxy.io
197+
parentRefs:
198+
- namespace: envoy-gateway
199+
name: gateway-1
200+
sectionName: http
201+
rules:
202+
- matches:
203+
- path:
204+
value: "/header-and-pathregex"
205+
backendRefs:
206+
- name: service-1
207+
port: 8080
208+
filters:
209+
- type: ExtensionRef
210+
extensionRef:
211+
group: gateway.envoyproxy.io
212+
kind: HTTPRouteFilter
213+
name: valid-header
214+
- type: ExtensionRef
215+
extensionRef:
216+
group: gateway.envoyproxy.io
217+
kind: HTTPRouteFilter
218+
name: valid-path-regex
189219
# PathRegex host rewrite is invalid on a dynamic resolver backend: the upstream host would be
190220
# derived from request-controlled path text, bypassing the dynamic forward proxy loopback protection.
191221
- apiVersion: gateway.networking.k8s.io/v1
@@ -273,13 +303,12 @@ httpFilters:
273303
- apiVersion: gateway.envoyproxy.io/v1alpha1
274304
kind: HTTPRouteFilter
275305
metadata:
276-
name: invalid-path-regex
306+
name: valid-path-regex
277307
namespace: default
278308
spec:
279309
urlRewrite:
280310
hostname:
281311
type: PathRegex
282312
pathRegex:
283-
pattern: '"([a-z]+)"*+?'
284-
substitution: "backend-\\1.service.namespace.svc.cluster.local"
285-
header: my-host
313+
pattern: "^/[^/]+/([^/]+).*"
314+
substitution: "\\1"

internal/gatewayapi/testdata/httproute-with-urlrewrite-hostname-filter-invalid.out.yaml

Lines changed: 72 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ gateways:
3131
protocol: HTTP
3232
status:
3333
listeners:
34-
- attachedRoutes: 7
34+
- attachedRoutes: 8
3535
conditions:
3636
- lastTransitionTime: null
3737
message: Sending translated listener configuration to the data plane
@@ -334,6 +334,54 @@ httpRoutes:
334334
name: gateway-1
335335
namespace: envoy-gateway
336336
sectionName: http
337+
- apiVersion: gateway.networking.k8s.io/v1
338+
kind: HTTPRoute
339+
metadata:
340+
name: httproute-header-and-pathregex-host-rewrites
341+
namespace: default
342+
spec:
343+
hostnames:
344+
- gateway.envoyproxy.io
345+
parentRefs:
346+
- name: gateway-1
347+
namespace: envoy-gateway
348+
sectionName: http
349+
rules:
350+
- backendRefs:
351+
- name: service-1
352+
port: 8080
353+
filters:
354+
- extensionRef:
355+
group: gateway.envoyproxy.io
356+
kind: HTTPRouteFilter
357+
name: valid-header
358+
type: ExtensionRef
359+
- extensionRef:
360+
group: gateway.envoyproxy.io
361+
kind: HTTPRouteFilter
362+
name: valid-path-regex
363+
type: ExtensionRef
364+
matches:
365+
- path:
366+
value: /header-and-pathregex
367+
status:
368+
parents:
369+
- conditions:
370+
- lastTransitionTime: null
371+
message: Cannot configure multiple urlRewrite filters for a single HTTPRouteRule.
372+
reason: UnsupportedValue
373+
status: "False"
374+
type: Accepted
375+
- lastTransitionTime: null
376+
message: Resolved all the Object references for the Route
377+
reason: ResolvedRefs
378+
status: "True"
379+
type: ResolvedRefs
380+
controllerName: gateway.envoyproxy.io/gatewayclass-controller
381+
parentRef:
382+
name: gateway-1
383+
namespace: envoy-gateway
384+
sectionName: http
337385
- apiVersion: gateway.networking.k8s.io/v1
338386
kind: HTTPRoute
339387
metadata:
@@ -369,7 +417,8 @@ httpRoutes:
369417
status: "True"
370418
type: Accepted
371419
- lastTransitionTime: null
372-
message: 'Unable to translate HTTPRouteFilter: default/valid-path-regex.'
420+
message: 'Failed to process route rule 0: host rewrite from path (PathRegex)
421+
is not supported with a dynamic resolver backend.'
373422
reason: UnsupportedValue
374423
status: "False"
375424
type: ResolvedRefs
@@ -452,6 +501,27 @@ xdsIR:
452501
distinct: false
453502
name: ""
454503
prefix: /dynamic-resolver-path-regex
504+
urlRewrite:
505+
host:
506+
pathRegex:
507+
pattern: ^/[^/]+/([^/]+).*
508+
substitution: \1
509+
- directResponse:
510+
statusCode: 500
511+
hostname: gateway.envoyproxy.io
512+
isHTTP2: false
513+
metadata:
514+
kind: HTTPRoute
515+
name: httproute-header-and-pathregex-host-rewrites
516+
namespace: default
517+
name: httproute/default/httproute-header-and-pathregex-host-rewrites/rule/0/match/0/gateway_envoyproxy_io
518+
pathMatch:
519+
distinct: false
520+
name: ""
521+
prefix: /header-and-pathregex
522+
urlRewrite:
523+
host:
524+
header: my-host
455525
- directResponse:
456526
statusCode: 500
457527
hostname: gateway.envoyproxy.io

0 commit comments

Comments
 (0)