moonming commented on code in PR #7554:
URL: https://github.com/apache/apisix/pull/7554#discussion_r931841965
##########
t/plugin/key-auth.t:
##########
@@ -585,3 +585,84 @@ GET /hello?auth=auth-one
auth: auth-one
--- no_error_log
[error]
+
+
+
+=== TEST 26: add consumer with plugin and username
+--- config
+ location /t {
+ content_by_lua_block {
+ local t = require("lib.test_admin").test
+ local code, body = t('/apisix/admin/consumers',
+ ngx.HTTP_PUT,
+ [[{
+ "username": "bob",
+ "plugins": {
+ "key-auth": {
+ "key": "12345:abc"
+ }
+ }
+ }]]
+ )
+
+ if code >= 300 then
+ ngx.status = code
+ end
+ ngx.say(body)
+ }
+ }
+--- request
+GET /t
+--- response_body
+passed
+--- no_error_log
+[error]
+
+
+
+=== TEST 27: add key-auth plugin with var_combination
+--- 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": {
+ "key-auth": {
+ "var_combination":
"${http_client_id}:${http_client_secret}"
Review Comment:
The example in the document is "$remote_addr $consumer_name", and there is
an extra colon in the test case. So which one is right?
##########
docs/en/latest/plugins/key-auth.md:
##########
@@ -45,8 +45,9 @@ For Route:
| Name | Type | Requirement | Default | Valid | Description
|
|--------|--------|-------------|---------|-------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
-| header | string | optional | apikey | | The header to get the key
from.
|
-| query | string | optional | apikey | | The query string to get
the key from. Lower priority than header.
|
+| var_combination | string | optional | | | Set which variable
combination we get the key from. For example, "$remote_addr $consumer_name"
will be combined into a key after parsing. highest priority. |
+| header | string | optional | apikey | | The header to get the key
from. Lower priority than `var_combination`.
|
Review Comment:
need to add example in doc.
--
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]