Skip to content

Commit cfdda4a

Browse files
authored
test: add URI escaping case to test (#79)
1 parent 3e56be3 commit cfdda4a

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

test/redis_client/test_cluster_config.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# frozen_string_literal: true
22

3+
require 'uri'
34
require 'testing_helper'
45

56
class RedisClient
@@ -98,7 +99,10 @@ def test_build_node_configs
9899
{ addrs: %w[redis://127.0.0.1:6379 redis://127.0.0.2:6380], want: [{ host: '127.0.0.1', port: 6379 }, { host: '127.0.0.2', port: 6380 }] },
99100
{ addrs: %w[rediss://foo:[email protected]:6379], want: [{ ssl: true, username: 'foo', password: 'bar', host: '127.0.0.1', port: 6379 }] },
100101
{ addrs: %w[redis://[email protected]:6379], want: [{ host: '127.0.0.1', port: 6379, username: 'foo' }] },
102+
{ addrs: %w[redis://foo:@127.0.0.1:6379], want: [{ host: '127.0.0.1', port: 6379, username: 'foo' }] },
101103
{ addrs: %w[redis://:[email protected]:6379], want: [{ host: '127.0.0.1', port: 6379, password: 'bar' }] },
104+
{ addrs: %W[redis://#{URI.encode_www_form_component('!&<123-abc>')}:@127.0.0.1:6379], want: [{ host: '127.0.0.1', port: 6379, username: '!&<123-abc>' }] },
105+
{ addrs: %W[redis://:#{URI.encode_www_form_component('!&<123-abc>')}@127.0.0.1:6379], want: [{ host: '127.0.0.1', port: 6379, password: '!&<123-abc>' }] },
102106
{ addrs: [{ host: '127.0.0.1', port: 6379 }], want: [{ host: '127.0.0.1', port: 6379 }] },
103107
{ addrs: [{ host: '127.0.0.1', port: 6379 }, { host: '127.0.0.2', port: '6380' }], want: [{ host: '127.0.0.1', port: 6379 }, { host: '127.0.0.2', port: 6380 }] },
104108
{ addrs: [{ host: '127.0.0.1', port: 6379, username: 'foo', password: 'bar', ssl: true }], want: [{ ssl: true, username: 'foo', password: 'bar', host: '127.0.0.1', port: 6379 }] },

0 commit comments

Comments
 (0)