From 431bc2e7de9ca3a58a20ae511086c3f916e1cdd4 Mon Sep 17 00:00:00 2001 From: Alexandre Iooss Date: Fri, 9 Oct 2020 23:08:50 +0200 Subject: [PATCH] More auth backend test --- auth/auth_test.go | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/auth/auth_test.go b/auth/auth_test.go index ea97e8c..bf98e62 100644 --- a/auth/auth_test.go +++ b/auth/auth_test.go @@ -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:") } }