mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-06 18:50:09 +01:00
Merge pull request #2116 from ywk253100/170424_ldap_fix
Return error when got more than one users in GetUser method
This commit is contained in:
commit
ee93627391
@ -22,6 +22,7 @@ import (
|
||||
|
||||
"github.com/astaxie/beego/orm"
|
||||
//"github.com/vmware/harbor/src/common/config"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/vmware/harbor/src/common/models"
|
||||
"github.com/vmware/harbor/src/common/utils"
|
||||
"github.com/vmware/harbor/src/common/utils/log"
|
||||
@ -402,6 +403,10 @@ func TestGetUser(t *testing.T) {
|
||||
if currentUser.Email != "tester01@vmware.com" {
|
||||
t.Errorf("the user's email does not match, expected: tester01@vmware.com, actual: %s", currentUser.Email)
|
||||
}
|
||||
|
||||
queryUser = models.User{}
|
||||
_, err = GetUser(queryUser)
|
||||
assert.NotNil(t, err)
|
||||
}
|
||||
|
||||
func TestListUsers(t *testing.T) {
|
||||
|
@ -60,6 +60,10 @@ func GetUser(query models.User) (*models.User, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
if n > 1 {
|
||||
return nil, fmt.Errorf("got more than one user when executing: %s param: %v", sql, queryParam)
|
||||
}
|
||||
|
||||
return &u[0], nil
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user