Skip to content

Commit b617d07

Browse files
authored
fix: HTTPRoute vars match (#84)
1 parent 414af9d commit b617d07

File tree

2 files changed

+45
-3
lines changed

2 files changed

+45
-3
lines changed

internal/provider/adc/adc.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ import (
99
"os/exec"
1010

1111
"go.uber.org/zap"
12-
"gopkg.in/yaml.v3"
1312
networkingv1 "k8s.io/api/networking/v1"
1413
"sigs.k8s.io/controller-runtime/pkg/client"
1514
gatewayv1 "sigs.k8s.io/gateway-api/apis/v1"
15+
"sigs.k8s.io/yaml"
1616

1717
types "github.com/api7/api7-ingress-controller/api/adc"
1818
"github.com/api7/api7-ingress-controller/api/v1alpha1"

test/e2e/gatewayapi/httproute.go

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,11 +195,11 @@ spec:
195195

196196
BeforeEach(beforeEachHTTP)
197197

198-
It("Create/Updtea/Delete HTTPRoute", func() {
198+
It("Create/Update/Delete HTTPRoute", func() {
199199
By("create HTTPRoute")
200200
ResourceApplied("HTTPRoute", "httpbin", exactRouteByGet, 1)
201201

202-
By("access daataplane to check the HTTPRoute")
202+
By("access dataplane to check the HTTPRoute")
203203
s.NewAPISIXClient().
204204
GET("/get").
205205
Expect().
@@ -266,6 +266,29 @@ spec:
266266
- name: httpbin-service-e2e-test
267267
port: 80
268268
`
269+
var varsRoute = `
270+
apiVersion: gateway.networking.k8s.io/v1
271+
kind: HTTPRoute
272+
metadata:
273+
name: httpbin
274+
spec:
275+
parentRefs:
276+
- name: api7ee
277+
hostnames:
278+
- httpbin.example
279+
rules:
280+
- matches:
281+
- path:
282+
type: Exact
283+
value: /get
284+
headers:
285+
- type: Exact
286+
name: X-Route-Name
287+
value: httpbin
288+
backendRefs:
289+
- name: httpbin-service-e2e-test
290+
port: 80
291+
`
269292

270293
var prefixRouteByStatus = `
271294
apiVersion: gateway.networking.k8s.io/v1
@@ -372,6 +395,25 @@ spec:
372395
Expect().
373396
Status(404)
374397
})
398+
399+
It("HTTPRoute Vars Match", func() {
400+
By("create HTTPRoute")
401+
ResourceApplied("HTTPRoute", "httpbin", varsRoute, 1)
402+
403+
By("access dataplane to check the HTTPRoute")
404+
s.NewAPISIXClient().
405+
GET("/get").
406+
WithHost("httpbin.example").
407+
Expect().
408+
Status(http.StatusNotFound)
409+
410+
s.NewAPISIXClient().
411+
GET("/get").
412+
WithHost("httpbin.example").
413+
WithHeader("X-Route-Name", "httpbin").
414+
Expect().
415+
Status(http.StatusOK)
416+
})
375417
})
376418

377419
Context("HTTPRoute Filters", func() {

0 commit comments

Comments
 (0)