"Fossies" - the Fresh Open Source Software Archive

Member "redis-7.0.5/tests/sentinel/tests/09-acl-support.tcl" (21 Sep 2022, 1669 Bytes) of package /linux/misc/redis-7.0.5.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Tcl/Tk source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 
    2 source "../tests/includes/init-tests.tcl"
    3 
    4 set ::user "testuser"
    5 set ::password "secret"
    6 
    7 proc setup_acl {} {
    8     foreach_sentinel_id id {
    9         assert_equal {OK} [S $id ACL SETUSER $::user >$::password +@all on]
   10         assert_equal {OK} [S $id ACL SETUSER default off]
   11 
   12         S $id CLIENT KILL USER default SKIPME no
   13         assert_equal {OK} [S $id AUTH $::user $::password]
   14     }
   15 }
   16 
   17 proc teardown_acl {} {
   18     foreach_sentinel_id id {
   19         assert_equal {OK} [S $id ACL SETUSER default on]
   20         assert_equal {1} [S $id ACL DELUSER $::user]
   21 
   22         S $id SENTINEL CONFIG SET sentinel-user ""
   23         S $id SENTINEL CONFIG SET sentinel-pass ""
   24     }
   25 }
   26 
   27 test "(post-init) Set up ACL configuration" {
   28     setup_acl
   29     assert_equal $::user [S 1 ACL WHOAMI]
   30 }
   31 
   32 test "SENTINEL CONFIG SET handles on-the-fly credentials reconfiguration" {
   33     # Make sure we're starting with a broken state...
   34     wait_for_condition 200 50 {
   35         [catch {S 1 SENTINEL CKQUORUM mymaster}] == 1
   36     } else {
   37         fail "Expected: Sentinel to be disconnected from master due to wrong password"
   38     }
   39     assert_error "*NOQUORUM*" {S 1 SENTINEL CKQUORUM mymaster}
   40 
   41     foreach_sentinel_id id {
   42         assert_equal {OK} [S $id SENTINEL CONFIG SET sentinel-user $::user]
   43         assert_equal {OK} [S $id SENTINEL CONFIG SET sentinel-pass $::password]
   44     }
   45 
   46     wait_for_condition 200 50 {
   47         [catch {S 1 SENTINEL CKQUORUM mymaster}] == 0
   48     } else {
   49          fail "Expected: Sentinel to be connected to master after setting password"
   50     }
   51     assert_match {*OK*} [S 1 SENTINEL CKQUORUM mymaster]
   52 }
   53 
   54 test "(post-cleanup) Tear down ACL configuration" {
   55     teardown_acl
   56 }