2019-04-25 04:52:08 +07:00
|
|
|
package configuration
|
|
|
|
|
|
|
|
import (
|
2020-01-22 03:56:44 +07:00
|
|
|
"os"
|
2019-04-25 04:52:08 +07:00
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
2020-01-22 03:56:44 +07:00
|
|
|
"github.com/stretchr/testify/require"
|
2019-04-25 04:52:08 +07:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestShouldParseConfigFile(t *testing.T) {
|
2020-01-22 03:56:44 +07:00
|
|
|
err := os.Setenv("AUTHELIA_JWT_SECRET", "secret_from_env")
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
err = os.Setenv("AUTHELIA_DUO_API_SECRET_KEY", "duo_secret_from_env")
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
2019-11-30 21:27:39 +07:00
|
|
|
config, errors := Read("./test_resources/config.yml")
|
2019-04-25 04:52:08 +07:00
|
|
|
|
2020-01-22 03:56:44 +07:00
|
|
|
require.Len(t, errors, 0)
|
2019-04-25 04:52:08 +07:00
|
|
|
|
|
|
|
assert.Equal(t, 9091, config.Port)
|
|
|
|
assert.Equal(t, "debug", config.LogsLevel)
|
|
|
|
assert.Equal(t, "https://home.example.com:8080/", config.DefaultRedirectionURL)
|
|
|
|
assert.Equal(t, "authelia.com", config.TOTP.Issuer)
|
2020-01-22 03:56:44 +07:00
|
|
|
assert.Equal(t, "secret_from_env", config.JWTSecret)
|
2019-04-25 04:52:08 +07:00
|
|
|
|
|
|
|
assert.Equal(t, "api-123456789.example.com", config.DuoAPI.Hostname)
|
|
|
|
assert.Equal(t, "ABCDEF", config.DuoAPI.IntegrationKey)
|
2020-01-22 03:56:44 +07:00
|
|
|
assert.Equal(t, "duo_secret_from_env", config.DuoAPI.SecretKey)
|
|
|
|
|
|
|
|
assert.Equal(t, "deny", config.AccessControl.DefaultPolicy)
|
|
|
|
assert.Len(t, config.AccessControl.Rules, 11)
|
2019-04-25 04:52:08 +07:00
|
|
|
}
|