Close client connections after each redis test
This commit is contained in:
parent
b0375e85fa
commit
5c8a66bcc9
@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
## Changes since v6.0.0
|
## Changes since v6.0.0
|
||||||
|
|
||||||
|
- [#654](https://github.com/oauth2-proxy/oauth2-proxy/pull/654) Close client connections after each redis test (@JoelSpeed)
|
||||||
- [#542](https://github.com/oauth2-proxy/oauth2-proxy/pull/542) Move SessionStore tests to independent package (@JoelSpeed)
|
- [#542](https://github.com/oauth2-proxy/oauth2-proxy/pull/542) Move SessionStore tests to independent package (@JoelSpeed)
|
||||||
- [#577](https://github.com/oauth2-proxy/oauth2-proxy/pull/577) Move Cipher and Session Store initialisation out of Validation (@JoelSpeed)
|
- [#577](https://github.com/oauth2-proxy/oauth2-proxy/pull/577) Move Cipher and Session Store initialisation out of Validation (@JoelSpeed)
|
||||||
- [#635](https://github.com/oauth2-proxy/oauth2-proxy/pull/635) Support specifying alternative provider TLS trust source(s) (@k-wall)
|
- [#635](https://github.com/oauth2-proxy/oauth2-proxy/pull/635) Support specifying alternative provider TLS trust source(s) (@k-wall)
|
||||||
|
@ -29,7 +29,14 @@ func TestSessionStore(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var _ = Describe("Redis SessionStore Tests", func() {
|
var _ = Describe("Redis SessionStore Tests", func() {
|
||||||
|
// helper interface to allow us to close client connections
|
||||||
|
// All non-nil redis clients should implement this
|
||||||
|
type closer interface {
|
||||||
|
Close() error
|
||||||
|
}
|
||||||
|
|
||||||
var mr *miniredis.Miniredis
|
var mr *miniredis.Miniredis
|
||||||
|
var ss sessionsapi.SessionStore
|
||||||
|
|
||||||
BeforeEach(func() {
|
BeforeEach(func() {
|
||||||
var err error
|
var err error
|
||||||
@ -41,12 +48,25 @@ var _ = Describe("Redis SessionStore Tests", func() {
|
|||||||
mr.Close()
|
mr.Close()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
JustAfterEach(func() {
|
||||||
|
// Release any connections immediately after the test ends
|
||||||
|
if redisStore, ok := ss.(*SessionStore); ok {
|
||||||
|
if redisStore.Client != nil {
|
||||||
|
Expect(redisStore.Client.(closer).Close()).To(Succeed())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
tests.RunSessionStoreTests(
|
tests.RunSessionStoreTests(
|
||||||
func(opts *options.SessionOptions, cookieOpts *options.CookieOptions) (sessionsapi.SessionStore, error) {
|
func(opts *options.SessionOptions, cookieOpts *options.CookieOptions) (sessionsapi.SessionStore, error) {
|
||||||
// Set the connection URL
|
// Set the connection URL
|
||||||
opts.Type = options.RedisSessionStoreType
|
opts.Type = options.RedisSessionStoreType
|
||||||
opts.Redis.ConnectionURL = "redis://" + mr.Addr()
|
opts.Redis.ConnectionURL = "redis://" + mr.Addr()
|
||||||
return NewRedisSessionStore(opts, cookieOpts)
|
|
||||||
|
// Capture the session store so that we can close the client
|
||||||
|
var err error
|
||||||
|
ss, err = NewRedisSessionStore(opts, cookieOpts)
|
||||||
|
return ss, err
|
||||||
},
|
},
|
||||||
func(d time.Duration) error {
|
func(d time.Duration) error {
|
||||||
mr.FastForward(d)
|
mr.FastForward(d)
|
||||||
@ -63,7 +83,7 @@ var _ = Describe("Redis SessionStore Tests", func() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
AfterEach(func() {
|
AfterEach(func() {
|
||||||
go ms.Close()
|
ms.Close()
|
||||||
})
|
})
|
||||||
|
|
||||||
tests.RunSessionStoreTests(
|
tests.RunSessionStoreTests(
|
||||||
@ -74,7 +94,11 @@ var _ = Describe("Redis SessionStore Tests", func() {
|
|||||||
opts.Redis.SentinelConnectionURLs = []string{sentinelAddr}
|
opts.Redis.SentinelConnectionURLs = []string{sentinelAddr}
|
||||||
opts.Redis.UseSentinel = true
|
opts.Redis.UseSentinel = true
|
||||||
opts.Redis.SentinelMasterName = ms.MasterInfo().Name
|
opts.Redis.SentinelMasterName = ms.MasterInfo().Name
|
||||||
return NewRedisSessionStore(opts, cookieOpts)
|
|
||||||
|
// Capture the session store so that we can close the client
|
||||||
|
var err error
|
||||||
|
ss, err = NewRedisSessionStore(opts, cookieOpts)
|
||||||
|
return ss, err
|
||||||
},
|
},
|
||||||
func(d time.Duration) error {
|
func(d time.Duration) error {
|
||||||
mr.FastForward(d)
|
mr.FastForward(d)
|
||||||
@ -90,7 +114,11 @@ var _ = Describe("Redis SessionStore Tests", func() {
|
|||||||
opts.Type = options.RedisSessionStoreType
|
opts.Type = options.RedisSessionStoreType
|
||||||
opts.Redis.ClusterConnectionURLs = []string{clusterAddr}
|
opts.Redis.ClusterConnectionURLs = []string{clusterAddr}
|
||||||
opts.Redis.UseCluster = true
|
opts.Redis.UseCluster = true
|
||||||
return NewRedisSessionStore(opts, cookieOpts)
|
|
||||||
|
// Capture the session store so that we can close the client
|
||||||
|
var err error
|
||||||
|
ss, err = NewRedisSessionStore(opts, cookieOpts)
|
||||||
|
return ss, err
|
||||||
},
|
},
|
||||||
func(d time.Duration) error {
|
func(d time.Duration) error {
|
||||||
mr.FastForward(d)
|
mr.FastForward(d)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user