1
0
mirror of https://gitlab.crans.org/nounous/ghostream.git synced 2024-12-22 15:02:19 +00:00

More auth backend test

This commit is contained in:
Alexandre Iooss 2020-10-09 23:08:50 +02:00
parent c7d38ba546
commit 431bc2e7de
No known key found for this signature in database
GPG Key ID: 6C79278F3FCDCC02

View File

@ -15,7 +15,7 @@ func TestLoadConfiguration(t *testing.T) {
Basic: basic.Options{Credentials: make(map[string]string)}, Basic: basic.Options{Credentials: make(map[string]string)},
}) })
if err != nil { if err != nil {
t.Error("Creating basic authentication backend failed:", err) t.Errorf("Creating basic authentication backend failed: %s", err)
} }
// Test to create a LDAP authentification backend // Test to create a LDAP authentification backend
@ -26,7 +26,7 @@ func TestLoadConfiguration(t *testing.T) {
LDAP: ldap.Options{URI: "ldap://127.0.0.1:389", UserDn: "cn=users,dc=example,dc=com"}, LDAP: ldap.Options{URI: "ldap://127.0.0.1:389", UserDn: "cn=users,dc=example,dc=com"},
}) })
if err == nil { if err == nil {
t.Error("Creating ldap authentication backend successed mysteriously:", err) t.Errorf("Creating ldap authentication backend successed mysteriously: %s", err)
} }
// Test to bypass authentification backend // Test to bypass authentification backend
@ -34,6 +34,15 @@ func TestLoadConfiguration(t *testing.T) {
Enabled: false, Enabled: false,
}) })
if backend != nil { if backend != nil {
t.Error("Failed to bypass authentication backend:", err) t.Errorf("Failed to bypass authentication backend: %s", err)
}
// Test bad authentification backend
_, err = New(&Options{
Enabled: true,
Backend: "idonotexist",
})
if err == nil {
t.Error("Failed to fail authentication backend init:")
} }
} }