Skip to content

Commit 54763f1

Browse files
committed
Update hiredis test suite
1 parent bbed096 commit 54763f1

File tree

3 files changed

+30
-41
lines changed

3 files changed

+30
-41
lines changed

Gemfile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,7 @@ gem 'minitest'
88
gem 'rake'
99
gem 'rubocop', '~> 1.25.1'
1010
gem 'mocha'
11-
gem 'redis-client', github: 'redis-rb/redis-client' # RESP2 supportnot yet released
12-
gem 'hiredis-client', github: 'redis-rb/redis-client' # RESP2 supportnot yet released
11+
12+
# RESP2 supportnot yet released
13+
gem 'redis-client', github: 'redis-rb/redis-client'
14+
gem 'hiredis-client', github: 'redis-rb/redis-client'

lib/redis/client.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class Client < ::RedisClient
1313
RedisClient::FailoverError => Redis::CannotConnectError,
1414
RedisClient::PermissionError => Redis::PermissionError,
1515
RedisClient::WrongTypeError => Redis::WrongTypeError,
16-
RedisClient::RESP3::UnknownType => Redis::ProtocolError,
16+
RedisClient::ProtocolError => Redis::ProtocolError,
1717
}.freeze
1818

1919
class << self

test/redis/ssl_test.rb

Lines changed: 25 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -5,55 +5,42 @@
55
class SslTest < Minitest::Test
66
include Helper::Client
77

8-
driver(:ruby) do
9-
def test_connection_to_non_ssl_server
10-
assert_raises(Redis::CannotConnectError) do
11-
redis = Redis.new(OPTIONS.merge(ssl: true, timeout: LOW_TIMEOUT))
12-
redis.ping
13-
end
14-
end
15-
16-
def test_verified_ssl_connection
17-
RedisMock.start({ ping: proc { "+PONG" } }, ssl_server_opts("trusted")) do |port|
18-
redis = Redis.new(host: "127.0.0.1", port: port, ssl: true, ssl_params: { ca_file: ssl_ca_file })
19-
assert_equal redis.ping, "PONG"
20-
end
8+
def test_connection_to_non_ssl_server
9+
assert_raises(Redis::CannotConnectError) do
10+
redis = Redis.new(OPTIONS.merge(ssl: true, timeout: LOW_TIMEOUT))
11+
redis.ping
2112
end
13+
end
2214

23-
def test_unverified_ssl_connection
24-
assert_raises(Redis::CannotConnectError) do
25-
RedisMock.start({ ping: proc { "+PONG" } }, ssl_server_opts("untrusted")) do |port|
26-
redis = Redis.new(port: port, ssl: true, ssl_params: { ca_file: ssl_ca_file })
27-
redis.ping
28-
end
29-
end
15+
def test_verified_ssl_connection
16+
RedisMock.start({ ping: proc { "+PONG" } }, ssl_server_opts("trusted")) do |port|
17+
redis = Redis.new(host: "127.0.0.1", port: port, ssl: true, ssl_params: { ca_file: ssl_ca_file })
18+
assert_equal redis.ping, "PONG"
3019
end
20+
end
3121

32-
def test_verify_certificates_by_default
33-
assert_raises(Redis::CannotConnectError) do
34-
RedisMock.start({ ping: proc { "+PONG" } }, ssl_server_opts("untrusted")) do |port|
35-
redis = Redis.new(port: port, ssl: true)
36-
redis.ping
37-
end
22+
def test_unverified_ssl_connection
23+
assert_raises(Redis::CannotConnectError) do
24+
RedisMock.start({ ping: proc { "+PONG" } }, ssl_server_opts("untrusted")) do |port|
25+
redis = Redis.new(port: port, ssl: true, ssl_params: { ca_file: ssl_ca_file })
26+
redis.ping
3827
end
3928
end
29+
end
4030

41-
def test_ssl_blocking
42-
RedisMock.start({}, ssl_server_opts("trusted")) do |port|
43-
redis = Redis.new(host: "127.0.0.1", port: port, ssl: true, ssl_params: { ca_file: ssl_ca_file })
44-
assert_equal redis.set("boom", "a" * 10_000_000), "OK"
31+
def test_verify_certificates_by_default
32+
assert_raises(Redis::CannotConnectError) do
33+
RedisMock.start({ ping: proc { "+PONG" } }, ssl_server_opts("untrusted")) do |port|
34+
redis = Redis.new(port: port, ssl: true)
35+
redis.ping
4536
end
4637
end
4738
end
4839

49-
driver(:hiredis) do
50-
def test_ssl_not_implemented_exception
51-
assert_raises(NotImplementedError) do
52-
RedisMock.start({ ping: proc { "+PONG" } }, ssl_server_opts("trusted")) do |port|
53-
redis = Redis.new(port: port, ssl: true, ssl_params: { ca_file: ssl_ca_file })
54-
redis.ping
55-
end
56-
end
40+
def test_ssl_blocking
41+
RedisMock.start({}, ssl_server_opts("trusted")) do |port|
42+
redis = Redis.new(host: "127.0.0.1", port: port, ssl: true, ssl_params: { ca_file: ssl_ca_file })
43+
assert_equal redis.set("boom", "a" * 10_000_000), "OK"
5744
end
5845
end
5946

0 commit comments

Comments
 (0)