8181 headers:
8282 X-Proxy-Test: "disabled"
8383`
84- var gatewayProxyWithPluginMetadata = `
84+ var (
85+ gatewayProxyWithPluginMetadata0 = `
8586apiVersion: gateway.apisix.io/v1alpha1
8687kind: GatewayProxy
8788metadata:
@@ -100,6 +101,26 @@ spec:
100101 }
101102 }
102103`
104+ gatewayProxyWithPluginMetadata1 = `
105+ apiVersion: gateway.apisix.io/v1alpha1
106+ kind: GatewayProxy
107+ metadata:
108+ name: api7-proxy-config
109+ spec:
110+ plugins:
111+ - name: error-page
112+ enabled: true
113+ config: {}
114+ pluginMetadata:
115+ error-page: {
116+ "enable": false,
117+ "error_404": {
118+ "body": "404 from plugin metadata",
119+ "content-type": "text/plain"
120+ }
121+ }
122+ `
123+ )
103124
104125 var httpRouteForTest = `
105126apiVersion: gateway.networking.k8s.io/v1
@@ -249,9 +270,9 @@ spec:
249270 err error
250271 )
251272
252- It ("Should work OK with error-page" , func () {
273+ FIt ("Should work OK with error-page" , func () {
253274 By ("Update GatewayProxy with PluginMetadata" )
254- err = s .CreateResourceFromString (gatewayProxyWithPluginMetadata )
275+ err = s .CreateResourceFromString (gatewayProxyWithPluginMetadata0 )
255276 Expect (err ).ShouldNot (HaveOccurred ())
256277 time .Sleep (5 * time .Second )
257278
@@ -265,6 +286,32 @@ spec:
265286 Expect ().
266287 Status (http .StatusNotFound ).
267288 Body ().Contains ("404 from plugin metadata" )
289+
290+ By ("Update GatewayProxy with PluginMetadata" )
291+ err = s .CreateResourceFromString (gatewayProxyWithPluginMetadata1 )
292+ Expect (err ).ShouldNot (HaveOccurred ())
293+ time .Sleep (5 * time .Second )
294+
295+ By ("Check PluginMetadata working" )
296+ s .NewAPISIXClient ().
297+ GET ("/not-found" ).
298+ WithHost ("example.com" ).
299+ Expect ().
300+ Status (http .StatusNotFound ).
301+ Body ().Contains (`{"error_msg":"404 Route Not Found"}` )
302+
303+ By ("Delete GatewayProxy" )
304+ err = s .DeleteResourceFromString (gatewayProxyWithPluginMetadata0 )
305+ Expect (err ).ShouldNot (HaveOccurred ())
306+ time .Sleep (5 * time .Second )
307+
308+ By ("Check PluginMetadata is not working" )
309+ s .NewAPISIXClient ().
310+ GET ("/not-found" ).
311+ WithHost ("example.com" ).
312+ Expect ().
313+ Status (http .StatusNotFound ).
314+ Body ().Contains (`{"error_msg":"404 Route Not Found"}` )
268315 })
269316 })
270317})
0 commit comments