2022-11-29 10:57:47 +01:00
|
|
|
package authntest
|
|
|
|
|
|
2022-12-02 15:10:03 +01:00
|
|
|
import (
|
|
|
|
|
"context"
|
|
|
|
|
|
|
|
|
|
"github.com/grafana/grafana/pkg/services/authn"
|
|
|
|
|
)
|
2022-11-29 10:57:47 +01:00
|
|
|
|
|
|
|
|
type FakeService struct {
|
|
|
|
|
authn.Service
|
|
|
|
|
}
|
2022-12-02 15:10:03 +01:00
|
|
|
|
|
|
|
|
var _ authn.Client = new(FakeClient)
|
|
|
|
|
|
|
|
|
|
type FakeClient struct {
|
2023-01-09 16:40:29 +01:00
|
|
|
ExpectedErr error
|
|
|
|
|
ExpectedTest bool
|
|
|
|
|
ExpectedIdentity *authn.Identity
|
2022-12-02 15:10:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (f *FakeClient) Authenticate(ctx context.Context, r *authn.Request) (*authn.Identity, error) {
|
|
|
|
|
return f.ExpectedIdentity, f.ExpectedErr
|
|
|
|
|
}
|
2022-12-19 09:22:11 +01:00
|
|
|
|
|
|
|
|
func (f *FakeClient) Test(ctx context.Context, r *authn.Request) bool {
|
|
|
|
|
return f.ExpectedTest
|
|
|
|
|
}
|
2023-01-09 16:40:29 +01:00
|
|
|
|
|
|
|
|
var _ authn.PasswordClient = new(FakePasswordClient)
|
|
|
|
|
|
|
|
|
|
type FakePasswordClient struct {
|
|
|
|
|
ExpectedErr error
|
|
|
|
|
ExpectedIdentity *authn.Identity
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (f FakePasswordClient) AuthenticatePassword(ctx context.Context, orgID int64, username, password string) (*authn.Identity, error) {
|
|
|
|
|
return f.ExpectedIdentity, f.ExpectedErr
|
|
|
|
|
}
|