@@ -208,6 +208,27 @@ spec:
208208 value: "%s"
209209`
210210
211+ gatewayProxyWithSecretYaml := `
212+ apiVersion: gateway.apisix.io/v1alpha1
213+ kind: GatewayProxy
214+ metadata:
215+ name: api7-proxy-config-with-secret
216+ namespace: default
217+ spec:
218+ provider:
219+ type: ControlPlane
220+ controlPlane:
221+ endpoints:
222+ - %s
223+ auth:
224+ type: AdminKey
225+ adminKey:
226+ valueFrom:
227+ secretKeyRef:
228+ name: admin-secret
229+ key: admin-key
230+ `
231+
211232 var ingressClassWithProxy = `
212233apiVersion: networking.k8s.io/v1
213234kind: IngressClass
@@ -225,6 +246,21 @@ spec:
225246 scope: "Namespace"
226247`
227248
249+ var ingressClassWithProxySecret = `
250+ apiVersion: networking.k8s.io/v1
251+ kind: IngressClass
252+ metadata:
253+ name: api7-with-proxy-secret
254+ spec:
255+ controller: "gateway.api7.io/api7-ingress-controller"
256+ parameters:
257+ apiGroup: "gateway.apisix.io"
258+ kind: "GatewayProxy"
259+ name: "api7-proxy-config-with-secret"
260+ namespace: "default"
261+ scope: "Namespace"
262+ `
263+
228264 var testIngress = `
229265apiVersion: networking.k8s.io/v1
230266kind: Ingress
@@ -245,6 +281,26 @@ spec:
245281 number: 80
246282`
247283
284+ var testIngressWithSecret = `
285+ apiVersion: networking.k8s.io/v1
286+ kind: Ingress
287+ metadata:
288+ name: api7-ingress-with-proxy-secret
289+ spec:
290+ ingressClassName: api7-with-proxy-secret
291+ rules:
292+ - host: proxy-secret.example.com
293+ http:
294+ paths:
295+ - path: /
296+ pathType: Prefix
297+ backend:
298+ service:
299+ name: httpbin-service-e2e-test
300+ port:
301+ number: 80
302+ `
303+
248304 It ("Test IngressClass with GatewayProxy" , func () {
249305 By ("create GatewayProxy" )
250306 gatewayProxy := fmt .Sprintf (gatewayProxyYaml , framework .DashboardTLSEndpoint , s .AdminKey ())
@@ -271,5 +327,45 @@ spec:
271327 Expect ().
272328 Status (200 )
273329 })
330+
331+ It ("Test IngressClass with GatewayProxy using Secret" , func () {
332+ By ("create admin key secret" )
333+ adminSecret := fmt .Sprintf (`
334+ apiVersion: v1
335+ kind: Secret
336+ metadata:
337+ name: admin-secret
338+ namespace: default
339+ type: Opaque
340+ stringData:
341+ admin-key: %s
342+ ` , s .AdminKey ())
343+ err := s .CreateResourceFromStringWithNamespace (adminSecret , "default" )
344+ Expect (err ).NotTo (HaveOccurred (), "creating admin secret" )
345+ time .Sleep (5 * time .Second )
346+
347+ By ("create GatewayProxy with Secret reference" )
348+ gatewayProxy := fmt .Sprintf (gatewayProxyWithSecretYaml , framework .DashboardTLSEndpoint )
349+ err = s .CreateResourceFromStringWithNamespace (gatewayProxy , "default" )
350+ Expect (err ).NotTo (HaveOccurred (), "creating GatewayProxy with Secret" )
351+ time .Sleep (5 * time .Second )
352+
353+ By ("create IngressClass with GatewayProxy reference" )
354+ err = s .CreateResourceFromStringWithNamespace (ingressClassWithProxySecret , "" )
355+ Expect (err ).NotTo (HaveOccurred (), "creating IngressClass with GatewayProxy" )
356+ time .Sleep (5 * time .Second )
357+
358+ By ("create Ingress with GatewayProxy IngressClass" )
359+ err = s .CreateResourceFromString (testIngressWithSecret )
360+ Expect (err ).NotTo (HaveOccurred (), "creating Ingress with GatewayProxy IngressClass" )
361+ time .Sleep (5 * time .Second )
362+
363+ By ("verify HTTP request" )
364+ s .NewAPISIXClient ().
365+ GET ("/get" ).
366+ WithHost ("proxy-secret.example.com" ).
367+ Expect ().
368+ Status (200 )
369+ })
274370 })
275371})
0 commit comments