mirror of
https://codeberg.org/redict/redict.git
synced 2025-01-23 16:48:27 -05:00
0bfccc55e2
This PR adds a spell checker CI action that will fail future PRs if they introduce typos and spelling mistakes. This spell checker is based on blacklist of common spelling mistakes, so it will not catch everything, but at least it is also unlikely to cause false positives. Besides that, the PR also fixes many spelling mistakes and types, not all are a result of the spell checker we use. Here's a summary of other changes: 1. Scanned the entire source code and fixes all sorts of typos and spelling mistakes (including missing or extra spaces). 2. Outdated function / variable / argument names in comments 3. Fix outdated keyspace masks error log when we check `config.notify-keyspace-events` in loadServerConfigFromString. 4. Trim the white space at the end of line in `module.c`. Check: https://github.com/redis/redis/pull/7751 5. Some outdated https link URLs. 6. Fix some outdated comment. Such as: - In README: about the rdb, we used to said create a `thread`, change to `process` - dbRandomKey function coment (about the dictGetRandomKey, change to dictGetFairRandomKey) - notifyKeyspaceEvent fucntion comment (add type arg) - Some others minor fix in comment (Most of them are incorrectly quoted by variable names) 7. Modified the error log so that users can easily distinguish between TCP and TLS in `changeBindAddr`
71 lines
2.2 KiB
Tcl
71 lines
2.2 KiB
Tcl
set testmodule [file normalize tests/modules/auth.so]
|
|
|
|
start_server {tags {"modules"}} {
|
|
r module load $testmodule
|
|
|
|
test {Modules can create a user that can be authenticated} {
|
|
# Make sure we start authenticated with default user
|
|
r auth default ""
|
|
assert_equal [r acl whoami] "default"
|
|
r auth.createmoduleuser
|
|
|
|
set id [r auth.authmoduleuser]
|
|
assert_equal [r client id] $id
|
|
|
|
# Verify returned id is the same as our current id and
|
|
# we are authenticated with the specified user
|
|
assert_equal [r acl whoami] "global"
|
|
}
|
|
|
|
test {De-authenticating clients is tracked and kills clients} {
|
|
assert_equal [r auth.changecount] 0
|
|
r auth.createmoduleuser
|
|
|
|
# Catch the I/O exception that was thrown when Redis
|
|
# disconnected with us.
|
|
catch { [r ping] } e
|
|
assert_match {*I/O*} $e
|
|
|
|
# Check that a user change was registered
|
|
assert_equal [r auth.changecount] 1
|
|
}
|
|
|
|
test {Modules can't authenticate with ACLs users that dont exist} {
|
|
catch { [r auth.authrealuser auth-module-test-fake] } e
|
|
assert_match {*Invalid user*} $e
|
|
}
|
|
|
|
test {Modules can authenticate with ACL users} {
|
|
assert_equal [r acl whoami] "default"
|
|
|
|
# Create user to auth into
|
|
r acl setuser auth-module-test on allkeys allcommands
|
|
|
|
set id [r auth.authrealuser auth-module-test]
|
|
|
|
# Verify returned id is the same as our current id and
|
|
# we are authenticated with the specified user
|
|
assert_equal [r client id] $id
|
|
assert_equal [r acl whoami] "auth-module-test"
|
|
}
|
|
|
|
test {Client callback is called on user switch} {
|
|
assert_equal [r auth.changecount] 0
|
|
|
|
# Auth again and validate change count
|
|
r auth.authrealuser auth-module-test
|
|
assert_equal [r auth.changecount] 1
|
|
|
|
# Re-auth with the default user
|
|
r auth default ""
|
|
assert_equal [r auth.changecount] 1
|
|
assert_equal [r acl whoami] "default"
|
|
|
|
# Re-auth with the default user again, to
|
|
# verify the callback isn't fired again
|
|
r auth default ""
|
|
assert_equal [r auth.changecount] 0
|
|
assert_equal [r acl whoami] "default"
|
|
}
|
|
|
|
} |