@@ -109,6 +109,83 @@ spec:
109109 s .ResourceApplied ("httproute" , "httpbin" , defaultHTTPRoute , 1 )
110110 }
111111
112+ Context ("Consumer plugins" , func () {
113+ var limitCountConsumer = `
114+ apiVersion: gateway.apisix.io/v1alpha1
115+ kind: Consumer
116+ metadata:
117+ name: consumer-sample
118+ spec:
119+ gatewayRef:
120+ name: api7ee
121+ credentials:
122+ - type: key-auth
123+ name: key-auth-sample
124+ config:
125+ key: sample-key
126+ plugins:
127+ - name: limit-count
128+ config:
129+ count: 2
130+ time_window: 60
131+ rejected_code: 503
132+ key: remote_addr
133+ `
134+
135+ var unlimitConsumer = `
136+ apiVersion: gateway.apisix.io/v1alpha1
137+ kind: Consumer
138+ metadata:
139+ name: consumer-sample2
140+ spec:
141+ gatewayRef:
142+ name: api7ee
143+ credentials:
144+ - type: key-auth
145+ name: key-auth-sample
146+ config:
147+ key: sample-key2
148+ `
149+
150+ BeforeEach (beforeEachHTTP )
151+
152+ It ("limit-count plugin" , func () {
153+ s .ResourceApplied ("Consumer" , "consumer-sample" , limitCountConsumer , 1 )
154+ s .ResourceApplied ("Consumer" , "consumer-sample2" , unlimitConsumer , 1 )
155+
156+ s .NewAPISIXClient ().
157+ GET ("/get" ).
158+ WithHeader ("apikey" , "sample-key" ).
159+ WithHost ("httpbin.org" ).
160+ Expect ().
161+ Status (200 )
162+
163+ s .NewAPISIXClient ().
164+ GET ("/get" ).
165+ WithHeader ("apikey" , "sample-key" ).
166+ WithHost ("httpbin.org" ).
167+ Expect ().
168+ Status (200 )
169+
170+ By ("trigger limit-count" )
171+ s .NewAPISIXClient ().
172+ GET ("/get" ).
173+ WithHeader ("apikey" , "sample-key" ).
174+ WithHost ("httpbin.org" ).
175+ Expect ().
176+ Status (503 )
177+
178+ for i := 0 ; i < 10 ; i ++ {
179+ s .NewAPISIXClient ().
180+ GET ("/get" ).
181+ WithHeader ("apikey" , "sample-key2" ).
182+ WithHost ("httpbin.org" ).
183+ Expect ().
184+ Status (200 )
185+ }
186+ })
187+ })
188+
112189 Context ("Credential" , func () {
113190 var defaultCredential = `apiVersion: gateway.apisix.io/v1alpha1
114191kind: Consumer
0 commit comments