mirror of
https://github.com/glauth/glauth.git
synced 2026-10-27 14:36:59 +00:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 54727ce9af | |||
| c8e7a7e7e6 | |||
| 2e125a4a2f |
@@ -1,7 +1,6 @@
|
|||||||
package handler
|
package handler
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"net"
|
"net"
|
||||||
"testing"
|
"testing"
|
||||||
@@ -14,9 +13,22 @@ import (
|
|||||||
"github.com/glauth/ldap"
|
"github.com/glauth/ldap"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type disabledBindTestMonitor struct{}
|
||||||
|
|
||||||
|
func (disabledBindTestMonitor) SetResponseTimeMetric(map[string]string, float64) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (disabledBindTestMonitor) SetLDAPMetric(map[string]string, float64) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func TestConfigBackendDisabledUserCannotBind(t *testing.T) {
|
func TestConfigBackendDisabledUserCannotBind(t *testing.T) {
|
||||||
pw := "correct horse"
|
pw := "correct horse"
|
||||||
raw, _ := bcrypt.GenerateFromPassword([]byte(pw), bcrypt.MinCost)
|
raw, err := bcrypt.GenerateFromPassword([]byte(pw), bcrypt.MinCost)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
hexHash := hex.EncodeToString(raw)
|
hexHash := hex.EncodeToString(raw)
|
||||||
|
|
||||||
cfg := &config.Config{}
|
cfg := &config.Config{}
|
||||||
@@ -37,13 +49,14 @@ func TestConfigBackendDisabledUserCannotBind(t *testing.T) {
|
|||||||
log: &logger,
|
log: &logger,
|
||||||
cfg: cfg,
|
cfg: cfg,
|
||||||
ldohelper: helper,
|
ldohelper: helper,
|
||||||
|
monitor: disabledBindTestMonitor{},
|
||||||
tracer: tracer,
|
tracer: tracer,
|
||||||
}
|
}
|
||||||
_, server := net.Pipe()
|
_, server := net.Pipe()
|
||||||
defer server.Close()
|
defer server.Close()
|
||||||
|
|
||||||
bind := func(dn, pass string) ldap.LDAPResultCode {
|
bind := func(dn, pass string) ldap.LDAPResultCode {
|
||||||
code, _ := helper.Bind(context.Background(), h, dn, pass, server)
|
code, _ := h.Bind(dn, pass, server)
|
||||||
return code
|
return code
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user