You've already forked oauth2-proxy
mirror of
https://github.com/oauth2-proxy/oauth2-proxy.git
synced 2025-08-06 22:42:56 +02:00
fix: return error for empty Redis URL list (#3101)
* fix: return error for empty Redis URL list * add changelog entry Signed-off-by: Jan Larwig <jan@larwig.com> --------- Signed-off-by: Jan Larwig <jan@larwig.com> Co-authored-by: Jan Larwig <jan@larwig.com>
This commit is contained in:
@ -11,6 +11,7 @@
|
|||||||
- [#3072](https://github.com/oauth2-proxy/oauth2-proxy/pull/3072) feat: support for multiple github orgs #3072 (@daniel-mersch)
|
- [#3072](https://github.com/oauth2-proxy/oauth2-proxy/pull/3072) feat: support for multiple github orgs #3072 (@daniel-mersch)
|
||||||
- [#3116](https://github.com/oauth2-proxy/oauth2-proxy/pull/3116) feat: bump to go1.24.5 and full dependency update (@wardviaene / @dolmen)
|
- [#3116](https://github.com/oauth2-proxy/oauth2-proxy/pull/3116) feat: bump to go1.24.5 and full dependency update (@wardviaene / @dolmen)
|
||||||
- [#3097](https://github.com/oauth2-proxy/oauth2-proxy/pull/3097) chore(deps): update alpine base image to v3.22.0
|
- [#3097](https://github.com/oauth2-proxy/oauth2-proxy/pull/3097) chore(deps): update alpine base image to v3.22.0
|
||||||
|
- [#3101](https://github.com/oauth2-proxy/oauth2-proxy/pull/3101) fix: return error for empty Redis URL list (@dgivens)
|
||||||
|
|
||||||
# V7.9.0
|
# V7.9.0
|
||||||
|
|
||||||
|
@ -218,6 +218,10 @@ func setupTLSConfig(opts options.RedisStoreOptions, opt *redis.Options) error {
|
|||||||
// parseRedisURLs parses a list of redis urls and returns a list
|
// parseRedisURLs parses a list of redis urls and returns a list
|
||||||
// of addresses in the form of host:port and redis.Options that can be used to connect to Redis
|
// of addresses in the form of host:port and redis.Options that can be used to connect to Redis
|
||||||
func parseRedisURLs(urls []string) ([]string, *redis.Options, error) {
|
func parseRedisURLs(urls []string) ([]string, *redis.Options, error) {
|
||||||
|
if len(urls) == 0 {
|
||||||
|
return nil, nil, fmt.Errorf("unable to parse redis urls: no redis urls provided")
|
||||||
|
}
|
||||||
|
|
||||||
addrs := []string{}
|
addrs := []string{}
|
||||||
var redisOptions *redis.Options
|
var redisOptions *redis.Options
|
||||||
for _, u := range urls {
|
for _, u := range urls {
|
||||||
|
@ -19,6 +19,7 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var _ = Describe("Redis SessionStore Tests", func() {
|
var _ = Describe("Redis SessionStore Tests", func() {
|
||||||
|
Describe("Redis SessionStore Creation", func() {
|
||||||
// helper interface to allow us to close client connections
|
// helper interface to allow us to close client connections
|
||||||
// All non-nil redis clients should implement this
|
// All non-nil redis clients should implement this
|
||||||
type closer interface {
|
type closer interface {
|
||||||
@ -242,4 +243,32 @@ var _ = Describe("Redis SessionStore Tests", func() {
|
|||||||
)
|
)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
Describe("Redis URL Parsing", func() {
|
||||||
|
It("should parse valid redis URL", func() {
|
||||||
|
addrs, opts, err := parseRedisURLs([]string{"redis://localhost:6379"})
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
Expect(addrs).To(Equal([]string{"localhost:6379"}))
|
||||||
|
Expect(opts).ToNot(BeNil())
|
||||||
|
Expect(opts.Addr).To(Equal("localhost:6379"))
|
||||||
|
})
|
||||||
|
|
||||||
|
It("should return error for invalid redis URL", func() {
|
||||||
|
addrs, opts, err := parseRedisURLs([]string{"invalid://url"})
|
||||||
|
Expect(err).To(HaveOccurred())
|
||||||
|
Expect(err.Error()).To(ContainSubstring("unable to parse redis url"))
|
||||||
|
Expect(err.Error()).To(Not(ContainSubstring("no redis urls provided")))
|
||||||
|
Expect(addrs).To(BeNil())
|
||||||
|
Expect(opts).To(BeNil())
|
||||||
|
})
|
||||||
|
|
||||||
|
It("should return error when no URLs provided", func() {
|
||||||
|
addrs, opts, err := parseRedisURLs([]string{})
|
||||||
|
Expect(err).To(HaveOccurred())
|
||||||
|
Expect(err.Error()).To(Equal("unable to parse redis urls: no redis urls provided"))
|
||||||
|
Expect(addrs).To(BeNil())
|
||||||
|
Expect(opts).To(BeNil())
|
||||||
|
})
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
Reference in New Issue
Block a user