mirror of
https://github.com/0rangebananaspy/authelia.git
synced 2024-09-14 22:47:21 +07:00
54694c4fca
* [MISC] Ignore errcheck recommendations for legacy code Some of this is likely intended to stay how it is, some could use refactoring, for now we will mark is and ignore it from the linter to be potentially addressed in the future. * [MISC] Ensure files are gofmt-ed
44 lines
991 B
Go
44 lines
991 B
Go
package handlers
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
|
|
"github.com/authelia/authelia/internal/mocks"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
"github.com/stretchr/testify/suite"
|
|
)
|
|
|
|
type LogoutSuite struct {
|
|
suite.Suite
|
|
|
|
mock *mocks.MockAutheliaCtx
|
|
}
|
|
|
|
func (s *LogoutSuite) SetupTest() {
|
|
s.mock = mocks.NewMockAutheliaCtx(s.T())
|
|
userSession := s.mock.Ctx.GetSession()
|
|
userSession.Username = "john"
|
|
s.mock.Ctx.SaveSession(userSession) //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting.
|
|
}
|
|
|
|
func (s *LogoutSuite) TearDownTest() {
|
|
s.mock.Close()
|
|
}
|
|
|
|
func (s *LogoutSuite) TestShouldDestroySession() {
|
|
LogoutPost(s.mock.Ctx)
|
|
b := s.mock.Ctx.Response.Header.PeekCookie("authelia_session")
|
|
|
|
// Reset the cookie, meaning it resets the value and expires the cookie by setting
|
|
// date to one minute in the past.
|
|
assert.True(s.T(), strings.HasPrefix(string(b), "authelia_session=;"))
|
|
}
|
|
|
|
func TestRunLogoutSuite(t *testing.T) {
|
|
s := new(LogoutSuite)
|
|
suite.Run(t, s)
|
|
}
|