File tree Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Original file line number Diff line number Diff line change @@ -109,4 +109,42 @@ def test_sentinel_failover_prioritize_healthy_sentinel
109
109
assert_equal commands [ :s1 ] , [ %w[ get-master-addr-by-name master1 ] ]
110
110
assert_equal commands [ :s2 ] , [ %w[ get-master-addr-by-name master1 ] , %w[ get-master-addr-by-name master1 ] ]
111
111
end
112
+
113
+ def test_sentinel_with_auth
114
+ sentinels = [ { :host => "127.0.0.1" , :port => 26381 } ]
115
+
116
+ commands = {
117
+ :s1 => [ ] ,
118
+ :m1 => [ ]
119
+ }
120
+
121
+ sentinel = {
122
+ :sentinel => lambda do |command , *args |
123
+ commands [ :s1 ] << [ command , *args ]
124
+ [ "127.0.0.1" , "6382" ]
125
+ end
126
+ }
127
+
128
+ master = {
129
+ :auth => lambda do |pass |
130
+ commands [ :m1 ] << [ "auth" , pass ]
131
+ "+OK"
132
+ end ,
133
+ :role => lambda do
134
+ commands [ :m1 ] << [ "role" ]
135
+ [ "master" ]
136
+ end
137
+ }
138
+
139
+ RedisMock . start ( master , { } , 6382 ) do
140
+ RedisMock . start ( sentinel , { } , 26381 ) do
141
+ redis = Redis . new ( :url => "redis://:foo@master1" , :sentinels => sentinels , :role => :master )
142
+
143
+ assert redis . ping
144
+ end
145
+ end
146
+
147
+ assert_equal commands [ :s1 ] , [ %w[ get-master-addr-by-name master1 ] ]
148
+ assert_equal commands [ :m1 ] , [ %w[ auth foo ] , %w[ role ] ]
149
+ end
112
150
end
You can’t perform that action at this time.
0 commit comments