@@ -262,6 +262,7 @@ spec:
262262 - path:
263263 type: Exact
264264 value: /get
265+ name: get
265266 backendRefs:
266267 - name: httpbin-service-e2e-test
267268 port: 80
@@ -288,6 +289,30 @@ spec:
288289 backendRefs:
289290 - name: httpbin-service-e2e-test
290291 port: 80
292+ `
293+ var httpRoutePolicy = `
294+ apiVersion: gateway.networking.k8s.io/v1
295+ kind: HTTPRoutePolicy
296+ metadata:
297+ name: httpRoutePolicy0
298+ spec:
299+ targetRefs:
300+ - group: gateway.apisix.io
301+ kind: HTTPRoute
302+ name: httpbin
303+ sectionName: get
304+ - group: gateway.apisix.io
305+ kind: HTTPRoute
306+ name: httpbin
307+ sectionName: put
308+ - group: gateway.apisix.io
309+ kind: HTTPRoute
310+ name: httpbin-1
311+ sectionName: get
312+ priority: 10
313+ vars:
314+ - ["http_x_hrp_name", "==", "httpRoutePolicy0"]
315+ - ["arg_hrp_name", "==", "httpRoutePolicy0"]
291316`
292317
293318 var prefixRouteByStatus = `
@@ -396,7 +421,7 @@ spec:
396421 Status (404 )
397422 })
398423
399- It ("HTTPRoute Vars Match" , func () {
424+ FIt ("HTTPRoute Vars Match" , func () {
400425 By ("create HTTPRoute" )
401426 ResourceApplied ("HTTPRoute" , "httpbin" , varsRoute , 1 )
402427
@@ -413,6 +438,26 @@ spec:
413438 WithHeader ("X-Route-Name" , "httpbin" ).
414439 Expect ().
415440 Status (http .StatusOK )
441+
442+ By ("create HTTPRoutePolicy" )
443+ ResourceApplied ("HTTPRoutePolicy" , "httpRoutePolicy0" , httpRoutePolicy , 1 )
444+
445+ By ("access dataplane to check the HTTPRoutePolicy" )
446+ s .NewAPISIXClient ().
447+ GET ("/get" ).
448+ WithHost ("httpbin.example" ).
449+ WithHeader ("X-Route-Name" , "httpbin" ).
450+ Expect ().
451+ Status (http .StatusNotFound )
452+
453+ s .NewAPISIXClient ().
454+ GET ("/get" ).
455+ WithHost ("httpbin.example" ).
456+ WithHeader ("X-Route-Name" , "httpbin" ).
457+ WithHeader ("X-HRP-Name" , "httpRoutePolicy0" ).
458+ WithQuery ("hrp_name" , "httpRoutePolicy0" ).
459+ Expect ().
460+ Status (http .StatusOK )
416461 })
417462 })
418463
0 commit comments