@@ -188,4 +188,88 @@ spec:
188188 Status (200 )
189189 })
190190 })
191+
192+ Context ("IngressClass with GatewayProxy" , func () {
193+ gatewayProxyYaml := `
194+ apiVersion: gateway.apisix.io/v1alpha1
195+ kind: GatewayProxy
196+ metadata:
197+ name: api7-proxy-config
198+ namespace: default
199+ spec:
200+ provider:
201+ type: ControlPlane
202+ controlPlane:
203+ endpoints:
204+ - %s
205+ auth:
206+ type: AdminKey
207+ adminKey:
208+ value: "%s"
209+ `
210+
211+ var ingressClassWithProxy = `
212+ apiVersion: networking.k8s.io/v1
213+ kind: IngressClass
214+ metadata:
215+ name: api7-with-proxy
216+ annotations:
217+ ingressclass.kubernetes.io/is-default-class: "true"
218+ spec:
219+ controller: "gateway.api7.io/api7-ingress-controller"
220+ parameters:
221+ apiGroup: "gateway.apisix.io"
222+ kind: "GatewayProxy"
223+ name: "api7-proxy-config"
224+ namespace: "default"
225+ scope: "Namespace"
226+ `
227+
228+ var testIngress = `
229+ apiVersion: networking.k8s.io/v1
230+ kind: Ingress
231+ metadata:
232+ name: api7-ingress-with-proxy
233+ spec:
234+ ingressClassName: api7-with-proxy
235+ rules:
236+ - host: proxy.example.com
237+ http:
238+ paths:
239+ - path: /
240+ pathType: Prefix
241+ backend:
242+ service:
243+ name: httpbin-service-e2e-test
244+ port:
245+ number: 80
246+ `
247+
248+ It ("Test IngressClass with GatewayProxy" , func () {
249+ By ("create GatewayProxy" )
250+ gatewayProxy := fmt .Sprintf (gatewayProxyYaml , framework .DashboardTLSEndpoint , s .AdminKey ())
251+
252+ By ("create GatewayProxy" )
253+ err := s .CreateResourceFromStringWithNamespace (gatewayProxy , "default" )
254+ Expect (err ).NotTo (HaveOccurred (), "creating GatewayProxy" )
255+ time .Sleep (5 * time .Second )
256+
257+ By ("create IngressClass with GatewayProxy reference" )
258+ err = s .CreateResourceFromStringWithNamespace (ingressClassWithProxy , "" )
259+ Expect (err ).NotTo (HaveOccurred (), "creating IngressClass with GatewayProxy" )
260+ time .Sleep (5 * time .Second )
261+
262+ By ("create Ingress with GatewayProxy IngressClass" )
263+ err = s .CreateResourceFromString (testIngress )
264+ Expect (err ).NotTo (HaveOccurred (), "creating Ingress with GatewayProxy IngressClass" )
265+ time .Sleep (5 * time .Second )
266+
267+ By ("verify HTTP request" )
268+ s .NewAPISIXClient ().
269+ GET ("/get" ).
270+ WithHost ("proxy.example.com" ).
271+ Expect ().
272+ Status (200 )
273+ })
274+ })
191275})
0 commit comments