-
Notifications
You must be signed in to change notification settings - Fork 996
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add simple TLS support in Go RedisOnlineStore (#2860)
* Add simple TLS support in RedisOnlineStore Per the go-redis docs: 'To enable TLS/SSL, you need to provide an empty tls.Config.' https://redis.uptrace.dev/guide/go-redis.html#using-tls This will allow users to append ',ssl=True' to their connection string in order to enable TLS/SSL support in the Redis client Signed-off-by: William Horton <william.horton@grandrounds.com> * Add tests of Redis config from connection string Signed-off-by: William Horton <william.horton@grandrounds.com>
- Loading branch information
Showing
2 changed files
with
65 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package onlinestore | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestNewRedisOnlineStore(t *testing.T) { | ||
var config = map[string]interface{}{ | ||
"connection_string": "redis://localhost:6379", | ||
} | ||
store, err := NewRedisOnlineStore("test", config) | ||
assert.Nil(t, err) | ||
var opts = store.client.Options() | ||
assert.Equal(t, opts.Addr, "redis://localhost:6379") | ||
assert.Equal(t, opts.Password, "") | ||
assert.Equal(t, opts.DB, 0) | ||
assert.Nil(t, opts.TLSConfig) | ||
} | ||
|
||
func TestNewRedisOnlineStoreWithPassword(t *testing.T) { | ||
var config = map[string]interface{}{ | ||
"connection_string": "redis://localhost:6379,password=secret", | ||
} | ||
store, err := NewRedisOnlineStore("test", config) | ||
assert.Nil(t, err) | ||
var opts = store.client.Options() | ||
assert.Equal(t, opts.Addr, "redis://localhost:6379") | ||
assert.Equal(t, opts.Password, "secret") | ||
} | ||
|
||
func TestNewRedisOnlineStoreWithDB(t *testing.T) { | ||
var config = map[string]interface{}{ | ||
"connection_string": "redis://localhost:6379,db=1", | ||
} | ||
store, err := NewRedisOnlineStore("test", config) | ||
assert.Nil(t, err) | ||
var opts = store.client.Options() | ||
assert.Equal(t, opts.Addr, "redis://localhost:6379") | ||
assert.Equal(t, opts.DB, 1) | ||
} | ||
|
||
func TestNewRedisOnlineStoreWithSsl(t *testing.T) { | ||
var config = map[string]interface{}{ | ||
"connection_string": "redis://localhost:6379,ssl=true", | ||
} | ||
store, err := NewRedisOnlineStore("test", config) | ||
assert.Nil(t, err) | ||
var opts = store.client.Options() | ||
assert.Equal(t, opts.Addr, "redis://localhost:6379") | ||
assert.NotNil(t, opts.TLSConfig) | ||
} |