Skip to content

Commit 8edfd07

Browse files
committed
update test files
Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com>
1 parent 825535c commit 8edfd07

2 files changed

Lines changed: 186 additions & 1 deletion

File tree

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

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,56 @@ httpRoutes:
216216
group: gateway.envoyproxy.io
217217
kind: HTTPRouteFilter
218218
name: valid-path-regex
219+
- apiVersion: gateway.networking.k8s.io/v1
220+
kind: HTTPRoute
221+
metadata:
222+
namespace: default
223+
name: httproute-invalid-path-regex
224+
spec:
225+
hostnames:
226+
- gateway.envoyproxy.io
227+
parentRefs:
228+
- namespace: envoy-gateway
229+
name: gateway-1
230+
sectionName: http
231+
rules:
232+
- matches:
233+
- path:
234+
value: "/invalid-path-regex"
235+
backendRefs:
236+
- name: service-1
237+
port: 8080
238+
filters:
239+
- type: ExtensionRef
240+
extensionRef:
241+
group: gateway.envoyproxy.io
242+
kind: HTTPRouteFilter
243+
name: invalid-path-regex
244+
- apiVersion: gateway.networking.k8s.io/v1
245+
kind: HTTPRoute
246+
metadata:
247+
namespace: default
248+
name: httproute-missing-path-regex
249+
spec:
250+
hostnames:
251+
- gateway.envoyproxy.io
252+
parentRefs:
253+
- namespace: envoy-gateway
254+
name: gateway-1
255+
sectionName: http
256+
rules:
257+
- matches:
258+
- path:
259+
value: "/missing-path-regex"
260+
backendRefs:
261+
- name: service-1
262+
port: 8080
263+
filters:
264+
- type: ExtensionRef
265+
extensionRef:
266+
group: gateway.envoyproxy.io
267+
kind: HTTPRouteFilter
268+
name: missing-path-regex
219269
# PathRegex host rewrite is invalid on a dynamic resolver backend: the upstream host would be
220270
# derived from request-controlled path text, bypassing the dynamic forward proxy loopback protection.
221271
- apiVersion: gateway.networking.k8s.io/v1
@@ -312,3 +362,25 @@ httpFilters:
312362
pathRegex:
313363
pattern: "^/[^/]+/([^/]+).*"
314364
substitution: "\\1"
365+
- apiVersion: gateway.envoyproxy.io/v1alpha1
366+
kind: HTTPRouteFilter
367+
metadata:
368+
name: invalid-path-regex
369+
namespace: default
370+
spec:
371+
urlRewrite:
372+
hostname:
373+
type: PathRegex
374+
pathRegex:
375+
pattern: '"([a-z]+)"*+?'
376+
substitution: "backend-\\1.service.namespace.svc.cluster.local"
377+
header: my-host
378+
- apiVersion: gateway.envoyproxy.io/v1alpha1
379+
kind: HTTPRouteFilter
380+
metadata:
381+
name: missing-path-regex
382+
namespace: default
383+
spec:
384+
urlRewrite:
385+
hostname:
386+
type: PathRegex

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

Lines changed: 114 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ gateways:
3131
protocol: HTTP
3232
status:
3333
listeners:
34-
- attachedRoutes: 8
34+
- attachedRoutes: 10
3535
conditions:
3636
- lastTransitionTime: null
3737
message: Sending translated listener configuration to the data plane
@@ -382,6 +382,93 @@ httpRoutes:
382382
name: gateway-1
383383
namespace: envoy-gateway
384384
sectionName: http
385+
- apiVersion: gateway.networking.k8s.io/v1
386+
kind: HTTPRoute
387+
metadata:
388+
name: httproute-invalid-path-regex
389+
namespace: default
390+
spec:
391+
hostnames:
392+
- gateway.envoyproxy.io
393+
parentRefs:
394+
- name: gateway-1
395+
namespace: envoy-gateway
396+
sectionName: http
397+
rules:
398+
- backendRefs:
399+
- name: service-1
400+
port: 8080
401+
filters:
402+
- extensionRef:
403+
group: gateway.envoyproxy.io
404+
kind: HTTPRouteFilter
405+
name: invalid-path-regex
406+
type: ExtensionRef
407+
matches:
408+
- path:
409+
value: /invalid-path-regex
410+
status:
411+
parents:
412+
- conditions:
413+
- lastTransitionTime: null
414+
message: PathRegex must be a valid RE2 regular expression.
415+
reason: UnsupportedValue
416+
status: "False"
417+
type: Accepted
418+
- lastTransitionTime: null
419+
message: Resolved all the Object references for the Route
420+
reason: ResolvedRefs
421+
status: "True"
422+
type: ResolvedRefs
423+
controllerName: gateway.envoyproxy.io/gatewayclass-controller
424+
parentRef:
425+
name: gateway-1
426+
namespace: envoy-gateway
427+
sectionName: http
428+
- apiVersion: gateway.networking.k8s.io/v1
429+
kind: HTTPRoute
430+
metadata:
431+
name: httproute-missing-path-regex
432+
namespace: default
433+
spec:
434+
hostnames:
435+
- gateway.envoyproxy.io
436+
parentRefs:
437+
- name: gateway-1
438+
namespace: envoy-gateway
439+
sectionName: http
440+
rules:
441+
- backendRefs:
442+
- name: service-1
443+
port: 8080
444+
filters:
445+
- extensionRef:
446+
group: gateway.envoyproxy.io
447+
kind: HTTPRouteFilter
448+
name: missing-path-regex
449+
type: ExtensionRef
450+
matches:
451+
- path:
452+
value: /missing-path-regex
453+
status:
454+
parents:
455+
- conditions:
456+
- lastTransitionTime: null
457+
message: PathRegex Pattern and Substitution must be set when rewrite hostname
458+
type is "PathRegex".
459+
reason: UnsupportedValue
460+
status: "False"
461+
type: Accepted
462+
- lastTransitionTime: null
463+
message: Resolved all the Object references for the Route
464+
reason: ResolvedRefs
465+
status: "True"
466+
type: ResolvedRefs
467+
controllerName: gateway.envoyproxy.io/gatewayclass-controller
468+
parentRef:
469+
name: gateway-1
470+
namespace: envoy-gateway
471+
sectionName: http
385472
- apiVersion: gateway.networking.k8s.io/v1
386473
kind: HTTPRoute
387474
metadata:
@@ -538,6 +625,32 @@ xdsIR:
538625
urlRewrite:
539626
host:
540627
header: my-host
628+
- directResponse:
629+
statusCode: 500
630+
hostname: gateway.envoyproxy.io
631+
isHTTP2: false
632+
metadata:
633+
kind: HTTPRoute
634+
name: httproute-invalid-path-regex
635+
namespace: default
636+
name: httproute/default/httproute-invalid-path-regex/rule/0/match/0/gateway_envoyproxy_io
637+
pathMatch:
638+
distinct: false
639+
name: ""
640+
prefix: /invalid-path-regex
641+
- directResponse:
642+
statusCode: 500
643+
hostname: gateway.envoyproxy.io
644+
isHTTP2: false
645+
metadata:
646+
kind: HTTPRoute
647+
name: httproute-missing-path-regex
648+
namespace: default
649+
name: httproute/default/httproute-missing-path-regex/rule/0/match/0/gateway_envoyproxy_io
650+
pathMatch:
651+
distinct: false
652+
name: ""
653+
prefix: /missing-path-regex
541654
- directResponse:
542655
statusCode: 500
543656
hostname: gateway.envoyproxy.io

0 commit comments

Comments
 (0)