1
0
mirror of https://gitlab.crans.org/nounous/ghostream.git synced 2025-02-06 05:33:00 +00:00
ghostream/auth/auth_test.go

40 lines
983 B
Go
Raw Normal View History

package auth
2020-10-01 20:11:43 +02:00
import (
2020-10-09 22:17:07 +02:00
"testing"
2020-10-01 20:11:43 +02:00
"gitlab.crans.org/nounous/ghostream/auth/basic"
"gitlab.crans.org/nounous/ghostream/auth/ldap"
)
func TestLoadConfiguration(t *testing.T) {
2020-10-09 22:42:09 +02:00
// Test to create a basic authentification backend
2020-10-09 22:17:07 +02:00
_, err := New(&Options{
Enabled: true,
Backend: "basic",
Basic: basic.Options{Credentials: make(map[string]string)},
})
2020-10-01 20:11:43 +02:00
if err != nil {
t.Error("Creating basic authentication backend failed:", err)
}
2020-10-09 22:42:09 +02:00
// Test to create a LDAP authentification backend
// FIXME Should fail as there is no LDAP server
2020-10-09 22:17:07 +02:00
_, err = New(&Options{
Enabled: true,
Backend: "ldap",
LDAP: ldap.Options{URI: "ldap://127.0.0.1:389", UserDn: "cn=users,dc=example,dc=com"},
})
2020-10-01 20:11:43 +02:00
if err == nil {
t.Error("Creating ldap authentication backend successed mysteriously:", err)
}
2020-10-09 22:42:09 +02:00
// Test to bypass authentification backend
backend, err := New(&Options{
Enabled: false,
})
if backend != nil {
t.Error("Failed to bypass authentication backend:", err)
}
2020-10-01 20:11:43 +02:00
}