RBAC: Enable rbac when creating new settings (#53531)

* Settings: Set RBACEnabled to true by default

* Remove accessControlEnabledFlag and explicitly set to false when needed

* Disable rbac for tests
This commit is contained in:
Karl Persson
2022-08-11 15:37:31 +02:00
committed by GitHub
parent b1ce721cf1
commit c08fe3a53c
19 changed files with 176 additions and 94 deletions
+20 -6
View File
@@ -39,6 +39,7 @@ import (
func TestAPIGetPublicDashboard(t *testing.T) {
t.Run("It should 404 if featureflag is not enabled", func(t *testing.T) {
cfg := setting.NewCfg()
cfg.RBACEnabled = false
qs := buildQueryDataService(t, nil, nil, nil)
service := publicdashboards.NewFakePublicDashboardService(t)
service.On("GetPublicDashboard", mock.Anything, mock.AnythingOfType("string")).
@@ -100,9 +101,12 @@ func TestAPIGetPublicDashboard(t *testing.T) {
service.On("GetPublicDashboardConfig", mock.Anything, mock.AnythingOfType("int64"), mock.AnythingOfType("string")).
Return(&PublicDashboard{}, nil).Maybe()
cfg := setting.NewCfg()
cfg.RBACEnabled = false
testServer := setupTestServer(
t,
setting.NewCfg(),
cfg,
buildQueryDataService(t, nil, nil, nil),
featuremgmt.WithFeatures(featuremgmt.FlagPublicDashboards),
service,
@@ -177,9 +181,12 @@ func TestAPIGetPublicDashboardConfig(t *testing.T) {
service.On("GetPublicDashboardConfig", mock.Anything, mock.AnythingOfType("int64"), mock.AnythingOfType("string")).
Return(test.PublicDashboardResult, test.PublicDashboardErr)
cfg := setting.NewCfg()
cfg.RBACEnabled = false
testServer := setupTestServer(
t,
setting.NewCfg(),
cfg,
buildQueryDataService(t, nil, nil, nil),
featuremgmt.WithFeatures(featuremgmt.FlagPublicDashboards),
service,
@@ -241,9 +248,12 @@ func TestApiSavePublicDashboardConfig(t *testing.T) {
service.On("SavePublicDashboardConfig", mock.Anything, mock.AnythingOfType("*models.SavePublicDashboardConfigDTO")).
Return(&PublicDashboard{IsEnabled: true}, test.SaveDashboardErr)
cfg := setting.NewCfg()
cfg.RBACEnabled = false
testServer := setupTestServer(
t,
setting.NewCfg(),
cfg,
buildQueryDataService(t, nil, nil, nil),
featuremgmt.WithFeatures(featuremgmt.FlagPublicDashboards),
service,
@@ -309,10 +319,12 @@ func TestAPIQueryPublicDashboard(t *testing.T) {
setup := func(enabled bool) (*web.Mux, *publicdashboards.FakePublicDashboardService) {
service := publicdashboards.NewFakePublicDashboardService(t)
cfg := setting.NewCfg()
cfg.RBACEnabled = false
testServer := setupTestServer(
t,
setting.NewCfg(),
cfg,
qds,
featuremgmt.WithFeatures(featuremgmt.FlagPublicDashboards, enabled),
service,
@@ -551,13 +563,15 @@ func TestIntegrationUnauthenticatedUserCanGetPubdashPanelQueryData(t *testing.T)
// create public dashboard
store := publicdashboardsStore.ProvideStore(db)
service := publicdashboardsService.ProvideService(setting.NewCfg(), store)
cfg := setting.NewCfg()
cfg.RBACEnabled = false
service := publicdashboardsService.ProvideService(cfg, store)
pubdash, err := service.SavePublicDashboardConfig(context.Background(), savePubDashboardCmd)
require.NoError(t, err)
// setup test server
server := setupTestServer(t,
setting.NewCfg(),
cfg,
qds,
featuremgmt.WithFeatures(featuremgmt.FlagPublicDashboards),
service,