nic-6443 commented on a change in pull request #6512: URL: https://github.com/apache/apisix/pull/6512#discussion_r824545133
########## File path: t/plugin/recaptcha.t ########## @@ -0,0 +1,242 @@ +# +# 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'; + +log_level('debug'); +repeat_each(1); +no_long_string(); +no_root_location(); +run_tests; + + +__DATA__ + +=== TEST 1: sanity +--- config + location /t { + content_by_lua_block { + local plugin = require("apisix.plugins.recaptcha") + local ok, err = plugin.check_schema({ + # https://developers.google.com/recaptcha/docs/faq#id-like-to-run-automated-tests-with-recaptcha + secret_key = "6LeIxAcTAAAAAGG-vFI1TnRWxMZNFuojJ4WifJWe", # Google automated-tests secret key + parameter_source = "header", + parameter_name = "captcha", + response = { + content_type = "application/json; charset=utf-8", + status_code = 400, + body = "{\"message\":\"invalid captcha\"}\n" + } + }) + if not ok then + ngx.say(err) + end + + ngx.say("done") + } + } +--- request Review comment: What he means is that there are duplicate fields in these test cases, e.g. ``` --- request GET /t --- no_error_log [error] ``` You can use the script provided above to remove these duplicate fields, and then use `add_block_preprocessor` to take care of them. See: https://github.com/apache/apisix/blob/0c2ba4bca6192fc200a34ff7b7bebf44a079f0df/docs/en/latest/internal/testing-framework.md?plain=1#L47-L63 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
