forked from grafana/grafana
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfake.go
40 lines (32 loc) · 980 Bytes
/
fake.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package service
import (
"github.com/grafana/grafana/pkg/services/ldap"
"github.com/grafana/grafana/pkg/services/ldap/multildap"
"github.com/grafana/grafana/pkg/services/login"
)
type LDAPFakeService struct {
ExpectedConfig *ldap.ServersConfig
ExpectedClient multildap.IMultiLDAP
ExpectedError error
ExpectedUser *login.ExternalUserInfo
UserCalled bool
}
func NewLDAPFakeService() *LDAPFakeService {
return &LDAPFakeService{}
}
func (s *LDAPFakeService) ReloadConfig() error {
return s.ExpectedError
}
func (s *LDAPFakeService) Config() *ldap.ServersConfig {
return s.ExpectedConfig
}
func (s *LDAPFakeService) Client() multildap.IMultiLDAP {
return s.ExpectedClient
}
func (s *LDAPFakeService) Login(query *login.LoginUserQuery) (*login.ExternalUserInfo, error) {
return s.ExpectedUser, s.ExpectedError
}
func (s *LDAPFakeService) User(username string) (*login.ExternalUserInfo, error) {
s.UserCalled = true
return s.ExpectedUser, s.ExpectedError
}