Skip to content

Commit

Permalink
connection string password bug (#173)
Browse files Browse the repository at this point in the history
  • Loading branch information
Richard P. Field III authored Sep 19, 2022
1 parent 53650de commit 3eeb031
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 3 deletions.
15 changes: 14 additions & 1 deletion docker/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,14 @@ services:
- redis-cluster3
- redis-cluster4
- redis-cluster5
redis-private:
image: redis
ports:
- "6379"
networks:
cluster-network:
ipv4_address: 192.168.57.35
command: --port 6379 --requirepass foobar
dotnet:
networks:
cluster-network:
Expand All @@ -137,10 +145,14 @@ services:
- redis-standalone
- redis-sentinel
- redis-cluster1
- redis-private
environment:
- STANDALONE_HOST_PORT=redis-standalone:6379
- SENTINLE_HOST_PORT=redis-sentinel:26379
- CLUSTER_HOST_PORT=redis-cluster1:6379
- PRIVATE_HOST=redis-private
- PRIVATE_PORT=6379
- PRIVATE_PASSWORD=foobar
build:
context: ../
depends_on:
Expand All @@ -155,4 +167,5 @@ services:
- redis-cluster3
- redis-cluster4
- redis-cluster5
- redis-cluster6
- redis-cluster6
- redis-private
2 changes: 1 addition & 1 deletion src/Redis.OM/RedisConnectionConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ public class RedisConnectionConfiguration
/// Builds SE connection string.
/// </summary>
/// <returns>A connection string.</returns>
public string ToStackExchangeConnectionString() => $"{Host}:{Port},password{Password}";
public string ToStackExchangeConnectionString() => $"{Host}:{Port},password={Password}";
}
}
24 changes: 23 additions & 1 deletion test/Redis.OM.Unit.Tests/ConnectionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,27 @@ public void GivenMultiplexerConnection_WhenTestingSetCommand_ThenShouldExecuteSe
var res = connection.Execute("GET", "Foo");
Assert.Equal("Bar", res);
}

[Fact]
public void TestPrivateConnection()
{
var host = Environment.GetEnvironmentVariable("PRIVATE_HOST") ?? "redis-private";
var port = Int32.Parse(Environment.GetEnvironmentVariable("PRIVATE_PORT") ?? "6379");
var password = Environment.GetEnvironmentVariable("PRIVATE_PASSWORD");
Console.WriteLine($"current host info: Host:{host}, port: {port}, password: {password}");
var configuration = new RedisConnectionConfiguration()
{
Host = host,
Port = port,
Password = password
};

var provider = new RedisConnectionProvider(configuration);

var connection = provider.Connection;
connection.Execute("SET", "Foo", "Bar");
var res = connection.Execute("GET", "Foo");
Assert.Equal("Bar",res);
}
}
}
}

0 comments on commit 3eeb031

Please sign in to comment.