Skip to content

Commit 377d360

Browse files
committed
Better handling of ssl_context option. Fixes #70.
1 parent 1039d88 commit 377d360

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

lib/async/redis/endpoint.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def self.for(scheme, host, port: nil, database: nil, **options)
8080
scheme ||= default_scheme
8181
end
8282

83-
scheme ||= options.key?(:ssl_context) ? "rediss" : "redis"
83+
scheme ||= options[:ssl_context] ? "rediss" : "redis"
8484

8585
uri_klass = SCHEMES.fetch(scheme.downcase) do
8686
raise ArgumentError, "Unsupported scheme: #{scheme.inspect}"

test/async/redis/endpoint.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,13 @@
163163
expect(endpoint.scheme).to be == "redis"
164164
expect(endpoint).not.to be(:secure?) # scheme takes precedence
165165
end
166+
167+
it "does not treat ssl_context: nil as requesting SSL" do
168+
ssl_context = nil
169+
endpoint = Async::Redis::Endpoint.for(nil, "localhost", port: 6379, ssl_context: ssl_context)
170+
expect(endpoint.scheme).to be == "redis"
171+
expect(endpoint).not.to be(:secure?)
172+
end
166173
end
167174

168175
with ".unix" do

0 commit comments

Comments
 (0)