1
0

auth.tcl 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. start_server {tags {"auth external:skip"}} {
  2. test {AUTH fails if there is no password configured server side} {
  3. catch {r auth foo} err
  4. set _ $err
  5. } {ERR*any password*}
  6. }
  7. start_server {tags {"auth external:skip"} overrides {requirepass foobar}} {
  8. test {AUTH fails when a wrong password is given} {
  9. catch {r auth wrong!} err
  10. set _ $err
  11. } {WRONGPASS*}
  12. test {Arbitrary command gives an error when AUTH is required} {
  13. catch {r set foo bar} err
  14. set _ $err
  15. } {NOAUTH*}
  16. test {AUTH succeeds when the right password is given} {
  17. r auth foobar
  18. } {OK}
  19. test {Once AUTH succeeded we can actually send commands to the server} {
  20. r set foo 100
  21. r incr foo
  22. } {101}
  23. }
  24. start_server {tags {"auth_binary_password external:skip"}} {
  25. test {AUTH fails when binary password is wrong} {
  26. r config set requirepass "abc\x00def"
  27. catch {r auth abc} err
  28. set _ $err
  29. } {WRONGPASS*}
  30. test {AUTH succeeds when binary password is correct} {
  31. r config set requirepass "abc\x00def"
  32. r auth "abc\x00def"
  33. } {OK}
  34. start_server {tags {"masterauth"}} {
  35. set master [srv -1 client]
  36. set master_host [srv -1 host]
  37. set master_port [srv -1 port]
  38. set slave [srv 0 client]
  39. test {MASTERAUTH test with binary password} {
  40. $master config set requirepass "abc\x00def"
  41. # Configure the replica with masterauth
  42. set loglines [count_log_lines 0]
  43. $slave slaveof $master_host $master_port
  44. $slave config set masterauth "abc"
  45. # Verify replica is not able to sync with master
  46. wait_for_log_messages 0 {"*Unable to AUTH to MASTER*"} $loglines 1000 10
  47. assert_equal {down} [s 0 master_link_status]
  48. # Test replica with the correct masterauth
  49. $slave config set masterauth "abc\x00def"
  50. wait_for_condition 50 100 {
  51. [s 0 master_link_status] eq {up}
  52. } else {
  53. fail "Can't turn the instance into a replica"
  54. }
  55. }
  56. }
  57. }