2019-11-06 14:41:21 -06:00
|
|
|
package ldap
|
|
|
|
|
|
|
|
import (
|
2023-02-28 05:13:46 -06:00
|
|
|
"crypto/tls"
|
2019-11-06 14:41:21 -06:00
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
2020-12-15 02:32:06 -06:00
|
|
|
"github.com/stretchr/testify/require"
|
2019-11-06 14:41:21 -06:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestReadingLDAPSettings(t *testing.T) {
|
|
|
|
config, err := readConfig("testdata/ldap.toml")
|
|
|
|
assert.Nil(t, err, "No error when reading ldap config")
|
|
|
|
assert.EqualValues(t, "127.0.0.1", config.Servers[0].Host)
|
2023-02-28 05:13:46 -06:00
|
|
|
assert.EqualValues(t, "tls1.3", config.Servers[0].MinTLSVersion)
|
|
|
|
assert.EqualValues(t, uint16(tls.VersionTLS13), config.Servers[0].minTLSVersion)
|
|
|
|
assert.EqualValues(t, []string{"TLS_CHACHA20_POLY1305_SHA256", "TLS_AES_128_GCM_SHA256"}, config.Servers[0].TLSCiphers)
|
|
|
|
assert.ElementsMatch(t, []uint16{tls.TLS_CHACHA20_POLY1305_SHA256, tls.TLS_AES_128_GCM_SHA256}, config.Servers[0].tlsCiphers)
|
2019-11-06 14:41:21 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestReadingLDAPSettingsWithEnvVariable(t *testing.T) {
|
2023-02-28 05:13:46 -06:00
|
|
|
t.Setenv("ENV_PASSWORD", "MySecret")
|
2019-11-06 14:41:21 -06:00
|
|
|
|
|
|
|
config, err := readConfig("testdata/ldap.toml")
|
2020-12-15 02:32:06 -06:00
|
|
|
require.NoError(t, err)
|
2019-11-06 14:41:21 -06:00
|
|
|
assert.EqualValues(t, "MySecret", config.Servers[0].BindPassword)
|
|
|
|
}
|