@@ -64,19 +64,46 @@ def test_ipv6_uri
64
64
assert_equal "::1" , config . host
65
65
end
66
66
67
- def test_user_password_uri
67
+ def test_resp2_user_password_uri
68
+ config = Config . new ( protocol :
2 , url :
"redis://username:[email protected] " )
69
+ assert_equal "example.com" , config . host
70
+ assert_equal 6379 , config . port
71
+ assert_equal "username" , config . username
72
+ assert_equal "password" , config . password
73
+ assert_equal 0 , config . db
74
+ refute_predicate config , :ssl?
75
+ assert_equal [ %w[ AUTH username password ] ] , config . connection_prelude
76
+ end
77
+
78
+ def test_resp3_user_password_uri
68
79
config = Config . new ( url :
"redis://username:[email protected] " )
69
80
assert_equal "example.com" , config . host
70
81
assert_equal 6379 , config . port
71
82
assert_equal "username" , config . username
72
83
assert_equal "password" , config . password
73
84
assert_equal 0 , config . db
74
85
refute_predicate config , :ssl?
86
+ assert_equal [ %w[ HELLO 3 AUTH username password ] ] , config . connection_prelude
75
87
end
76
88
77
- def test_frozen_prelude
89
+ def test_resp2_frozen_prelude
90
+ config = Config . new ( protocol :
2 , url :
"redis://username:[email protected] " )
91
+ prelude = config . connection_prelude
92
+
93
+ assert_equal [ %w[ AUTH username password ] ] , prelude
94
+ assert_equal true , prelude . frozen?
95
+ assert_equal true , ( prelude . all? { |commands | commands . frozen? } )
96
+
97
+ prelude . each do |commands |
98
+ assert_equal true , ( commands . all? { |arg | arg . frozen? } )
99
+ end
100
+ end
101
+
102
+ def test_resp3_frozen_prelude
78
103
config = Config . new ( url :
"redis://username:[email protected] " )
79
104
prelude = config . connection_prelude
105
+
106
+ assert_equal [ %w[ HELLO 3 AUTH username password ] ] , prelude
80
107
assert_equal true , prelude . frozen?
81
108
assert_equal true , ( prelude . all? { |commands | commands . frozen? } )
82
109
@@ -85,14 +112,26 @@ def test_frozen_prelude
85
112
end
86
113
end
87
114
88
- def test_simple_password_uri
115
+ def test_resp2_simple_password_uri
116
+ config = Config . new ( protocol :
2 , url :
"redis://[email protected] " )
117
+ assert_equal "example.com" , config . host
118
+ assert_equal 6379 , config . port
119
+ assert_equal "default" , config . username
120
+ assert_equal "password" , config . password
121
+ assert_equal 0 , config . db
122
+ refute_predicate config , :ssl?
123
+ assert_equal [ %w[ AUTH password ] ] , config . connection_prelude
124
+ end
125
+
126
+ def test_resp3_simple_password_uri
89
127
config = Config . new ( url :
"redis://[email protected] " )
90
128
assert_equal "example.com" , config . host
91
129
assert_equal 6379 , config . port
92
130
assert_equal "default" , config . username
93
131
assert_equal "password" , config . password
94
132
assert_equal 0 , config . db
95
133
refute_predicate config , :ssl?
134
+ assert_equal [ %w[ HELLO 3 AUTH default password ] ] , config . connection_prelude
96
135
end
97
136
98
137
def test_simple_password_uri_empty_user
@@ -103,6 +142,7 @@ def test_simple_password_uri_empty_user
103
142
assert_equal "password" , config . password
104
143
assert_equal 0 , config . db
105
144
refute_predicate config , :ssl?
145
+ assert_equal [ %w[ HELLO 3 AUTH default password ] ] , config . connection_prelude
106
146
end
107
147
108
148
def test_percent_encoded_password_uri
@@ -114,6 +154,7 @@ def test_percent_encoded_password_uri
114
154
assert_equal "p@ssw0rd" , config . password
115
155
assert_equal 12 , config . db
116
156
refute_predicate config , :ssl?
157
+ assert_equal [ %w[ HELLO 3 AUTH default p@ssw0rd ] , %w[ SELECT 12 ] ] , config . connection_prelude
117
158
end
118
159
119
160
def test_rediss_url
@@ -124,13 +165,16 @@ def test_rediss_url
124
165
assert_nil config . password
125
166
assert_equal 0 , config . db
126
167
assert_predicate config , :ssl?
168
+ assert_equal [ %w[ HELLO 3 ] ] , config . connection_prelude
127
169
end
128
170
129
171
def test_trailing_slash_url
130
172
config = Config . new ( url : "redis://example.com/" )
131
173
assert_equal 0 , config . db
174
+ assert_equal [ %w[ HELLO 3 ] ] , config . connection_prelude
132
175
config = Config . new ( url : "redis://[::1]/" )
133
176
assert_equal 0 , config . db
177
+ assert_equal [ %w[ HELLO 3 ] ] , config . connection_prelude
134
178
end
135
179
136
180
def test_overriding
@@ -150,6 +194,7 @@ def test_overriding
150
194
assert_equal "hunter2" , config . password
151
195
assert_equal 5 , config . db
152
196
assert_predicate config , :ssl?
197
+ assert_equal [ %w[ HELLO 3 AUTH george hunter2 ] , %w[ SELECT 5 ] ] , config . connection_prelude
153
198
end
154
199
155
200
def test_server_url
0 commit comments