Files
grafana/pkg/services/authn/authntest/mock.go
Karl Persson cdd7392f68 AuthN: Make client params part of the identity (#61050)
* AuthN: Change client params to be a return value of authenticate

* AuthN: move client params to be part of the identity
2023-01-05 20:17:41 +01:00

29 lines
644 B
Go

package authntest
import (
"context"
"github.com/grafana/grafana/pkg/services/authn"
)
var _ authn.Client = new(MockClient)
type MockClient struct {
AuthenticateFunc func(ctx context.Context, r *authn.Request) (*authn.Identity, error)
TestFunc func(ctx context.Context, r *authn.Request) bool
}
func (m MockClient) Authenticate(ctx context.Context, r *authn.Request) (*authn.Identity, error) {
if m.AuthenticateFunc != nil {
return m.AuthenticateFunc(ctx, r)
}
return nil, nil
}
func (m MockClient) Test(ctx context.Context, r *authn.Request) bool {
if m.TestFunc != nil {
return m.TestFunc(ctx, r)
}
return false
}