summaryrefslogtreecommitdiff
path: root/internal/configuration/validator/authentication_test.go
diff options
context:
space:
mode:
authorJames Elliott <james-d-elliott@users.noreply.github.com>2023-11-23 08:20:36 +1100
committerGitHub <noreply@github.com>2023-11-23 08:20:36 +1100
commitc49b973120c7fd755923a2b88afd794c7d320d6e (patch)
tree5fcef6de1a85568eee3c67470f73b790b294dda8 /internal/configuration/validator/authentication_test.go
parentfa141929a39e546f3f3ca6bcbc7bd72c64e575c8 (diff)
fix(configuration): illogical refresh interval default (#6319)
When using the file provider with watch enabled, the refresh interval should just be set to always default as the cost is minimal. Signed-off-by: James Elliott <james-d-elliott@users.noreply.github.com>
Diffstat (limited to 'internal/configuration/validator/authentication_test.go')
-rw-r--r--internal/configuration/validator/authentication_test.go29
1 files changed, 17 insertions, 12 deletions
diff --git a/internal/configuration/validator/authentication_test.go b/internal/configuration/validator/authentication_test.go
index f06a53af1..1248de0cd 100644
--- a/internal/configuration/validator/authentication_test.go
+++ b/internal/configuration/validator/authentication_test.go
@@ -65,6 +65,19 @@ func (suite *FileBasedAuthenticationBackend) TestShouldValidateCompleteConfigura
suite.Len(suite.validator.Errors(), 0)
}
+func (suite *FileBasedAuthenticationBackend) TestShouldValidateWatchDefaultResetInterval() {
+ suite.config.File.Watch = true
+
+ ValidateAuthenticationBackend(&suite.config, suite.validator)
+
+ suite.Len(suite.validator.Warnings(), 0)
+ suite.Len(suite.validator.Errors(), 0)
+
+ suite.True(suite.config.RefreshInterval.Valid())
+ suite.True(suite.config.RefreshInterval.Always())
+ suite.False(suite.config.RefreshInterval.Never())
+}
+
func (suite *FileBasedAuthenticationBackend) TestShouldRaiseErrorWhenNoPathProvided() {
suite.config.File.Path = ""
@@ -751,17 +764,6 @@ func (suite *LDAPAuthenticationBackendSuite) TestShouldNotRaiseOnEmptyUsernameAt
suite.Len(suite.validator.Errors(), 0)
}
-func (suite *LDAPAuthenticationBackendSuite) TestShouldRaiseOnBadRefreshInterval() {
- suite.config.RefreshInterval = "blah"
-
- ValidateAuthenticationBackend(&suite.config, suite.validator)
-
- suite.Len(suite.validator.Warnings(), 0)
- suite.Require().Len(suite.validator.Errors(), 1)
-
- suite.EqualError(suite.validator.Errors()[0], "authentication_backend: option 'refresh_interval' is configured to 'blah' but it must be either in duration common syntax or one of 'disable', or 'always': could not parse 'blah' as a duration")
-}
-
func (suite *LDAPAuthenticationBackendSuite) TestShouldSetDefaultImplementation() {
ValidateAuthenticationBackend(&suite.config, suite.validator)
@@ -820,7 +822,10 @@ func (suite *LDAPAuthenticationBackendSuite) TestShouldSetDefaultRefreshInterval
suite.Len(suite.validator.Warnings(), 0)
suite.Len(suite.validator.Errors(), 0)
- suite.Equal("5m", suite.config.RefreshInterval)
+ suite.Require().NotNil(suite.config.RefreshInterval)
+ suite.False(suite.config.RefreshInterval.Always())
+ suite.False(suite.config.RefreshInterval.Never())
+ suite.Equal(time.Minute*5, suite.config.RefreshInterval.Value())
}
func (suite *LDAPAuthenticationBackendSuite) TestShouldRaiseWhenUsersFilterDoesNotContainEnclosingParenthesis() {