mirror of
https://github.com/0rangebananaspy/authelia.git
synced 2024-09-14 22:47:21 +07:00
c9e8a924e0
* implement read buffer size config option * implement write buffer size config option * implement fasthttp ErrorHandler so we can log errors to Authelia as well * add struct/schema validation * add default value * add docs * add config key to validator * refactoring * apply suggestions from code review Co-authored-by: Amir Zarrinkafsh <nightah@me.com>
36 lines
960 B
Go
36 lines
960 B
Go
package validator
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
|
|
"github.com/authelia/authelia/internal/configuration/schema"
|
|
)
|
|
|
|
func TestShouldSetDefaultConfig(t *testing.T) {
|
|
validator := schema.NewStructValidator()
|
|
config := schema.ServerConfiguration{}
|
|
|
|
ValidateServer(&config, validator)
|
|
|
|
require.Len(t, validator.Errors(), 0)
|
|
assert.Equal(t, defaultReadBufferSize, config.ReadBufferSize)
|
|
assert.Equal(t, defaultWriteBufferSize, config.WriteBufferSize)
|
|
}
|
|
|
|
func TestShouldRaiseOnNegativeValues(t *testing.T) {
|
|
validator := schema.NewStructValidator()
|
|
config := schema.ServerConfiguration{
|
|
ReadBufferSize: -1,
|
|
WriteBufferSize: -1,
|
|
}
|
|
|
|
ValidateServer(&config, validator)
|
|
|
|
require.Len(t, validator.Errors(), 2)
|
|
assert.EqualError(t, validator.Errors()[0], "server read buffer size must be above 0")
|
|
assert.EqualError(t, validator.Errors()[1], "server write buffer size must be above 0")
|
|
}
|