2019-12-07 16:40:42 +00:00
|
|
|
package handlers
|
|
|
|
|
|
|
|
import (
|
2020-04-05 12:37:21 +00:00
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/suite"
|
|
|
|
|
2019-12-24 02:14:52 +00:00
|
|
|
"github.com/authelia/authelia/internal/mocks"
|
2020-04-03 23:11:33 +00:00
|
|
|
"github.com/authelia/authelia/internal/session"
|
2019-12-07 16:40:42 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type ConfigurationSuite struct {
|
|
|
|
suite.Suite
|
|
|
|
|
|
|
|
mock *mocks.MockAutheliaCtx
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *ConfigurationSuite) SetupTest() {
|
|
|
|
s.mock = mocks.NewMockAutheliaCtx(s.T())
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *ConfigurationSuite) TearDownTest() {
|
|
|
|
s.mock.Close()
|
|
|
|
}
|
|
|
|
|
2020-04-03 23:11:33 +00:00
|
|
|
func (s *ConfigurationSuite) TestShouldDisableRememberMe() {
|
|
|
|
s.mock.Ctx.Configuration.Session.RememberMeDuration = "0"
|
|
|
|
s.mock.Ctx.Providers.SessionProvider = session.NewProvider(
|
|
|
|
s.mock.Ctx.Configuration.Session)
|
|
|
|
expectedBody := ConfigurationBody{
|
2020-05-15 23:41:42 +00:00
|
|
|
RememberMe: false,
|
|
|
|
ResetPassword: true,
|
2020-04-04 23:28:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ConfigurationGet(s.mock.Ctx)
|
|
|
|
s.mock.Assert200OK(s.T(), expectedBody)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *ConfigurationSuite) TestShouldDisableResetPassword() {
|
|
|
|
s.mock.Ctx.Configuration.AuthenticationBackend.DisableResetPassword = true
|
|
|
|
expectedBody := ConfigurationBody{
|
2020-05-15 23:41:42 +00:00
|
|
|
RememberMe: true,
|
|
|
|
ResetPassword: false,
|
2020-04-03 23:11:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ConfigurationGet(s.mock.Ctx)
|
|
|
|
s.mock.Assert200OK(s.T(), expectedBody)
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestRunHandlerConfigurationSuite(t *testing.T) {
|
|
|
|
s := new(ConfigurationSuite)
|
|
|
|
suite.Run(t, s)
|
|
|
|
}
|