You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by we...@apache.org on 2020/02/20 07:23:40 UTC
[incubator-apisix] branch master updated: bugfix: checked
`consumer` first, it maybe a boolean value when it was beed deleted. (#1139)
This is an automated email from the ASF dual-hosted git repository.
wenming pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-apisix.git
The following commit(s) were added to refs/heads/master by this push:
new fbb9bd0 bugfix: checked `consumer` first, it maybe a boolean value when it was beed deleted. (#1139)
fbb9bd0 is described below
commit fbb9bd039c528b9cd02d621304fb6f9eb9de7aa0
Author: YuanSheng Wang <me...@gmail.com>
AuthorDate: Thu Feb 20 15:23:30 2020 +0800
bugfix: checked `consumer` first, it maybe a boolean value when it was beed deleted. (#1139)
---
lua/apisix/consumer.lua | 7 ++++++
t/plugin/jwt-auth.t | 61 ++++++++++++++++++++++++++++++++++++++++++++++---
2 files changed, 65 insertions(+), 3 deletions(-)
diff --git a/lua/apisix/consumer.lua b/lua/apisix/consumer.lua
index fd0c91b..31dfa05 100644
--- a/lua/apisix/consumer.lua
+++ b/lua/apisix/consumer.lua
@@ -19,6 +19,7 @@ local plugin = require("apisix.plugin")
local error = error
local ipairs = ipairs
local pairs = pairs
+local type = type
local consumers
@@ -35,6 +36,10 @@ local function plugin_consumer()
end
for _, consumer in ipairs(consumers.values) do
+ if type(consumer) ~= "table" then
+ goto CONTINUE
+ end
+
for name, config in pairs(consumer.value.plugins or {}) do
local plugin_obj = plugin.get(name)
if plugin_obj and plugin_obj.type == "auth" then
@@ -54,6 +59,8 @@ local function plugin_consumer()
break
end
end
+
+ ::CONTINUE::
end
return plugins
diff --git a/t/plugin/jwt-auth.t b/t/plugin/jwt-auth.t
index fa91d59..d910bc2 100644
--- a/t/plugin/jwt-auth.t
+++ b/t/plugin/jwt-auth.t
@@ -29,9 +29,7 @@ __DATA__
location /t {
content_by_lua_block {
local plugin = require("apisix.plugins.jwt-auth")
- local conf = {
-
- }
+ local conf = {}
local ok, err = plugin.check_schema(conf)
if not ok then
@@ -272,3 +270,60 @@ Authorization: bearer invalid-eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJrZXkiOiJ1c
{"message":"invalid header: invalid-eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9"}
--- no_error_log
[error]
+
+
+
+=== TEST 16: delete a exist consumer
+--- config
+ location /t {
+ content_by_lua_block {
+ ngx.sleep(1)
+
+ local t = require("lib.test_admin").test
+ local code, body = t('/apisix/admin/consumers',
+ ngx.HTTP_PUT,
+ [[{
+ "username": "jack",
+ "plugins": {
+ "jwt-auth": {
+ "key": "user-key",
+ "secret": "my-secret-key"
+ }
+ }
+ }]]
+ )
+ ngx.say("code: ", code < 300, " body: ", body)
+
+ code, body = t('/apisix/admin/consumers',
+ ngx.HTTP_PUT,
+ [[{
+ "username": "chen",
+ "plugins": {
+ "jwt-auth": {
+ "key": "chen-key",
+ "secret": "chen-key"
+ }
+ }
+ }]]
+ )
+ ngx.say("code: ", code < 300, " body: ", body)
+
+ code, body = t('/apisix/admin/consumers/jack',
+ ngx.HTTP_DELETE)
+ ngx.say("code: ", code < 300, " body: ", body)
+
+ ngx.sleep(1)
+ code, body = t('/apisix/plugin/jwt/sign?key=chen-key',
+ ngx.HTTP_GET)
+ ngx.say("code: ", code < 300, " body: ", body)
+ }
+ }
+--- request
+GET /t
+--- response_body
+code: true body: passed
+code: true body: passed
+code: true body: passed
+code: true body: passed
+--- no_error_log
+[error]