This is an automated email from the ASF dual-hosted git repository.
young pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git
The following commit(s) were added to refs/heads/master by this push:
new 1f2c541a6 feat: admin api no longer populates default values when
writing (#12603)
1f2c541a6 is described below
commit 1f2c541a6fbd3b24d1f6d828ad9942f4efd00d9f
Author: YYYoung <[email protected]>
AuthorDate: Fri Sep 19 08:38:20 2025 +0800
feat: admin api no longer populates default values when writing (#12603)
---
apisix/admin/consumer_group.lua | 7 ++++
apisix/admin/consumers.lua | 7 ++++
apisix/admin/credentials.lua | 8 ++++
apisix/admin/global_rules.lua | 7 ++++
apisix/admin/plugin_config.lua | 7 ++++
apisix/admin/plugin_metadata.lua | 47 ++++++++++++++++-----
apisix/admin/plugins.lua | 9 ++--
apisix/admin/resource.lua | 8 +++-
apisix/admin/routes.lua | 8 ++++
apisix/admin/services.lua | 10 ++++-
apisix/admin/upstreams.lua | 6 +++
apisix/admin/utils.lua | 2 +-
apisix/plugins/request-id.lua | 5 ++-
apisix/upstream.lua | 13 +++---
t/admin/consumer-group.t | 1 -
t/admin/global-rules.t | 44 ++++++++++++++++++--
t/admin/global-rules2.t | 2 +-
t/admin/plugin-configs.t | 89 +++++++++++++++++++++++++++++++++++++++-
t/admin/routes2.t | 8 ++--
t/admin/routes4.t | 3 +-
t/admin/services.t | 7 +---
t/admin/services2.t | 8 ++--
t/admin/ssl2.t | 8 ++--
t/admin/stream-routes.t | 6 +--
t/admin/upstream.t | 1 -
t/admin/upstream2.t | 8 ++--
t/plugin/jwt-auth.t | 31 ++++++--------
t/plugin/proxy-rewrite.t | 2 +-
t/plugin/request-id2.t | 3 +-
t/plugin/response-rewrite.t | 2 +-
30 files changed, 290 insertions(+), 77 deletions(-)
diff --git a/apisix/admin/consumer_group.lua b/apisix/admin/consumer_group.lua
index 9aed58f06..12607ffb6 100644
--- a/apisix/admin/consumer_group.lua
+++ b/apisix/admin/consumer_group.lua
@@ -18,6 +18,7 @@ local core = require("apisix.core")
local consumers = require("apisix.consumer").consumers
local resource = require("apisix.admin.resource")
local schema_plugin = require("apisix.admin.plugins").check_schema
+local plugins_encrypt_conf = require("apisix.admin.plugins").encrypt_conf
local type = type
local tostring = tostring
local ipairs = ipairs
@@ -38,6 +39,11 @@ local function check_conf(id, conf, need_id, schema)
end
+local function encrypt_conf(id, conf)
+ plugins_encrypt_conf(conf.plugins)
+end
+
+
local function delete_checker(id)
local consumers, consumers_ver = consumers()
if consumers_ver and consumers then
@@ -61,6 +67,7 @@ return resource.new({
kind = "consumer group",
schema = core.schema.consumer_group,
checker = check_conf,
+ encrypt_conf = encrypt_conf,
unsupported_methods = {"post"},
delete_checker = delete_checker
})
diff --git a/apisix/admin/consumers.lua b/apisix/admin/consumers.lua
index 0cd17a74d..32b1a9440 100644
--- a/apisix/admin/consumers.lua
+++ b/apisix/admin/consumers.lua
@@ -16,6 +16,7 @@
--
local core = require("apisix.core")
local plugins = require("apisix.admin.plugins")
+local plugins_encrypt_conf = require("apisix.admin.plugins").encrypt_conf
local resource = require("apisix.admin.resource")
@@ -57,10 +58,16 @@ local function check_conf(username, conf, need_username,
schema, opts)
end
+local function encrypt_conf(id, conf)
+ plugins_encrypt_conf(conf.plugins, core.schema.TYPE_CONSUMER)
+end
+
+
return resource.new({
name = "consumers",
kind = "consumer",
schema = core.schema.consumer,
checker = check_conf,
+ encrypt_conf = encrypt_conf,
unsupported_methods = {"post", "patch"}
})
diff --git a/apisix/admin/credentials.lua b/apisix/admin/credentials.lua
index 362286752..d15b78eca 100644
--- a/apisix/admin/credentials.lua
+++ b/apisix/admin/credentials.lua
@@ -18,6 +18,7 @@ local core = require("apisix.core")
local plugins = require("apisix.admin.plugins")
local plugin = require("apisix.plugin")
local resource = require("apisix.admin.resource")
+local plugins_encrypt_conf = require("apisix.admin.plugins").encrypt_conf
local pairs = pairs
local function check_conf(_id, conf, _need_id, schema)
@@ -46,6 +47,12 @@ local function check_conf(_id, conf, _need_id, schema)
return true, nil
end
+
+local function encrypt_conf(id, conf)
+ plugins_encrypt_conf(conf.plugins, core.schema.TYPE_CONSUMER)
+end
+
+
-- get_credential_etcd_key is used to splice the credential's etcd key
(without prefix)
-- from credential_id and sub_path.
-- Parameter credential_id is from the uri or payload; sub_path is in the form
of
@@ -69,6 +76,7 @@ return resource.new({
kind = "credential",
schema = core.schema.credential,
checker = check_conf,
+ encrypt_conf = encrypt_conf,
get_resource_etcd_key = get_credential_etcd_key,
unsupported_methods = {"post", "patch"}
})
diff --git a/apisix/admin/global_rules.lua b/apisix/admin/global_rules.lua
index 81db85052..3531a6c7e 100644
--- a/apisix/admin/global_rules.lua
+++ b/apisix/admin/global_rules.lua
@@ -17,6 +17,7 @@
local core = require("apisix.core")
local resource = require("apisix.admin.resource")
local schema_plugin = require("apisix.admin.plugins").check_schema
+local plugins_encrypt_conf = require("apisix.admin.plugins").encrypt_conf
local function check_conf(id, conf, need_id, schema)
@@ -34,10 +35,16 @@ local function check_conf(id, conf, need_id, schema)
end
+local function encrypt_conf(id, conf)
+ plugins_encrypt_conf(conf.plugins)
+end
+
+
return resource.new({
name = "global_rules",
kind = "global rule",
schema = core.schema.global_rule,
checker = check_conf,
+ encrypt_conf = encrypt_conf,
unsupported_methods = {"post"}
})
diff --git a/apisix/admin/plugin_config.lua b/apisix/admin/plugin_config.lua
index 153a7bd9e..1918e7860 100644
--- a/apisix/admin/plugin_config.lua
+++ b/apisix/admin/plugin_config.lua
@@ -18,6 +18,7 @@ local core = require("apisix.core")
local get_routes = require("apisix.router").http_routes
local resource = require("apisix.admin.resource")
local schema_plugin = require("apisix.admin.plugins").check_schema
+local plugins_encrypt_conf = require("apisix.admin.plugins").encrypt_conf
local type = type
local tostring = tostring
local ipairs = ipairs
@@ -38,6 +39,11 @@ local function check_conf(id, conf, need_id, schema)
end
+local function encrypt_conf(id, conf)
+ plugins_encrypt_conf(conf.plugins)
+end
+
+
local function delete_checker(id)
local routes, routes_ver = get_routes()
if routes_ver and routes then
@@ -61,6 +67,7 @@ return resource.new({
kind = "plugin config",
schema = core.schema.plugin_config,
checker = check_conf,
+ encrypt_conf = encrypt_conf,
unsupported_methods = {"post"},
delete_checker = delete_checker
})
diff --git a/apisix/admin/plugin_metadata.lua b/apisix/admin/plugin_metadata.lua
index 1387ca0ee..c4b54be55 100644
--- a/apisix/admin/plugin_metadata.lua
+++ b/apisix/admin/plugin_metadata.lua
@@ -18,7 +18,7 @@ local pcall = pcall
local require = require
local core = require("apisix.core")
local resource = require("apisix.admin.resource")
-local encrypt_conf = require("apisix.plugin").encrypt_conf
+local plugin_encrypt_conf = require("apisix.plugin").encrypt_conf
local injected_mark = "injected metadata_schema"
@@ -35,6 +35,17 @@ local function validate_plugin(name)
end
+local function inject_metadata_schema(plugin_object)
+ if not plugin_object.metadata_schema then
+ plugin_object.metadata_schema = {
+ type = "object",
+ ['$comment'] = injected_mark,
+ properties = {},
+ }
+ end
+end
+
+
local function check_conf(plugin_name, conf)
if not plugin_name then
return nil, {error_msg = "missing plugin name"}
@@ -45,13 +56,8 @@ local function check_conf(plugin_name, conf)
return nil, {error_msg = "invalid plugin name"}
end
- if not plugin_object.metadata_schema then
- plugin_object.metadata_schema = {
- type = "object",
- ['$comment'] = injected_mark,
- properties = {},
- }
- end
+ inject_metadata_schema(plugin_object)
+
local schema = plugin_object.metadata_schema
local ok, err
@@ -64,8 +70,6 @@ local function check_conf(plugin_name, conf)
ok, err = plugin_object.check_schema(conf, core.schema.TYPE_METADATA)
end
- encrypt_conf(plugin_name, conf, core.schema.TYPE_METADATA)
-
if not ok then
return nil, {error_msg = "invalid configuration: " .. err}
end
@@ -73,11 +77,34 @@ local function check_conf(plugin_name, conf)
return plugin_name
end
+local function encrypt_conf(plugin_name, conf)
+ if not plugin_name then
+ -- This situation shouldn't happen according to the execution order.
+ core.log.info("missing plugin name")
+ return
+ end
+
+ local ok, plugin_object = validate_plugin(plugin_name)
+ if not ok then
+ -- This situation shouldn't happen according to the execution order.
+ core.log.info("invalid plugin name")
+ return
+ end
+
+ inject_metadata_schema(plugin_object)
+
+ local schema = plugin_object.metadata_schema
+ if schema['$comment'] ~= injected_mark and plugin_object.check_schema then
+ plugin_encrypt_conf(plugin_name, conf, core.schema.TYPE_METADATA)
+ end
+end
+
return resource.new({
name = "plugin_metadata",
kind = "plugin_metadata",
schema = core.schema.plugin_metadata,
checker = check_conf,
+ encrypt_conf = encrypt_conf,
unsupported_methods = {"post", "patch"}
})
diff --git a/apisix/admin/plugins.lua b/apisix/admin/plugins.lua
index 201f8f3c9..8494c11c3 100644
--- a/apisix/admin/plugins.lua
+++ b/apisix/admin/plugins.lua
@@ -31,13 +31,16 @@ local _M = {}
function _M.check_schema(plugins_conf, schema_type)
- local ok, err = check_schema(plugins_conf, schema_type, false)
- if ok then
+ return check_schema(plugins_conf, schema_type, false)
+end
+
+
+function _M.encrypt_conf(plugins_conf, schema_type)
+ if plugins_conf then
for name, conf in pairs(plugins_conf) do
encrypt_conf(name, conf, schema_type)
end
end
- return ok, err
end
diff --git a/apisix/admin/resource.lua b/apisix/admin/resource.lua
index 6491b3a96..cb4822ed7 100644
--- a/apisix/admin/resource.lua
+++ b/apisix/admin/resource.lua
@@ -18,6 +18,7 @@ local core = require("apisix.core")
local utils = require("apisix.admin.utils")
local apisix_ssl = require("apisix.ssl")
local apisix_consumer = require("apisix.consumer")
+local tbl_deepcopy = require("apisix.core.table").deepcopy
local setmetatable = setmetatable
local tostring = tostring
local ipairs = ipairs
@@ -123,7 +124,12 @@ function _M:check_conf(id, conf, need_id, typ, allow_time)
core.log.info("schema: ", core.json.delay_encode(self.schema))
end
- local ok, err = self.checker(id, conf, need_id, self.schema, {secret_type
= typ})
+ local conf_for_check = tbl_deepcopy(conf)
+ local ok, err = self.checker(id, conf_for_check, need_id, self.schema,
{secret_type = typ})
+
+ if self.encrypt_conf then
+ self.encrypt_conf(id, conf)
+ end
if not ok then
return ok, err
diff --git a/apisix/admin/routes.lua b/apisix/admin/routes.lua
index ba80aca86..9896e800f 100644
--- a/apisix/admin/routes.lua
+++ b/apisix/admin/routes.lua
@@ -19,6 +19,7 @@ local core = require("apisix.core")
local apisix_upstream = require("apisix.upstream")
local resource = require("apisix.admin.resource")
local schema_plugin = require("apisix.admin.plugins").check_schema
+local plugins_encrypt_conf = require("apisix.admin.plugins").encrypt_conf
local type = type
local loadstring = loadstring
local ipairs = ipairs
@@ -173,11 +174,18 @@ local function check_conf(id, conf, need_id, schema, opts)
end
+local function encrypt_conf(id, conf)
+ apisix_upstream.encrypt_conf(conf.upstream)
+ plugins_encrypt_conf(conf.plugins)
+end
+
+
return resource.new({
name = "routes",
kind = "route",
schema = core.schema.route,
checker = check_conf,
+ encrypt_conf = encrypt_conf,
list_filter_fields = {
service_id = true,
upstream_id = true,
diff --git a/apisix/admin/services.lua b/apisix/admin/services.lua
index cf2de62e8..3f2468611 100644
--- a/apisix/admin/services.lua
+++ b/apisix/admin/services.lua
@@ -20,6 +20,7 @@ local get_stream_routes =
require("apisix.router").stream_routes
local apisix_upstream = require("apisix.upstream")
local resource = require("apisix.admin.resource")
local schema_plugin = require("apisix.admin.plugins").check_schema
+local plugins_encrypt_conf = require("apisix.admin.plugins").encrypt_conf
local tostring = tostring
local ipairs = ipairs
local type = type
@@ -120,10 +121,17 @@ local function delete_checker(id)
end
+local function encrypt_conf(id, conf)
+ apisix_upstream.encrypt_conf(conf.upstream)
+ plugins_encrypt_conf(conf.plugins)
+end
+
+
return resource.new({
name = "services",
kind = "service",
schema = core.schema.service,
checker = check_conf,
- delete_checker = delete_checker
+ encrypt_conf = encrypt_conf,
+ delete_checker = delete_checker,
})
diff --git a/apisix/admin/upstreams.lua b/apisix/admin/upstreams.lua
index 6c04d9379..f94883768 100644
--- a/apisix/admin/upstreams.lua
+++ b/apisix/admin/upstreams.lua
@@ -38,6 +38,11 @@ local function check_conf(id, conf, need_id)
end
+local function encrypt_conf(id, conf)
+ apisix_upstream.encrypt_conf(conf)
+end
+
+
local function up_id_in_plugins(plugins, up_id)
if plugins and plugins["traffic-split"]
and plugins["traffic-split"].rules then
@@ -130,5 +135,6 @@ return resource.new({
kind = "upstream",
schema = core.schema.upstream,
checker = check_conf,
+ encrypt_conf = encrypt_conf,
delete_checker = delete_checker
})
diff --git a/apisix/admin/utils.lua b/apisix/admin/utils.lua
index eee2787f0..6ce4ea378 100644
--- a/apisix/admin/utils.lua
+++ b/apisix/admin/utils.lua
@@ -106,7 +106,7 @@ function _M.decrypt_params(decrypt_func, body, schema_type)
-- metadata
if schema_type == core.schema.TYPE_METADATA then
local conf = body.node and body.node.value
- decrypt_func(conf.name, conf, schema_type)
+ decrypt_func(conf.id, conf, schema_type)
end
end
diff --git a/apisix/plugins/request-id.lua b/apisix/plugins/request-id.lua
index d9569302a..7eb06389f 100644
--- a/apisix/plugins/request-id.lua
+++ b/apisix/plugins/request-id.lua
@@ -51,7 +51,10 @@ local schema = {
default =
"abcdefghijklmnopqrstuvwxyzABCDEFGHIGKLMNOPQRSTUVWXYZ0123456789"
}
},
- default = {}
+ default = {
+ length = 16,
+ char_set =
"abcdefghijklmnopqrstuvwxyzABCDEFGHIGKLMNOPQRSTUVWXYZ0123456789"
+ }
}
}
}
diff --git a/apisix/upstream.lua b/apisix/upstream.lua
index fb47deb63..ad374b7b5 100644
--- a/apisix/upstream.lua
+++ b/apisix/upstream.lua
@@ -396,11 +396,6 @@ local function check_upstream_conf(in_dp, conf)
.. "wrong ssl type"
end
end
-
- -- encrypt the key in the admin
- if conf.tls and conf.tls.client_key then
- conf.tls.client_key =
apisix_ssl.aes_encrypt_pkey(conf.tls.client_key)
- end
end
if is_http then
@@ -449,6 +444,14 @@ function _M.check_upstream_conf(conf)
end
+function _M.encrypt_conf(conf)
+ -- encrypt the key in the admin
+ if conf and conf.tls and conf.tls.client_key then
+ conf.tls.client_key = apisix_ssl.aes_encrypt_pkey(conf.tls.client_key)
+ end
+end
+
+
local function filter_upstream(value, parent)
if not value then
return
diff --git a/t/admin/consumer-group.t b/t/admin/consumer-group.t
index 176ed9f8a..305afe48f 100644
--- a/t/admin/consumer-group.t
+++ b/t/admin/consumer-group.t
@@ -135,7 +135,6 @@ passed
"plugins": {
"limit-count": {
"time_window": 60,
- "policy": "local",
"count": 2,
"key": "remote_addr",
"rejected_code": 503
diff --git a/t/admin/global-rules.t b/t/admin/global-rules.t
index 0819f2d3e..f93f84399 100644
--- a/t/admin/global-rules.t
+++ b/t/admin/global-rules.t
@@ -127,7 +127,6 @@ passed
"plugins": {
"limit-count": {
"time_window": 60,
- "policy": "local",
"count": 2,
"key": "remote_addr",
"rejected_code": 503
@@ -403,7 +402,7 @@ passed
}
}
--- response_body
-{"key":"/apisix/global_rules/1","value":{"id":"1","plugins":{"proxy-rewrite":{"uri":"/","use_real_request_uri_unsafe":false}}}}
+{"key":"/apisix/global_rules/1","value":{"id":"1","plugins":{"proxy-rewrite":{"uri":"/"}}}}
--- request
GET /t
@@ -439,7 +438,7 @@ GET /t
}
}
--- response_body
-{"key":"/apisix/global_rules/1","value":{"id":"1","plugins":{"proxy-rewrite":{"uri":"/","use_real_request_uri_unsafe":false}}}}
+{"key":"/apisix/global_rules/1","value":{"id":"1","plugins":{"proxy-rewrite":{"uri":"/"}}}}
--- request
GET /t
@@ -474,7 +473,7 @@ GET /t
}
}
--- response_body
-{"key":"/apisix/global_rules/1","value":{"id":"1","plugins":{"proxy-rewrite":{"uri":"/","use_real_request_uri_unsafe":false}}}}
+{"key":"/apisix/global_rules/1","value":{"id":"1","plugins":{"proxy-rewrite":{"uri":"/"}}}}
--- request
GET /t
@@ -504,3 +503,40 @@ GET /t
{"deleted":"1","key":"/apisix/global_rules/1"}
--- request
GET /t
+
+
+
+=== TEST 15: not unwanted data, PUT with use_real_request_uri_unsafe
+--- config
+ location /t {
+ content_by_lua_block {
+ local json = require("toolkit.json")
+ local t = require("lib.test_admin").test
+ local code, message, res = t('/apisix/admin/global_rules/1',
+ ngx.HTTP_PUT,
+ [[{
+ "plugins": {
+ "proxy-rewrite": {
+ "uri": "/",
+ "use_real_request_uri_unsafe": true
+ }
+ }
+ }]]
+ )
+
+ if code >= 300 then
+ ngx.status = code
+ ngx.say(message)
+ return
+ end
+
+ res = json.decode(res)
+ res.value.create_time = nil
+ res.value.update_time = nil
+ ngx.say(json.encode(res))
+ }
+ }
+--- response_body
+{"key":"/apisix/global_rules/1","value":{"id":"1","plugins":{"proxy-rewrite":{"uri":"/","use_real_request_uri_unsafe":true}}}}
+--- request
+GET /t
diff --git a/t/admin/global-rules2.t b/t/admin/global-rules2.t
index 345f67f62..1e910f505 100644
--- a/t/admin/global-rules2.t
+++ b/t/admin/global-rules2.t
@@ -94,7 +94,7 @@ __DATA__
}
}
--- response_body
-{"key":"/apisix/global_rules/1","value":{"id":"1","plugins":{"proxy-rewrite":{"uri":"/","use_real_request_uri_unsafe":false}}}}
+{"key":"/apisix/global_rules/1","value":{"id":"1","plugins":{"proxy-rewrite":{"uri":"/"}}}}
diff --git a/t/admin/plugin-configs.t b/t/admin/plugin-configs.t
index 852631666..ab6d2592b 100644
--- a/t/admin/plugin-configs.t
+++ b/t/admin/plugin-configs.t
@@ -135,7 +135,6 @@ passed
"plugins": {
"limit-count": {
"time_window": 60,
- "policy": "local",
"count": 2,
"key": "remote_addr",
"rejected_code": 503
@@ -521,3 +520,91 @@ passed
}
--- response_body
passed
+
+
+
+=== TEST 15: PUT with limit-count policy=local
+--- config
+ location /t {
+ content_by_lua_block {
+ local t = require("lib.test_admin").test
+ local etcd = require("apisix.core.etcd")
+ local code, body = t('/apisix/admin/plugin_configs/1',
+ ngx.HTTP_PUT,
+ [[{
+ "plugins": {
+ "limit-count": {
+ "count": 2,
+ "time_window": 60,
+ "rejected_code": 503,
+ "key": "remote_addr",
+ "policy": "local"
+ }
+ }
+ }]],
+ [[{
+ "value": {
+ "plugins": {
+ "limit-count": {
+ "count": 2,
+ "time_window": 60,
+ "rejected_code": 503,
+ "key": "remote_addr",
+ "policy": "local"
+ }
+ }
+ },
+ "key": "/apisix/plugin_configs/1"
+ }]]
+ )
+
+ ngx.status = code
+ ngx.say(body)
+
+ local res = assert(etcd.get('/plugin_configs/1'))
+ local create_time = res.body.node.value.create_time
+ assert(create_time ~= nil, "create_time is nil")
+ local update_time = res.body.node.value.update_time
+ assert(update_time ~= nil, "update_time is nil")
+ }
+ }
+--- response_body
+passed
+
+
+
+=== TEST 16: GET all with limit-count policy=local
+--- config
+ location /t {
+ content_by_lua_block {
+ local t = require("lib.test_admin").test
+ local code, body = t('/apisix/admin/plugin_configs',
+ ngx.HTTP_GET,
+ nil,
+ [[{
+ "total": 1,
+ "list": [
+ {
+ "key": "/apisix/plugin_configs/1",
+ "value": {
+ "plugins": {
+ "limit-count": {
+ "time_window": 60,
+ "count": 2,
+ "key": "remote_addr",
+ "rejected_code": 503,
+ "policy": "local"
+ }
+ }
+ }
+ }
+ ]
+ }]]
+ )
+
+ ngx.status = code
+ ngx.say(body)
+ }
+ }
+--- response_body
+passed
diff --git a/t/admin/routes2.t b/t/admin/routes2.t
index 41d11cf42..fc12ffbe9 100644
--- a/t/admin/routes2.t
+++ b/t/admin/routes2.t
@@ -197,7 +197,7 @@ GET /t
--- request
GET /t
--- response_body
-{"value":{"methods":["GET"],"priority":0,"status":1,"upstream":{"hash_on":"vars","nodes":{"127.0.0.1:8080":1},"pass_host":"pass","scheme":"http","type":"roundrobin"},"uri":"/not_unwanted_data_post"}}
+{"value":{"methods":["GET"],"upstream":{"nodes":{"127.0.0.1:8080":1},"type":"roundrobin"},"uri":"/not_unwanted_data_post"}}
@@ -237,7 +237,7 @@ GET /t
--- request
GET /t
--- response_body
-{"key":"/apisix/routes/1","value":{"id":1,"methods":["GET"],"priority":0,"status":1,"upstream":{"hash_on":"vars","nodes":{"127.0.0.1:8080":1},"pass_host":"pass","scheme":"http","type":"roundrobin"},"uri":"/index.html"}}
+{"key":"/apisix/routes/1","value":{"id":1,"methods":["GET"],"upstream":{"nodes":{"127.0.0.1:8080":1},"type":"roundrobin"},"uri":"/index.html"}}
@@ -276,7 +276,7 @@ GET /t
--- request
GET /t
--- response_body
-{"key":"/apisix/routes/1","value":{"id":"1","methods":["GET"],"priority":0,"status":1,"upstream":{"hash_on":"vars","nodes":{"127.0.0.1:8080":1},"pass_host":"pass","scheme":"http","type":"roundrobin"},"uri":"/index"}}
+{"key":"/apisix/routes/1","value":{"id":"1","methods":["GET"],"upstream":{"nodes":{"127.0.0.1:8080":1},"type":"roundrobin"},"uri":"/index"}}
@@ -311,7 +311,7 @@ GET /t
--- request
GET /t
--- response_body
-{"key":"/apisix/routes/1","value":{"id":"1","methods":["GET"],"priority":0,"status":1,"upstream":{"hash_on":"vars","nodes":{"127.0.0.1:8080":1},"pass_host":"pass","scheme":"http","type":"roundrobin"},"uri":"/index"}}
+{"key":"/apisix/routes/1","value":{"id":"1","methods":["GET"],"upstream":{"nodes":{"127.0.0.1:8080":1},"type":"roundrobin"},"uri":"/index"}}
diff --git a/t/admin/routes4.t b/t/admin/routes4.t
index 0bab4506b..8ae024b8b 100644
--- a/t/admin/routes4.t
+++ b/t/admin/routes4.t
@@ -193,7 +193,8 @@ location /t {
"type": "roundrobin"
},
"desc": "new route",
- "uri": "/index.html"
+ "uri": "/index.html",
+ "priority": 0
}]],
[[{
"value": {
diff --git a/t/admin/services.t b/t/admin/services.t
index 90a5e9271..77613195c 100644
--- a/t/admin/services.t
+++ b/t/admin/services.t
@@ -1009,17 +1009,14 @@ passed
"time_window":60,
"count":2,
"rejected_code":503,
- "key":"remote_addr",
- "policy":"local"
+ "key":"remote_addr"
}
},
"upstream":{
"type":"roundrobin",
"nodes":{
"127.0.0.1:80":1
- },
- "hash_on":"vars",
- "pass_host":"pass"
+ }
},
"id":"1"
}
diff --git a/t/admin/services2.t b/t/admin/services2.t
index a47592bad..d40a6fc16 100644
--- a/t/admin/services2.t
+++ b/t/admin/services2.t
@@ -74,7 +74,7 @@ __DATA__
}
}
--- response_body
-{"value":{"upstream":{"hash_on":"vars","nodes":{"127.0.0.1:8080":1},"pass_host":"pass","scheme":"http","type":"roundrobin"}}}
+{"value":{"upstream":{"nodes":{"127.0.0.1:8080":1},"type":"roundrobin"}}}
@@ -109,7 +109,7 @@ __DATA__
}
}
--- response_body
-{"key":"/apisix/services/1","value":{"id":"1","upstream":{"hash_on":"vars","nodes":{"127.0.0.1:8080":1},"pass_host":"pass","scheme":"http","type":"roundrobin"}}}
+{"key":"/apisix/services/1","value":{"id":"1","upstream":{"nodes":{"127.0.0.1:8080":1},"type":"roundrobin"}}}
@@ -144,7 +144,7 @@ __DATA__
}
}
--- response_body
-{"key":"/apisix/services/1","value":{"id":"1","upstream":{"hash_on":"vars","nodes":{"127.0.0.1:8080":1},"pass_host":"pass","scheme":"http","type":"roundrobin"}}}
+{"key":"/apisix/services/1","value":{"id":"1","upstream":{"nodes":{"127.0.0.1:8080":1},"type":"roundrobin"}}}
@@ -175,7 +175,7 @@ __DATA__
}
}
--- response_body
-{"key":"/apisix/services/1","value":{"id":"1","upstream":{"hash_on":"vars","nodes":{"127.0.0.1:8080":1},"pass_host":"pass","scheme":"http","type":"roundrobin"}}}
+{"key":"/apisix/services/1","value":{"id":"1","upstream":{"nodes":{"127.0.0.1:8080":1},"type":"roundrobin"}}}
diff --git a/t/admin/ssl2.t b/t/admin/ssl2.t
index 15abf37eb..fcac3ab9e 100644
--- a/t/admin/ssl2.t
+++ b/t/admin/ssl2.t
@@ -76,7 +76,7 @@ __DATA__
}
}
--- response_body
-{"value":{"cert":"","key":"","sni":"not-unwanted-post.com","status":1,"type":"server"}}
+{"value":{"cert":"","key":"","sni":"not-unwanted-post.com"}}
@@ -113,7 +113,7 @@ __DATA__
}
}
--- response_body
-{"key":"/apisix/ssls/1","value":{"cert":"","id":"1","key":"","sni":"test.com","status":1,"type":"server"}}
+{"key":"/apisix/ssls/1","value":{"cert":"","id":"1","key":"","sni":"test.com"}}
@@ -150,7 +150,7 @@ __DATA__
}
}
--- response_body
-{"key":"/apisix/ssls/1","value":{"cert":"","id":"1","key":"","sni":"t.com","status":1,"type":"server"}}
+{"key":"/apisix/ssls/1","value":{"cert":"","id":"1","key":"","sni":"t.com"}}
@@ -186,7 +186,7 @@ __DATA__
}
}
--- response_body
-{"key":"/apisix/ssls/1","value":{"cert":"","id":"1","sni":"t.com","status":1,"type":"server"}}
+{"key":"/apisix/ssls/1","value":{"cert":"","id":"1","sni":"t.com"}}
diff --git a/t/admin/stream-routes.t b/t/admin/stream-routes.t
index 77a6d5bad..cc3f27ecb 100644
--- a/t/admin/stream-routes.t
+++ b/t/admin/stream-routes.t
@@ -421,7 +421,7 @@ GET /t
}
}
--- response_body
-{"value":{"remote_addr":"127.0.0.1","upstream":{"hash_on":"vars","nodes":{"127.0.0.1:8080":1},"pass_host":"pass","scheme":"http","type":"roundrobin"}}}
+{"value":{"remote_addr":"127.0.0.1","upstream":{"nodes":{"127.0.0.1:8080":1},"type":"roundrobin"}}}
--- request
GET /t
@@ -461,7 +461,7 @@ GET /t
}
}
--- response_body
-{"key":"/apisix/stream_routes/1","value":{"id":"1","remote_addr":"127.0.0.1","upstream":{"hash_on":"vars","nodes":{"127.0.0.1:8080":1},"pass_host":"pass","scheme":"http","type":"roundrobin"}}}
+{"key":"/apisix/stream_routes/1","value":{"id":"1","remote_addr":"127.0.0.1","upstream":{"nodes":{"127.0.0.1:8080":1},"type":"roundrobin"}}}
--- request
GET /t
@@ -496,7 +496,7 @@ GET /t
}
}
--- response_body
-{"key":"/apisix/stream_routes/1","value":{"id":"1","remote_addr":"127.0.0.1","upstream":{"hash_on":"vars","nodes":{"127.0.0.1:8080":1},"pass_host":"pass","scheme":"http","type":"roundrobin"}}}
+{"key":"/apisix/stream_routes/1","value":{"id":"1","remote_addr":"127.0.0.1","upstream":{"nodes":{"127.0.0.1:8080":1},"type":"roundrobin"}}}
--- request
GET /t
diff --git a/t/admin/upstream.t b/t/admin/upstream.t
index b92a2f403..cbc44d49a 100644
--- a/t/admin/upstream.t
+++ b/t/admin/upstream.t
@@ -708,7 +708,6 @@ GET /t
"nodes": {
"127.0.0.1:8080": 1
},
- "type": "roundrobin",
"desc": "new upstream"
},
"key": "/apisix/upstreams/admin_up"
diff --git a/t/admin/upstream2.t b/t/admin/upstream2.t
index 618861c74..dadf507e7 100644
--- a/t/admin/upstream2.t
+++ b/t/admin/upstream2.t
@@ -73,7 +73,7 @@ __DATA__
}
}
--- response_body
-{"value":{"hash_on":"vars","nodes":{"127.0.0.1:8080":1},"pass_host":"pass","scheme":"http","type":"roundrobin"}}
+{"value":{"nodes":{"127.0.0.1:8080":1},"type":"roundrobin"}}
@@ -108,7 +108,7 @@ __DATA__
}
}
--- response_body
-{"key":"/apisix/upstreams/unwanted","value":{"hash_on":"vars","id":"unwanted","nodes":{"127.0.0.1:8080":1},"pass_host":"pass","scheme":"http","type":"roundrobin"}}
+{"key":"/apisix/upstreams/unwanted","value":{"id":"unwanted","nodes":{"127.0.0.1:8080":1},"type":"roundrobin"}}
@@ -143,7 +143,7 @@ __DATA__
}
}
--- response_body
-{"key":"/apisix/upstreams/unwanted","value":{"hash_on":"vars","id":"unwanted","nodes":{"127.0.0.1:8080":1},"pass_host":"pass","scheme":"http","type":"roundrobin"}}
+{"key":"/apisix/upstreams/unwanted","value":{"id":"unwanted","nodes":{"127.0.0.1:8080":1},"type":"roundrobin"}}
@@ -174,7 +174,7 @@ __DATA__
}
}
--- response_body
-{"key":"/apisix/upstreams/unwanted","value":{"hash_on":"vars","id":"unwanted","nodes":{"127.0.0.1:8080":1},"pass_host":"pass","scheme":"http","type":"roundrobin"}}
+{"key":"/apisix/upstreams/unwanted","value":{"id":"unwanted","nodes":{"127.0.0.1:8080":1},"type":"roundrobin"}}
diff --git a/t/plugin/jwt-auth.t b/t/plugin/jwt-auth.t
index 0a7110330..91f883feb 100644
--- a/t/plugin/jwt-auth.t
+++ b/t/plugin/jwt-auth.t
@@ -1001,25 +1001,20 @@ base64_secret required but the secret is not in base64
format
--- config
location /t {
content_by_lua_block {
- local t = require("lib.test_admin").test
- local code, body, res = t('/apisix/admin/consumers',
- ngx.HTTP_PUT,
- [[{
- "username": "kerouac",
- "plugins": {
- "jwt-auth": {
- "key": "exp-not-set",
- "secret": "my-secret-key"
- }
- }
- }]]
- )
-
- res = require("toolkit.json").decode(res)
- assert(res.value.plugins["jwt-auth"].exp == 86400)
+ local core = require("apisix.core")
+ local plugin = require("apisix.plugins.jwt-auth")
+ local conf = {
+ key = "exp-not-set",
+ secret = "my-secret-key"
+ }
+ local ok, err = plugin.check_schema(conf,
core.schema.TYPE_CONSUMER)
- ngx.status = code
- ngx.say(body)
+ if not ok then
+ ngx.say(err)
+ else
+ assert(conf.exp == 86400, "exp should be 86400")
+ ngx.say("passed")
+ end
}
}
--- response_body
diff --git a/t/plugin/proxy-rewrite.t b/t/plugin/proxy-rewrite.t
index 4d7465862..276dd02ed 100644
--- a/t/plugin/proxy-rewrite.t
+++ b/t/plugin/proxy-rewrite.t
@@ -1000,7 +1000,7 @@ q: apisix)
--- request
GET /t
--- response_body
-{"proxy-rewrite":{"headers":{"X-Api":"v2"},"uri":"/uri/plugin_proxy_rewrite","use_real_request_uri_unsafe":false}}
+{"proxy-rewrite":{"headers":{"X-Api":"v2"},"uri":"/uri/plugin_proxy_rewrite"}}
diff --git a/t/plugin/request-id2.t b/t/plugin/request-id2.t
index 421a0891c..6a91af85e 100644
--- a/t/plugin/request-id2.t
+++ b/t/plugin/request-id2.t
@@ -122,8 +122,7 @@ GET /opentracing
[[{
"plugins": {
"request-id": {
- "algorithm": "range_id",
- "range_id": {}
+ "algorithm": "range_id"
}
},
"upstream": {
diff --git a/t/plugin/response-rewrite.t b/t/plugin/response-rewrite.t
index 2e4dcf4eb..fda43bedc 100644
--- a/t/plugin/response-rewrite.t
+++ b/t/plugin/response-rewrite.t
@@ -449,7 +449,7 @@ invalid base64 content
--- request
GET /t
--- response_body
-{"response-rewrite":{"body":"new
body\n","body_base64":false,"headers":{"Content-Type":"","X-Server-id":3,"X-Server-status":"on"}}}
+{"response-rewrite":{"body":"new
body\n","headers":{"Content-Type":"","X-Server-id":3,"X-Server-status":"on"}}}