fixing lint and tests
This commit is contained in:
parent
02c755edd0
commit
5b027c7c78
|
|
@ -34,7 +34,7 @@ type SessionStore struct {
|
|||
}
|
||||
|
||||
// ClearAll implements sessions.SessionStore.
|
||||
func (s *SessionStore) ClearAllUserSessions(req *http.Request, session *sessions.SessionState) error {
|
||||
func (s *SessionStore) ClearAllUserSessions(_ *http.Request, _ *sessions.SessionState) error {
|
||||
return fmt.Errorf("ClearAllUserSessions is only supported by redis store")
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ func (m *Manager) Save(rw http.ResponseWriter, req *http.Request, s *sessions.Se
|
|||
|
||||
err = tckt.saveSession(
|
||||
s,
|
||||
func(key string, val []byte, exp time.Duration, s *sessions.SessionState) error {
|
||||
func(key string, val []byte, exp time.Duration) error {
|
||||
return m.Store.Save(req.Context(), key, val, exp)
|
||||
},
|
||||
func(key string, val string, exp time.Duration) error {
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ import (
|
|||
|
||||
// saveFunc performs a persistent store's save functionality using
|
||||
// a key string, value []byte & (optional) expiration time.Duration
|
||||
type saveFunc func(string, []byte, time.Duration, *sessions.SessionState) error
|
||||
type saveFunc func(string, []byte, time.Duration) error
|
||||
|
||||
// saveUserStateFunc performs a persistent store's save functionality using
|
||||
// a key string, value []byte & (optional) expiration time.Duration
|
||||
|
|
@ -173,7 +173,7 @@ func (t *ticket) saveSession(s *sessions.SessionState, saver saveFunc, saverUser
|
|||
|
||||
encodedUserState := encryption.EncryptStringWithSecret(s.User+s.Email, t.options.Secret)
|
||||
saverUserMapSession(encodedUserState, t.id, 2*time.Hour)
|
||||
return saver(t.id, ciphertext, t.options.Expire, s)
|
||||
return saver(t.id, ciphertext, t.options.Expire)
|
||||
}
|
||||
|
||||
// loadSession loads a session from the disk store via the passed loadFunc
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ var _ = Describe("Session Ticket Tests", func() {
|
|||
}
|
||||
err = t.saveSession(
|
||||
ss,
|
||||
func(k string, v []byte, e time.Duration, s *sessions.SessionState) error {
|
||||
func(k string, v []byte, e time.Duration) error {
|
||||
store[k] = v
|
||||
return nil
|
||||
},
|
||||
|
|
@ -98,7 +98,7 @@ var _ = Describe("Session Ticket Tests", func() {
|
|||
|
||||
err = t.saveSession(
|
||||
&sessions.SessionState{User: "foobar"},
|
||||
func(k string, v []byte, e time.Duration, s *sessions.SessionState) error {
|
||||
func(k string, v []byte, e time.Duration) error {
|
||||
return errors.New("save error")
|
||||
},
|
||||
func(key string, value string, d time.Duration) error {
|
||||
|
|
@ -113,7 +113,7 @@ var _ = Describe("Session Ticket Tests", func() {
|
|||
|
||||
err = t.saveSession(
|
||||
&sessions.SessionState{User: "foobar"},
|
||||
func(k string, v []byte, e time.Duration, s *sessions.SessionState) error {
|
||||
func(k string, v []byte, e time.Duration) error {
|
||||
return nil
|
||||
},
|
||||
func(key string, value string, d time.Duration) error {
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ type MockStore struct {
|
|||
}
|
||||
|
||||
// LoadList implements persistence.Store.
|
||||
func (s *MockStore) LoadList(ctx context.Context, key string) ([]string, error) {
|
||||
func (s *MockStore) LoadList(_ context.Context, key string) ([]string, error) {
|
||||
entry, ok := s.cacheList[key]
|
||||
if !ok || entry.expiration <= s.elapsed {
|
||||
delete(s.cache, key)
|
||||
|
|
@ -39,7 +39,7 @@ func (s *MockStore) LoadList(ctx context.Context, key string) ([]string, error)
|
|||
}
|
||||
|
||||
// RPush implements persistence.Store.
|
||||
func (s *MockStore) RPush(ctx context.Context, key string, value string, time time.Duration) error {
|
||||
func (s *MockStore) RPush(_ context.Context, key string, value string, time time.Duration) error {
|
||||
entry, ok := s.cacheList[key]
|
||||
if ok {
|
||||
// If the key exists, check if the expiration is still valid
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ type testInput struct {
|
|||
request *http.Request
|
||||
response *httptest.ResponseRecorder
|
||||
persistentFastForward PersistentStoreFastForwardFunc
|
||||
opts *options.SessionOptions
|
||||
}
|
||||
|
||||
// sessionStoreFunc is used in testInput to wrap the SessionStore interface.
|
||||
|
|
@ -93,6 +94,7 @@ func RunSessionStoreTests(newSS NewSessionStoreFunc, persistentFastForward Persi
|
|||
request: request,
|
||||
response: response,
|
||||
persistentFastForward: persistentFastForward,
|
||||
opts: opts,
|
||||
}
|
||||
})
|
||||
|
||||
|
|
@ -463,6 +465,10 @@ func SessionStoreInterfaceTests(in *testInput) {
|
|||
}
|
||||
})
|
||||
It("should clear all user sessions", func() {
|
||||
if in.opts.Type == options.CookieSessionStoreType {
|
||||
Expect(in.ss().ClearAllUserSessions(in.request, in.session)).To(MatchError("ClearAllUserSessions is only supported by redis store"))
|
||||
return
|
||||
}
|
||||
err := in.ss().ClearAllUserSessions(in.request, in.session)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue