This is an automated email from the ASF dual-hosted git repository.

spacewander pushed a commit to branch release/2.15
in repository https://gitbox.apache.org/repos/asf/apisix.git


The following commit(s) were added to refs/heads/release/2.15 by this push:
     new e1c3008c9 fix: use previous way to disable plugins (#8609)
e1c3008c9 is described below

commit e1c3008c9eb7a336390d436ef9ffae6628f498d6
Author: 罗泽轩 <[email protected]>
AuthorDate: Fri Jan 6 15:39:51 2023 +0800

    fix: use previous way to disable plugins (#8609)
    
    Fixes https://github.com/apache/apisix/issues/8603
---
 apisix/plugin.lua  |  4 +++
 t/plugin/plugin2.t | 82 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 86 insertions(+)

diff --git a/apisix/plugin.lua b/apisix/plugin.lua
index 7408786cb..0f7845fe0 100644
--- a/apisix/plugin.lua
+++ b/apisix/plugin.lua
@@ -81,6 +81,10 @@ local function check_disable(plugin_conf)
         return nil
     end
 
+    if plugin_conf.disable then
+        return plugin_conf.disable
+    end
+
     if not plugin_conf._meta then
        return nil
     end
diff --git a/t/plugin/plugin2.t b/t/plugin/plugin2.t
new file mode 100644
index 000000000..71a3593a8
--- /dev/null
+++ b/t/plugin/plugin2.t
@@ -0,0 +1,82 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+use t::APISIX 'no_plan';
+
+add_block_preprocessor(sub {
+    my ($block) = @_;
+
+    $block->set_value("no_error_log", "[error]");
+
+    if (!defined $block->request) {
+        $block->set_value("request", "GET /t");
+    }
+
+    $block;
+});
+
+no_long_string();
+no_root_location();
+log_level("info");
+run_tests;
+
+__DATA__
+
+=== TEST 1: disable plugin in the previous way
+--- 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": {
+                        "limit-count": {
+                            "count": 2,
+                            "time_window": 60,
+                            "rejected_code": 503,
+                            "key": "remote_addr",
+                            "disable": true
+                        }
+                    },
+                    "uri": "/server_port",
+                    "upstream": {
+                        "nodes": {
+                            "127.0.0.1:1980": 1
+                        },
+                        "type": "roundrobin"
+                    }
+                }]]
+            )
+
+            if code >= 300 then
+                ngx.status = code
+            end
+            ngx.say(body)
+        }
+    }
+--- response_body
+passed
+
+
+
+=== TEST 2: hit routes
+--- request
+GET /server_port
+--- raw_response_headers_unlike eval
+qr/X-RateLimit-Limit/
+--- response_body eval
+qr/1980/

Reply via email to