@@ -72,8 +72,10 @@ def test_sentinels_connection_string_escaped
72
72
73
73
conn = StorageSync . send :new , Storage ::Helpers . config_with ( config_obj )
74
74
assert_sentinel_config ( { url : config_obj [ :url ] ,
75
- sentinels : [ { host : '127.0.0.1' , port : 26_379 , password : 'passw,ord' } ,
76
- { host : '127.0.0.1' , port : 36_379 } ] } ,
75
+ sentinels : [ { host : '127.0.0.1' , port : 26_379 } ,
76
+ { host : '127.0.0.1' , port : 36_379 } ] ,
77
+ sentinel_username : 'user' ,
78
+ sentinel_password : 'passw,ord' } ,
77
79
conn )
78
80
end
79
81
@@ -90,21 +92,6 @@ def test_sentinels_connection_array_strings
90
92
conn )
91
93
end
92
94
93
- def test_sentinels_connection_array_hashes
94
- config_obj = {
95
- url : 'redis://master-group-name' ,
96
- sentinels : [ { host : '127.0.0.1' , port : 26_379 } ,
97
- { } ,
98
- { host : '127.0.0.1' , port : 36_379 } ,
99
- nil ]
100
- }
101
-
102
- conn = StorageSync . send :new , Storage ::Helpers . config_with ( config_obj )
103
- assert_sentinel_config ( { url : config_obj [ :url ] ,
104
- sentinels : config_obj [ :sentinels ] . compact . reject ( &:empty? ) } ,
105
- conn )
106
- end
107
-
108
95
def test_sentinels_malformed_url
109
96
config_obj = {
110
97
url : 'redis://master-group-name' ,
@@ -127,24 +114,6 @@ def test_sentinels_simple_url
127
114
conn )
128
115
end
129
116
130
- def test_sentinels_array_hashes_default_port
131
- default_sentinel_port = Storage ::Helpers . singleton_class . const_get ( :DEFAULT_SENTINEL_PORT )
132
- config_obj = {
133
- url : 'redis://master-group-name' ,
134
- sentinels : [ { host : '127.0.0.1' } , { host : '192.168.1.1' } ,
135
- { host : '192.168.1.2' , port : nil } ,
136
- { host : '127.0.0.1' , port : 36379 } ]
137
- }
138
-
139
- conn = StorageSync . send :new , Storage ::Helpers . config_with ( config_obj )
140
- assert_sentinel_config ( { url : config_obj [ :url ] ,
141
- sentinels : [ { host : '127.0.0.1' , port : default_sentinel_port } ,
142
- { host : '192.168.1.1' , port : default_sentinel_port } ,
143
- { host : '192.168.1.2' , port : default_sentinel_port } ,
144
- { host : '127.0.0.1' , port : 36379 } ] } ,
145
- conn )
146
- end
147
-
148
117
def test_sentinels_array_strings_default_port
149
118
default_sentinel_port = Storage ::Helpers . singleton_class . const_get ( :DEFAULT_SENTINEL_PORT )
150
119
config_obj = {
@@ -164,22 +133,6 @@ def test_sentinels_array_strings_default_port
164
133
conn )
165
134
end
166
135
167
- def test_sentinels_array_hashes_password
168
- config_obj = {
169
- url : 'redis://master-group-name' ,
170
- sentinels : [ { host : '192.168.1.1' , port : 3333 , password : 'abc' } ,
171
- { host : '192.168.1.2' , port : 4444 , password : '' } ,
172
- { host : '192.168.1.3' , port : 5555 , password : nil } ]
173
- }
174
-
175
- conn = StorageSync . send :new , Storage ::Helpers . config_with ( config_obj )
176
- assert_sentinel_config ( { url : config_obj [ :url ] ,
177
- sentinels : [ { host : '192.168.1.1' , port : 3333 , password : 'abc' } ,
178
- { host : '192.168.1.2' , port : 4444 } ,
179
- { host : '192.168.1.3' , port : 5555 } ] } ,
180
- conn )
181
- end
182
-
183
136
def test_sentinels_array_strings_password
184
137
config_obj = {
185
138
url : 'redis://master-group-name' ,
@@ -190,9 +143,10 @@ def test_sentinels_array_strings_password
190
143
191
144
conn = StorageSync . send :new , Storage ::Helpers . config_with ( config_obj )
192
145
assert_sentinel_config ( { url : config_obj [ :url ] ,
193
- sentinels : [ { host : '192.168.1.1' , port : 3333 , password : 'abc' } ,
146
+ sentinels : [ { host : '192.168.1.1' , port : 3333 } ,
194
147
{ host : '192.168.1.2' , port : 4444 } ,
195
- { host : '192.168.1.3' , port : 5555 } ] } ,
148
+ { host : '192.168.1.3' , port : 5555 } ] ,
149
+ sentinel_password : 'abc' } ,
196
150
conn )
197
151
end
198
152
@@ -234,7 +188,7 @@ def test_role_empty_when_sentinels_does_not_exist
234
188
end
235
189
236
190
def test_sentinels_empty
237
- [ nil , '' , ' ' , [ ] , [ nil ] , [ '' ] , [ ' ' ] , [ { } ] ] . each do |sentinels_val |
191
+ [ nil , '' , ' ' , [ ] , [ nil ] , [ '' ] , [ ' ' ] ] . each do |sentinels_val |
238
192
config_obj = {
239
193
url : 'redis://master-group-name' ,
240
194
sentinels : sentinels_val
@@ -337,8 +291,10 @@ def assert_sentinel_config(conf, client)
337
291
conf [ :sentinels ] . each_with_index do |s , i |
338
292
assert_equal s [ :host ] , config . sentinels [ i ] . host
339
293
assert_equal s [ :port ] , config . sentinels [ i ] . port
340
- assert_equal s [ :password ] , config . sentinels [ i ] . password
341
294
end
295
+ extra_conf = config . instance_variable_get ( :@extra_config )
296
+ assert_equal conf [ :sentinel_username ] , extra_conf [ :username ]
297
+ assert_equal conf [ :sentinel_password ] , extra_conf [ :password ]
342
298
end
343
299
344
300
def url ( url )
0 commit comments