mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Dashboards: Allow updating a dashboard if the user doesn't have access to the parent folder (#78075)
* change where folder checks are done for dash creation/updates * add test for folder not being found * test fixes * more test fixes * add nlint directive to where folder IDs are used * fix bad merge * fix test
This commit is contained in:
@@ -93,6 +93,16 @@ func TestDashboardService(t *testing.T) {
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("Should return validation error if a folder that is specified can't be found", func(t *testing.T) {
|
||||
dto.Dashboard = dashboards.NewDashboard("Dash")
|
||||
dto.Dashboard.FolderUID = "non-existing-folder"
|
||||
folderStore := foldertest.FakeFolderStore{}
|
||||
folderStore.On("GetFolderByUID", mock.Anything, mock.AnythingOfType("int64"), mock.AnythingOfType("string")).Return(nil, dashboards.ErrFolderNotFound).Once()
|
||||
service.folderStore = &folderStore
|
||||
_, err := service.SaveDashboard(context.Background(), dto, false)
|
||||
require.Equal(t, err, dashboards.ErrFolderNotFound)
|
||||
})
|
||||
|
||||
t.Run("Should return validation error if dashboard is provisioned", func(t *testing.T) {
|
||||
fakeStore.On("ValidateDashboardBeforeSave", mock.Anything, mock.Anything, mock.AnythingOfType("bool")).Return(true, nil).Once()
|
||||
fakeStore.On("GetProvisionedDataByDashboardID", mock.Anything, mock.AnythingOfType("int64")).Return(&dashboards.DashboardProvisioning{}, nil).Once()
|
||||
|
Reference in New Issue
Block a user