4242 name: api7-proxy-config
4343`
4444
45- var gatewayWithoutProxy = `
46- apiVersion: gateway.networking.k8s.io/v1
47- kind: Gateway
48- metadata:
49- name: api7
50- spec:
51- gatewayClassName: %s
52- listeners:
53- - name: http
54- protocol: HTTP
55- port: 80
56- `
57-
5845 var gatewayProxyWithEnabledPlugin = `
5946apiVersion: gateway.apisix.io/v1alpha1
6047kind: GatewayProxy
@@ -84,6 +71,15 @@ kind: GatewayProxy
8471metadata:
8572 name: api7-proxy-config
8673spec:
74+ provider:
75+ type: ControlPlane
76+ controlPlane:
77+ endpoints:
78+ - %s
79+ auth:
80+ type: AdminKey
81+ adminKey:
82+ value: "%s"
8783 plugins:
8884 - name: response-rewrite
8985 enabled: false
@@ -98,6 +94,15 @@ kind: GatewayProxy
9894metadata:
9995 name: api7-proxy-config
10096spec:
97+ provider:
98+ type: ControlPlane
99+ controlPlane:
100+ endpoints:
101+ - %s
102+ auth:
103+ type: AdminKey
104+ adminKey:
105+ value: "%s"
101106 plugins:
102107 - name: error-page
103108 enabled: true
@@ -117,6 +122,15 @@ kind: GatewayProxy
117122metadata:
118123 name: api7-proxy-config
119124spec:
125+ provider:
126+ type: ControlPlane
127+ controlPlane:
128+ endpoints:
129+ - %s
130+ auth:
131+ type: AdminKey
132+ adminKey:
133+ value: "%s"
120134 plugins:
121135 - name: error-page
122136 enabled: true
@@ -226,7 +240,7 @@ spec:
226240 resp .Header ("X-Proxy-Test" ).IsEqual ("enabled" )
227241
228242 By ("Update GatewayProxy with disabled plugin" )
229- err := s .CreateResourceFromString (gatewayProxyWithDisabledPlugin )
243+ err := s .CreateResourceFromString (fmt . Sprintf ( gatewayProxyWithDisabledPlugin , framework . DashboardTLSEndpoint , s . AdminKey ()) )
230244 Expect (err ).NotTo (HaveOccurred (), "updating GatewayProxy with disabled plugin" )
231245 time .Sleep (5 * time .Second )
232246
@@ -242,37 +256,6 @@ spec:
242256
243257 resp .Header ("X-Proxy-Test" ).IsEmpty ()
244258 })
245-
246- It ("Should work normally without GatewayProxy" , func () {
247- By ("Create HTTPRoute for Gateway with GatewayProxy" )
248- resourceApplied ("HTTPRoute" , "test-route" , fmt .Sprintf (httpRouteForTest , "api7" ), 1 )
249-
250- By ("Check if the plugin is applied" )
251- resp := s .NewAPISIXClient ().
252- GET ("/get" ).
253- WithHost ("example.com" ).
254- Expect ().
255- Status (200 )
256-
257- resp .Header ("X-Proxy-Test" ).IsEqual ("enabled" )
258-
259- By ("Update Gateway without GatewayProxy" )
260- err := s .CreateResourceFromString (fmt .Sprintf (gatewayWithoutProxy , gatewayClassName ))
261- Expect (err ).NotTo (HaveOccurred (), "updating Gateway without GatewayProxy" )
262- time .Sleep (5 * time .Second )
263-
264- By ("Create HTTPRoute for Gateway without GatewayProxy" )
265- resourceApplied ("HTTPRoute" , "test-route" , fmt .Sprintf (httpRouteForTest , "api7" ), 1 )
266-
267- By ("Check if the route works without plugin" )
268- resp = s .NewAPISIXClient ().
269- GET ("/get" ).
270- WithHost ("example.com" ).
271- Expect ().
272- Status (200 )
273-
274- resp .Header ("X-Proxy-Test" ).IsEmpty ()
275- })
276259 })
277260
278261 Context ("Test Gateway with PluginMetadata" , func () {
@@ -282,7 +265,7 @@ spec:
282265
283266 It ("Should work OK with error-page" , func () {
284267 By ("Update GatewayProxy with PluginMetadata" )
285- err = s .CreateResourceFromString (gatewayProxyWithPluginMetadata0 )
268+ err = s .CreateResourceFromString (fmt . Sprintf ( gatewayProxyWithPluginMetadata0 , framework . DashboardTLSEndpoint , s . AdminKey ()) )
286269 Expect (err ).ShouldNot (HaveOccurred ())
287270 time .Sleep (5 * time .Second )
288271
@@ -298,7 +281,7 @@ spec:
298281 Body ().Contains ("404 from plugin metadata" )
299282
300283 By ("Update GatewayProxy with PluginMetadata" )
301- err = s .CreateResourceFromString (gatewayProxyWithPluginMetadata1 )
284+ err = s .CreateResourceFromString (fmt . Sprintf ( gatewayProxyWithPluginMetadata1 , framework . DashboardTLSEndpoint , s . AdminKey ()) )
302285 Expect (err ).ShouldNot (HaveOccurred ())
303286 time .Sleep (5 * time .Second )
304287
@@ -311,7 +294,7 @@ spec:
311294 Body ().Contains (`{"error_msg":"404 Route Not Found"}` )
312295
313296 By ("Delete GatewayProxy" )
314- err = s .DeleteResourceFromString (gatewayProxyWithPluginMetadata0 )
297+ err = s .DeleteResourceFromString (fmt . Sprintf ( gatewayProxyWithPluginMetadata0 , framework . DashboardTLSEndpoint , s . AdminKey ()) )
315298 Expect (err ).ShouldNot (HaveOccurred ())
316299 time .Sleep (5 * time .Second )
317300
0 commit comments