mirror of
https://github.com/0rangebananaspy/authelia.git
synced 2024-09-14 22:47:21 +07:00
05406cfc7b
This adds method to validate the system clock is synchronized on startup. Configuration allows adjusting the server address, enabled state, desync limit, and if the error is fatal. Co-authored-by: James Elliott <james-d-elliott@users.noreply.github.com>
27 lines
602 B
Go
27 lines
602 B
Go
package ntp
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
"github.com/authelia/authelia/v4/internal/configuration/schema"
|
|
"github.com/authelia/authelia/v4/internal/configuration/validator"
|
|
)
|
|
|
|
func TestShouldCheckNTP(t *testing.T) {
|
|
config := schema.NTPConfiguration{
|
|
Address: "time.cloudflare.com:123",
|
|
Version: 4,
|
|
MaximumDesync: "3s",
|
|
DisableStartupCheck: false,
|
|
}
|
|
sv := schema.NewStructValidator()
|
|
validator.ValidateNTP(&config, sv)
|
|
|
|
NTP := NewProvider(&config)
|
|
|
|
checkfailed, _ := NTP.StartupCheck()
|
|
assert.Equal(t, false, checkfailed)
|
|
}
|