AuthN: Add functions for fake (#65522)

This commit is contained in:
Karl Persson 2023-03-29 15:40:09 +02:00 committed by GitHub
parent 7b92849508
commit d4397fae25
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -6,10 +6,32 @@ import (
"github.com/grafana/grafana/pkg/services/authn"
)
var _ authn.Service = new(FakeService)
type FakeService struct {
authn.Service
ExpectedErr error
ExpectedRedirect *authn.Redirect
ExpectedIdentity *authn.Identity
}
func (f FakeService) Authenticate(ctx context.Context, r *authn.Request) (*authn.Identity, error) {
return f.ExpectedIdentity, f.ExpectedErr
}
func (f FakeService) RegisterPostAuthHook(hook authn.PostAuthHookFn, priority uint) {}
func (f FakeService) Login(ctx context.Context, client string, r *authn.Request) (*authn.Identity, error) {
return f.ExpectedIdentity, f.ExpectedErr
}
func (f FakeService) RegisterPostLoginHook(hook authn.PostLoginHookFn, priority uint) {}
func (f FakeService) RedirectURL(ctx context.Context, client string, r *authn.Request) (*authn.Redirect, error) {
return f.ExpectedRedirect, f.ExpectedErr
}
func (f FakeService) RegisterClient(c authn.Client) {}
var _ authn.ContextAwareClient = new(FakeClient)
type FakeClient struct {