09-acl-support.tcl 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. source "../tests/includes/init-tests.tcl"
  2. set ::user "testuser"
  3. set ::password "secret"
  4. proc setup_acl {} {
  5. foreach_sentinel_id id {
  6. assert_equal {OK} [S $id ACL SETUSER $::user >$::password +@all on]
  7. assert_equal {OK} [S $id ACL SETUSER default off]
  8. S $id CLIENT KILL USER default SKIPME no
  9. assert_equal {OK} [S $id AUTH $::user $::password]
  10. }
  11. }
  12. proc teardown_acl {} {
  13. foreach_sentinel_id id {
  14. assert_equal {OK} [S $id ACL SETUSER default on]
  15. assert_equal {1} [S $id ACL DELUSER $::user]
  16. S $id SENTINEL CONFIG SET sentinel-user ""
  17. S $id SENTINEL CONFIG SET sentinel-pass ""
  18. }
  19. }
  20. test "(post-init) Set up ACL configuration" {
  21. setup_acl
  22. assert_equal $::user [S 1 ACL WHOAMI]
  23. }
  24. test "SENTINEL CONFIG SET handles on-the-fly credentials reconfiguration" {
  25. # Make sure we're starting with a broken state...
  26. after 5000
  27. catch {S 1 SENTINEL CKQUORUM mymaster} err
  28. assert_match {*NOQUORUM*} $err
  29. foreach_sentinel_id id {
  30. assert_equal {OK} [S $id SENTINEL CONFIG SET sentinel-user $::user]
  31. assert_equal {OK} [S $id SENTINEL CONFIG SET sentinel-pass $::password]
  32. }
  33. after 5000
  34. assert_match {*OK*} [S 1 SENTINEL CKQUORUM mymaster]
  35. }
  36. test "(post-cleanup) Tear down ACL configuration" {
  37. teardown_acl
  38. }