@ -8,10 +8,33 @@ import (
"github.com/grafana/grafana/pkg/services/authn"
"github.com/grafana/grafana/pkg/services/authn"
)
)
var _ authn . Service = new ( FakeService )
var _ authn . SSOClientConfig = new ( FakeSSOClientConfig )
var _ authn . IdentitySynchronizer = new ( FakeService )
type FakeSSOClientConfig struct {
ExpectedName string
ExpectedIsAutoLoginEnabled bool
ExpectedIsSingleLogoutEnabled bool
}
func ( f * FakeSSOClientConfig ) GetDisplayName ( ) string {
return f . ExpectedName
}
func ( f * FakeSSOClientConfig ) IsAutoLoginEnabled ( ) bool {
return f . ExpectedIsAutoLoginEnabled
}
func ( f * FakeSSOClientConfig ) IsSingleLogoutEnabled ( ) bool {
return f . ExpectedIsSingleLogoutEnabled
}
var (
_ authn . Service = new ( FakeService )
_ authn . IdentitySynchronizer = new ( FakeService )
)
type FakeService struct {
type FakeService struct {
ExpectedClientConfig authn . SSOClientConfig
ExpectedErr error
ExpectedErr error
ExpectedRedirect * authn . Redirect
ExpectedRedirect * authn . Redirect
ExpectedIdentity * authn . Identity
ExpectedIdentity * authn . Identity
@ -44,6 +67,13 @@ func (f *FakeService) IsClientEnabled(name string) bool {
return true
return true
}
}
func ( f * FakeService ) GetClientConfig ( name string ) ( authn . SSOClientConfig , bool ) {
if f . ExpectedClientConfig == nil {
return nil , false
}
return f . ExpectedClientConfig , true
}
func ( f * FakeService ) RegisterPostAuthHook ( hook authn . PostAuthHookFn , priority uint ) { }
func ( f * FakeService ) RegisterPostAuthHook ( hook authn . PostAuthHookFn , priority uint ) { }
func ( f * FakeService ) RegisterPreLogoutHook ( hook authn . PreLogoutHookFn , priority uint ) { }
func ( f * FakeService ) RegisterPreLogoutHook ( hook authn . PreLogoutHookFn , priority uint ) { }
@ -127,6 +157,10 @@ func (f *FakeClient) Authenticate(ctx context.Context, r *authn.Request) (*authn
func ( f FakeClient ) IsEnabled ( ) bool { return true }
func ( f FakeClient ) IsEnabled ( ) bool { return true }
func ( f * FakeClient ) GetConfig ( ) authn . SSOClientConfig {
return nil
}
func ( f * FakeClient ) Test ( ctx context . Context , r * authn . Request ) bool {
func ( f * FakeClient ) Test ( ctx context . Context , r * authn . Request ) bool {
return f . ExpectedTest
return f . ExpectedTest
}
}