2021-09-17 11:44:35 +07:00
|
|
|
package ntp
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
2022-03-02 13:40:26 +07:00
|
|
|
"time"
|
2021-09-17 11:44:35 +07:00
|
|
|
|
|
|
|
"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) {
|
2022-02-28 10:15:01 +07:00
|
|
|
config := &schema.Configuration{
|
2022-03-02 13:40:26 +07:00
|
|
|
NTP: schema.NTPConfiguration{
|
|
|
|
Address: "time.cloudflare.com:123",
|
|
|
|
Version: 4,
|
|
|
|
MaximumDesync: time.Second * 3,
|
2022-02-28 10:15:01 +07:00
|
|
|
},
|
2021-09-17 11:44:35 +07:00
|
|
|
}
|
2022-02-28 10:15:01 +07:00
|
|
|
|
2021-09-17 11:44:35 +07:00
|
|
|
sv := schema.NewStructValidator()
|
2022-02-28 10:15:01 +07:00
|
|
|
validator.ValidateNTP(config, sv)
|
2021-09-17 11:44:35 +07:00
|
|
|
|
2022-03-02 13:40:26 +07:00
|
|
|
ntp := NewProvider(&config.NTP)
|
2021-09-17 11:44:35 +07:00
|
|
|
|
2021-11-23 16:45:38 +07:00
|
|
|
assert.NoError(t, ntp.StartupCheck())
|
2021-09-17 11:44:35 +07:00
|
|
|
}
|