mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
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
This commit is contained in:
@@ -13,19 +13,16 @@ type FakeService struct {
|
||||
var _ authn.Client = new(FakeClient)
|
||||
|
||||
type FakeClient struct {
|
||||
ExpectedErr error
|
||||
ExpectedTest bool
|
||||
ExpectedIdentity *authn.Identity
|
||||
ExpectedErr error
|
||||
ExpectedTest bool
|
||||
ExpectedIdentity *authn.Identity
|
||||
ExpectedClientParams *authn.ClientParams
|
||||
}
|
||||
|
||||
func (f *FakeClient) Authenticate(ctx context.Context, r *authn.Request) (*authn.Identity, error) {
|
||||
return f.ExpectedIdentity, f.ExpectedErr
|
||||
}
|
||||
|
||||
func (f *FakeClient) ClientParams() *authn.ClientParams {
|
||||
return &authn.ClientParams{}
|
||||
}
|
||||
|
||||
func (f *FakeClient) Test(ctx context.Context, r *authn.Request) bool {
|
||||
return f.ExpectedTest
|
||||
}
|
||||
|
||||
@@ -10,7 +10,6 @@ var _ authn.Client = new(MockClient)
|
||||
|
||||
type MockClient struct {
|
||||
AuthenticateFunc func(ctx context.Context, r *authn.Request) (*authn.Identity, error)
|
||||
ClientParamsFunc func() *authn.ClientParams
|
||||
TestFunc func(ctx context.Context, r *authn.Request) bool
|
||||
}
|
||||
|
||||
@@ -21,13 +20,6 @@ func (m MockClient) Authenticate(ctx context.Context, r *authn.Request) (*authn.
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (m MockClient) ClientParams() *authn.ClientParams {
|
||||
if m.ClientParamsFunc != nil {
|
||||
return m.ClientParamsFunc()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m MockClient) Test(ctx context.Context, r *authn.Request) bool {
|
||||
if m.TestFunc != nil {
|
||||
return m.TestFunc(ctx, r)
|
||||
|
||||
Reference in New Issue
Block a user