diff options
author | guybe7 <guy.benoish@redislabs.com> | 2021-11-23 09:38:25 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-23 10:38:25 +0200 |
commit | b161cff5f92a01acc23ac4ff533e65bda579e1a6 (patch) | |
tree | 71f279b7b43efc944bcc143f60941ee541cab658 /tests | |
parent | f07dedf73facfed5044efaf2a7a780581bf73ffa (diff) | |
download | redis-b161cff5f92a01acc23ac4ff533e65bda579e1a6.tar.gz |
QUIT is a command, HOST: and POST are not (#9798)
Some people complain that QUIT is missing from help/command table.
Not appearing in COMMAND command, command stats, ACL, etc.
and instead, there's a hack in processCommand with a comment that looks outdated.
Note that it is [documented](https://redis.io/commands/quit)
At the same time, HOST: and POST are there in the command table although these are not real commands.
They would appear in the COMMAND command, and even in commandstats.
Other changes:
1. Initialize the static logged_time static var in securityWarningCommand
2. add `no-auth` flag to RESET so it can always be executed.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/modules/misc.c | 11 | ||||
-rw-r--r-- | tests/unit/info.tcl | 8 | ||||
-rw-r--r-- | tests/unit/moduleapi/misc.tcl | 6 |
3 files changed, 17 insertions, 8 deletions
diff --git a/tests/modules/misc.c b/tests/modules/misc.c index 88039c6dd..daed69952 100644 --- a/tests/modules/misc.c +++ b/tests/modules/misc.c @@ -295,6 +295,14 @@ int test_log_tsctx(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) return REDISMODULE_OK; } +int test_weird_cmd(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { + REDISMODULE_NOT_USED(argv); + REDISMODULE_NOT_USED(argc); + + RedisModule_ReplyWithSimpleString(ctx, "OK"); + return REDISMODULE_OK; +} + int RedisModule_OnLoad(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { REDISMODULE_NOT_USED(argv); REDISMODULE_NOT_USED(argc); @@ -331,6 +339,9 @@ int RedisModule_OnLoad(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) return REDISMODULE_ERR; if (RedisModule_CreateCommand(ctx,"test.log_tsctx", test_log_tsctx,"",0,0,0) == REDISMODULE_ERR) return REDISMODULE_ERR; + /* Add a command with ':' in it's name, so that we can check commandstats sanitization. */ + if (RedisModule_CreateCommand(ctx,"test.weird:cmd", test_weird_cmd,"readonly",0,0,0) == REDISMODULE_ERR) + return REDISMODULE_ERR; return REDISMODULE_OK; } diff --git a/tests/unit/info.tcl b/tests/unit/info.tcl index 9c76f8f03..7e383bec3 100644 --- a/tests/unit/info.tcl +++ b/tests/unit/info.tcl @@ -164,12 +164,4 @@ start_server {tags {"info" "external:skip"}} { assert_match {} [errorstat NOPERM] } } - - start_server {} { - test {Unsafe command names are sanitized in INFO output} { - catch {r host:} e - set info [r info commandstats] - assert_match {*cmdstat_host_:calls=1*} $info - } - } } diff --git a/tests/unit/moduleapi/misc.tcl b/tests/unit/moduleapi/misc.tcl index a74c89aec..091de4a87 100644 --- a/tests/unit/moduleapi/misc.tcl +++ b/tests/unit/moduleapi/misc.tcl @@ -122,4 +122,10 @@ start_server {tags {"modules"}} { test {test RM_Call CLIENT INFO} { assert_match "*fd=-1*" [r test.call_generic client info] } + + test {Unsafe command names are sanitized in INFO output} { + r test.weird:cmd + set info [r info commandstats] + assert_match {*cmdstat_test.weird_cmd:calls=1*} $info + } } |