Skip to content

Commit bd1f6c1

Browse files
authored
feat: basic support Apache APISIX 2.13.0 (#2428)
1 parent 30fa852 commit bd1f6c1

File tree

21 files changed

+883
-149
lines changed

21 files changed

+883
-149
lines changed

api/conf/schema.json

Lines changed: 660 additions & 92 deletions
Large diffs are not rendered by default.

api/internal/core/store/validate_test.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,9 @@ func TestAPISIXJsonSchemaValidator_Validate(t *testing.T) {
8282
"count": 2,
8383
"time_window": 60,
8484
"rejected_code": 503,
85-
"key": "remote_addr"
86-
}
85+
"key": "remote_addr",
86+
"policy": "local"
87+
}
8788
},
8889
"desc": "test description"
8990
}`
@@ -105,7 +106,8 @@ func TestAPISIXJsonSchemaValidator_Validate(t *testing.T) {
105106
"limit-count": {
106107
"time_window": 60,
107108
"rejected_code": 503,
108-
"key": "remote_addr"
109+
"key": "remote_addr",
110+
"policy": "local"
109111
}
110112
},
111113
"desc": "test description"

api/test/e2enew/consumer/consumer_test.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ var _ = Describe("Consumer", func() {
4141
"count": 2,
4242
"time_window": 60,
4343
"rejected_code": 503,
44-
"key": "remote_addr"
44+
"key": "remote_addr",
45+
"policy": "local"
4546
}
4647
},
4748
"desc": "test description"
@@ -69,7 +70,8 @@ var _ = Describe("Consumer", func() {
6970
"count": 2,
7071
"time_window": 60,
7172
"rejected_code": 504,
72-
"key": "remote_addr"
73+
"key": "remote_addr",
74+
"policy": "local"
7375
}
7476
},
7577
"desc": "test description"
@@ -111,7 +113,8 @@ var _ = Describe("Consumer", func() {
111113
"count": 2,
112114
"time_window": 60,
113115
"rejected_code": 503,
114-
"key": "remote_addr"
116+
"key": "remote_addr",
117+
"policy": "local"
115118
}
116119
},
117120
"desc": "test description"

api/test/e2enew/label/label_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,8 @@ var _ = ginkgo.Describe("Test label", func() {
109109
"count": 2,
110110
"time_window": 60,
111111
"rejected_code": 503,
112-
"key": "remote_addr"
112+
"key": "remote_addr",
113+
"policy": "local"
113114
}
114115
},
115116
"upstream": {

api/test/e2enew/route/route_export_test.go

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ var _ = ginkgo.Describe("Route", func() {
6666
"limit-count": {
6767
"count": 2,
6868
"key": "remote_addr",
69+
"policy": "local",
6970
"rejected_code": 503,
7071
"time_window": 60
7172
}
@@ -100,6 +101,7 @@ var _ = ginkgo.Describe("Route", func() {
100101
"limit-count": {
101102
"count": 2,
102103
"key": "remote_addr",
104+
"policy": "local",
103105
"rejected_code": 503,
104106
"time_window": 60
105107
}
@@ -142,7 +144,8 @@ var _ = ginkgo.Describe("Route", func() {
142144
"count": 2,
143145
"time_window": 60,
144146
"rejected_code": 503,
145-
"key": "remote_addr"
147+
"key": "remote_addr",
148+
"policy": "local"
146149
}
147150
},
148151
"status": 1,
@@ -195,6 +198,7 @@ var _ = ginkgo.Describe("Route", func() {
195198
"limit-count": {
196199
"count": 2,
197200
"key": "remote_addr",
201+
"policy": "local",
198202
"rejected_code": 503,
199203
"time_window": 60
200204
}
@@ -229,6 +233,7 @@ var _ = ginkgo.Describe("Route", func() {
229233
"limit-count": {
230234
"count": 2,
231235
"key": "remote_addr",
236+
"policy": "local",
232237
"rejected_code": 503,
233238
"time_window": 60
234239
}
@@ -272,7 +277,8 @@ var _ = ginkgo.Describe("Route", func() {
272277
"count": 2,
273278
"time_window": 60,
274279
"rejected_code": 503,
275-
"key": "remote_addr"
280+
"key": "remote_addr",
281+
"policy": "local"
276282
}
277283
},
278284
"status": 1,
@@ -376,6 +382,7 @@ var _ = ginkgo.Describe("Route", func() {
376382
"limit-count": {
377383
"count": 100,
378384
"key": "remote_addr",
385+
"policy": "local",
379386
"rejected_code": 503,
380387
"time_window": 60
381388
}
@@ -417,6 +424,7 @@ var _ = ginkgo.Describe("Route", func() {
417424
"limit-count": {
418425
"count": 100,
419426
"key": "remote_addr",
427+
"policy": "local",
420428
"rejected_code": 503,
421429
"time_window": 60
422430
}
@@ -455,6 +463,7 @@ var _ = ginkgo.Describe("Route", func() {
455463
"limit-count": {
456464
"count": 100,
457465
"time_window": 60,
466+
"policy": "local",
458467
"rejected_code": 503,
459468
"key": "remote_addr"
460469
}
@@ -557,6 +566,7 @@ var _ = ginkgo.Describe("Route", func() {
557566
"limit-count": {
558567
"count": 100,
559568
"key": "remote_addr",
569+
"policy": "local",
560570
"rejected_code": 503,
561571
"time_window": 60
562572
}
@@ -598,6 +608,7 @@ var _ = ginkgo.Describe("Route", func() {
598608
"limit-count": {
599609
"count": 100,
600610
"key": "remote_addr",
611+
"policy": "local",
601612
"rejected_code": 503,
602613
"time_window": 60
603614
},
@@ -640,7 +651,8 @@ var _ = ginkgo.Describe("Route", func() {
640651
"count": 100,
641652
"time_window": 60,
642653
"rejected_code": 503,
643-
"key": "remote_addr"
654+
"key": "remote_addr",
655+
"policy": "local"
644656
}
645657
},
646658
"upstream": {
@@ -746,6 +758,7 @@ var _ = ginkgo.Describe("Route", func() {
746758
"limit-count": {
747759
"count": 100,
748760
"key": "remote_addr",
761+
"policy": "local",
749762
"rejected_code": 503,
750763
"time_window": 60
751764
}
@@ -787,6 +800,7 @@ var _ = ginkgo.Describe("Route", func() {
787800
"limit-count": {
788801
"count": 100,
789802
"key": "remote_addr",
803+
"policy": "local",
790804
"rejected_code": 503,
791805
"time_window": 60
792806
},
@@ -847,7 +861,8 @@ var _ = ginkgo.Describe("Route", func() {
847861
"count": 100,
848862
"time_window": 60,
849863
"rejected_code": 503,
850-
"key": "remote_addr"
864+
"key": "remote_addr",
865+
"policy": "local"
851866
}
852867
},
853868
"upstream_id": "1"

api/test/e2enew/route/route_with_plugin_limit_count_test.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ var _ = ginkgo.Describe("route with limit plugin", func() {
5050
"count": 2,
5151
"time_window": 2,
5252
"rejected_code": 503,
53-
"key": "remote_addr"
53+
"key": "remote_addr",
54+
"policy": "local"
5455
}
5556
},
5657
"upstream": {
@@ -137,7 +138,8 @@ var _ = ginkgo.Describe("route with limit plugin by consumer", func() {
137138
"count": 2,
138139
"time_window": 2,
139140
"rejected_code": 503,
140-
"key": "consumer_name"
141+
"key": "consumer_name",
142+
"policy": "local"
141143
}
142144
},
143145
"upstream": {
@@ -305,7 +307,8 @@ var _ = ginkgo.Describe("route with limit count and disable", func() {
305307
"time_window": 2,
306308
"rejected_code": 503,
307309
"key": "remote_addr",
308-
"disable": false
310+
"disable": false,
311+
"policy": "local"
309312
}
310313
},
311314
"upstream": {
@@ -362,7 +365,8 @@ var _ = ginkgo.Describe("route with limit count and disable", func() {
362365
"time_window": 2,
363366
"rejected_code": 503,
364367
"key": "remote_addr",
365-
"disable": true
368+
"disable": true,
369+
"policy": "local"
366370
}
367371
},
368372
"upstream": {

api/test/e2enew/schema/schema_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ var _ = ginkgo.Describe("Schema Test", func() {
4545
Path: "/apisix/admin/schema/plugins/jwt-auth",
4646
Headers: map[string]string{"Authorization": base.GetToken()},
4747
ExpectStatus: http.StatusOK,
48-
ExpectBody: "{\"$comment\":\"this is a mark for our injected plugin schema\",\"properties\":{\"disable\":{\"type\":\"boolean\"}},\"type\":\"object\"}",
48+
ExpectBody: `{"$comment":"this is a mark for our injected plugin schema","properties":{"cookie":{"default":"jwt","type":"string"},"disable":{"type":"boolean"},"header":{"default":"authorization","type":"string"},"query":{"default":"jwt","type":"string"}}`,
4949
Sleep: base.SleepTime,
5050
}),
5151
table.Entry("get schema of non-existent plugin", base.HttpTestCase{
@@ -63,7 +63,7 @@ var _ = ginkgo.Describe("Schema Test", func() {
6363
Path: "/apisix/admin/schemas/consumer",
6464
Headers: map[string]string{"Authorization": base.GetToken()},
6565
ExpectStatus: http.StatusOK,
66-
ExpectBody: `"properties":{"create_time":{"type":"integer"},"desc":{"maxLength":256,"type":"string"},"labels":{"description":"key/value pairs to specify attributes","maxProperties":16,"patternProperties":{".*":{"description":"value of label","maxLength":64,"minLength":1,"pattern":"^\\S+$","type":"string"}},"type":"object"},"plugins":{"type":"object"},"update_time":{"type":"integer"},"username":{"maxLength":100,"minLength":1,"pattern":"^[a-zA-Z0-9_]+$","type":"string"}}`,
66+
ExpectBody: `"properties":{"create_time":{"type":"integer"},"desc":{"maxLength":256,"type":"string"},"labels":{"description":"key/value pairs to specify attributes","patternProperties":{".*":{"description":"value of label","maxLength":64,"minLength":1,"pattern":"^\\S+$","type":"string"}},"type":"object"},"plugins":{"type":"object"},"update_time":{"type":"integer"},"username":{"maxLength":100,"minLength":1,"pattern":"^[a-zA-Z0-9_]+$","type":"string"}}`,
6767
Sleep: base.SleepTime,
6868
}),
6969
table.Entry("get schema of non-existent resources", base.HttpTestCase{

api/test/e2enew/service/service_test.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ var _ = ginkgo.Describe("create service with plugin", func() {
193193
"time_window": 60,
194194
"rejected_code": 503,
195195
"key": "remote_addr",
196+
"policy": "local",
196197
},
197198
},
198199
"upstream": map[string]interface{}{
@@ -225,7 +226,7 @@ var _ = ginkgo.Describe("create service with plugin", func() {
225226
Path: "/apisix/admin/services/s1",
226227
Headers: map[string]string{"Authorization": base.GetToken()},
227228
ExpectCode: http.StatusOK,
228-
ExpectBody: "\"upstream\":{\"nodes\":[{\"host\":\"" + base.UpstreamIp + "\",\"port\":1980,\"weight\":1}],\"type\":\"roundrobin\"},\"plugins\":{\"limit-count\":{\"count\":100,\"key\":\"remote_addr\",\"rejected_code\":503,\"time_window\":60}}",
229+
ExpectBody: "\"upstream\":{\"nodes\":[{\"host\":\"" + base.UpstreamIp + "\",\"port\":1980,\"weight\":1}],\"type\":\"roundrobin\"},\"plugins\":{\"limit-count\":{\"count\":100,\"key\":\"remote_addr\",\"policy\":\"local\",\"rejected_code\":503,\"time_window\":60}}",
229230
Sleep: base.SleepTime,
230231
})
231232
})
@@ -306,6 +307,7 @@ var _ = ginkgo.Describe("create service with all options via POST method", func(
306307
"time_window": 60,
307308
"rejected_code": 503,
308309
"key": "remote_addr",
310+
"policy": "local",
309311
},
310312
},
311313
"upstream": map[string]interface{}{
@@ -341,7 +343,7 @@ var _ = ginkgo.Describe("create service with all options via POST method", func(
341343
Path: "/apisix/admin/services/s2",
342344
Headers: map[string]string{"Authorization": base.GetToken()},
343345
ExpectCode: http.StatusOK,
344-
ExpectBody: "\"name\":\"testservice22\",\"desc\":\"testservice_desc\",\"upstream\":{\"nodes\":[{\"host\":\"" + base.UpstreamIp + "\",\"port\":1980,\"weight\":1}],\"type\":\"roundrobin\"},\"plugins\":{\"limit-count\":{\"count\":100,\"key\":\"remote_addr\",\"rejected_code\":503,\"time_window\":60}},\"labels\":{\"build\":\"16\",\"env\":\"production\",\"version\":\"v2\"},\"enable_websocket\":true}",
346+
ExpectBody: "\"name\":\"testservice22\",\"desc\":\"testservice_desc\",\"upstream\":{\"nodes\":[{\"host\":\"" + base.UpstreamIp + "\",\"port\":1980,\"weight\":1}],\"type\":\"roundrobin\"},\"plugins\":{\"limit-count\":{\"count\":100,\"key\":\"remote_addr\",\"policy\":\"local\",\"rejected_code\":503,\"time_window\":60}},\"labels\":{\"build\":\"16\",\"env\":\"production\",\"version\":\"v2\"},\"enable_websocket\":true}",
345347
Sleep: base.SleepTime,
346348
})
347349
})

api/test/testdata/invalid-dag-conf.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@
2929
"count":2,
3030
"time_window":60,
3131
"rejected_code":503,
32-
"key":"remote_addr"
32+
"key":"remote_addr",
33+
"policy": "local"
3334
}
3435
},
3536
"yy-uu-ii-oo":{

docs/en/latest/IMPORT_OPENAPI_USER_GUIDE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ paths:
219219
time_window: 60
220220
rejected_code: 503
221221
key: remote_addr
222+
policy: local
222223
responses:
223224
'200':
224225
description: list response

0 commit comments

Comments
 (0)