mirror of
https://github.com/grafana/grafana.git
synced 2024-11-26 02:40:26 -06:00
7e97dbde65
* update ldap library and use go module path * add TLS min version and accepted min TLS version * set default min ver to library default * set default min ver to library default * add cipher list to toml * Update pkg/services/ldap/settings.go Co-authored-by: Karl Persson <kalle.persson@grafana.com> * Apply suggestions from code review Co-authored-by: Christopher Moyer <35463610+chri2547@users.noreply.github.com> * lint --------- Co-authored-by: Karl Persson <kalle.persson@grafana.com> Co-authored-by: Christopher Moyer <35463610+chri2547@users.noreply.github.com>
28 lines
981 B
Go
28 lines
981 B
Go
package ldap
|
|
|
|
import (
|
|
"crypto/tls"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
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)
|
|
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)
|
|
}
|
|
|
|
func TestReadingLDAPSettingsWithEnvVariable(t *testing.T) {
|
|
t.Setenv("ENV_PASSWORD", "MySecret")
|
|
|
|
config, err := readConfig("testdata/ldap.toml")
|
|
require.NoError(t, err)
|
|
assert.EqualValues(t, "MySecret", config.Servers[0].BindPassword)
|
|
}
|