From a2097fbc2f22994920d23e35012afea765ffb402 Mon Sep 17 00:00:00 2001 From: "Arati R." <33031346+suntala@users.noreply.github.com> Date: Mon, 27 Jan 2025 14:29:47 +0100 Subject: [PATCH] Folders: Add user service to folder service implementation (#99518) Add user service to folder service implementation --- pkg/api/dashboard_test.go | 6 +- pkg/api/folder_bench_test.go | 5 +- .../ossaccesscontrol/testutil/testutil.go | 6 +- .../accesscontrol/accesscontrol_test.go | 6 +- .../annotationsimpl/annotations_test.go | 11 +-- .../database/database_folder_test.go | 4 +- .../dashboards/database/database_test.go | 10 ++- .../dashboard_service_integration_test.go | 75 +++++++++++++++++-- pkg/services/folder/folderimpl/folder.go | 3 + pkg/services/folder/folderimpl/folder_test.go | 5 +- .../libraryelements/libraryelements_test.go | 20 +++-- .../librarypanels/librarypanels_test.go | 10 ++- .../ngalert/api/api_provisioning_test.go | 5 +- .../ngalert/provisioning/alert_rules_test.go | 5 +- pkg/services/ngalert/testutil/testutil.go | 2 +- .../publicdashboards/service/service_test.go | 4 +- pkg/services/quota/quotaimpl/quota_test.go | 6 +- .../sqlstore/permissions/dashboard_test.go | 5 +- .../permissions/dashboards_bench_test.go | 5 +- .../federated/federatedtests/stats_test.go | 6 +- 20 files changed, 142 insertions(+), 57 deletions(-) diff --git a/pkg/api/dashboard_test.go b/pkg/api/dashboard_test.go index 9cc1a396ee9..34c6c2c4dbe 100644 --- a/pkg/api/dashboard_test.go +++ b/pkg/api/dashboard_test.go @@ -829,9 +829,9 @@ func getDashboardShouldReturn200WithConfig(t *testing.T, sc *scenarioContext, pr db := db.InitTestDB(t) fStore := folderimpl.ProvideStore(db) quotaService := quotatest.New(false, nil) - folderSvc := folderimpl.ProvideService(fStore, ac, bus.ProvideBus(tracing.InitializeTracerForTest()), - dashboardStore, folderStore, db, features, - supportbundlestest.NewFakeBundleService(), nil, cfg, nil, tracing.InitializeTracerForTest()) + folderSvc := folderimpl.ProvideService( + fStore, ac, bus.ProvideBus(tracing.InitializeTracerForTest()), dashboardStore, folderStore, + nil, db, features, supportbundlestest.NewFakeBundleService(), nil, cfg, nil, tracing.InitializeTracerForTest()) if dashboardService == nil { dashboardService, err = service.ProvideDashboardServiceImpl( cfg, dashboardStore, folderStore, features, folderPermissions, diff --git a/pkg/api/folder_bench_test.go b/pkg/api/folder_bench_test.go index 618a8ee8deb..0448eaddde1 100644 --- a/pkg/api/folder_bench_test.go +++ b/pkg/api/folder_bench_test.go @@ -460,8 +460,9 @@ func setupServer(b testing.TB, sc benchScenario, features featuremgmt.FeatureTog cfg := setting.NewCfg() actionSets := resourcepermissions.NewActionSetService(features) fStore := folderimpl.ProvideStore(sc.db) - folderServiceWithFlagOn := folderimpl.ProvideService(fStore, ac, bus.ProvideBus(tracing.InitializeTracerForTest()), dashStore, - folderStore, sc.db, features, supportbundlestest.NewFakeBundleService(), nil, cfg, nil, tracing.InitializeTracerForTest()) + folderServiceWithFlagOn := folderimpl.ProvideService( + fStore, ac, bus.ProvideBus(tracing.InitializeTracerForTest()), dashStore, folderStore, + nil, sc.db, features, supportbundlestest.NewFakeBundleService(), nil, cfg, nil, tracing.InitializeTracerForTest()) acSvc := acimpl.ProvideOSSService( sc.cfg, acdb.ProvideService(sc.db), actionSets, localcache.ProvideService(), features, tracing.InitializeTracerForTest(), zanzana.NewNoopClient(), sc.db, permreg.ProvidePermissionRegistry(), nil, folderServiceWithFlagOn, diff --git a/pkg/services/accesscontrol/ossaccesscontrol/testutil/testutil.go b/pkg/services/accesscontrol/ossaccesscontrol/testutil/testutil.go index 6ede8612b71..a5f469ec293 100644 --- a/pkg/services/accesscontrol/ossaccesscontrol/testutil/testutil.go +++ b/pkg/services/accesscontrol/ossaccesscontrol/testutil/testutil.go @@ -47,9 +47,9 @@ func ProvideFolderPermissions( fStore := folderimpl.ProvideStore(sqlStore) folderStore := folderimpl.ProvideDashboardFolderStore(sqlStore) - fService := folderimpl.ProvideService(fStore, ac, bus.ProvideBus(tracing.InitializeTracerForTest()), - dashboardStore, folderStore, sqlStore, features, - supportbundlestest.NewFakeBundleService(), nil, cfg, nil, tracing.InitializeTracerForTest()) + fService := folderimpl.ProvideService( + fStore, ac, bus.ProvideBus(tracing.InitializeTracerForTest()), dashboardStore, folderStore, + nil, sqlStore, features, supportbundlestest.NewFakeBundleService(), nil, cfg, nil, tracing.InitializeTracerForTest()) acSvc := acimpl.ProvideOSSService( cfg, acdb.ProvideService(sqlStore), actionSets, localcache.ProvideService(), diff --git a/pkg/services/annotations/accesscontrol/accesscontrol_test.go b/pkg/services/annotations/accesscontrol/accesscontrol_test.go index a4f2442d31e..2e982273e28 100644 --- a/pkg/services/annotations/accesscontrol/accesscontrol_test.go +++ b/pkg/services/annotations/accesscontrol/accesscontrol_test.go @@ -47,9 +47,9 @@ func TestIntegrationAuthorize(t *testing.T) { dashStore, err := database.ProvideDashboardStore(sql, cfg, featuremgmt.WithFeatures(), tagimpl.ProvideService(sql)) require.NoError(t, err) ac := acimpl.ProvideAccessControl(featuremgmt.WithFeatures()) - folderSvc := folderimpl.ProvideService(fStore, accesscontrolmock.New(), bus.ProvideBus(tracing.InitializeTracerForTest()), - dashStore, folderStore, sql, featuremgmt.WithFeatures(), - supportbundlestest.NewFakeBundleService(), nil, cfg, nil, tracing.InitializeTracerForTest()) + folderSvc := folderimpl.ProvideService( + fStore, accesscontrolmock.New(), bus.ProvideBus(tracing.InitializeTracerForTest()), dashStore, folderStore, + nil, sql, featuremgmt.WithFeatures(), supportbundlestest.NewFakeBundleService(), nil, cfg, nil, tracing.InitializeTracerForTest()) dashSvc, err := dashboardsservice.ProvideDashboardServiceImpl(cfg, dashStore, folderStore, featuremgmt.WithFeatures(), accesscontrolmock.NewMockedPermissionsService(), ac, folderSvc, fStore, nil, nil, nil, nil, quotatest.New(false, nil), nil, nil) require.NoError(t, err) diff --git a/pkg/services/annotations/annotationsimpl/annotations_test.go b/pkg/services/annotations/annotationsimpl/annotations_test.go index eaa059af380..555ebbe4e88 100644 --- a/pkg/services/annotations/annotationsimpl/annotations_test.go +++ b/pkg/services/annotations/annotationsimpl/annotations_test.go @@ -59,9 +59,9 @@ func TestIntegrationAnnotationListingWithRBAC(t *testing.T) { dashStore, err := database.ProvideDashboardStore(sql, cfg, featuremgmt.WithFeatures(), tagimpl.ProvideService(sql)) require.NoError(t, err) ac := acimpl.ProvideAccessControl(featuremgmt.WithFeatures()) - folderSvc := folderimpl.ProvideService(fStore, accesscontrolmock.New(), bus.ProvideBus(tracing.InitializeTracerForTest()), - dashStore, folderStore, sql, featuremgmt.WithFeatures(), - supportbundlestest.NewFakeBundleService(), nil, cfg, nil, tracing.InitializeTracerForTest()) + folderSvc := folderimpl.ProvideService( + fStore, accesscontrolmock.New(), bus.ProvideBus(tracing.InitializeTracerForTest()), dashStore, folderStore, + nil, sql, featuremgmt.WithFeatures(), supportbundlestest.NewFakeBundleService(), nil, cfg, nil, tracing.InitializeTracerForTest()) dashSvc, err := dashboardsservice.ProvideDashboardServiceImpl(cfg, dashStore, folderStore, featuremgmt.WithFeatures(), accesscontrolmock.NewMockedPermissionsService(), ac, folderSvc, fStore, nil, nil, nil, nil, quotatest.New(false, nil), nil, nil) require.NoError(t, err) @@ -242,8 +242,9 @@ func TestIntegrationAnnotationListingWithInheritedRBAC(t *testing.T) { ac := acimpl.ProvideAccessControl(features) fStore := folderimpl.ProvideStore(sql) folderStore := folderimpl.ProvideDashboardFolderStore(sql) - folderSvc := folderimpl.ProvideService(fStore, ac, bus.ProvideBus(tracing.InitializeTracerForTest()), dashStore, - folderStore, sql, features, supportbundlestest.NewFakeBundleService(), nil, cfg, nil, tracing.InitializeTracerForTest()) + folderSvc := folderimpl.ProvideService( + fStore, ac, bus.ProvideBus(tracing.InitializeTracerForTest()), dashStore, folderStore, + nil, sql, features, supportbundlestest.NewFakeBundleService(), nil, cfg, nil, tracing.InitializeTracerForTest()) dashSvc, err := dashboardsservice.ProvideDashboardServiceImpl(cfg, dashStore, folderStore, features, accesscontrolmock.NewMockedPermissionsService(), ac, folderSvc, fStore, nil, nil, nil, nil, quotatest.New(false, nil), nil, nil) require.NoError(t, err) diff --git a/pkg/services/dashboards/database/database_folder_test.go b/pkg/services/dashboards/database/database_folder_test.go index 5a64a2388d8..9ec6d2f5708 100644 --- a/pkg/services/dashboards/database/database_folder_test.go +++ b/pkg/services/dashboards/database/database_folder_test.go @@ -300,7 +300,9 @@ func TestIntegrationDashboardInheritedFolderRBAC(t *testing.T) { }) folderStore := folderimpl.ProvideStore(sqlStore) - folderSvc := folderimpl.ProvideService(folderStore, mock.New(), bus.ProvideBus(tracer), dashboardWriteStore, folderimpl.ProvideDashboardFolderStore(sqlStore), sqlStore, features, supportbundlestest.NewFakeBundleService(), nil, cfg, nil, tracing.InitializeTracerForTest()) + folderSvc := folderimpl.ProvideService( + folderStore, mock.New(), bus.ProvideBus(tracer), dashboardWriteStore, folderimpl.ProvideDashboardFolderStore(sqlStore), + nil, sqlStore, features, supportbundlestest.NewFakeBundleService(), nil, cfg, nil, tracing.InitializeTracerForTest()) parentUID := "" for i := 0; ; i++ { diff --git a/pkg/services/dashboards/database/database_test.go b/pkg/services/dashboards/database/database_test.go index eb75f0c5907..ff33a306a9e 100644 --- a/pkg/services/dashboards/database/database_test.go +++ b/pkg/services/dashboards/database/database_test.go @@ -901,8 +901,9 @@ func TestIntegrationFindDashboardsByTitle(t *testing.T) { ac := acimpl.ProvideAccessControl(features) folderStore := folderimpl.ProvideDashboardFolderStore(sqlStore) fStore := folderimpl.ProvideStore(sqlStore) - folderServiceWithFlagOn := folderimpl.ProvideService(fStore, ac, bus.ProvideBus(tracing.InitializeTracerForTest()), dashboardStore, - folderStore, sqlStore, features, supportbundlestest.NewFakeBundleService(), nil, cfg, nil, tracing.InitializeTracerForTest()) + folderServiceWithFlagOn := folderimpl.ProvideService( + fStore, ac, bus.ProvideBus(tracing.InitializeTracerForTest()), dashboardStore, folderStore, + nil, sqlStore, features, supportbundlestest.NewFakeBundleService(), nil, cfg, nil, tracing.InitializeTracerForTest()) user := &user.SignedInUser{ OrgID: 1, @@ -1020,8 +1021,9 @@ func TestIntegrationFindDashboardsByFolder(t *testing.T) { folderStore := folderimpl.ProvideDashboardFolderStore(sqlStore) fStore := folderimpl.ProvideStore(sqlStore) - folderServiceWithFlagOn := folderimpl.ProvideService(fStore, ac, bus.ProvideBus(tracing.InitializeTracerForTest()), dashboardStore, - folderStore, sqlStore, features, supportbundlestest.NewFakeBundleService(), nil, cfg, nil, tracing.InitializeTracerForTest()) + folderServiceWithFlagOn := folderimpl.ProvideService( + fStore, ac, bus.ProvideBus(tracing.InitializeTracerForTest()), dashboardStore, folderStore, + nil, sqlStore, features, supportbundlestest.NewFakeBundleService(), nil, cfg, nil, tracing.InitializeTracerForTest()) user := &user.SignedInUser{ OrgID: 1, diff --git a/pkg/services/dashboards/service/dashboard_service_integration_test.go b/pkg/services/dashboards/service/dashboard_service_integration_test.go index 666a2fa18ae..b2deeba68fe 100644 --- a/pkg/services/dashboards/service/dashboard_service_integration_test.go +++ b/pkg/services/dashboards/service/dashboard_service_integration_test.go @@ -881,7 +881,20 @@ func permissionScenario(t *testing.T, desc string, canSave bool, fn permissionSc tracer := tracing.InitializeTracerForTest() publicDashboardFakeService := publicdashboards.NewFakePublicDashboardServiceWrapper(t) folderStore2 := folderimpl.ProvideStore(sqlStore) - folderService := folderimpl.ProvideService(folderStore2, actest.FakeAccessControl{ExpectedEvaluate: true}, bus.ProvideBus(tracer), dashboardStore, folderStore, sqlStore, features, supportbundlestest.NewFakeBundleService(), publicDashboardFakeService, cfg, nil, tracer) + folderService := folderimpl.ProvideService( + folderStore2, + actest.FakeAccessControl{ExpectedEvaluate: true}, + bus.ProvideBus(tracer), + dashboardStore, + folderStore, + nil, + sqlStore, + features, + supportbundlestest.NewFakeBundleService(), + publicDashboardFakeService, + cfg, + nil, + tracer) dashboardPermissions := accesscontrolmock.NewMockedPermissionsService() dashboardService, err := ProvideDashboardServiceImpl( cfg, dashboardStore, folderStore, @@ -955,9 +968,23 @@ func callSaveWithResult(t *testing.T, cmd dashboards.SaveDashboardCommand, sqlSt tracer := tracing.InitializeTracerForTest() publicDashboardFakeService := publicdashboards.NewFakePublicDashboardServiceWrapper(t) folderStore2 := folderimpl.ProvideStore(sqlStore) - folderService := folderimpl.ProvideService(folderStore2, actest.FakeAccessControl{ExpectedEvaluate: true}, bus.ProvideBus(tracer), dashboardStore, folderStore, sqlStore, features, supportbundlestest.NewFakeBundleService(), publicDashboardFakeService, cfg, nil, tracer) + folderService := folderimpl.ProvideService( + folderStore2, + actest.FakeAccessControl{ExpectedEvaluate: true}, + bus.ProvideBus(tracer), + dashboardStore, + folderStore, + nil, + sqlStore, + features, + supportbundlestest.NewFakeBundleService(), + publicDashboardFakeService, + cfg, + nil, + tracer) dashboardPermissions := accesscontrolmock.NewMockedPermissionsService() - dashboardPermissions.On("SetPermissions", mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return([]accesscontrol.ResourcePermission{}, nil) + dashboardPermissions.On("SetPermissions", + mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return([]accesscontrol.ResourcePermission{}, nil) service, err := ProvideDashboardServiceImpl( cfg, dashboardStore, folderStore, featuremgmt.WithFeatures(), @@ -992,7 +1019,19 @@ func callSaveWithError(t *testing.T, cmd dashboards.SaveDashboardCommand, sqlSto tracer := tracing.InitializeTracerForTest() publicDashboardFakeService := publicdashboards.NewFakePublicDashboardServiceWrapper(t) folderStore2 := folderimpl.ProvideStore(sqlStore) - folderService := folderimpl.ProvideService(folderStore2, actest.FakeAccessControl{ExpectedEvaluate: true}, bus.ProvideBus(tracer), dashboardStore, folderStore, sqlStore, features, supportbundlestest.NewFakeBundleService(), publicDashboardFakeService, cfg, nil, tracer) + folderService := folderimpl.ProvideService(folderStore2, + actest.FakeAccessControl{ExpectedEvaluate: true}, + bus.ProvideBus(tracer), + dashboardStore, + folderStore, + nil, + sqlStore, + features, + supportbundlestest.NewFakeBundleService(), + publicDashboardFakeService, + cfg, + nil, + tracer) service, err := ProvideDashboardServiceImpl( cfg, dashboardStore, folderStore, featuremgmt.WithFeatures(), @@ -1046,7 +1085,19 @@ func saveTestDashboard(t *testing.T, title string, orgID int64, folderUID string tracer := tracing.InitializeTracerForTest() publicDashboardFakeService := publicdashboards.NewFakePublicDashboardServiceWrapper(t) folderStore2 := folderimpl.ProvideStore(sqlStore) - folderService := folderimpl.ProvideService(folderStore2, actest.FakeAccessControl{ExpectedEvaluate: true}, bus.ProvideBus(tracer), dashboardStore, folderStore, sqlStore, features, supportbundlestest.NewFakeBundleService(), publicDashboardFakeService, cfg, nil, tracer) + folderService := folderimpl.ProvideService(folderStore2, + actest.FakeAccessControl{ExpectedEvaluate: true}, + bus.ProvideBus(tracer), + dashboardStore, + folderStore, + nil, + sqlStore, + features, + supportbundlestest.NewFakeBundleService(), + publicDashboardFakeService, + cfg, + nil, + tracer) service, err := ProvideDashboardServiceImpl( cfg, dashboardStore, folderStore, features, @@ -1106,7 +1157,19 @@ func saveTestFolder(t *testing.T, title string, orgID int64, sqlStore db.DB) *da tracer := tracing.InitializeTracerForTest() publicDashboardFakeService := publicdashboards.NewFakePublicDashboardServiceWrapper(t) folderStore2 := folderimpl.ProvideStore(sqlStore) - folderService := folderimpl.ProvideService(folderStore2, actest.FakeAccessControl{ExpectedEvaluate: true}, bus.ProvideBus(tracer), dashboardStore, folderStore, sqlStore, features, supportbundlestest.NewFakeBundleService(), publicDashboardFakeService, cfg, nil, tracer) + folderService := folderimpl.ProvideService(folderStore2, + actest.FakeAccessControl{ExpectedEvaluate: true}, + bus.ProvideBus(tracer), + dashboardStore, + folderStore, + nil, + sqlStore, + features, + supportbundlestest.NewFakeBundleService(), + publicDashboardFakeService, + cfg, + nil, + tracer) folderPermissions.On("SetPermissions", mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return([]accesscontrol.ResourcePermission{}, nil) service, err := ProvideDashboardServiceImpl( cfg, dashboardStore, folderStore, diff --git a/pkg/services/folder/folderimpl/folder.go b/pkg/services/folder/folderimpl/folder.go index da82fabd08f..9c918f9d360 100644 --- a/pkg/services/folder/folderimpl/folder.go +++ b/pkg/services/folder/folderimpl/folder.go @@ -53,6 +53,7 @@ type Service struct { log *slog.Logger dashboardStore dashboards.Store dashboardFolderStore folder.FolderStore + userService user.Service features featuremgmt.FeatureToggles accessControl accesscontrol.AccessControl k8sclient folderK8sHandler @@ -73,6 +74,7 @@ func ProvideService( bus bus.Bus, dashboardStore dashboards.Store, folderStore folder.FolderStore, + userService user.Service, db db.DB, // DB for the (new) nested folder store features featuremgmt.FeatureToggles, supportBundles supportbundles.Service, @@ -86,6 +88,7 @@ func ProvideService( dashboardStore: dashboardStore, dashboardFolderStore: folderStore, store: store, + userService: userService, features: features, accessControl: ac, bus: bus, diff --git a/pkg/services/folder/folderimpl/folder_test.go b/pkg/services/folder/folderimpl/folder_test.go index a44b75114e5..e187dd71502 100644 --- a/pkg/services/folder/folderimpl/folder_test.go +++ b/pkg/services/folder/folderimpl/folder_test.go @@ -64,8 +64,9 @@ func TestIntegrationProvideFolderService(t *testing.T) { ac := acmock.New() db, cfg := db.InitTestDBWithCfg(t) store := ProvideStore(db) - ProvideService(store, ac, bus.ProvideBus(tracing.InitializeTracerForTest()), nil, nil, db, - featuremgmt.WithFeatures(), supportbundlestest.NewFakeBundleService(), nil, cfg, nil, tracing.InitializeTracerForTest()) + ProvideService( + store, ac, bus.ProvideBus(tracing.InitializeTracerForTest()), + nil, nil, nil, db, featuremgmt.WithFeatures(), supportbundlestest.NewFakeBundleService(), nil, cfg, nil, tracing.InitializeTracerForTest()) require.Len(t, ac.Calls.RegisterAttributeScopeResolver, 2) }) diff --git a/pkg/services/libraryelements/libraryelements_test.go b/pkg/services/libraryelements/libraryelements_test.go index f67a3e64ec6..8050e1f7320 100644 --- a/pkg/services/libraryelements/libraryelements_test.go +++ b/pkg/services/libraryelements/libraryelements_test.go @@ -304,8 +304,9 @@ func createDashboard(t *testing.T, sqlStore db.DB, user user.SignedInUser, dash dashboardPermissions.On("SetPermissions", mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return([]accesscontrol.ResourcePermission{}, nil) folderStore := folderimpl.ProvideDashboardFolderStore(sqlStore) fStore := folderimpl.ProvideStore(sqlStore) - folderSvc := folderimpl.ProvideService(fStore, ac, bus.ProvideBus(tracing.InitializeTracerForTest()), dashboardStore, - folderStore, sqlStore, features, supportbundlestest.NewFakeBundleService(), nil, cfg, nil, tracing.InitializeTracerForTest()) + folderSvc := folderimpl.ProvideService( + fStore, ac, bus.ProvideBus(tracing.InitializeTracerForTest()), dashboardStore, folderStore, + nil, sqlStore, features, supportbundlestest.NewFakeBundleService(), nil, cfg, nil, tracing.InitializeTracerForTest()) _, err = folderSvc.Create(context.Background(), &folder.CreateFolderCommand{UID: folderUID, SignedInUser: &user, Title: folderUID + "-title"}) require.NoError(t, err) service, err := dashboardservice.ProvideDashboardServiceImpl( @@ -341,8 +342,9 @@ func createFolder(t *testing.T, sc scenarioContext, title string, folderSvc fold folderStore := folderimpl.ProvideDashboardFolderStore(sc.sqlStore) store := folderimpl.ProvideStore(sc.sqlStore) - folderSvc = folderimpl.ProvideService(store, ac, bus.ProvideBus(tracing.InitializeTracerForTest()), dashboardStore, folderStore, sc.sqlStore, - features, supportbundlestest.NewFakeBundleService(), nil, cfg, nil, tracing.InitializeTracerForTest()) + folderSvc = folderimpl.ProvideService( + store, ac, bus.ProvideBus(tracing.InitializeTracerForTest()), dashboardStore, folderStore, + nil, sc.sqlStore, features, supportbundlestest.NewFakeBundleService(), nil, cfg, nil, tracing.InitializeTracerForTest()) t.Logf("Creating folder with title %q and UID uid_for_%s", title, title) } ctx := identity.WithRequester(context.Background(), &sc.user) @@ -404,8 +406,9 @@ func scenarioWithPanel(t *testing.T, desc string, fn func(t *testing.T, sc scena dashboardPermissions := acmock.NewMockedPermissionsService() folderStore := folderimpl.ProvideDashboardFolderStore(sqlStore) fStore := folderimpl.ProvideStore(sqlStore) - folderSvc := folderimpl.ProvideService(fStore, ac, bus.ProvideBus(tracing.InitializeTracerForTest()), dashboardStore, - folderStore, sqlStore, features, supportbundlestest.NewFakeBundleService(), nil, cfg, nil, tracing.InitializeTracerForTest()) + folderSvc := folderimpl.ProvideService( + fStore, ac, bus.ProvideBus(tracing.InitializeTracerForTest()), dashboardStore, folderStore, + nil, sqlStore, features, supportbundlestest.NewFakeBundleService(), nil, cfg, nil, tracing.InitializeTracerForTest()) dashboardService, svcErr := dashboardservice.ProvideDashboardServiceImpl( cfg, dashboardStore, folderStore, features, folderPermissions, ac, @@ -470,8 +473,9 @@ func testScenario(t *testing.T, desc string, fn func(t *testing.T, sc scenarioCo dashboardPermissions := acmock.NewMockedPermissionsService() folderStore := folderimpl.ProvideDashboardFolderStore(sqlStore) fStore := folderimpl.ProvideStore(sqlStore) - folderSvc := folderimpl.ProvideService(fStore, ac, bus.ProvideBus(tracing.InitializeTracerForTest()), dashboardStore, - folderStore, sqlStore, features, supportbundlestest.NewFakeBundleService(), nil, cfg, nil, tracing.InitializeTracerForTest()) + folderSvc := folderimpl.ProvideService( + fStore, ac, bus.ProvideBus(tracing.InitializeTracerForTest()), dashboardStore, folderStore, + nil, sqlStore, features, supportbundlestest.NewFakeBundleService(), nil, cfg, nil, tracing.InitializeTracerForTest()) dashService, dashSvcErr := dashboardservice.ProvideDashboardServiceImpl( cfg, dashboardStore, folderStore, features, folderPermissions, ac, diff --git a/pkg/services/librarypanels/librarypanels_test.go b/pkg/services/librarypanels/librarypanels_test.go index ccb24ca6477..c83faa09be5 100644 --- a/pkg/services/librarypanels/librarypanels_test.go +++ b/pkg/services/librarypanels/librarypanels_test.go @@ -755,8 +755,9 @@ func createFolder(t *testing.T, sc scenarioContext, title string) *folder.Folder require.NoError(t, err) folderStore := folderimpl.ProvideDashboardFolderStore(sc.sqlStore) fStore := folderimpl.ProvideStore(sc.sqlStore) - s := folderimpl.ProvideService(fStore, ac, bus.ProvideBus(tracing.InitializeTracerForTest()), dashboardStore, folderStore, sc.sqlStore, - features, supportbundlestest.NewFakeBundleService(), nil, cfg, nil, tracing.InitializeTracerForTest()) + s := folderimpl.ProvideService( + fStore, ac, bus.ProvideBus(tracing.InitializeTracerForTest()), dashboardStore, folderStore, + nil, sc.sqlStore, features, supportbundlestest.NewFakeBundleService(), nil, cfg, nil, tracing.InitializeTracerForTest()) t.Logf("Creating folder with title and UID %q", title) ctx := identity.WithRequester(context.Background(), sc.user) @@ -842,8 +843,9 @@ func testScenario(t *testing.T, desc string, fn func(t *testing.T, sc scenarioCo require.NoError(t, err) fStore := folderimpl.ProvideStore(sqlStore) - folderService := folderimpl.ProvideService(fStore, ac, bus.ProvideBus(tracing.InitializeTracerForTest()), dashboardStore, folderStore, sqlStore, - features, supportbundlestest.NewFakeBundleService(), nil, cfg, nil, tracing.InitializeTracerForTest()) + folderService := folderimpl.ProvideService( + fStore, ac, bus.ProvideBus(tracing.InitializeTracerForTest()), dashboardStore, folderStore, + nil, sqlStore, features, supportbundlestest.NewFakeBundleService(), nil, cfg, nil, tracing.InitializeTracerForTest()) elementService := libraryelements.ProvideService(cfg, sqlStore, routing.NewRouteRegister(), folderService, features, ac) service := LibraryPanelService{ diff --git a/pkg/services/ngalert/api/api_provisioning_test.go b/pkg/services/ngalert/api/api_provisioning_test.go index fd7fe1cc65e..f35c6236258 100644 --- a/pkg/services/ngalert/api/api_provisioning_test.go +++ b/pkg/services/ngalert/api/api_provisioning_test.go @@ -1919,8 +1919,9 @@ func createTestEnv(t *testing.T, testConfig string) testEnvironment { folderStore := folderimpl.ProvideDashboardFolderStore(sqlStore) fStore := folderimpl.ProvideStore(sqlStore) - folderService := folderimpl.ProvideService(fStore, actest.FakeAccessControl{ExpectedEvaluate: true}, bus.ProvideBus(tracing.InitializeTracerForTest()), dashboardStore, folderStore, sqlStore, - featuremgmt.WithFeatures(), supportbundlestest.NewFakeBundleService(), nil, cfg, nil, tracing.InitializeTracerForTest()) + folderService := folderimpl.ProvideService( + fStore, actest.FakeAccessControl{ExpectedEvaluate: true}, bus.ProvideBus(tracing.InitializeTracerForTest()), dashboardStore, folderStore, + nil, sqlStore, featuremgmt.WithFeatures(), supportbundlestest.NewFakeBundleService(), nil, cfg, nil, tracing.InitializeTracerForTest()) store := store.DBstore{ Logger: log, SQLStore: sqlStore, diff --git a/pkg/services/ngalert/provisioning/alert_rules_test.go b/pkg/services/ngalert/provisioning/alert_rules_test.go index ec15a851280..6ac4cfa1f89 100644 --- a/pkg/services/ngalert/provisioning/alert_rules_test.go +++ b/pkg/services/ngalert/provisioning/alert_rules_test.go @@ -1604,8 +1604,9 @@ func TestProvisiongWithFullpath(t *testing.T) { ac := acmock.New() features := featuremgmt.WithFeatures(featuremgmt.FlagNestedFolders) fStore := folderimpl.ProvideStore(sqlStore) - folderService := folderimpl.ProvideService(fStore, ac, inProcBus, dashboardStore, folderStore, sqlStore, - features, supportbundlestest.NewFakeBundleService(), nil, cfg, nil, tracing.InitializeTracerForTest()) + folderService := folderimpl.ProvideService( + fStore, ac, inProcBus, dashboardStore, folderStore, + nil, sqlStore, features, supportbundlestest.NewFakeBundleService(), nil, cfg, nil, tracing.InitializeTracerForTest()) ruleService := createAlertRuleService(t, folderService) var orgID int64 = 1 diff --git a/pkg/services/ngalert/testutil/testutil.go b/pkg/services/ngalert/testutil/testutil.go index 30973387296..284322e1571 100644 --- a/pkg/services/ngalert/testutil/testutil.go +++ b/pkg/services/ngalert/testutil/testutil.go @@ -28,7 +28,7 @@ import ( func SetupFolderService(tb testing.TB, cfg *setting.Cfg, db db.DB, dashboardStore dashboards.Store, folderStore *folderimpl.DashboardFolderStoreImpl, bus *bus.InProcBus, features featuremgmt.FeatureToggles, ac accesscontrol.AccessControl) folder.Service { tb.Helper() fStore := folderimpl.ProvideStore(db) - return folderimpl.ProvideService(fStore, ac, bus, dashboardStore, folderStore, db, + return folderimpl.ProvideService(fStore, ac, bus, dashboardStore, folderStore, nil, db, features, supportbundlestest.NewFakeBundleService(), nil, cfg, nil, tracing.InitializeTracerForTest()) } diff --git a/pkg/services/publicdashboards/service/service_test.go b/pkg/services/publicdashboards/service/service_test.go index 5148d68a9d0..bec987a72a8 100644 --- a/pkg/services/publicdashboards/service/service_test.go +++ b/pkg/services/publicdashboards/service/service_test.go @@ -1394,7 +1394,9 @@ func TestPublicDashboardServiceImpl_ListPublicDashboards(t *testing.T) { fStore := folderimpl.ProvideStore(testDB) folderPermissions := acmock.NewMockedPermissionsService() folderStore := folderimpl.ProvideDashboardFolderStore(testDB) - folderSvc := folderimpl.ProvideService(fStore, ac, bus.ProvideBus(tracing.InitializeTracerForTest()), dashStore, folderStore, testDB, features, supportbundlestest.NewFakeBundleService(), nil, cfg, nil, tracing.InitializeTracerForTest()) + folderSvc := folderimpl.ProvideService( + fStore, ac, bus.ProvideBus(tracing.InitializeTracerForTest()), dashStore, folderStore, + nil, testDB, features, supportbundlestest.NewFakeBundleService(), nil, cfg, nil, tracing.InitializeTracerForTest()) dashboardService, err := dashsvc.ProvideDashboardServiceImpl(cfg, dashStore, folderStore, featuremgmt.WithFeatures(), folderPermissions, ac, folderSvc, fStore, nil, nil, nil, nil, quotatest.New(false, nil), nil, nil) require.NoError(t, err) diff --git a/pkg/services/quota/quotaimpl/quota_test.go b/pkg/services/quota/quotaimpl/quota_test.go index 5009dc50182..4030fe0c19b 100644 --- a/pkg/services/quota/quotaimpl/quota_test.go +++ b/pkg/services/quota/quotaimpl/quota_test.go @@ -491,9 +491,9 @@ func setupEnv(t *testing.T, sqlStore db.DB, cfg *setting.Cfg, b bus.Bus, quotaSe dashStore, err := dashboardStore.ProvideDashboardStore(sqlStore, cfg, featuremgmt.WithFeatures(), tagimpl.ProvideService(sqlStore)) require.NoError(t, err) ac := acimpl.ProvideAccessControl(featuremgmt.WithFeatures()) - folderSvc := folderimpl.ProvideService(fStore, acmock.New(), bus.ProvideBus(tracing.InitializeTracerForTest()), - dashStore, folderStore, sqlStore, featuremgmt.WithFeatures(), - supportbundlestest.NewFakeBundleService(), nil, cfg, nil, tracing.InitializeTracerForTest()) + folderSvc := folderimpl.ProvideService( + fStore, acmock.New(), bus.ProvideBus(tracing.InitializeTracerForTest()), dashStore, folderStore, + nil, sqlStore, featuremgmt.WithFeatures(), supportbundlestest.NewFakeBundleService(), nil, cfg, nil, tracing.InitializeTracerForTest()) dashService, err := dashService.ProvideDashboardServiceImpl(cfg, dashStore, folderStore, featuremgmt.WithFeatures(), acmock.NewMockedPermissionsService(), ac, folderSvc, fStore, nil, nil, nil, nil, quotaService, nil, nil) require.NoError(t, err) diff --git a/pkg/services/sqlstore/permissions/dashboard_test.go b/pkg/services/sqlstore/permissions/dashboard_test.go index 30ea430e369..739ff8619bf 100644 --- a/pkg/services/sqlstore/permissions/dashboard_test.go +++ b/pkg/services/sqlstore/permissions/dashboard_test.go @@ -822,8 +822,9 @@ func setupNestedTest(t *testing.T, usr *user.SignedInUser, perms []accesscontrol require.NoError(t, err) fStore := folderimpl.ProvideStore(db) - folderSvc := folderimpl.ProvideService(fStore, actest.FakeAccessControl{ExpectedEvaluate: true}, bus.ProvideBus(tracing.InitializeTracerForTest()), dashStore, - folderimpl.ProvideDashboardFolderStore(db), db, features, supportbundlestest.NewFakeBundleService(), nil, cfg, nil, tracing.InitializeTracerForTest()) + folderSvc := folderimpl.ProvideService( + fStore, actest.FakeAccessControl{ExpectedEvaluate: true}, bus.ProvideBus(tracing.InitializeTracerForTest()), dashStore, folderimpl.ProvideDashboardFolderStore(db), + nil, db, features, supportbundlestest.NewFakeBundleService(), nil, cfg, nil, tracing.InitializeTracerForTest()) // create parent folder parent, err := folderSvc.Create(context.Background(), &folder.CreateFolderCommand{ diff --git a/pkg/services/sqlstore/permissions/dashboards_bench_test.go b/pkg/services/sqlstore/permissions/dashboards_bench_test.go index be785990b9d..c82b3468c5e 100644 --- a/pkg/services/sqlstore/permissions/dashboards_bench_test.go +++ b/pkg/services/sqlstore/permissions/dashboards_bench_test.go @@ -79,8 +79,9 @@ func setupBenchMark(b *testing.B, usr user.SignedInUser, features featuremgmt.Fe require.NoError(b, err) fStore := folderimpl.ProvideStore(store) - folderSvc := folderimpl.ProvideService(fStore, mock.New(), bus.ProvideBus(tracing.InitializeTracerForTest()), dashboardWriteStore, folderimpl.ProvideDashboardFolderStore(store), - store, features, supportbundlestest.NewFakeBundleService(), nil, cfg, nil, tracing.InitializeTracerForTest()) + folderSvc := folderimpl.ProvideService( + fStore, mock.New(), bus.ProvideBus(tracing.InitializeTracerForTest()), dashboardWriteStore, folderimpl.ProvideDashboardFolderStore(store), + nil, store, features, supportbundlestest.NewFakeBundleService(), nil, cfg, nil, tracing.InitializeTracerForTest()) origNewGuardian := guardian.New guardian.MockDashboardGuardian(&guardian.FakeDashboardGuardian{CanViewValue: true, CanSaveValue: true}) diff --git a/pkg/storage/unified/federated/federatedtests/stats_test.go b/pkg/storage/unified/federated/federatedtests/stats_test.go index 8b67af4fce9..bdb54e1f00d 100644 --- a/pkg/storage/unified/federated/federatedtests/stats_test.go +++ b/pkg/storage/unified/federated/federatedtests/stats_test.go @@ -50,9 +50,9 @@ func TestDirectSQLStats(t *testing.T) { guardian.MockDashboardGuardian(fakeGuardian) require.NoError(t, err) fStore := folderimpl.ProvideStore(db) - folderSvc := folderimpl.ProvideService(fStore, actest.FakeAccessControl{ExpectedEvaluate: true}, bus.ProvideBus(tracing.InitializeTracerForTest()), dashStore, - folderimpl.ProvideDashboardFolderStore(db), db, featuremgmt.WithFeatures(), - supportbundlestest.NewFakeBundleService(), nil, cfg, nil, tracing.InitializeTracerForTest()) + folderSvc := folderimpl.ProvideService( + fStore, actest.FakeAccessControl{ExpectedEvaluate: true}, bus.ProvideBus(tracing.InitializeTracerForTest()), dashStore, folderimpl.ProvideDashboardFolderStore(db), + nil, db, featuremgmt.WithFeatures(), supportbundlestest.NewFakeBundleService(), nil, cfg, nil, tracing.InitializeTracerForTest()) // create parent folder