grafana/pkg/services/ssosettings/ssosettingstests/store_fake.go
Misi 20bb0a3ab1
AuthN: Support reloading SSO config after the sso settings have changed (#80734)
* Add AuthNSvc reload handling

* Working, need to add test

* Remove commented out code

* Add Reload implementation to connectors

* Align and add tests, refactor

* Add more tests, linting

* Add extra checks + tests to oauth client

* Clean up based on reviews

* Move config instantiation into newSocialBase

* Use specific error
2024-01-22 14:54:48 +01:00

55 lines
1.3 KiB
Go

package ssosettingstests
import (
context "context"
"github.com/grafana/grafana/pkg/services/ssosettings"
models "github.com/grafana/grafana/pkg/services/ssosettings/models"
)
var _ ssosettings.Store = (*FakeStore)(nil)
type FakeStore struct {
ExpectedSSOSetting *models.SSOSettings
ExpectedSSOSettings []*models.SSOSettings
ExpectedError error
ActualSSOSettings models.SSOSettings
GetFn func(ctx context.Context, provider string) (*models.SSOSettings, error)
UpsertFn func(ctx context.Context, settings *models.SSOSettings) error
}
func NewFakeStore() *FakeStore {
return &FakeStore{}
}
func (f *FakeStore) Get(ctx context.Context, provider string) (*models.SSOSettings, error) {
if f.GetFn != nil {
return f.GetFn(ctx, provider)
}
return f.ExpectedSSOSetting, f.ExpectedError
}
func (f *FakeStore) List(ctx context.Context) ([]*models.SSOSettings, error) {
return f.ExpectedSSOSettings, f.ExpectedError
}
func (f *FakeStore) Upsert(ctx context.Context, settings *models.SSOSettings) error {
if f.UpsertFn != nil {
return f.UpsertFn(ctx, settings)
}
f.ActualSSOSettings = *settings
return f.ExpectedError
}
func (f *FakeStore) Patch(ctx context.Context, provider string, data map[string]any) error {
return f.ExpectedError
}
func (f *FakeStore) Delete(ctx context.Context, provider string) error {
return f.ExpectedError
}