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
1 changed files with 12 additions and 3 deletions

View File

@ -15,7 +15,7 @@ func TestLoadConfiguration(t *testing.T) {
Basic: basic.Options{Credentials: make(map[string]string)},
})
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
@ -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"},
})
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
@ -34,6 +34,15 @@ func TestLoadConfiguration(t *testing.T) {
Enabled: false,
})
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:")
}
}