This repository was archived by the owner on Dec 24, 2022. It is now read-only.
File tree Expand file tree Collapse file tree
tests/ServiceStack.Redis.Tests Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -54,7 +54,7 @@ public override string ToString()
5454 if ( Client != null )
5555 args . Add ( "Client=" + Client ) ;
5656 if ( Password != null )
57- args . Add ( "Password=" + Password ) ;
57+ args . Add ( "Password=" + Password . UrlEncode ( ) ) ;
5858 if ( Db != RedisConfig . DefaultDb )
5959 args . Add ( "Db=" + Db ) ;
6060 if ( Ssl )
Original file line number Diff line number Diff line change 11using NUnit . Framework ;
2+ using ServiceStack . Text ;
23
34namespace ServiceStack . Redis . Tests
45{
@@ -81,6 +82,25 @@ public void Does_set_all_properties_on_Client_using_ClientsManagers()
8182 }
8283 }
8384
85+ [ Test ]
86+ public void Does_encode_values_when_serializing_to_ConnectionString ( )
87+ {
88+ var config = new RedisEndpoint
89+ {
90+ Host = "host" ,
91+ Port = 1 ,
92+ Password = "p@55W0rd="
93+ } ;
94+
95+ var connString = config . ToString ( ) ;
96+ Assert . That ( connString , Is . EqualTo ( "host:1?Password=p%4055W0rd%3d" ) ) ;
97+
98+ var fromConfig = connString . ToRedisEndpoint ( ) ;
99+ Assert . That ( fromConfig . Host , Is . EqualTo ( config . Host ) ) ;
100+ Assert . That ( fromConfig . Port , Is . EqualTo ( config . Port ) ) ;
101+ Assert . That ( fromConfig . Password , Is . EqualTo ( config . Password ) ) ;
102+ }
103+
84104 private static void AssertClientManager ( IRedisClientsManager redisManager , RedisEndpoint expected )
85105 {
86106 using ( var readWrite = ( RedisClient ) redisManager . GetClient ( ) )
You can’t perform that action at this time.
0 commit comments