mirror of
https://github.com/0rangebananaspy/authelia.git
synced 2024-09-14 22:47:21 +07:00
150116a172
* Implement an automatic theme The "auto" theme will automatically switch between "dark" and "light" depending on user preference. This allows for automatic dark mode. * fix(configuration): allow the "auto" theme when validating The new theme "auto" was not allowed to be used in a configuration file. * docs: clarify what critera controls the automatic theme How the "auto" theme functioned was unclear. * docs: typeset themes as code * fix(web): apply useEffector to media query watch * docs: add technical details * fix(configuration): resolve merge conflicts
45 lines
1.1 KiB
Go
45 lines
1.1 KiB
Go
package validator
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/suite"
|
|
|
|
"github.com/authelia/authelia/internal/configuration/schema"
|
|
)
|
|
|
|
type Theme struct {
|
|
suite.Suite
|
|
configuration *schema.Configuration
|
|
validator *schema.StructValidator
|
|
}
|
|
|
|
func (suite *Theme) SetupTest() {
|
|
suite.validator = schema.NewStructValidator()
|
|
suite.configuration = &schema.Configuration{
|
|
Theme: "light",
|
|
}
|
|
}
|
|
|
|
func (suite *Theme) TestShouldValidateCompleteConfiguration() {
|
|
ValidateTheme(suite.configuration, suite.validator)
|
|
|
|
suite.Assert().False(suite.validator.HasWarnings())
|
|
suite.Assert().False(suite.validator.HasErrors())
|
|
}
|
|
|
|
func (suite *Theme) TestShouldRaiseErrorWhenInvalidThemeProvided() {
|
|
suite.configuration.Theme = "invalid"
|
|
|
|
ValidateTheme(suite.configuration, suite.validator)
|
|
|
|
suite.Assert().False(suite.validator.HasWarnings())
|
|
suite.Require().Len(suite.validator.Errors(), 1)
|
|
|
|
suite.Assert().EqualError(suite.validator.Errors()[0], "Theme: invalid is not valid, valid themes are: \"light\", \"dark\", \"grey\" or \"auto\"")
|
|
}
|
|
|
|
func TestThemes(t *testing.T) {
|
|
suite.Run(t, new(Theme))
|
|
}
|