Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: basic support Apache APISIX 2.13.0 #2428

Merged
merged 18 commits into from
May 6, 2022
Merged
752 changes: 660 additions & 92 deletions api/conf/schema.json

Large diffs are not rendered by default.

8 changes: 5 additions & 3 deletions api/internal/core/store/validate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,9 @@ func TestAPISIXJsonSchemaValidator_Validate(t *testing.T) {
"count": 2,
"time_window": 60,
"rejected_code": 503,
"key": "remote_addr"
}
"key": "remote_addr",
"policy": "local"
}
},
"desc": "test description"
}`
Expand All @@ -105,7 +106,8 @@ func TestAPISIXJsonSchemaValidator_Validate(t *testing.T) {
"limit-count": {
"time_window": 60,
"rejected_code": 503,
"key": "remote_addr"
"key": "remote_addr",
"policy": "local"
}
},
"desc": "test description"
Expand Down
9 changes: 6 additions & 3 deletions api/test/e2enew/consumer/consumer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ var _ = Describe("Consumer", func() {
"count": 2,
"time_window": 60,
"rejected_code": 503,
"key": "remote_addr"
"key": "remote_addr",
"policy": "local"
}
},
"desc": "test description"
Expand Down Expand Up @@ -69,7 +70,8 @@ var _ = Describe("Consumer", func() {
"count": 2,
"time_window": 60,
"rejected_code": 504,
"key": "remote_addr"
"key": "remote_addr",
"policy": "local"
}
},
"desc": "test description"
Expand Down Expand Up @@ -111,7 +113,8 @@ var _ = Describe("Consumer", func() {
"count": 2,
"time_window": 60,
"rejected_code": 503,
"key": "remote_addr"
"key": "remote_addr",
"policy": "local"
}
},
"desc": "test description"
Expand Down
3 changes: 2 additions & 1 deletion api/test/e2enew/label/label_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ var _ = ginkgo.Describe("Test label", func() {
"count": 2,
"time_window": 60,
"rejected_code": 503,
"key": "remote_addr"
"key": "remote_addr",
"policy": "local"
}
},
"upstream": {
Expand Down
23 changes: 19 additions & 4 deletions api/test/e2enew/route/route_export_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ var _ = ginkgo.Describe("Route", func() {
"limit-count": {
"count": 2,
"key": "remote_addr",
"policy": "local",
"rejected_code": 503,
"time_window": 60
}
Expand Down Expand Up @@ -100,6 +101,7 @@ var _ = ginkgo.Describe("Route", func() {
"limit-count": {
"count": 2,
"key": "remote_addr",
"policy": "local",
"rejected_code": 503,
"time_window": 60
}
Expand Down Expand Up @@ -142,7 +144,8 @@ var _ = ginkgo.Describe("Route", func() {
"count": 2,
"time_window": 60,
"rejected_code": 503,
"key": "remote_addr"
"key": "remote_addr",
"policy": "local"
}
},
"status": 1,
Expand Down Expand Up @@ -195,6 +198,7 @@ var _ = ginkgo.Describe("Route", func() {
"limit-count": {
"count": 2,
"key": "remote_addr",
"policy": "local",
"rejected_code": 503,
"time_window": 60
}
Expand Down Expand Up @@ -229,6 +233,7 @@ var _ = ginkgo.Describe("Route", func() {
"limit-count": {
"count": 2,
"key": "remote_addr",
"policy": "local",
"rejected_code": 503,
"time_window": 60
}
Expand Down Expand Up @@ -272,7 +277,8 @@ var _ = ginkgo.Describe("Route", func() {
"count": 2,
"time_window": 60,
"rejected_code": 503,
"key": "remote_addr"
"key": "remote_addr",
"policy": "local"
}
},
"status": 1,
Expand Down Expand Up @@ -376,6 +382,7 @@ var _ = ginkgo.Describe("Route", func() {
"limit-count": {
"count": 100,
"key": "remote_addr",
"policy": "local",
"rejected_code": 503,
"time_window": 60
}
Expand Down Expand Up @@ -417,6 +424,7 @@ var _ = ginkgo.Describe("Route", func() {
"limit-count": {
"count": 100,
"key": "remote_addr",
"policy": "local",
"rejected_code": 503,
"time_window": 60
}
Expand Down Expand Up @@ -455,6 +463,7 @@ var _ = ginkgo.Describe("Route", func() {
"limit-count": {
"count": 100,
"time_window": 60,
"policy": "local",
"rejected_code": 503,
"key": "remote_addr"
}
Expand Down Expand Up @@ -557,6 +566,7 @@ var _ = ginkgo.Describe("Route", func() {
"limit-count": {
"count": 100,
"key": "remote_addr",
"policy": "local",
"rejected_code": 503,
"time_window": 60
}
Expand Down Expand Up @@ -598,6 +608,7 @@ var _ = ginkgo.Describe("Route", func() {
"limit-count": {
"count": 100,
"key": "remote_addr",
"policy": "local",
"rejected_code": 503,
"time_window": 60
},
Expand Down Expand Up @@ -640,7 +651,8 @@ var _ = ginkgo.Describe("Route", func() {
"count": 100,
"time_window": 60,
"rejected_code": 503,
"key": "remote_addr"
"key": "remote_addr",
"policy": "local"
}
},
"upstream": {
Expand Down Expand Up @@ -746,6 +758,7 @@ var _ = ginkgo.Describe("Route", func() {
"limit-count": {
"count": 100,
"key": "remote_addr",
"policy": "local",
"rejected_code": 503,
"time_window": 60
}
Expand Down Expand Up @@ -787,6 +800,7 @@ var _ = ginkgo.Describe("Route", func() {
"limit-count": {
"count": 100,
"key": "remote_addr",
"policy": "local",
"rejected_code": 503,
"time_window": 60
},
Expand Down Expand Up @@ -847,7 +861,8 @@ var _ = ginkgo.Describe("Route", func() {
"count": 100,
"time_window": 60,
"rejected_code": 503,
"key": "remote_addr"
"key": "remote_addr",
"policy": "local"
}
},
"upstream_id": "1"
Expand Down
12 changes: 8 additions & 4 deletions api/test/e2enew/route/route_with_plugin_limit_count_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ var _ = ginkgo.Describe("route with limit plugin", func() {
"count": 2,
"time_window": 2,
"rejected_code": 503,
"key": "remote_addr"
"key": "remote_addr",
"policy": "local"
}
},
"upstream": {
Expand Down Expand Up @@ -137,7 +138,8 @@ var _ = ginkgo.Describe("route with limit plugin by consumer", func() {
"count": 2,
"time_window": 2,
"rejected_code": 503,
"key": "consumer_name"
"key": "consumer_name",
"policy": "local"
}
},
"upstream": {
Expand Down Expand Up @@ -305,7 +307,8 @@ var _ = ginkgo.Describe("route with limit count and disable", func() {
"time_window": 2,
"rejected_code": 503,
"key": "remote_addr",
"disable": false
"disable": false,
"policy": "local"
}
},
"upstream": {
Expand Down Expand Up @@ -362,7 +365,8 @@ var _ = ginkgo.Describe("route with limit count and disable", func() {
"time_window": 2,
"rejected_code": 503,
"key": "remote_addr",
"disable": true
"disable": true,
"policy": "local"
}
},
"upstream": {
Expand Down
4 changes: 2 additions & 2 deletions api/test/e2enew/schema/schema_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ var _ = ginkgo.Describe("Schema Test", func() {
Path: "/apisix/admin/schema/plugins/jwt-auth",
Headers: map[string]string{"Authorization": base.GetToken()},
ExpectStatus: http.StatusOK,
ExpectBody: "{\"$comment\":\"this is a mark for our injected plugin schema\",\"properties\":{\"disable\":{\"type\":\"boolean\"}},\"type\":\"object\"}",
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"}}`,
Sleep: base.SleepTime,
}),
table.Entry("get schema of non-existent plugin", base.HttpTestCase{
Expand All @@ -63,7 +63,7 @@ var _ = ginkgo.Describe("Schema Test", func() {
Path: "/apisix/admin/schemas/consumer",
Headers: map[string]string{"Authorization": base.GetToken()},
ExpectStatus: http.StatusOK,
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"}}`,
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"}}`,
Sleep: base.SleepTime,
}),
table.Entry("get schema of non-existent resources", base.HttpTestCase{
Expand Down
6 changes: 4 additions & 2 deletions api/test/e2enew/service/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ var _ = ginkgo.Describe("create service with plugin", func() {
"time_window": 60,
"rejected_code": 503,
"key": "remote_addr",
"policy": "local",
},
},
"upstream": map[string]interface{}{
Expand Down Expand Up @@ -225,7 +226,7 @@ var _ = ginkgo.Describe("create service with plugin", func() {
Path: "/apisix/admin/services/s1",
Headers: map[string]string{"Authorization": base.GetToken()},
ExpectCode: http.StatusOK,
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}}",
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}}",
Sleep: base.SleepTime,
})
})
Expand Down Expand Up @@ -306,6 +307,7 @@ var _ = ginkgo.Describe("create service with all options via POST method", func(
"time_window": 60,
"rejected_code": 503,
"key": "remote_addr",
"policy": "local",
},
},
"upstream": map[string]interface{}{
Expand Down Expand Up @@ -341,7 +343,7 @@ var _ = ginkgo.Describe("create service with all options via POST method", func(
Path: "/apisix/admin/services/s2",
Headers: map[string]string{"Authorization": base.GetToken()},
ExpectCode: http.StatusOK,
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}",
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}",
Sleep: base.SleepTime,
})
})
Expand Down
3 changes: 2 additions & 1 deletion api/test/testdata/invalid-dag-conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
"count":2,
"time_window":60,
"rejected_code":503,
"key":"remote_addr"
"key":"remote_addr",
"policy": "local"
}
},
"yy-uu-ii-oo":{
Expand Down
1 change: 1 addition & 0 deletions docs/en/latest/IMPORT_OPENAPI_USER_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ paths:
time_window: 60
rejected_code: 503
key: remote_addr
policy: local
responses:
'200':
description: list response
Expand Down
23 changes: 17 additions & 6 deletions web/cypress/fixtures/plugin-dataset.json
Original file line number Diff line number Diff line change
Expand Up @@ -593,22 +593,30 @@
"limit-count": [
{
"shouldValid": true,
"data": { "count": 2, "time_window": 60, "rejected_code": 503, "key": "remote_addr" }
"data": {
"count": 2,
"time_window": 60,
"rejected_code": 503,
"key": "remote_addr",
"policy": "local"
}
},
{
"shouldValid": true,
"data": {
"count": 2,
"time_window": 60,
"rejected_code": 503,
"key": "host"
"key": "host",
"policy": "local"
}
},
{
"shouldValid": false,
"data": {
"time_window": 60,
"rejected_code": 503
"rejected_code": 503,
"policy": "local"
}
},
{
Expand All @@ -617,7 +625,8 @@
"count": -100,
"time_window": 60,
"rejected_code": 503,
"key": "remote_addr"
"key": "remote_addr",
"policy": "local"
}
},
{
Expand All @@ -626,15 +635,17 @@
"count": 2,
"time_window": 60,
"rejected_code": 503,
"key": "server_addr"
"key": "server_addr",
"policy": "local"
}
},
{
"shouldValid": true,
"data": {
"count": 2,
"time_window": 60,
"key": "remote_addr"
"key": "remote_addr",
"policy": "local"
}
}
],
Expand Down
19 changes: 14 additions & 5 deletions web/src/components/Plugin/PluginDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,16 @@ const PluginDetail: React.FC<Props> = ({

if (name === 'cors') {
const newMethods = formData.allow_methods.join(',');
const compactAllowRegex = compact(formData.allow_origins_by_regex);
// Note: default allow_origins_by_regex setted for UI is [''], but this is not allowed, omit it.
if (compactAllowRegex.length === 0) {
return omit({ ...formData, allow_methods: newMethods }, ['allow_origins_by_regex']);
const isFilterAllowRegex = compact(formData.allow_origins_by_regex).length === 0;
const isFilterAllowMetadata = compact(formData.allow_origins_by_metadata).length === 0;
// Note: default allow_origins_by_regex and allow_origins_by_metadata setted for UI is [''], but this is not allowed, omit it.
if (isFilterAllowRegex || isFilterAllowMetadata) {
const filterAllowRegex = (isFilterAllowRegex && 'allow_origins_by_regex') || '';
const filterAllowMetadata = (isFilterAllowMetadata && 'allow_origins_by_metadata') || '';
return omit({ ...formData, allow_methods: newMethods }, [
filterAllowRegex,
filterAllowMetadata,
]);
}

return { ...formData, allow_methods: newMethods };
Expand Down Expand Up @@ -309,7 +315,10 @@ const PluginDetail: React.FC<Props> = ({
};

const isNoConfigurationRequired =
pluginType === 'auth' && schemaType !== 'consumer' && monacoMode !== monacoModeList.UIForm && targetPluginName !== 'key-auth';
pluginType === 'auth' &&
schemaType !== 'consumer' &&
monacoMode !== monacoModeList.UIForm &&
targetPluginName !== 'key-auth';

return (
<Drawer
Expand Down
Loading