Skip to content

Commit 3eeb031

Browse files
author
Richard P. Field III
authored
connection string password bug (#173)
1 parent 53650de commit 3eeb031

File tree

3 files changed

+38
-3
lines changed

3 files changed

+38
-3
lines changed

docker/docker-compose.yaml

+14-1
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,14 @@ services:
129129
- redis-cluster3
130130
- redis-cluster4
131131
- redis-cluster5
132+
redis-private:
133+
image: redis
134+
ports:
135+
- "6379"
136+
networks:
137+
cluster-network:
138+
ipv4_address: 192.168.57.35
139+
command: --port 6379 --requirepass foobar
132140
dotnet:
133141
networks:
134142
cluster-network:
@@ -137,10 +145,14 @@ services:
137145
- redis-standalone
138146
- redis-sentinel
139147
- redis-cluster1
148+
- redis-private
140149
environment:
141150
- STANDALONE_HOST_PORT=redis-standalone:6379
142151
- SENTINLE_HOST_PORT=redis-sentinel:26379
143152
- CLUSTER_HOST_PORT=redis-cluster1:6379
153+
- PRIVATE_HOST=redis-private
154+
- PRIVATE_PORT=6379
155+
- PRIVATE_PASSWORD=foobar
144156
build:
145157
context: ../
146158
depends_on:
@@ -155,4 +167,5 @@ services:
155167
- redis-cluster3
156168
- redis-cluster4
157169
- redis-cluster5
158-
- redis-cluster6
170+
- redis-cluster6
171+
- redis-private

src/Redis.OM/RedisConnectionConfiguration.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,6 @@ public class RedisConnectionConfiguration
2424
/// Builds SE connection string.
2525
/// </summary>
2626
/// <returns>A connection string.</returns>
27-
public string ToStackExchangeConnectionString() => $"{Host}:{Port},password{Password}";
27+
public string ToStackExchangeConnectionString() => $"{Host}:{Port},password={Password}";
2828
}
2929
}

test/Redis.OM.Unit.Tests/ConnectionTests.cs

+23-1
Original file line numberDiff line numberDiff line change
@@ -62,5 +62,27 @@ public void GivenMultiplexerConnection_WhenTestingSetCommand_ThenShouldExecuteSe
6262
var res = connection.Execute("GET", "Foo");
6363
Assert.Equal("Bar", res);
6464
}
65+
66+
[Fact]
67+
public void TestPrivateConnection()
68+
{
69+
var host = Environment.GetEnvironmentVariable("PRIVATE_HOST") ?? "redis-private";
70+
var port = Int32.Parse(Environment.GetEnvironmentVariable("PRIVATE_PORT") ?? "6379");
71+
var password = Environment.GetEnvironmentVariable("PRIVATE_PASSWORD");
72+
Console.WriteLine($"current host info: Host:{host}, port: {port}, password: {password}");
73+
var configuration = new RedisConnectionConfiguration()
74+
{
75+
Host = host,
76+
Port = port,
77+
Password = password
78+
};
79+
80+
var provider = new RedisConnectionProvider(configuration);
81+
82+
var connection = provider.Connection;
83+
connection.Execute("SET", "Foo", "Bar");
84+
var res = connection.Execute("GET", "Foo");
85+
Assert.Equal("Bar",res);
86+
}
6587
}
66-
}
88+
}

0 commit comments

Comments
 (0)