mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Co-authored-by: Karl Persson <kalle.persson@grafana.com> Fix: Prefer pointer to struct in lookup Co-authored-by: Karl Persson <kalle.persson@grafana.com> Fix: user email for ldap Co-authored-by: Karl Persson <kalle.persson@grafana.com> Fix: Use only login for lookup in LDAP Co-authored-by: Karl Persson <kalle.persson@grafana.com> Fix: use user email for ldap Co-authored-by: Karl Persson <kalle.persson@grafana.com> fix remaining test fix nit picks
67 lines
1.9 KiB
Go
67 lines
1.9 KiB
Go
package logintest
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/grafana/grafana/pkg/models"
|
|
"github.com/grafana/grafana/pkg/services/login"
|
|
"github.com/grafana/grafana/pkg/services/user"
|
|
)
|
|
|
|
type LoginServiceFake struct{}
|
|
|
|
func (l *LoginServiceFake) CreateUser(cmd user.CreateUserCommand) (*user.User, error) {
|
|
return nil, nil
|
|
}
|
|
func (l *LoginServiceFake) UpsertUser(ctx context.Context, cmd *models.UpsertUserCommand) error {
|
|
return nil
|
|
}
|
|
func (l *LoginServiceFake) DisableExternalUser(ctx context.Context, username string) error {
|
|
return nil
|
|
}
|
|
func (l *LoginServiceFake) SetTeamSyncFunc(login.TeamSyncFunc) {}
|
|
|
|
type AuthInfoServiceFake struct {
|
|
LatestUserID int64
|
|
ExpectedUser *user.User
|
|
ExpectedExternalUser *models.ExternalUserInfo
|
|
ExpectedError error
|
|
}
|
|
|
|
func (a *AuthInfoServiceFake) LookupAndUpdate(ctx context.Context, query *models.GetUserByAuthInfoQuery) (*user.User, error) {
|
|
if query.UserLookupParams.UserID != nil {
|
|
a.LatestUserID = *query.UserLookupParams.UserID
|
|
} else {
|
|
a.LatestUserID = 0
|
|
}
|
|
return a.ExpectedUser, a.ExpectedError
|
|
}
|
|
|
|
func (a *AuthInfoServiceFake) GetAuthInfo(ctx context.Context, query *models.GetAuthInfoQuery) error {
|
|
a.LatestUserID = query.UserId
|
|
return a.ExpectedError
|
|
}
|
|
|
|
func (a *AuthInfoServiceFake) SetAuthInfo(ctx context.Context, cmd *models.SetAuthInfoCommand) error {
|
|
return a.ExpectedError
|
|
}
|
|
|
|
func (a *AuthInfoServiceFake) UpdateAuthInfo(ctx context.Context, cmd *models.UpdateAuthInfoCommand) error {
|
|
return a.ExpectedError
|
|
}
|
|
|
|
func (a *AuthInfoServiceFake) GetExternalUserInfoByLogin(ctx context.Context, query *models.GetExternalUserInfoByLoginQuery) error {
|
|
query.Result = a.ExpectedExternalUser
|
|
return a.ExpectedError
|
|
}
|
|
|
|
type AuthenticatorFake struct {
|
|
ExpectedUser *user.User
|
|
ExpectedError error
|
|
}
|
|
|
|
func (a *AuthenticatorFake) AuthenticateUser(c context.Context, query *models.LoginUserQuery) error {
|
|
query.User = a.ExpectedUser
|
|
return a.ExpectedError
|
|
}
|