2020-09-28 19:18:49 +00:00
|
|
|
package basic
|
2020-10-01 18:11:43 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestBasicLogin(t *testing.T) {
|
|
|
|
basicCredentials := make(map[string]string)
|
|
|
|
basicCredentials["demo"] = "$2b$15$LRnG3eIHFlYIguTxZOLH7eHwbQC/vqjnLq6nDFiHSUDKIU.f5/1H6"
|
|
|
|
|
2020-10-09 20:42:09 +00:00
|
|
|
// Test good credentials
|
2020-10-01 18:11:43 +00:00
|
|
|
backend, _ := New(&Options{Credentials: basicCredentials})
|
|
|
|
ok, err := backend.Login("demo", "demo")
|
|
|
|
if !ok {
|
|
|
|
t.Error("Error while logging with the basic authentication:", err)
|
|
|
|
}
|
2020-10-09 20:42:09 +00:00
|
|
|
|
|
|
|
// Test bad credentials
|
|
|
|
ok, err = backend.Login("demo", "badpass")
|
|
|
|
if ok {
|
|
|
|
t.Error("Authentification failed to fail:", err)
|
|
|
|
}
|
|
|
|
|
2020-10-01 18:11:43 +00:00
|
|
|
backend.Close()
|
|
|
|
}
|