@@ -16,6 +16,6 @@ type Interface interface {
|
||||
// Get gets a user by its username from ldap, return ErrUserNotExists if user not exists
|
||||
Get(name string) (*iam.User, error)
|
||||
|
||||
// Verify checks if (name, password) is valid, return ErrInvalidCredentials if not
|
||||
Verify(name string, password string) error
|
||||
// Authenticate checks if (name, password) is valid, return ErrInvalidCredentials if not
|
||||
Authenticate(name string, password string) error
|
||||
}
|
||||
|
||||
@@ -347,7 +347,7 @@ func (l *ldapInterfaceImpl) Update(newUser *iam.User) error {
|
||||
|
||||
}
|
||||
|
||||
func (l *ldapInterfaceImpl) Verify(username, password string) error {
|
||||
func (l *ldapInterfaceImpl) Authenticate(username, password string) error {
|
||||
conn, err := l.newConn()
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -60,7 +60,7 @@ func (s simpleLdap) Get(name string) (*iam.User, error) {
|
||||
}
|
||||
}
|
||||
|
||||
func (s simpleLdap) Verify(name string, password string) error {
|
||||
func (s simpleLdap) Authenticate(name string, password string) error {
|
||||
if user, err := s.Get(name); err != nil {
|
||||
return err
|
||||
} else {
|
||||
|
||||
@@ -85,12 +85,12 @@ func TestSimpleLdap(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
err = ldapClient.Verify(foo.Name, foo.Password)
|
||||
err = ldapClient.Authenticate(foo.Name, foo.Password)
|
||||
if err != nil {
|
||||
t.Fatalf("should pass but got an error %v", err)
|
||||
}
|
||||
|
||||
err = ldapClient.Verify(foo.Name, "gibberish")
|
||||
err = ldapClient.Authenticate(foo.Name, "gibberish")
|
||||
if err == nil || err != ErrInvalidCredentials {
|
||||
t.Fatalf("expected error ErrInvalidCrenentials but got %v", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user