@@ -942,6 +942,60 @@ spec:
942942 })
943943 })
944944
945+ It ("HTTPRoute RegularExpression Match" , func () {
946+ var regexRoute = fmt .Sprintf (`
947+ apiVersion: gateway.networking.k8s.io/v1
948+ kind: HTTPRoute
949+ metadata:
950+ name: httpbin
951+ spec:
952+ parentRefs:
953+ - name: %s
954+ hostnames:
955+ - httpbin.example
956+ rules:
957+ - matches:
958+ - path:
959+ type: RegularExpression
960+ value: /status/[0-9]+
961+ backendRefs:
962+ - name: httpbin-service-e2e-test
963+ port: 80
964+ ` , s .Namespace ())
965+
966+ By ("create HTTPRoute with RegularExpression path type" )
967+ s .ResourceApplied ("HTTPRoute" , "httpbin" , regexRoute , 1 )
968+
969+ By ("access dataplane: path matching regex should succeed" )
970+ s .RequestAssert (& scaffold.RequestAssert {
971+ Method : "GET" ,
972+ Path : "/status/200" ,
973+ Host : "httpbin.example" ,
974+ Check : scaffold .WithExpectedStatus (http .StatusOK ),
975+ Timeout : time .Second * 30 ,
976+ Interval : time .Second * 2 ,
977+ })
978+
979+ s .RequestAssert (& scaffold.RequestAssert {
980+ Method : "GET" ,
981+ Path : "/status/201" ,
982+ Host : "httpbin.example" ,
983+ Check : scaffold .WithExpectedStatus (http .StatusCreated ),
984+ Timeout : time .Second * 30 ,
985+ Interval : time .Second * 2 ,
986+ })
987+
988+ By ("access dataplane: path not matching regex should return 404" )
989+ s .RequestAssert (& scaffold.RequestAssert {
990+ Method : "GET" ,
991+ Path : "/status/ok" ,
992+ Host : "httpbin.example" ,
993+ Check : scaffold .WithExpectedStatus (http .StatusNotFound ),
994+ Timeout : time .Second * 30 ,
995+ Interval : time .Second * 2 ,
996+ })
997+ })
998+
945999 It ("HTTPRoute Method Match" , func () {
9461000 By ("create HTTPRoute" )
9471001 s .ResourceApplied ("HTTPRoute" , "httpbin" , fmt .Sprintf (methodRouteGETAndDELETEByAnything , s .Namespace ()), 1 )
0 commit comments