diff --git a/internal/provider/adc/adc.go b/internal/provider/adc/adc.go index 04e28ad27..ddf5779e1 100644 --- a/internal/provider/adc/adc.go +++ b/internal/provider/adc/adc.go @@ -9,10 +9,10 @@ import ( "os/exec" "go.uber.org/zap" - "gopkg.in/yaml.v3" networkingv1 "k8s.io/api/networking/v1" "sigs.k8s.io/controller-runtime/pkg/client" gatewayv1 "sigs.k8s.io/gateway-api/apis/v1" + "sigs.k8s.io/yaml" types "github.com/api7/api7-ingress-controller/api/adc" "github.com/api7/api7-ingress-controller/api/v1alpha1" diff --git a/test/e2e/gatewayapi/httproute.go b/test/e2e/gatewayapi/httproute.go index db0204463..509c1e042 100644 --- a/test/e2e/gatewayapi/httproute.go +++ b/test/e2e/gatewayapi/httproute.go @@ -195,11 +195,11 @@ spec: BeforeEach(beforeEachHTTP) - It("Create/Updtea/Delete HTTPRoute", func() { + It("Create/Update/Delete HTTPRoute", func() { By("create HTTPRoute") ResourceApplied("HTTPRoute", "httpbin", exactRouteByGet, 1) - By("access daataplane to check the HTTPRoute") + By("access dataplane to check the HTTPRoute") s.NewAPISIXClient(). GET("/get"). Expect(). @@ -266,6 +266,29 @@ spec: - name: httpbin-service-e2e-test port: 80 ` + var varsRoute = ` +apiVersion: gateway.networking.k8s.io/v1 +kind: HTTPRoute +metadata: + name: httpbin +spec: + parentRefs: + - name: api7ee + hostnames: + - httpbin.example + rules: + - matches: + - path: + type: Exact + value: /get + headers: + - type: Exact + name: X-Route-Name + value: httpbin + backendRefs: + - name: httpbin-service-e2e-test + port: 80 +` var prefixRouteByStatus = ` apiVersion: gateway.networking.k8s.io/v1 @@ -372,6 +395,25 @@ spec: Expect(). Status(404) }) + + It("HTTPRoute Vars Match", func() { + By("create HTTPRoute") + ResourceApplied("HTTPRoute", "httpbin", varsRoute, 1) + + By("access dataplane to check the HTTPRoute") + s.NewAPISIXClient(). + GET("/get"). + WithHost("httpbin.example"). + Expect(). + Status(http.StatusNotFound) + + s.NewAPISIXClient(). + GET("/get"). + WithHost("httpbin.example"). + WithHeader("X-Route-Name", "httpbin"). + Expect(). + Status(http.StatusOK) + }) }) Context("HTTPRoute Filters", func() {