mirror of
https://github.com/0rangebananaspy/authelia.git
synced 2024-09-14 22:47:21 +07:00
daa30f3aa3
* [FEATURE] Add theme support This change allows users to select a theme for Authelia on start-up. The default will continue to be the existing theme which is known as `light`. Three new options are now also provided: * `dark` * `grey` * `custom` The `custom` theme allows users to specify a primary and secondary hex color code to be utilised to style the portal. Co-authored-by: BankaiNoJutsu <lbegert@gmail.com> * Add themes to integration tests * Remove custom theme * Fix linting issue in access_control_test.go Co-authored-by: BankaiNoJutsu <lbegert@gmail.com>
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\" or \"grey\"")
|
|
}
|
|
|
|
func TestThemes(t *testing.T) {
|
|
suite.Run(t, new(Theme))
|
|
}
|