Drop Session suffix from SessionStore methods
This commit is contained in:
parent
455e0004b8
commit
1d29a0d094
@ -6,7 +6,7 @@ import (
|
||||
|
||||
// SessionStore is an interface to storing user sessions in the proxy
|
||||
type SessionStore interface {
|
||||
SaveSession(rw http.ResponseWriter, req *http.Request, s *SessionState) error
|
||||
LoadSession(req *http.Request) (*SessionState, error)
|
||||
ClearSession(rw http.ResponseWriter, req *http.Request) error
|
||||
Save(rw http.ResponseWriter, req *http.Request, s *SessionState) error
|
||||
Load(req *http.Request) (*SessionState, error)
|
||||
Clear(rw http.ResponseWriter, req *http.Request) error
|
||||
}
|
||||
|
@ -37,9 +37,9 @@ type SessionStore struct {
|
||||
CookieSecure bool
|
||||
}
|
||||
|
||||
// SaveSession takes a sessions.SessionState and stores the information from it
|
||||
// Save takes a sessions.SessionState and stores the information from it
|
||||
// within Cookies set on the HTTP response writer
|
||||
func (s *SessionStore) SaveSession(rw http.ResponseWriter, req *http.Request, ss *sessions.SessionState) error {
|
||||
func (s *SessionStore) Save(rw http.ResponseWriter, req *http.Request, ss *sessions.SessionState) error {
|
||||
value, err := utils.CookieForSession(ss, s.CookieCipher)
|
||||
if err != nil {
|
||||
return err
|
||||
@ -48,9 +48,9 @@ func (s *SessionStore) SaveSession(rw http.ResponseWriter, req *http.Request, ss
|
||||
return nil
|
||||
}
|
||||
|
||||
// LoadSession reads sessions.SessionState information from Cookies within the
|
||||
// Load reads sessions.SessionState information from Cookies within the
|
||||
// HTTP request object
|
||||
func (s *SessionStore) LoadSession(req *http.Request) (*sessions.SessionState, error) {
|
||||
func (s *SessionStore) Load(req *http.Request) (*sessions.SessionState, error) {
|
||||
c, err := loadCookie(req, s.CookieName)
|
||||
if err != nil {
|
||||
// always http.ErrNoCookie
|
||||
@ -68,9 +68,9 @@ func (s *SessionStore) LoadSession(req *http.Request) (*sessions.SessionState, e
|
||||
return session, nil
|
||||
}
|
||||
|
||||
// ClearSession clears any saved session information by writing a cookie to
|
||||
// Clear clears any saved session information by writing a cookie to
|
||||
// clear the session
|
||||
func (s *SessionStore) ClearSession(rw http.ResponseWriter, req *http.Request) error {
|
||||
func (s *SessionStore) Clear(rw http.ResponseWriter, req *http.Request) error {
|
||||
var cookies []*http.Cookie
|
||||
|
||||
// matches CookieName, CookieName_<number>
|
||||
|
@ -76,9 +76,9 @@ var _ = Describe("NewSessionStore", func() {
|
||||
}
|
||||
|
||||
SessionStoreInterfaceTests := func() {
|
||||
Context("when SaveSession is called", func() {
|
||||
Context("when Save is called", func() {
|
||||
BeforeEach(func() {
|
||||
err := ss.SaveSession(response, request, session)
|
||||
err := ss.Save(response, request, session)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
})
|
||||
|
||||
@ -89,7 +89,7 @@ var _ = Describe("NewSessionStore", func() {
|
||||
CheckCookieOptions()
|
||||
})
|
||||
|
||||
Context("when ClearSession is called", func() {
|
||||
Context("when Clear is called", func() {
|
||||
BeforeEach(func() {
|
||||
cookie := cookies.MakeCookie(request,
|
||||
cookieOpts.CookieName,
|
||||
@ -102,7 +102,7 @@ var _ = Describe("NewSessionStore", func() {
|
||||
time.Now(),
|
||||
)
|
||||
request.AddCookie(cookie)
|
||||
err := ss.ClearSession(response, request)
|
||||
err := ss.Clear(response, request)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
})
|
||||
|
||||
@ -113,18 +113,18 @@ var _ = Describe("NewSessionStore", func() {
|
||||
CheckCookieOptions()
|
||||
})
|
||||
|
||||
Context("when LoadSession is called", func() {
|
||||
Context("when Load is called", func() {
|
||||
var loadedSession *sessionsapi.SessionState
|
||||
BeforeEach(func() {
|
||||
req := httptest.NewRequest("GET", "http://example.com/", nil)
|
||||
resp := httptest.NewRecorder()
|
||||
err := ss.SaveSession(resp, req, session)
|
||||
err := ss.Save(resp, req, session)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
|
||||
for _, cookie := range resp.Result().Cookies() {
|
||||
request.AddCookie(cookie)
|
||||
}
|
||||
loadedSession, err = ss.LoadSession(request)
|
||||
loadedSession, err = ss.Load(request)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
})
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user