From 79d01c10c6b59955e3c6b79ca3d204102a6d04e4 Mon Sep 17 00:00:00 2001 From: spacewander Date: Wed, 11 Aug 2021 10:27:18 +0800 Subject: [PATCH] feat: make A/B test APISIX easier by removing "additionalProperties = false" Signed-off-by: spacewander --- apisix/plugins/authz-casbin.lua | 2 - apisix/plugins/basic-auth.lua | 2 - apisix/plugins/batch-requests.lua | 3 - apisix/plugins/echo.lua | 1 - apisix/plugins/example-plugin.lua | 1 - apisix/plugins/hmac-auth.lua | 2 - apisix/plugins/http-logger.lua | 1 - apisix/plugins/ip-restriction/init.lua | 1 - apisix/plugins/jwt-auth.lua | 2 - apisix/plugins/kafka-logger.lua | 1 - apisix/plugins/key-auth.lua | 2 - apisix/plugins/log-rotate.lua | 1 - apisix/plugins/node-status.lua | 1 - apisix/plugins/prometheus.lua | 1 - apisix/plugins/proxy-rewrite.lua | 1 - apisix/plugins/referer-restriction.lua | 1 - apisix/plugins/response-rewrite.lua | 1 - apisix/plugins/server-info.lua | 1 - apisix/plugins/skywalking.lua | 2 - apisix/plugins/traffic-split.lua | 2 - apisix/plugins/ua-restriction.lua | 1 - apisix/schema_def.lua | 9 -- docs/en/latest/plugin-develop.md | 2 - docs/zh/latest/plugin-develop.md | 2 - t/admin/global-rules.t | 48 +------ t/admin/plugins.t | 12 +- t/admin/services-string-id.t | 49 ++----- t/admin/services.t | 77 ++++------- t/core/schema_def.t | 1 - t/plugin/basic-auth.t | 14 +- t/plugin/echo.t | 36 +---- t/plugin/hmac-auth2.t | 6 +- t/plugin/jwt-auth.t | 99 ++++---------- t/plugin/prometheus.t | 182 ++++++------------------- t/plugin/proxy-rewrite.t | 46 ++----- t/plugin/response-rewrite.t | 47 ++----- t/plugin/traffic-split3.t | 106 +------------- 37 files changed, 155 insertions(+), 611 deletions(-) diff --git a/apisix/plugins/authz-casbin.lua b/apisix/plugins/authz-casbin.lua index 4fce006334aa..d81d34089968 100644 --- a/apisix/plugins/authz-casbin.lua +++ b/apisix/plugins/authz-casbin.lua @@ -36,7 +36,6 @@ local schema = { {required = {"model_path", "policy_path", "username"}}, {required = {"model", "policy", "username"}} }, - additionalProperties = false } local metadata_schema = { @@ -46,7 +45,6 @@ local metadata_schema = { policy = {type = "string"}, }, required = {"model", "policy"}, - additionalProperties = false } local _M = { diff --git a/apisix/plugins/basic-auth.lua b/apisix/plugins/basic-auth.lua index 53e089f47547..1df25daefa86 100644 --- a/apisix/plugins/basic-auth.lua +++ b/apisix/plugins/basic-auth.lua @@ -31,7 +31,6 @@ local schema = { type = "object", title = "work with route or service object", properties = {}, - additionalProperties = false, } local consumer_schema = { @@ -42,7 +41,6 @@ local consumer_schema = { password = { type = "string" }, }, required = {"username", "password"}, - additionalProperties = false, } local plugin_name = "basic-auth" diff --git a/apisix/plugins/batch-requests.lua b/apisix/plugins/batch-requests.lua index 90f1cebcdfa8..47a2cbf93cad 100644 --- a/apisix/plugins/batch-requests.lua +++ b/apisix/plugins/batch-requests.lua @@ -37,12 +37,10 @@ local attr_schema = { default = default_uri } }, - additionalProperties = false, } local schema = { type = "object", - additionalProperties = false, } local default_max_body_size = 1024 * 1024 -- 1MiB @@ -56,7 +54,6 @@ local metadata_schema = { default = default_max_body_size, }, }, - additionalProperties = false, } local method_schema = core.table.clone(core.schema.method_schema) diff --git a/apisix/plugins/echo.lua b/apisix/plugins/echo.lua index 434ed55c34e0..525c1750e0bf 100644 --- a/apisix/plugins/echo.lua +++ b/apisix/plugins/echo.lua @@ -47,7 +47,6 @@ local schema = { {required = {"after_body"}} }, minProperties = 1, - additionalProperties = false, } local plugin_name = "echo" diff --git a/apisix/plugins/example-plugin.lua b/apisix/plugins/example-plugin.lua index 042779fa9916..f1d1cc33c625 100644 --- a/apisix/plugins/example-plugin.lua +++ b/apisix/plugins/example-plugin.lua @@ -38,7 +38,6 @@ local metadata_schema = { skey = {type = "string"}, }, required = {"ikey", "skey"}, - additionalProperties = false, } local plugin_name = "example-plugin" diff --git a/apisix/plugins/hmac-auth.lua b/apisix/plugins/hmac-auth.lua index eca78a236760..c456aaa46e3c 100644 --- a/apisix/plugins/hmac-auth.lua +++ b/apisix/plugins/hmac-auth.lua @@ -45,7 +45,6 @@ local schema = { type = "object", title = "work with route or service object", properties = {}, - additionalProperties = false, } local consumer_schema = { @@ -83,7 +82,6 @@ local consumer_schema = { } }, required = {"access_key", "secret_key"}, - additionalProperties = false, } local _M = { diff --git a/apisix/plugins/http-logger.lua b/apisix/plugins/http-logger.lua index a28ada2a59f3..28d0ec2ee4a3 100644 --- a/apisix/plugins/http-logger.lua +++ b/apisix/plugins/http-logger.lua @@ -56,7 +56,6 @@ local metadata_schema = { properties = { log_format = log_util.metadata_schema_log_format, }, - additionalProperties = false, } diff --git a/apisix/plugins/ip-restriction/init.lua b/apisix/plugins/ip-restriction/init.lua index 373ea2cb17e8..c74ac4a8634c 100644 --- a/apisix/plugins/ip-restriction/init.lua +++ b/apisix/plugins/ip-restriction/init.lua @@ -49,7 +49,6 @@ local schema = { {required = {"whitelist"}}, {required = {"blacklist"}}, }, - additionalProperties = false, } diff --git a/apisix/plugins/jwt-auth.lua b/apisix/plugins/jwt-auth.lua index dde755726b2a..cf3152a2a1a7 100644 --- a/apisix/plugins/jwt-auth.lua +++ b/apisix/plugins/jwt-auth.lua @@ -36,14 +36,12 @@ local lrucache = core.lrucache.new({ local schema = { type = "object", - additionalProperties = false, properties = {}, } local consumer_schema = { type = "object", -- can't use additionalProperties with dependencies - -- additionalProperties = false, properties = { key = {type = "string"}, secret = {type = "string"}, diff --git a/apisix/plugins/kafka-logger.lua b/apisix/plugins/kafka-logger.lua index 9f3fe2d0d57c..a7788a0c1d19 100644 --- a/apisix/plugins/kafka-logger.lua +++ b/apisix/plugins/kafka-logger.lua @@ -70,7 +70,6 @@ local metadata_schema = { properties = { log_format = log_util.metadata_schema_log_format, }, - additionalProperties = false, } local _M = { diff --git a/apisix/plugins/key-auth.lua b/apisix/plugins/key-auth.lua index 92a7c59535f6..a6ea9dcae0b5 100644 --- a/apisix/plugins/key-auth.lua +++ b/apisix/plugins/key-auth.lua @@ -26,7 +26,6 @@ local lrucache = core.lrucache.new({ local schema = { type = "object", - additionalProperties = false, properties = { header = { type = "string", @@ -41,7 +40,6 @@ local schema = { local consumer_schema = { type = "object", - additionalProperties = false, properties = { key = {type = "string"}, }, diff --git a/apisix/plugins/log-rotate.lua b/apisix/plugins/log-rotate.lua index e61c58696121..c44abe221d72 100644 --- a/apisix/plugins/log-rotate.lua +++ b/apisix/plugins/log-rotate.lua @@ -36,7 +36,6 @@ local MAX_KEPT = 24 * 7 -- max number of log files will be kept local schema = { type = "object", properties = {}, - additionalProperties = false, } diff --git a/apisix/plugins/node-status.lua b/apisix/plugins/node-status.lua index ceb574ba3e84..5ac76fa731f9 100644 --- a/apisix/plugins/node-status.lua +++ b/apisix/plugins/node-status.lua @@ -25,7 +25,6 @@ local ipairs = ipairs local schema = { type = "object", - additionalProperties = false, } diff --git a/apisix/plugins/prometheus.lua b/apisix/plugins/prometheus.lua index 1b9f6ef14fe0..27c94f519acd 100644 --- a/apisix/plugins/prometheus.lua +++ b/apisix/plugins/prometheus.lua @@ -30,7 +30,6 @@ local schema = { default = false } }, - additionalProperties = false, } diff --git a/apisix/plugins/proxy-rewrite.lua b/apisix/plugins/proxy-rewrite.lua index c678b5957ee6..397d6d055545 100644 --- a/apisix/plugins/proxy-rewrite.lua +++ b/apisix/plugins/proxy-rewrite.lua @@ -62,7 +62,6 @@ local schema = { }, }, minProperties = 1, - additionalProperties = false, } diff --git a/apisix/plugins/referer-restriction.lua b/apisix/plugins/referer-restriction.lua index e67b45586c5b..867159911314 100644 --- a/apisix/plugins/referer-restriction.lua +++ b/apisix/plugins/referer-restriction.lua @@ -36,7 +36,6 @@ local schema = { }, }, required = {"whitelist"}, - additionalProperties = false, } diff --git a/apisix/plugins/response-rewrite.lua b/apisix/plugins/response-rewrite.lua index 2f767bca33b4..7706bc96ed3e 100644 --- a/apisix/plugins/response-rewrite.lua +++ b/apisix/plugins/response-rewrite.lua @@ -50,7 +50,6 @@ local schema = { }, }, minProperties = 1, - additionalProperties = false, } diff --git a/apisix/plugins/server-info.lua b/apisix/plugins/server-info.lua index cc195cd6548c..5be3aa3b1abd 100644 --- a/apisix/plugins/server-info.lua +++ b/apisix/plugins/server-info.lua @@ -31,7 +31,6 @@ local default_report_ttl = 7200 local schema = { type = "object", - additionalProperties = false, } local attr_schema = { type = "object", diff --git a/apisix/plugins/skywalking.lua b/apisix/plugins/skywalking.lua index 94c721529646..ffba5291262b 100644 --- a/apisix/plugins/skywalking.lua +++ b/apisix/plugins/skywalking.lua @@ -45,7 +45,6 @@ local attr_schema = { type = "integer", }, }, - additionalProperties = false, } local schema = { @@ -58,7 +57,6 @@ local schema = { default = 1 } }, - additionalProperties = false, } diff --git a/apisix/plugins/traffic-split.lua b/apisix/plugins/traffic-split.lua index cf9bec52ab4b..de6d57048240 100644 --- a/apisix/plugins/traffic-split.lua +++ b/apisix/plugins/traffic-split.lua @@ -85,11 +85,9 @@ local schema = { match = match_schema, weighted_upstreams = upstreams_schema }, - additionalProperties = false } } }, - additionalProperties = false } local plugin_name = "traffic-split" diff --git a/apisix/plugins/ua-restriction.lua b/apisix/plugins/ua-restriction.lua index 95bc3d47a7f2..3683a15fba56 100644 --- a/apisix/plugins/ua-restriction.lua +++ b/apisix/plugins/ua-restriction.lua @@ -49,7 +49,6 @@ local schema = { default = "Not allowed" }, }, - additionalProperties = false, } local plugin_name = "ua-restriction" diff --git a/apisix/schema_def.lua b/apisix/schema_def.lua index 58d6a044cdce..c8f4ad50f17a 100644 --- a/apisix/schema_def.lua +++ b/apisix/schema_def.lua @@ -280,7 +280,6 @@ local health_checker = { } } }, - additionalProperties = false, anyOf = { {required = {"active"}}, {required = {"active", "passive"}}, @@ -642,7 +641,6 @@ _M.route = { {required = {"script", "plugin_config_id"}}, } }, - additionalProperties = false, } @@ -665,7 +663,6 @@ _M.service = { }, }, - additionalProperties = false, } @@ -683,7 +680,6 @@ _M.consumer = { desc = desc_def, }, required = {"username"}, - additionalProperties = false, } @@ -748,7 +744,6 @@ _M.ssl = { {required = {"sni", "key", "cert"}}, {required = {"snis", "key", "cert"}} }, - additionalProperties = false, } @@ -765,7 +760,6 @@ _M.proto = { } }, required = {"content"}, - additionalProperties = false, } @@ -778,7 +772,6 @@ _M.global_rule = { update_time = timestamp_def }, required = {"plugins"}, - additionalProperties = false, } @@ -823,7 +816,6 @@ _M.plugins = { stream = { type = "boolean" }, - additionalProperties = false, }, required = {"name"} } @@ -841,7 +833,6 @@ _M.plugin_config = { update_time = timestamp_def }, required = {"id", "plugins"}, - additionalProperties = false, } diff --git a/docs/en/latest/plugin-develop.md b/docs/en/latest/plugin-develop.md index f7c85861206f..f850a3805cb0 100644 --- a/docs/en/latest/plugin-develop.md +++ b/docs/en/latest/plugin-develop.md @@ -227,7 +227,6 @@ local metadata_schema = { skey = {type = "string"}, }, required = {"ikey", "skey"}, - additionalProperties = false, } local plugin_name = "example-plugin" @@ -268,7 +267,6 @@ To validate the configuration, the plugin uses a schema like this: ```lua local consumer_schema = { type = "object", - additionalProperties = false, properties = { key = {type = "string"}, }, diff --git a/docs/zh/latest/plugin-develop.md b/docs/zh/latest/plugin-develop.md index 1a428f394d96..56ff1358311c 100644 --- a/docs/zh/latest/plugin-develop.md +++ b/docs/zh/latest/plugin-develop.md @@ -173,7 +173,6 @@ local metadata_schema = { skey = {type = "string"}, }, required = {"ikey", "skey"}, - additionalProperties = false, } local plugin_name = "example-plugin" @@ -214,7 +213,6 @@ local _M = { ```lua local consumer_schema = { type = "object", - additionalProperties = false, properties = { key = {type = "string"}, }, diff --git a/t/admin/global-rules.t b/t/admin/global-rules.t index 001ad04e737c..422652a46c74 100644 --- a/t/admin/global-rules.t +++ b/t/admin/global-rules.t @@ -337,41 +337,7 @@ GET /t -=== TEST 8: set global rules(invalid host option) ---- config - location /t { - content_by_lua_block { - local t = require("lib.test_admin").test - local code, body = t('/apisix/admin/global_rules/1', - ngx.HTTP_PUT, - [[{ - "host": "foo.com", - "plugins": { - "limit-count": { - "count": 2, - "time_window": 60, - "rejected_code": 503, - "key": "remote_addr" - } - } - }]] - ) - - ngx.status = code - ngx.print(body) - } - } ---- request -GET /t ---- error_code: 400 ---- response_body -{"error_msg":"invalid configuration: additional properties forbidden, found host"} ---- no_error_log -[error] - - - -=== TEST 9: set global rules(missing plugins) +=== TEST 8: set global rules(missing plugins) --- config location /t { content_by_lua_block { @@ -395,7 +361,7 @@ GET /t -=== TEST 10: string id +=== TEST 9: string id --- config location /t { content_by_lua_block { @@ -428,7 +394,7 @@ passed -=== TEST 11: string id(DELETE) +=== TEST 10: string id(DELETE) --- config location /t { content_by_lua_block { @@ -451,7 +417,7 @@ passed -=== TEST 12: not unwanted data, PUT +=== TEST 11: not unwanted data, PUT --- config location /t { content_by_lua_block { @@ -489,7 +455,7 @@ GET /t -=== TEST 13: not unwanted data, PATCH +=== TEST 12: not unwanted data, PATCH --- config location /t { content_by_lua_block { @@ -527,7 +493,7 @@ GET /t -=== TEST 14: not unwanted data, GET +=== TEST 13: not unwanted data, GET --- config location /t { content_by_lua_block { @@ -563,7 +529,7 @@ GET /t -=== TEST 15: not unwanted data, DELETE +=== TEST 14: not unwanted data, DELETE --- config location /t { content_by_lua_block { diff --git a/t/admin/plugins.t b/t/admin/plugins.t index 67b8c0a01a79..11354e94cc2c 100644 --- a/t/admin/plugins.t +++ b/t/admin/plugins.t @@ -90,7 +90,7 @@ plugins: ngx.HTTP_GET, nil, [[ -{"properties":{"disable":{"type":"boolean"}},"additionalProperties":false,"type":"object"} +{"properties":{"disable":{"type":"boolean"}},"type":"object"} ]] ) @@ -111,7 +111,7 @@ plugins: ngx.HTTP_GET, nil, [[ -{"properties":{"disable":{"type":"boolean"}},"additionalProperties":false,"type":"object"} +{"properties":{"disable":{"type":"boolean"}},"type":"object"} ]] ) @@ -132,7 +132,7 @@ plugins: ngx.HTTP_GET, nil, [[ -{"properties":{"disable":{"type":"boolean"}},"title":"work with route or service object","additionalProperties":false,"type":"object"} +{"properties":{"disable":{"type":"boolean"}},"title":"work with route or service object","type":"object"} ]] ) @@ -153,7 +153,7 @@ plugins: ngx.HTTP_GET, nil, [[ -{"title":"work with consumer object","additionalProperties":false,"required":["username","password"],"properties":{"username":{"type":"string"},"password":{"type":"string"}},"type":"object"} +{"title":"work with consumer object","required":["username","password"],"properties":{"username":{"type":"string"},"password":{"type":"string"}},"type":"object"} ]] ) @@ -191,7 +191,7 @@ plugins: } } --- response_body eval -qr/\{"metadata_schema":\{"additionalProperties":false,"properties":\{"ikey":\{"minimum":0,"type":"number"\},"skey":\{"type":"string"\}\},"required":\["ikey","skey"\],"type":"object"\},"priority":0,"schema":\{"\$comment":"this is a mark for our injected plugin schema","properties":\{"disable":\{"type":"boolean"\},"i":\{"minimum":0,"type":"number"\},"ip":\{"type":"string"\},"port":\{"type":"integer"\},"s":\{"type":"string"\},"t":\{"minItems":1,"type":"array"\}\},"required":\["i"\],"type":"object"\},"version":0.1\}/ +qr/\{"metadata_schema":\{"properties":\{"ikey":\{"minimum":0,"type":"number"\},"skey":\{"type":"string"\}\},"required":\["ikey","skey"\],"type":"object"\},"priority":0,"schema":\{"\$comment":"this is a mark for our injected plugin schema","properties":\{"disable":\{"type":"boolean"\},"i":\{"minimum":0,"type":"number"\},"ip":\{"type":"string"\},"port":\{"type":"integer"\},"s":\{"type":"string"\},"t":\{"minItems":1,"type":"array"\}\},"required":\["i"\],"type":"object"\},"version":0.1\}/ --- no_error_log [error] @@ -266,6 +266,6 @@ qr/\[\{"name":"wolf-rbac","priority":2555\},\{"name":"hmac-auth","priority":2530 } } --- response_body eval -qr/\{"additionalProperties":false,"properties":\{"password":\{"type":"string"\},"username":\{"type":"string"\}\},"required":\["username","password"\],"title":"work with consumer object","type":"object"\}/ +qr/\{"properties":\{"password":\{"type":"string"\},"username":\{"type":"string"\}\},"required":\["username","password"\],"title":"work with consumer object","type":"object"\}/ --- no_error_log [error] diff --git a/t/admin/services-string-id.t b/t/admin/services-string-id.t index aa116c03d648..e42be0166fdf 100644 --- a/t/admin/services-string-id.t +++ b/t/admin/services-string-id.t @@ -466,34 +466,7 @@ GET /t -=== TEST 13: no additional properties is valid ---- config - location /t { - content_by_lua_block { - local t = require("lib.test_admin").test - local code, body = t('/apisix/admin/services', - ngx.HTTP_PUT, - [[{ - "id": "5eeb3dc90f747328b2930b0b", - "invalid_property": "/index.html" - }]] - ) - - ngx.status = code - ngx.print(body) - } - } ---- request -GET /t ---- error_code: 400 ---- response_body -{"error_msg":"invalid configuration: additional properties forbidden, found invalid_property"} ---- no_error_log -[error] - - - -=== TEST 14: invalid upstream_id +=== TEST 13: invalid upstream_id --- config location /t { content_by_lua_block { @@ -520,7 +493,7 @@ GET /t -=== TEST 15: not exist upstream_id +=== TEST 14: not exist upstream_id --- config location /t { content_by_lua_block { @@ -547,7 +520,7 @@ GET /t -=== TEST 16: wrong service id +=== TEST 15: wrong service id --- config location /t { content_by_lua_block { @@ -573,7 +546,7 @@ GET /t -=== TEST 17: wrong service id +=== TEST 16: wrong service id --- config location /t { content_by_lua_block { @@ -600,7 +573,7 @@ GET /t -=== TEST 18: patch service(whole) +=== TEST 17: patch service(whole) --- config location /t { content_by_lua_block { @@ -646,7 +619,7 @@ passed -=== TEST 19: patch service(new desc) +=== TEST 18: patch service(new desc) --- config location /t { content_by_lua_block { @@ -686,7 +659,7 @@ passed -=== TEST 20: patch service(new nodes) +=== TEST 19: patch service(new nodes) --- config location /t { content_by_lua_block { @@ -731,7 +704,7 @@ passed -=== TEST 21: set service(id: 5eeb3dc90f747328b2930b0b) and upstream(type:chash, default hash_on: vars, missing key) +=== TEST 20: set service(id: 5eeb3dc90f747328b2930b0b) and upstream(type:chash, default hash_on: vars, missing key) --- config location /t { content_by_lua_block { @@ -762,7 +735,7 @@ GET /t -=== TEST 22: set service(id: 5eeb3dc90f747328b2930b0b) and upstream(type:chash, hash_on: header, missing key) +=== TEST 21: set service(id: 5eeb3dc90f747328b2930b0b) and upstream(type:chash, hash_on: header, missing key) --- config location /t { content_by_lua_block { @@ -794,7 +767,7 @@ GET /t -=== TEST 23: set service(id: 5eeb3dc90f747328b2930b0b) and upstream(type:chash, hash_on: cookie, missing key) +=== TEST 22: set service(id: 5eeb3dc90f747328b2930b0b) and upstream(type:chash, hash_on: cookie, missing key) --- config location /t { content_by_lua_block { @@ -826,7 +799,7 @@ GET /t -=== TEST 24: set service(id: 5eeb3dc90f747328b2930b0b) and upstream(type:chash, hash_on: consumer, missing key is ok) +=== TEST 23: set service(id: 5eeb3dc90f747328b2930b0b) and upstream(type:chash, hash_on: consumer, missing key is ok) --- config location /t { content_by_lua_block { diff --git a/t/admin/services.t b/t/admin/services.t index 1bf450180544..dcb7c7aed9d5 100644 --- a/t/admin/services.t +++ b/t/admin/services.t @@ -480,34 +480,7 @@ GET /t -=== TEST 13: no additional properties is valid ---- config - location /t { - content_by_lua_block { - local t = require("lib.test_admin").test - local code, body = t('/apisix/admin/services', - ngx.HTTP_PUT, - [[{ - "id": 1, - "invalid_property": "/index.html" - }]] - ) - - ngx.status = code - ngx.print(body) - } - } ---- request -GET /t ---- error_code: 400 ---- response_body -{"error_msg":"invalid configuration: additional properties forbidden, found invalid_property"} ---- no_error_log -[error] - - - -=== TEST 14: invalid upstream_id +=== TEST 13: invalid upstream_id --- config location /t { content_by_lua_block { @@ -534,7 +507,7 @@ GET /t -=== TEST 15: not exist upstream_id +=== TEST 14: not exist upstream_id --- config location /t { content_by_lua_block { @@ -561,7 +534,7 @@ GET /t -=== TEST 16: wrong service id +=== TEST 15: wrong service id --- config location /t { content_by_lua_block { @@ -587,7 +560,7 @@ GET /t -=== TEST 17: wrong service id +=== TEST 16: wrong service id --- config location /t { content_by_lua_block { @@ -614,7 +587,7 @@ GET /t -=== TEST 18: patch service(whole) +=== TEST 17: patch service(whole) --- config location /t { content_by_lua_block { @@ -674,7 +647,7 @@ passed -=== TEST 19: patch service(new desc) +=== TEST 18: patch service(new desc) --- config location /t { content_by_lua_block { @@ -714,7 +687,7 @@ passed -=== TEST 20: patch service(new nodes) +=== TEST 19: patch service(new nodes) --- config location /t { content_by_lua_block { @@ -759,7 +732,7 @@ passed -=== TEST 21: patch service(whole - sub path) +=== TEST 20: patch service(whole - sub path) --- config location /t { content_by_lua_block { @@ -805,7 +778,7 @@ passed -=== TEST 22: patch service(new desc - sub path) +=== TEST 21: patch service(new desc - sub path) --- config location /t { content_by_lua_block { @@ -843,7 +816,7 @@ passed -=== TEST 23: patch service(new nodes - sub path) +=== TEST 22: patch service(new nodes - sub path) --- config location /t { content_by_lua_block { @@ -885,7 +858,7 @@ passed -=== TEST 24: set service(id: 1) and upstream(type:chash, default hash_on: vars, missing key) +=== TEST 23: set service(id: 1) and upstream(type:chash, default hash_on: vars, missing key) --- config location /t { content_by_lua_block { @@ -916,7 +889,7 @@ GET /t -=== TEST 25: set service(id: 1) and upstream(type:chash, hash_on: header, missing key) +=== TEST 24: set service(id: 1) and upstream(type:chash, hash_on: header, missing key) --- config location /t { content_by_lua_block { @@ -948,7 +921,7 @@ GET /t -=== TEST 26: set service(id: 1) and upstream(type:chash, hash_on: cookie, missing key) +=== TEST 25: set service(id: 1) and upstream(type:chash, hash_on: cookie, missing key) --- config location /t { content_by_lua_block { @@ -980,7 +953,7 @@ GET /t -=== TEST 27: set service(id: 1) and upstream(type:chash, hash_on: consumer, missing key is ok) +=== TEST 26: set service(id: 1) and upstream(type:chash, hash_on: consumer, missing key is ok) --- config location /t { content_by_lua_block { @@ -1011,7 +984,7 @@ GET /t -=== TEST 28: set service(id: 1 + test service name) +=== TEST 27: set service(id: 1 + test service name) --- config location /t { content_by_lua_block { @@ -1057,7 +1030,7 @@ passed -=== TEST 29: invalid string id +=== TEST 28: invalid string id --- config location /t { content_by_lua_block { @@ -1088,7 +1061,7 @@ GET /t -=== TEST 30: set empty service. (id: 1)(allow empty `service` object) +=== TEST 29: set empty service. (id: 1)(allow empty `service` object) --- config location /t { content_by_lua_block { @@ -1117,7 +1090,7 @@ passed -=== TEST 31: patch content to the empty service. +=== TEST 30: patch content to the empty service. --- config location /t { content_by_lua_block { @@ -1182,7 +1155,7 @@ passed -=== TEST 32: set service(with labels) +=== TEST 31: set service(with labels) --- config location /t { content_by_lua_block { @@ -1238,7 +1211,7 @@ passed -=== TEST 33: patch service(change labels) +=== TEST 32: patch service(change labels) --- config location /t { content_by_lua_block { @@ -1285,7 +1258,7 @@ passed -=== TEST 34: invalid format of label value: set service +=== TEST 33: invalid format of label value: set service --- config location /t { content_by_lua_block { @@ -1320,7 +1293,7 @@ GET /t -=== TEST 35: create service with create_time and update_time(id: 1) +=== TEST 34: create service with create_time and update_time(id: 1) --- config location /t { content_by_lua_block { @@ -1368,7 +1341,7 @@ passed -=== TEST 36: delete test service(id: 1) +=== TEST 35: delete test service(id: 1) --- config location /t { content_by_lua_block { @@ -1392,7 +1365,7 @@ GET /t -=== TEST 37: limit the length of service's name +=== TEST 36: limit the length of service's name --- config location /t { content_by_lua_block { @@ -1416,7 +1389,7 @@ GET /t -=== TEST 38: allow dot in the id +=== TEST 37: allow dot in the id --- config location /t { content_by_lua_block { diff --git a/t/core/schema_def.t b/t/core/schema_def.t index 2c3254a184c4..0afee9c9de60 100644 --- a/t/core/schema_def.t +++ b/t/core/schema_def.t @@ -51,7 +51,6 @@ __DATA__ anyOf = schema_def.ip_def, } }, - additionalProperties = false, } local cases = { diff --git a/t/plugin/basic-auth.t b/t/plugin/basic-auth.t index 8382de0cc2e0..79078b1aeb49 100644 --- a/t/plugin/basic-auth.t +++ b/t/plugin/basic-auth.t @@ -51,8 +51,9 @@ done --- config location /t { content_by_lua_block { + local core = require("apisix.core") local plugin = require("apisix.plugins.basic-auth") - local ok, err = plugin.check_schema({username = 123, password = "bar"}) + local ok, err = plugin.check_schema({username = 123, password = "bar"}, core.schema.TYPE_CONSUMER) if not ok then ngx.say(err) end @@ -62,10 +63,9 @@ done } --- request GET /t ---- response_body_like eval -qr/additional properties forbidden, found (username|password) +--- response_body +property "username" validation failed: wrong type: expected string, got number done -/ --- no_error_log [error] @@ -302,7 +302,7 @@ GET /t ngx.HTTP_GET, nil, [[ -{"properties":{"disable":{"type":"boolean"}},"title":"work with route or service object","additionalProperties":false,"type":"object"} +{"properties":{"disable":{"type":"boolean"}},"title":"work with route or service object","type":"object"} ]] ) ngx.status = code @@ -324,7 +324,7 @@ GET /t ngx.HTTP_GET, nil, [[ -{"title":"work with consumer object","additionalProperties":false,"required":["username","password"],"properties":{"username":{"type":"string"},"password":{"type":"string"}},"type":"object"} +{"title":"work with consumer object","required":["username","password"],"properties":{"username":{"type":"string"},"password":{"type":"string"}},"type":"object"} ]] ) ngx.status = code @@ -346,7 +346,7 @@ GET /t ngx.HTTP_GET, nil, [[ -{"properties":{"disable":{"type":"boolean"}},"title":"work with route or service object","additionalProperties":false,"type":"object"} +{"properties":{"disable":{"type":"boolean"}},"title":"work with route or service object","type":"object"} ]] ) ngx.status = code diff --git a/t/plugin/echo.t b/t/plugin/echo.t index 296ed0639e8c..f9af4d07ffd2 100644 --- a/t/plugin/echo.t +++ b/t/plugin/echo.t @@ -270,35 +270,7 @@ GET /t -=== TEST 8: additional property ---- config - location /t { - content_by_lua_block { - local plugin = require("apisix.plugins.echo") - local ok, err = plugin.check_schema({ - before_body = "body before", - body = "body to attach", - after_body = "body to attach", - invalid_att = "invalid", - }) - - if not ok then - ngx.say(err) - else - ngx.say("done") - end - } - } ---- request -GET /t ---- response_body -additional properties forbidden, found invalid_att ---- no_error_log -[error] - - - -=== TEST 9: set body with chunked upstream +=== TEST 8: set body with chunked upstream --- config location /t { content_by_lua_block { @@ -336,7 +308,7 @@ passed -=== TEST 10: access +=== TEST 9: access --- request GET /hello_chunked --- response_body chomp @@ -346,7 +318,7 @@ hello upstream -=== TEST 11: add before/after body with chunked upstream +=== TEST 10: add before/after body with chunked upstream --- config location /t { content_by_lua_block { @@ -385,7 +357,7 @@ passed -=== TEST 12: access +=== TEST 11: access --- request GET /hello_chunked --- response_body chomp diff --git a/t/plugin/hmac-auth2.t b/t/plugin/hmac-auth2.t index 40c9123f0a39..e0a3bfdff0f5 100644 --- a/t/plugin/hmac-auth2.t +++ b/t/plugin/hmac-auth2.t @@ -400,7 +400,7 @@ x-real-ip: 127.0.0.1 ngx.HTTP_GET, nil, [[ -{"properties":{"disable":{"type":"boolean"}},"title":"work with route or service object","additionalProperties":false,"type":"object"} +{"properties":{"disable":{"type":"boolean"}},"title":"work with route or service object","type":"object"} ]] ) ngx.status = code @@ -418,7 +418,7 @@ x-real-ip: 127.0.0.1 ngx.HTTP_GET, nil, [[ -{"title":"work with consumer object","additionalProperties":false,"required":["access_key","secret_key"],"properties":{"clock_skew":{"default":0,"type":"integer"},"encode_uri_params":{"title":"Whether to escape the uri parameter","default":true,"type":"boolean"},"keep_headers":{"title":"whether to keep the http request header","default":false,"type":"boolean"},"secret_key":{"minLength":1,"maxLength":256,"type":"string"},"algorithm":{"type":"string","default":"hmac-sha256","enum":["hmac-sha1","hmac-sha256","hmac-sha512"]},"signed_headers":{"items":{"minLength":1,"maxLength":50,"type":"string"},"type":"array"},"access_key":{"minLength":1,"maxLength":256,"type":"string"}},"type":"object"} +{"title":"work with consumer object","required":["access_key","secret_key"],"properties":{"clock_skew":{"default":0,"type":"integer"},"encode_uri_params":{"title":"Whether to escape the uri parameter","default":true,"type":"boolean"},"keep_headers":{"title":"whether to keep the http request header","default":false,"type":"boolean"},"secret_key":{"minLength":1,"maxLength":256,"type":"string"},"algorithm":{"type":"string","default":"hmac-sha256","enum":["hmac-sha1","hmac-sha256","hmac-sha512"]},"signed_headers":{"items":{"minLength":1,"maxLength":50,"type":"string"},"type":"array"},"access_key":{"minLength":1,"maxLength":256,"type":"string"}},"type":"object"} ]] ) ngx.status = code @@ -436,7 +436,7 @@ x-real-ip: 127.0.0.1 ngx.HTTP_GET, nil, [[ -{"properties":{"disable":{"type":"boolean"}},"title":"work with route or service object","additionalProperties":false,"type":"object"} +{"properties":{"disable":{"type":"boolean"}},"title":"work with route or service object","type":"object"} ]] ) ngx.status = code diff --git a/t/plugin/jwt-auth.t b/t/plugin/jwt-auth.t index d5b3de86bf12..fd3359a5529f 100644 --- a/t/plugin/jwt-auth.t +++ b/t/plugin/jwt-auth.t @@ -517,46 +517,7 @@ property "key" is required -=== TEST 23: enable jwt auth plugin with extra field ---- config - location /t { - content_by_lua_block { - local t = require("lib.test_admin").test - local code, body = t('/apisix/admin/routes/1', - ngx.HTTP_PUT, - [[{ - "plugins": { - "jwt-auth": { - "key": "123" - } - }, - "upstream": { - "nodes": { - "127.0.0.1:1980": 1 - }, - "type": "roundrobin" - }, - "uri": "/hello" - }]] - ) - - if code >= 300 then - ngx.status = code - end - ngx.say(body) - } - } ---- request -GET /t ---- error_code: 400 ---- response_body_like -\{"error_msg":"failed to check the configuration of plugin jwt-auth err: additional properties forbidden, found key"\} ---- no_error_log -[error] - - - -=== TEST 24: get the schema by schema_type +=== TEST 23: get the schema by schema_type --- config location /t { content_by_lua_block { @@ -578,7 +539,7 @@ GET /t -=== TEST 25: get the schema by error schema_type +=== TEST 24: get the schema by error schema_type --- config location /t { content_by_lua_block { @@ -587,7 +548,7 @@ GET /t ngx.HTTP_GET, nil, [[ - {"properties":{"disable":{"type":"boolean"}},"additionalProperties":false,"type":"object"} + {"properties":{"disable":{"type":"boolean"}},"type":"object"} ]] ) ngx.status = code @@ -600,7 +561,7 @@ GET /t -=== TEST 26: get the schema by default schema_type +=== TEST 25: get the schema by default schema_type --- config location /t { content_by_lua_block { @@ -609,7 +570,7 @@ GET /t ngx.HTTP_GET, nil, [[ - {"properties":{"disable":{"type":"boolean"}},"additionalProperties":false,"type":"object"} + {"properties":{"disable":{"type":"boolean"}},"type":"object"} ]] ) ngx.status = code @@ -622,7 +583,7 @@ GET /t -=== TEST 27: add consumer with username and plugins with public_key, private_key(private_key numbits = 512) +=== TEST 26: add consumer with username and plugins with public_key, private_key(private_key numbits = 512) --- config location /t { content_by_lua_block { @@ -670,7 +631,7 @@ passed -=== TEST 28: JWT sign and verify use RS256 algorithm(private_key numbits = 512) +=== TEST 27: JWT sign and verify use RS256 algorithm(private_key numbits = 512) --- config location /t { content_by_lua_block { @@ -706,7 +667,7 @@ passed -=== TEST 29: sign/verify use RS256 algorithm(private_key numbits = 512) +=== TEST 28: sign/verify use RS256 algorithm(private_key numbits = 512) --- config location /t { content_by_lua_block { @@ -738,7 +699,7 @@ hello world -=== TEST 30: add consumer with username and plugins with public_key, private_key(private_key numbits = 1024) +=== TEST 29: add consumer with username and plugins with public_key, private_key(private_key numbits = 1024) --- config location /t { content_by_lua_block { @@ -789,7 +750,7 @@ passed -=== TEST 31: JWT sign and verify use RS256 algorithm(private_key numbits = 1024) +=== TEST 30: JWT sign and verify use RS256 algorithm(private_key numbits = 1024) --- config location /t { content_by_lua_block { @@ -825,7 +786,7 @@ passed -=== TEST 32: sign/verify use RS256 algorithm(private_key numbits = 1024) +=== TEST 31: sign/verify use RS256 algorithm(private_key numbits = 1024) --- config location /t { content_by_lua_block { @@ -857,7 +818,7 @@ hello world -=== TEST 33: sign/verify use RS256 algorithm(private_key numbits = 1024,with extra payload) +=== TEST 32: sign/verify use RS256 algorithm(private_key numbits = 1024,with extra payload) --- config location /t { content_by_lua_block { @@ -889,7 +850,7 @@ hello world -=== TEST 34: add consumer with username and plugins with public_key, private_key(private_key numbits = 2048) +=== TEST 33: add consumer with username and plugins with public_key, private_key(private_key numbits = 2048) --- config location /t { content_by_lua_block { @@ -940,7 +901,7 @@ passed -=== TEST 35: JWT sign and verify use RS256 algorithm(private_key numbits = 2048) +=== TEST 34: JWT sign and verify use RS256 algorithm(private_key numbits = 2048) --- config location /t { content_by_lua_block { @@ -976,7 +937,7 @@ passed -=== TEST 36: sign/verify use RS256 algorithm(private_key numbits = 2048) +=== TEST 35: sign/verify use RS256 algorithm(private_key numbits = 2048) --- config location /t { content_by_lua_block { @@ -1008,7 +969,7 @@ hello world -=== TEST 37: sign/verify use RS256 algorithm(private_key numbits = 2048,with extra payload) +=== TEST 36: sign/verify use RS256 algorithm(private_key numbits = 2048,with extra payload) --- config location /t { content_by_lua_block { @@ -1040,7 +1001,7 @@ hello world -=== TEST 38: JWT sign with the public key when using the RS256 algorithm +=== TEST 37: JWT sign with the public key when using the RS256 algorithm --- config location /t { content_by_lua_block { @@ -1088,7 +1049,7 @@ passed -=== TEST 39: JWT sign and verify RS256 +=== TEST 38: JWT sign and verify RS256 --- config location /t { content_by_lua_block { @@ -1124,7 +1085,7 @@ passed -=== TEST 40: sign failed +=== TEST 39: sign failed --- request GET /apisix/plugin/jwt/sign?key=user-key-rs256 --- error_code: 500 @@ -1133,7 +1094,7 @@ qr/failed to sign jwt/ -=== TEST 41: sanity(algorithm = HS512) +=== TEST 40: sanity(algorithm = HS512) --- config location /t { content_by_lua_block { @@ -1158,7 +1119,7 @@ qr/{"algorithm":"HS512","base64_secret":false,"exp":86400,"key":"123","secret":" -=== TEST 42: add consumer with username and plugins use HS512 algorithm +=== TEST 41: add consumer with username and plugins use HS512 algorithm --- config location /t { content_by_lua_block { @@ -1205,7 +1166,7 @@ passed -=== TEST 43: JWT sign and verify use HS512 algorithm +=== TEST 42: JWT sign and verify use HS512 algorithm --- config location /t { content_by_lua_block { @@ -1241,7 +1202,7 @@ passed -=== TEST 44: sign / verify (algorithm = HS512) +=== TEST 43: sign / verify (algorithm = HS512) --- config location /t { content_by_lua_block { @@ -1273,7 +1234,7 @@ hello world -=== TEST 45: sign / verify (algorithm = HS512,with extra payload) +=== TEST 44: sign / verify (algorithm = HS512,with extra payload) --- config location /t { content_by_lua_block { @@ -1305,7 +1266,7 @@ hello world -=== TEST 46: test for unsupported algorithm +=== TEST 45: test for unsupported algorithm --- request PATCH /apisix/plugin/jwt/sign?key=user-key --- config @@ -1330,7 +1291,7 @@ qr/property "algorithm" validation failed/ -=== TEST 47: wrong format of secret +=== TEST 46: wrong format of secret --- config location /t { content_by_lua_block { @@ -1357,7 +1318,7 @@ GET /t -=== TEST 48: when the exp value is not set, make sure the default value(86400) works +=== TEST 47: when the exp value is not set, make sure the default value(86400) works --- config location /t { content_by_lua_block { @@ -1402,7 +1363,7 @@ qr/"exp":86400/ -=== TEST 49: when the exp value is not set, sign jwt use the default value(86400) +=== TEST 48: when the exp value is not set, sign jwt use the default value(86400) --- config location /t { content_by_lua_block { @@ -1427,7 +1388,7 @@ true -=== TEST 50: RS256 without public key +=== TEST 49: RS256 without public key --- config location /t { content_by_lua_block { @@ -1458,7 +1419,7 @@ qr/failed to validate dependent schema for \\"algorithm\\"/ -=== TEST 51: RS256 without private key +=== TEST 50: RS256 without private key --- config location /t { content_by_lua_block { diff --git a/t/plugin/prometheus.t b/t/plugin/prometheus.t index 68055f96134d..af88949ffddd 100644 --- a/t/plugin/prometheus.t +++ b/t/plugin/prometheus.t @@ -56,32 +56,7 @@ done -=== TEST 2: wrong value of key ---- config - location /t { - content_by_lua_block { - local plugin = require("apisix.plugins.prometheus") - local ok, err = plugin.check_schema({ - invalid = "invalid" - }) - if not ok then - ngx.say(err) - return - end - - ngx.say("done") - } - } ---- request -GET /t ---- response_body -additional properties forbidden, found invalid ---- no_error_log -[error] - - - -=== TEST 3: set it in route +=== TEST 2: set it in route --- config location /t { content_by_lua_block { @@ -117,7 +92,7 @@ passed -=== TEST 4: fetch the prometheus metric data +=== TEST 3: fetch the prometheus metric data --- request GET /apisix/prometheus/metrics --- response_body_like @@ -127,7 +102,7 @@ apisix_etcd_reachable 1 -=== TEST 5: request from client (all hit) +=== TEST 4: request from client (all hit) --- pipelined_requests eval ["GET /hello", "GET /hello", "GET /hello", "GET /hello"] --- error_code eval @@ -137,7 +112,7 @@ apisix_etcd_reachable 1 -=== TEST 6: request from client (part hit) +=== TEST 5: request from client (part hit) --- pipelined_requests eval ["GET /hello1", "GET /hello", "GET /hello2", "GET /hello", "GET /hello"] --- error_code eval @@ -147,7 +122,7 @@ apisix_etcd_reachable 1 -=== TEST 7: fetch the prometheus metric data +=== TEST 6: fetch the prometheus metric data --- request GET /apisix/prometheus/metrics --- response_body eval @@ -157,91 +132,14 @@ qr/apisix_bandwidth\{type="egress",route="1",service="",consumer="",node="127.0. -=== TEST 8: test for unsupported method +=== TEST 7: test for unsupported method --- request PATCH /apisix/prometheus/metrics --- error_code: 404 -=== TEST 9: set it in route (with wrong property) ---- config - location /t { - content_by_lua_block { - local t = require("lib.test_admin").test - local code, body = t('/apisix/admin/routes/1', - ngx.HTTP_PUT, - [[{ - "plugins": { - "prometheus": { - "invalid_property": 1 - } - }, - "upstream": { - "nodes": { - "127.0.0.1:1980": 1 - }, - "type": "roundrobin" - }, - "uri": "/hello" - }]] - ) - - if code >= 300 then - ngx.status = code - end - ngx.print(body) - } - } ---- request -GET /t ---- error_code: 400 ---- response_body -{"error_msg":"failed to check the configuration of plugin prometheus err: additional properties forbidden, found invalid_property"} ---- no_error_log -[error] - - - -=== TEST 10: set it in service (with wrong property) ---- config - location /t { - content_by_lua_block { - local t = require("lib.test_admin").test - local code, body = t('/apisix/admin/services/1', - ngx.HTTP_PUT, - [[{ - "plugins": { - "prometheus": { - "invalid_property": 1 - } - }, - "upstream": { - "nodes": { - "127.0.0.1:1980": 1 - }, - "type": "roundrobin" - } - }]] - ) - - if code >= 300 then - ngx.status = code - end - ngx.print(body) - } - } ---- request -GET /t ---- error_code: 400 ---- response_body -{"error_msg":"failed to check the configuration of plugin prometheus err: additional properties forbidden, found invalid_property"} ---- no_error_log -[error] - - - -=== TEST 11: set route without id in post body +=== TEST 8: set route without id in post body --- config location /t { content_by_lua_block { @@ -279,7 +177,7 @@ passed -=== TEST 12: pipeline of client request +=== TEST 9: pipeline of client request --- pipelined_requests eval ["GET /hello", "GET /not_found", "GET /hello", "GET /hello"] --- error_code eval @@ -289,7 +187,7 @@ passed -=== TEST 13: fetch the prometheus metric data +=== TEST 10: fetch the prometheus metric data --- request GET /apisix/prometheus/metrics --- response_body eval @@ -299,7 +197,7 @@ qr/apisix_bandwidth\{type="egress",route="1",service="",consumer="",node="127.0. -=== TEST 14: fetch the prometheus metric data +=== TEST 11: fetch the prometheus metric data --- request GET /apisix/prometheus/metrics --- response_body eval @@ -309,7 +207,7 @@ qr/apisix_http_latency_count\{type="request",route="1",service="",consumer="",no -=== TEST 15: create service +=== TEST 12: create service --- config location /t { content_by_lua_block { @@ -344,7 +242,7 @@ passed -=== TEST 16: use service 1 in route 2 +=== TEST 13: use service 1 in route 2 --- config location /t { content_by_lua_block { @@ -372,7 +270,7 @@ passed -=== TEST 17: pipeline of client request +=== TEST 14: pipeline of client request --- pipelined_requests eval ["GET /hello1", "GET /not_found", "GET /hello1", "GET /hello1"] --- error_code eval @@ -382,7 +280,7 @@ passed -=== TEST 18: fetch the prometheus metric data +=== TEST 15: fetch the prometheus metric data --- request GET /apisix/prometheus/metrics --- response_body eval @@ -392,7 +290,7 @@ qr/apisix_bandwidth\{type="egress",route="2",service="1",consumer="",node="127.0 -=== TEST 19: delete route 2 +=== TEST 16: delete route 2 --- config location /t { content_by_lua_block { @@ -416,7 +314,7 @@ passed -=== TEST 20: set it in route with plugin `fault-injection` +=== TEST 17: set it in route with plugin `fault-injection` --- config location /t { content_by_lua_block { @@ -452,7 +350,7 @@ passed -=== TEST 21: pipeline of client request +=== TEST 18: pipeline of client request --- pipelined_requests eval ["GET /hello", "GET /not_found", "GET /hello", "GET /hello"] --- error_code eval @@ -462,7 +360,7 @@ passed -=== TEST 22: set it in global rule +=== TEST 19: set it in global rule --- config location /t { content_by_lua_block { @@ -507,7 +405,7 @@ passed -=== TEST 23: request from client +=== TEST 20: request from client --- pipelined_requests eval ["GET /hello3", "GET /hello3"] --- error_code eval @@ -517,7 +415,7 @@ passed -=== TEST 24: fetch the prometheus metric data +=== TEST 21: fetch the prometheus metric data --- request GET /apisix/prometheus/metrics --- response_body eval @@ -527,7 +425,7 @@ qr/apisix_http_status\{code="404",route="3",matched_uri="\/hello3",matched_host= -=== TEST 25: fetch the prometheus metric data with apisix latency +=== TEST 22: fetch the prometheus metric data with apisix latency --- request GET /apisix/prometheus/metrics --- response_body eval @@ -537,7 +435,7 @@ qr/.*apisix_http_latency_bucket\{type="apisix".*/ -=== TEST 26: add service 3 to distinguish other services +=== TEST 23: add service 3 to distinguish other services --- config location /t { content_by_lua_block { @@ -572,7 +470,7 @@ passed -=== TEST 27: add a route 4 to redirect /mysleep?seconds=1 +=== TEST 24: add a route 4 to redirect /mysleep?seconds=1 --- config location /t { content_by_lua_block { @@ -600,7 +498,7 @@ passed -=== TEST 28: request from client to /mysleep?seconds=1 ( all hit) +=== TEST 25: request from client to /mysleep?seconds=1 ( all hit) --- pipelined_requests eval ["GET /mysleep?seconds=1", "GET /mysleep?seconds=1", "GET /mysleep?seconds=1"] --- error_code eval @@ -610,7 +508,7 @@ passed -=== TEST 29: fetch the prometheus metric data with apisix latency (latency < 1s) +=== TEST 26: fetch the prometheus metric data with apisix latency (latency < 1s) --- request GET /apisix/prometheus/metrics --- response_body eval @@ -620,7 +518,7 @@ qr/apisix_http_latency_bucket\{type="apisix".*service=\"3\".*le=\"500.*/ -=== TEST 30: delete route 4 +=== TEST 27: delete route 4 --- config location /t { content_by_lua_block { @@ -643,7 +541,7 @@ passed -=== TEST 31: delete service 3 +=== TEST 28: delete service 3 --- config location /t { content_by_lua_block { @@ -666,7 +564,7 @@ passed -=== TEST 32: fetch the prometheus metric data with `modify_indexes consumers` +=== TEST 29: fetch the prometheus metric data with `modify_indexes consumers` --- request GET /apisix/prometheus/metrics --- response_body_like eval @@ -676,7 +574,7 @@ qr/apisix_etcd_modify_indexes\{key="consumers"\} \d+/ -=== TEST 33: fetch the prometheus metric data with `modify_indexes global_rules` +=== TEST 30: fetch the prometheus metric data with `modify_indexes global_rules` --- request GET /apisix/prometheus/metrics --- response_body_like eval @@ -686,7 +584,7 @@ qr/apisix_etcd_modify_indexes\{key="global_rules"\} \d+/ -=== TEST 34: fetch the prometheus metric data with `modify_indexes max_modify_index` +=== TEST 31: fetch the prometheus metric data with `modify_indexes max_modify_index` --- request GET /apisix/prometheus/metrics --- response_body_like eval @@ -696,7 +594,7 @@ qr/apisix_etcd_modify_indexes\{key="max_modify_index"\} \d+/ -=== TEST 35: fetch the prometheus metric data with `modify_indexes protos` +=== TEST 32: fetch the prometheus metric data with `modify_indexes protos` --- request GET /apisix/prometheus/metrics --- response_body_like eval @@ -706,7 +604,7 @@ qr/apisix_etcd_modify_indexes\{key="protos"\} \d+/ -=== TEST 36: fetch the prometheus metric data with `modify_indexes routes` +=== TEST 33: fetch the prometheus metric data with `modify_indexes routes` --- request GET /apisix/prometheus/metrics --- response_body_like eval @@ -716,7 +614,7 @@ qr/apisix_etcd_modify_indexes\{key="routes"\} \d+/ -=== TEST 37: fetch the prometheus metric data with `modify_indexes services` +=== TEST 34: fetch the prometheus metric data with `modify_indexes services` --- request GET /apisix/prometheus/metrics --- response_body_like eval @@ -726,7 +624,7 @@ qr/apisix_etcd_modify_indexes\{key="services"\} \d+/ -=== TEST 38: fetch the prometheus metric data with `modify_indexes ssls` +=== TEST 35: fetch the prometheus metric data with `modify_indexes ssls` --- request GET /apisix/prometheus/metrics --- response_body_like eval @@ -736,7 +634,7 @@ qr/apisix_etcd_modify_indexes\{key="ssls"\} \d+/ -=== TEST 39: fetch the prometheus metric data with `modify_indexes stream_routes` +=== TEST 36: fetch the prometheus metric data with `modify_indexes stream_routes` --- request GET /apisix/prometheus/metrics --- response_body_like eval @@ -746,7 +644,7 @@ qr/apisix_etcd_modify_indexes\{key="stream_routes"\} \d+/ -=== TEST 40: fetch the prometheus metric data with `modify_indexes upstreams` +=== TEST 37: fetch the prometheus metric data with `modify_indexes upstreams` --- request GET /apisix/prometheus/metrics --- response_body_like eval @@ -756,7 +654,7 @@ qr/apisix_etcd_modify_indexes\{key="upstreams"\} \d+/ -=== TEST 41: fetch the prometheus metric data with `modify_indexes prev_index` +=== TEST 38: fetch the prometheus metric data with `modify_indexes prev_index` --- request GET /apisix/prometheus/metrics --- response_body_like eval @@ -766,7 +664,7 @@ qr/apisix_etcd_modify_indexes\{key="prev_index"\} \d+/ -=== TEST 42: fetch the prometheus metric data with `modify_indexes x_etcd_index` +=== TEST 39: fetch the prometheus metric data with `modify_indexes x_etcd_index` --- request GET /apisix/prometheus/metrics --- response_body_like eval @@ -776,7 +674,7 @@ qr/apisix_etcd_modify_indexes\{key="x_etcd_index"\} \d+/ -=== TEST 43: fetch the prometheus metric data -- hostname +=== TEST 40: fetch the prometheus metric data -- hostname --- request GET /apisix/prometheus/metrics --- response_body eval @@ -786,7 +684,7 @@ qr/apisix_node_info\{hostname=".*"\} 1/ -=== TEST 44: don't try to provide etcd metrics when you don't use it +=== TEST 41: don't try to provide etcd metrics when you don't use it --- yaml_config apisix: node_listen: 1984 diff --git a/t/plugin/proxy-rewrite.t b/t/plugin/proxy-rewrite.t index ddc8cb1b8966..fbca1b621b51 100644 --- a/t/plugin/proxy-rewrite.t +++ b/t/plugin/proxy-rewrite.t @@ -1103,35 +1103,7 @@ GET /t -=== TEST 37: additional property ---- config - location /t { - content_by_lua_block { - local plugin = require("apisix.plugins.proxy-rewrite") - local ok, err = plugin.check_schema({ - uri = '/apisix/home', - host = 'apisix.iresty.com', - scheme = 'http', - invalid_att = "invalid", - }) - - if not ok then - ngx.say(err) - else - ngx.say("done") - end - } - } ---- request -GET /t ---- response_body -additional properties forbidden, found invalid_att ---- no_error_log -[error] - - - -=== TEST 38: set route(header contains nginx variables) +=== TEST 37: set route(header contains nginx variables) --- config location /t { content_by_lua_block { @@ -1174,7 +1146,7 @@ passed -=== TEST 39: hit route(header supports nginx variables) +=== TEST 38: hit route(header supports nginx variables) --- request GET /hello?name=Bill HTTP/1.1 --- more_headers @@ -1192,7 +1164,7 @@ x-real-ip: 127.0.0.1 -=== TEST 40: set route(nginx variable does not exist) +=== TEST 39: set route(nginx variable does not exist) --- config location /t { content_by_lua_block { @@ -1236,7 +1208,7 @@ passed -=== TEST 41: hit route(get nginx variable is nil) +=== TEST 40: hit route(get nginx variable is nil) --- request GET /hello HTTP/1.1 --- response_body @@ -1249,7 +1221,7 @@ x-real-ip: 127.0.0.1 -=== TEST 42: set route(rewrite uri based on ctx.var) +=== TEST 41: set route(rewrite uri based on ctx.var) --- config location /t { content_by_lua_block { @@ -1287,7 +1259,7 @@ passed -=== TEST 43: hit route(upstream uri: should be /hello) +=== TEST 42: hit route(upstream uri: should be /hello) --- request GET /test?new_uri=hello --- response_body @@ -1297,7 +1269,7 @@ hello world -=== TEST 44: host with port +=== TEST 43: host with port --- config location /t { content_by_lua_block { @@ -1321,7 +1293,7 @@ done -=== TEST 45: set route(rewrite host with port) +=== TEST 44: set route(rewrite host with port) --- config location /t { content_by_lua_block { @@ -1361,7 +1333,7 @@ passed -=== TEST 46: rewrite host with port +=== TEST 45: rewrite host with port --- request GET /hello --- response_body diff --git a/t/plugin/response-rewrite.t b/t/plugin/response-rewrite.t index 670e536798ef..bdc54caef640 100644 --- a/t/plugin/response-rewrite.t +++ b/t/plugin/response-rewrite.t @@ -483,36 +483,7 @@ GET /t -=== TEST 16: additional property ---- config - location /t { - content_by_lua_block { - local plugin = require("apisix.plugins.response-rewrite") - local ok, err = plugin.check_schema({ - body = 'Hello world', - headers = { - ["X-Server-id"] = 3 - }, - invalid_att = "invalid", - }) - - if not ok then - ngx.say(err) - else - ngx.say("done") - end - } - } ---- request -GET /t ---- response_body -additional properties forbidden, found invalid_att ---- no_error_log -[error] - - - -=== TEST 17: add validate vars +=== TEST 16: add validate vars --- config location /t { content_by_lua_block { @@ -539,7 +510,7 @@ done -=== TEST 18: add plugin with invalidate vars +=== TEST 17: add plugin with invalidate vars --- config location /t { content_by_lua_block { @@ -566,7 +537,7 @@ failed to validate the 'vars' expression: rule too short -=== TEST 19: set route with http status code as expr +=== TEST 18: set route with http status code as expr --- config location /t { content_by_lua_block { @@ -608,7 +579,7 @@ passed -=== TEST 20: check http code that matches http_status +=== TEST 19: check http code that matches http_status --- request GET /server_error --- response_body @@ -620,7 +591,7 @@ new body3 -=== TEST 21: check http code that not matches http_status +=== TEST 20: check http code that not matches http_status --- request GET /hello --- response_body @@ -632,7 +603,7 @@ hello world -=== TEST 22: set an empty body with setting body_base64 to true +=== TEST 21: set an empty body with setting body_base64 to true --- config location /t { content_by_lua_block { @@ -656,7 +627,7 @@ invalid base64 content -=== TEST 23: set an nil body with setting body_base64 to true +=== TEST 22: set an nil body with setting body_base64 to true --- config location /t { content_by_lua_block { @@ -679,7 +650,7 @@ invalid base64 content -=== TEST 24: rewrite header with variables +=== TEST 23: rewrite header with variables --- config location /t { content_by_lua_block { @@ -720,7 +691,7 @@ passed -=== TEST 25: hit +=== TEST 24: hit --- request GET /with_header --- response_headers diff --git a/t/plugin/traffic-split3.t b/t/plugin/traffic-split3.t index d8a965fdf797..4851cebd2038 100644 --- a/t/plugin/traffic-split3.t +++ b/t/plugin/traffic-split3.t @@ -525,105 +525,7 @@ upstream_key: roundrobin#route_1_1 -=== TEST 17: schema validation, "additionalProperties = false" to limit the plugin configuration ---- config - location /t { - content_by_lua_block { - local plugin = require("apisix.plugins.traffic-split") - local ok, err = plugin.check_schema({ - additional_properties = "hello", - rules = { - { - match = { - { - vars = { - {"arg_name", "==", "jack"}, - {"arg_age", "!", "<", "16"} - } - }, - { - vars = { - {"arg_name", "==", "rose"}, - {"arg_age", "!", ">", "32"} - } - } - }, - weighted_upstreams = { - { - upstream = { - name = "upstream_A", - type = "roundrobin", - nodes = {["127.0.0.1:1981"]=2}, - timeout = {connect = 15, send = 15, read = 15} - }, - weight = 2 - } - } - } - } - }) - if not ok then - ngx.say(err) - end - - ngx.say("done") - } - } ---- response_body eval -qr/additional properties forbidden, found additional_properties/ - - - -=== TEST 18: schema validation, "additionalProperties = false" to limit the "rules" configuration ---- config - location /t { - content_by_lua_block { - local plugin = require("apisix.plugins.traffic-split") - local ok, err = plugin.check_schema({ - rules = { - { - additional_properties = "hello", - match = { - { - vars = { - {"arg_name", "==", "jack"}, - {"arg_age", "!", "<", "16"} - } - }, - { - vars = { - {"arg_name", "==", "rose"}, - {"arg_age", "!", ">", "32"} - } - } - }, - weighted_upstreams = { - { - upstream = { - name = "upstream_A", - type = "roundrobin", - nodes = {["127.0.0.1:1981"]=2}, - timeout = {connect = 15, send = 15, read = 15} - }, - weight = 2 - } - } - } - } - }) - if not ok then - ngx.say(err) - end - - ngx.say("done") - } - } ---- response_body eval -qr/property "rules" validation failed: failed to validate item 1: additional properties forbidden, found additional_properties/ - - - -=== TEST 19: the request header contains horizontal lines("-") +=== TEST 17: the request header contains horizontal lines("-") --- config location /t { content_by_lua_block { @@ -668,7 +570,7 @@ passed -=== TEST 20: `match` rule passed +=== TEST 18: `match` rule passed --- config location /t { content_by_lua_block { @@ -689,7 +591,7 @@ location /t { -=== TEST 21: request args and request headers contain horizontal lines("-") +=== TEST 19: request args and request headers contain horizontal lines("-") --- config location /t { content_by_lua_block { @@ -734,7 +636,7 @@ passed -=== TEST 22: `match` rule passed +=== TEST 20: `match` rule passed --- config location /t { content_by_lua_block {