mirror of
https://github.com/grafana/grafana.git
synced 2026-08-19 01:34:54 -05:00
Rename Acl to ACL (#52342)
* Rename Acl to ACL * Fix yaml files * Add xorm tags and fix test
This commit is contained in:
@@ -26,7 +26,7 @@ var (
|
||||
)
|
||||
|
||||
type setUpConf struct {
|
||||
aclMockResp []*models.DashboardAclInfoDTO
|
||||
aclMockResp []*models.DashboardACLInfoDTO
|
||||
}
|
||||
|
||||
type mockSearchService struct{ ExpectedResult models.HitList }
|
||||
@@ -43,7 +43,7 @@ func setUp(confs ...setUpConf) *HTTPServer {
|
||||
hs := &HTTPServer{SQLStore: store, SearchService: &mockSearchService{}}
|
||||
store.ExpectedAlert = singleAlert
|
||||
|
||||
aclMockResp := []*models.DashboardAclInfoDTO{}
|
||||
aclMockResp := []*models.DashboardACLInfoDTO{}
|
||||
for _, c := range confs {
|
||||
if c.aclMockResp != nil {
|
||||
aclMockResp = c.aclMockResp
|
||||
@@ -51,8 +51,8 @@ func setUp(confs ...setUpConf) *HTTPServer {
|
||||
}
|
||||
store.ExpectedTeamsByUser = []*models.TeamDTO{}
|
||||
dashSvc := &dashboards.FakeDashboardService{}
|
||||
dashSvc.On("GetDashboardAclInfoList", mock.Anything, mock.AnythingOfType("*models.GetDashboardAclInfoListQuery")).Run(func(args mock.Arguments) {
|
||||
q := args.Get(1).(*models.GetDashboardAclInfoListQuery)
|
||||
dashSvc.On("GetDashboardACLInfoList", mock.Anything, mock.AnythingOfType("*models.GetDashboardACLInfoListQuery")).Run(func(args mock.Arguments) {
|
||||
q := args.Get(1).(*models.GetDashboardACLInfoListQuery)
|
||||
q.Result = aclMockResp
|
||||
}).Return(nil)
|
||||
guardian.InitLegacyGuardian(store, dashSvc)
|
||||
@@ -84,7 +84,7 @@ func TestAlertingAPIEndpoint(t *testing.T) {
|
||||
postAlertScenario(t, hs, "When calling POST on", "/api/alerts/1/pause", "/api/alerts/:alertId/pause",
|
||||
models.ROLE_EDITOR, cmd, func(sc *scenarioContext) {
|
||||
setUp(setUpConf{
|
||||
aclMockResp: []*models.DashboardAclInfoDTO{
|
||||
aclMockResp: []*models.DashboardACLInfoDTO{
|
||||
{Role: &viewerRole, Permission: models.PERMISSION_VIEW},
|
||||
{Role: &editorRole, Permission: models.PERMISSION_EDIT},
|
||||
},
|
||||
|
||||
@@ -1003,9 +1003,9 @@ func setUpACL() {
|
||||
store := mockstore.NewSQLStoreMock()
|
||||
store.ExpectedTeamsByUser = []*models.TeamDTO{}
|
||||
dashSvc := &dashboards.FakeDashboardService{}
|
||||
dashSvc.On("GetDashboardAclInfoList", mock.Anything, mock.AnythingOfType("*models.GetDashboardAclInfoListQuery")).Run(func(args mock.Arguments) {
|
||||
q := args.Get(1).(*models.GetDashboardAclInfoListQuery)
|
||||
q.Result = []*models.DashboardAclInfoDTO{
|
||||
dashSvc.On("GetDashboardACLInfoList", mock.Anything, mock.AnythingOfType("*models.GetDashboardACLInfoListQuery")).Run(func(args mock.Arguments) {
|
||||
q := args.Get(1).(*models.GetDashboardACLInfoListQuery)
|
||||
q.Result = []*models.DashboardACLInfoDTO{
|
||||
{Role: &viewerRole, Permission: models.PERMISSION_VIEW},
|
||||
{Role: &editorRole, Permission: models.PERMISSION_EDIT},
|
||||
}
|
||||
|
||||
@@ -133,7 +133,7 @@ func (hs *HTTPServer) GetDashboard(c *models.ReqContext) response.Response {
|
||||
UpdatedBy: updater,
|
||||
CreatedBy: creator,
|
||||
Version: dash.Version,
|
||||
HasAcl: dash.HasAcl,
|
||||
HasACL: dash.HasACL,
|
||||
IsFolder: dash.IsFolder,
|
||||
FolderId: dash.FolderId,
|
||||
Url: dash.GetUrl(),
|
||||
|
||||
@@ -46,7 +46,7 @@ func (hs *HTTPServer) GetDashboardPermissionList(c *models.ReqContext) response.
|
||||
return response.Error(500, "Failed to get dashboard permissions", err)
|
||||
}
|
||||
|
||||
filteredAcls := make([]*models.DashboardAclInfoDTO, 0, len(acl))
|
||||
filteredACLs := make([]*models.DashboardACLInfoDTO, 0, len(acl))
|
||||
for _, perm := range acl {
|
||||
if perm.UserId > 0 && dtos.IsHiddenUser(perm.UserLogin, c.SignedInUser, hs.Cfg) {
|
||||
continue
|
||||
@@ -61,16 +61,16 @@ func (hs *HTTPServer) GetDashboardPermissionList(c *models.ReqContext) response.
|
||||
perm.Url = models.GetDashboardFolderUrl(perm.IsFolder, perm.Uid, perm.Slug)
|
||||
}
|
||||
|
||||
filteredAcls = append(filteredAcls, perm)
|
||||
filteredACLs = append(filteredACLs, perm)
|
||||
}
|
||||
|
||||
return response.JSON(http.StatusOK, filteredAcls)
|
||||
return response.JSON(http.StatusOK, filteredACLs)
|
||||
}
|
||||
|
||||
func (hs *HTTPServer) UpdateDashboardPermissions(c *models.ReqContext) response.Response {
|
||||
var dashID int64
|
||||
var err error
|
||||
apiCmd := dtos.UpdateDashboardAclCommand{}
|
||||
apiCmd := dtos.UpdateDashboardACLCommand{}
|
||||
if err := web.Bind(c.Req, &apiCmd); err != nil {
|
||||
return response.Error(http.StatusBadRequest, "bad request data", err)
|
||||
}
|
||||
@@ -100,9 +100,9 @@ func (hs *HTTPServer) UpdateDashboardPermissions(c *models.ReqContext) response.
|
||||
return dashboardGuardianResponse(err)
|
||||
}
|
||||
|
||||
var items []*models.DashboardAcl
|
||||
var items []*models.DashboardACL
|
||||
for _, item := range apiCmd.Items {
|
||||
items = append(items, &models.DashboardAcl{
|
||||
items = append(items, &models.DashboardACL{
|
||||
OrgID: c.OrgId,
|
||||
DashboardID: dashID,
|
||||
UserID: item.UserID,
|
||||
@@ -133,7 +133,7 @@ func (hs *HTTPServer) UpdateDashboardPermissions(c *models.ReqContext) response.
|
||||
}
|
||||
|
||||
if !hs.AccessControl.IsDisabled() {
|
||||
old, err := g.GetAcl()
|
||||
old, err := g.GetACL()
|
||||
if err != nil {
|
||||
return response.Error(500, "Error while checking dashboard permissions", err)
|
||||
}
|
||||
@@ -144,7 +144,7 @@ func (hs *HTTPServer) UpdateDashboardPermissions(c *models.ReqContext) response.
|
||||
}
|
||||
|
||||
if err := hs.DashboardService.UpdateDashboardACL(c.Req.Context(), dashID, items); err != nil {
|
||||
if errors.Is(err, models.ErrDashboardAclInfoMissing) ||
|
||||
if errors.Is(err, models.ErrDashboardACLInfoMissing) ||
|
||||
errors.Is(err, models.ErrDashboardPermissionDashboardEmpty) {
|
||||
return response.Error(409, err.Error(), err)
|
||||
}
|
||||
@@ -155,7 +155,7 @@ func (hs *HTTPServer) UpdateDashboardPermissions(c *models.ReqContext) response.
|
||||
}
|
||||
|
||||
// updateDashboardAccessControl is used for api backward compatibility
|
||||
func (hs *HTTPServer) updateDashboardAccessControl(ctx context.Context, orgID int64, uid string, isFolder bool, items []*models.DashboardAcl, old []*models.DashboardAclInfoDTO) error {
|
||||
func (hs *HTTPServer) updateDashboardAccessControl(ctx context.Context, orgID int64, uid string, isFolder bool, items []*models.DashboardACL, old []*models.DashboardACLInfoDTO) error {
|
||||
commands := []accesscontrol.SetResourcePermissionCommand{}
|
||||
for _, item := range items {
|
||||
permissions := item.Permission.String()
|
||||
@@ -216,7 +216,7 @@ func (hs *HTTPServer) updateDashboardAccessControl(ctx context.Context, orgID in
|
||||
return nil
|
||||
}
|
||||
|
||||
func validatePermissionsUpdate(apiCmd dtos.UpdateDashboardAclCommand) error {
|
||||
func validatePermissionsUpdate(apiCmd dtos.UpdateDashboardACLCommand) error {
|
||||
for _, item := range apiCmd.Items {
|
||||
if item.UserID > 0 && item.TeamID > 0 {
|
||||
return models.ErrPermissionsWithUserAndTeamNotAllowed
|
||||
|
||||
@@ -58,8 +58,8 @@ func TestDashboardPermissionAPIEndpoint(t *testing.T) {
|
||||
assert.Equal(t, 403, sc.resp.Code)
|
||||
}, mockSQLStore)
|
||||
|
||||
cmd := dtos.UpdateDashboardAclCommand{
|
||||
Items: []dtos.DashboardAclUpdateItem{
|
||||
cmd := dtos.UpdateDashboardACLCommand{
|
||||
Items: []dtos.DashboardACLUpdateItem{
|
||||
{UserID: 1000, Permission: models.PERMISSION_ADMIN},
|
||||
},
|
||||
}
|
||||
@@ -86,7 +86,7 @@ func TestDashboardPermissionAPIEndpoint(t *testing.T) {
|
||||
guardian.MockDashboardGuardian(&guardian.FakeDashboardGuardian{
|
||||
CanAdminValue: true,
|
||||
CheckPermissionBeforeUpdateValue: true,
|
||||
GetAclValue: []*models.DashboardAclInfoDTO{
|
||||
GetACLValue: []*models.DashboardACLInfoDTO{
|
||||
{OrgId: 1, DashboardId: 1, UserId: 2, Permission: models.PERMISSION_VIEW},
|
||||
{OrgId: 1, DashboardId: 1, UserId: 3, Permission: models.PERMISSION_EDIT},
|
||||
{OrgId: 1, DashboardId: 1, UserId: 4, Permission: models.PERMISSION_ADMIN},
|
||||
@@ -100,7 +100,7 @@ func TestDashboardPermissionAPIEndpoint(t *testing.T) {
|
||||
callGetDashboardPermissions(sc, hs)
|
||||
assert.Equal(t, 200, sc.resp.Code)
|
||||
|
||||
var resp []*models.DashboardAclInfoDTO
|
||||
var resp []*models.DashboardACLInfoDTO
|
||||
err := json.Unmarshal(sc.resp.Body.Bytes(), &resp)
|
||||
require.NoError(t, err)
|
||||
|
||||
@@ -109,8 +109,8 @@ func TestDashboardPermissionAPIEndpoint(t *testing.T) {
|
||||
assert.Equal(t, models.PERMISSION_VIEW, resp[0].Permission)
|
||||
}, mockSQLStore)
|
||||
|
||||
cmd := dtos.UpdateDashboardAclCommand{
|
||||
Items: []dtos.DashboardAclUpdateItem{
|
||||
cmd := dtos.UpdateDashboardACLCommand{
|
||||
Items: []dtos.DashboardACLUpdateItem{
|
||||
{UserID: 1000, Permission: models.PERMISSION_ADMIN},
|
||||
},
|
||||
}
|
||||
@@ -138,8 +138,8 @@ func TestDashboardPermissionAPIEndpoint(t *testing.T) {
|
||||
CheckPermissionBeforeUpdateValue: true,
|
||||
})
|
||||
|
||||
cmd := dtos.UpdateDashboardAclCommand{
|
||||
Items: []dtos.DashboardAclUpdateItem{
|
||||
cmd := dtos.UpdateDashboardACLCommand{
|
||||
Items: []dtos.DashboardACLUpdateItem{
|
||||
{UserID: 1000, TeamID: 1, Permission: models.PERMISSION_ADMIN},
|
||||
},
|
||||
}
|
||||
@@ -170,8 +170,8 @@ func TestDashboardPermissionAPIEndpoint(t *testing.T) {
|
||||
CheckPermissionBeforeUpdateError: guardian.ErrGuardianPermissionExists,
|
||||
})
|
||||
|
||||
cmd := dtos.UpdateDashboardAclCommand{
|
||||
Items: []dtos.DashboardAclUpdateItem{
|
||||
cmd := dtos.UpdateDashboardACLCommand{
|
||||
Items: []dtos.DashboardACLUpdateItem{
|
||||
{UserID: 1000, Permission: models.PERMISSION_ADMIN},
|
||||
},
|
||||
}
|
||||
@@ -190,14 +190,14 @@ func TestDashboardPermissionAPIEndpoint(t *testing.T) {
|
||||
|
||||
t.Run("When trying to update team or user permissions with a role", func(t *testing.T) {
|
||||
role := models.ROLE_EDITOR
|
||||
cmds := []dtos.UpdateDashboardAclCommand{
|
||||
cmds := []dtos.UpdateDashboardACLCommand{
|
||||
{
|
||||
Items: []dtos.DashboardAclUpdateItem{
|
||||
Items: []dtos.DashboardACLUpdateItem{
|
||||
{UserID: 1000, Permission: models.PERMISSION_ADMIN, Role: &role},
|
||||
},
|
||||
},
|
||||
{
|
||||
Items: []dtos.DashboardAclUpdateItem{
|
||||
Items: []dtos.DashboardACLUpdateItem{
|
||||
{TeamID: 1000, Permission: models.PERMISSION_ADMIN, Role: &role},
|
||||
},
|
||||
},
|
||||
@@ -232,8 +232,8 @@ func TestDashboardPermissionAPIEndpoint(t *testing.T) {
|
||||
CheckPermissionBeforeUpdateError: guardian.ErrGuardianOverride},
|
||||
)
|
||||
|
||||
cmd := dtos.UpdateDashboardAclCommand{
|
||||
Items: []dtos.DashboardAclUpdateItem{
|
||||
cmd := dtos.UpdateDashboardACLCommand{
|
||||
Items: []dtos.DashboardACLUpdateItem{
|
||||
{UserID: 1000, Permission: models.PERMISSION_ADMIN},
|
||||
},
|
||||
}
|
||||
@@ -262,19 +262,19 @@ func TestDashboardPermissionAPIEndpoint(t *testing.T) {
|
||||
})
|
||||
|
||||
mockSQLStore := mockstore.NewSQLStoreMock()
|
||||
var resp []*models.DashboardAclInfoDTO
|
||||
var resp []*models.DashboardACLInfoDTO
|
||||
loggedInUserScenarioWithRole(t, "When calling GET on", "GET", "/api/dashboards/id/1/permissions",
|
||||
"/api/dashboards/id/:dashboardId/permissions", models.ROLE_ADMIN, func(sc *scenarioContext) {
|
||||
setUp()
|
||||
guardian.MockDashboardGuardian(&guardian.FakeDashboardGuardian{
|
||||
CanAdminValue: true,
|
||||
CheckPermissionBeforeUpdateValue: true,
|
||||
GetAclValue: []*models.DashboardAclInfoDTO{
|
||||
GetACLValue: []*models.DashboardACLInfoDTO{
|
||||
{OrgId: 1, DashboardId: 1, UserId: 2, UserLogin: "hiddenUser", Permission: models.PERMISSION_VIEW},
|
||||
{OrgId: 1, DashboardId: 1, UserId: 3, UserLogin: testUserLogin, Permission: models.PERMISSION_EDIT},
|
||||
{OrgId: 1, DashboardId: 1, UserId: 4, UserLogin: "user_1", Permission: models.PERMISSION_ADMIN},
|
||||
},
|
||||
GetHiddenAclValue: []*models.DashboardAcl{
|
||||
GetHiddenACLValue: []*models.DashboardACL{
|
||||
{OrgID: 1, DashboardID: 1, UserID: 2, Permission: models.PERMISSION_VIEW},
|
||||
},
|
||||
})
|
||||
@@ -292,22 +292,22 @@ func TestDashboardPermissionAPIEndpoint(t *testing.T) {
|
||||
assert.Equal(t, models.PERMISSION_ADMIN, resp[1].Permission)
|
||||
}, mockSQLStore)
|
||||
|
||||
cmd := dtos.UpdateDashboardAclCommand{
|
||||
Items: []dtos.DashboardAclUpdateItem{
|
||||
cmd := dtos.UpdateDashboardACLCommand{
|
||||
Items: []dtos.DashboardACLUpdateItem{
|
||||
{UserID: 1000, Permission: models.PERMISSION_ADMIN},
|
||||
},
|
||||
}
|
||||
for _, acl := range resp {
|
||||
cmd.Items = append(cmd.Items, dtos.DashboardAclUpdateItem{
|
||||
cmd.Items = append(cmd.Items, dtos.DashboardACLUpdateItem{
|
||||
UserID: acl.UserId,
|
||||
Permission: acl.Permission,
|
||||
})
|
||||
}
|
||||
assert.Len(t, cmd.Items, 3)
|
||||
|
||||
var numOfItems []*models.DashboardAcl
|
||||
var numOfItems []*models.DashboardACL
|
||||
dashboardStore.On("UpdateDashboardACL", mock.Anything, mock.Anything, mock.Anything).Run(func(args mock.Arguments) {
|
||||
items := args.Get(2).([]*models.DashboardAcl)
|
||||
items := args.Get(2).([]*models.DashboardACL)
|
||||
numOfItems = items
|
||||
}).Return(nil).Once()
|
||||
updateDashboardPermissionScenario(t, updatePermissionContext{
|
||||
@@ -339,7 +339,7 @@ type updatePermissionContext struct {
|
||||
desc string
|
||||
url string
|
||||
routePattern string
|
||||
cmd dtos.UpdateDashboardAclCommand
|
||||
cmd dtos.UpdateDashboardACLCommand
|
||||
fn scenarioFunc
|
||||
}
|
||||
|
||||
|
||||
@@ -69,7 +69,7 @@ func TestDashboardSnapshotAPIEndpoint_singleSnapshot(t *testing.T) {
|
||||
sc.handlerFunc = hs.DeleteDashboardSnapshot
|
||||
|
||||
dashSvc := dashboards.NewFakeDashboardService(t)
|
||||
dashSvc.On("GetDashboardAclInfoList", mock.Anything, mock.AnythingOfType("*models.GetDashboardAclInfoListQuery")).Return(nil).Maybe()
|
||||
dashSvc.On("GetDashboardACLInfoList", mock.Anything, mock.AnythingOfType("*models.GetDashboardACLInfoListQuery")).Return(nil).Maybe()
|
||||
|
||||
guardian.InitLegacyGuardian(sc.sqlStore, dashSvc)
|
||||
sc.fakeReqWithParams("DELETE", sc.url, map[string]string{"key": "12345"}).exec()
|
||||
@@ -106,9 +106,9 @@ func TestDashboardSnapshotAPIEndpoint_singleSnapshot(t *testing.T) {
|
||||
|
||||
t.Run("When user is editor and dashboard has default ACL", func(t *testing.T) {
|
||||
dashSvc := &dashboards.FakeDashboardService{}
|
||||
dashSvc.On("GetDashboardAclInfoList", mock.Anything, mock.AnythingOfType("*models.GetDashboardAclInfoListQuery")).Run(func(args mock.Arguments) {
|
||||
q := args.Get(1).(*models.GetDashboardAclInfoListQuery)
|
||||
q.Result = []*models.DashboardAclInfoDTO{
|
||||
dashSvc.On("GetDashboardACLInfoList", mock.Anything, mock.AnythingOfType("*models.GetDashboardACLInfoListQuery")).Run(func(args mock.Arguments) {
|
||||
q := args.Get(1).(*models.GetDashboardACLInfoListQuery)
|
||||
q.Result = []*models.DashboardACLInfoDTO{
|
||||
{Role: &viewerRole, Permission: models.PERMISSION_VIEW},
|
||||
{Role: &editorRole, Permission: models.PERMISSION_EDIT},
|
||||
}
|
||||
|
||||
+29
-29
@@ -123,7 +123,7 @@ func TestDashboardAPIEndpoint(t *testing.T) {
|
||||
fakeDash := models.NewDashboard("Child dash")
|
||||
fakeDash.Id = 1
|
||||
fakeDash.FolderId = 1
|
||||
fakeDash.HasAcl = false
|
||||
fakeDash.HasACL = false
|
||||
fakeDashboardVersionService := dashvertest.NewDashboardVersionServiceFake()
|
||||
fakeDashboardVersionService.ExpectedDashboardVersion = &dashver.DashboardVersion{}
|
||||
dashboardService := dashboards.NewFakeDashboardService(t)
|
||||
@@ -147,9 +147,9 @@ func TestDashboardAPIEndpoint(t *testing.T) {
|
||||
setUp := func() {
|
||||
viewerRole := models.ROLE_VIEWER
|
||||
editorRole := models.ROLE_EDITOR
|
||||
dashboardService.On("GetDashboardAclInfoList", mock.Anything, mock.AnythingOfType("*models.GetDashboardAclInfoListQuery")).Run(func(args mock.Arguments) {
|
||||
q := args.Get(1).(*models.GetDashboardAclInfoListQuery)
|
||||
q.Result = []*models.DashboardAclInfoDTO{
|
||||
dashboardService.On("GetDashboardACLInfoList", mock.Anything, mock.AnythingOfType("*models.GetDashboardACLInfoListQuery")).Run(func(args mock.Arguments) {
|
||||
q := args.Get(1).(*models.GetDashboardACLInfoListQuery)
|
||||
q.Result = []*models.DashboardACLInfoDTO{
|
||||
{Role: &viewerRole, Permission: models.PERMISSION_VIEW},
|
||||
{Role: &editorRole, Permission: models.PERMISSION_EDIT},
|
||||
}
|
||||
@@ -229,7 +229,7 @@ func TestDashboardAPIEndpoint(t *testing.T) {
|
||||
fakeDash := models.NewDashboard("Child dash")
|
||||
fakeDash.Id = 1
|
||||
fakeDash.FolderId = 1
|
||||
fakeDash.HasAcl = true
|
||||
fakeDash.HasACL = true
|
||||
fakeDashboardVersionService := dashvertest.NewDashboardVersionServiceFake()
|
||||
fakeDashboardVersionService.ExpectedDashboardVersion = &dashver.DashboardVersion{}
|
||||
dashboardService := dashboards.NewFakeDashboardService(t)
|
||||
@@ -237,9 +237,9 @@ func TestDashboardAPIEndpoint(t *testing.T) {
|
||||
q := args.Get(1).(*models.GetDashboardQuery)
|
||||
q.Result = fakeDash
|
||||
}).Return(nil)
|
||||
dashboardService.On("GetDashboardAclInfoList", mock.Anything, mock.AnythingOfType("*models.GetDashboardAclInfoListQuery")).Run(func(args mock.Arguments) {
|
||||
q := args.Get(1).(*models.GetDashboardAclInfoListQuery)
|
||||
q.Result = []*models.DashboardAclInfoDTO{
|
||||
dashboardService.On("GetDashboardACLInfoList", mock.Anything, mock.AnythingOfType("*models.GetDashboardACLInfoListQuery")).Run(func(args mock.Arguments) {
|
||||
q := args.Get(1).(*models.GetDashboardACLInfoListQuery)
|
||||
q.Result = []*models.DashboardACLInfoDTO{
|
||||
{
|
||||
DashboardId: 1,
|
||||
Permission: models.PERMISSION_EDIT,
|
||||
@@ -368,9 +368,9 @@ func TestDashboardAPIEndpoint(t *testing.T) {
|
||||
setting.ViewersCanEdit = false
|
||||
|
||||
dashboardService := dashboards.NewFakeDashboardService(t)
|
||||
dashboardService.On("GetDashboardAclInfoList", mock.Anything, mock.AnythingOfType("*models.GetDashboardAclInfoListQuery")).Run(func(args mock.Arguments) {
|
||||
q := args.Get(1).(*models.GetDashboardAclInfoListQuery)
|
||||
q.Result = []*models.DashboardAclInfoDTO{
|
||||
dashboardService.On("GetDashboardACLInfoList", mock.Anything, mock.AnythingOfType("*models.GetDashboardACLInfoListQuery")).Run(func(args mock.Arguments) {
|
||||
q := args.Get(1).(*models.GetDashboardACLInfoListQuery)
|
||||
q.Result = []*models.DashboardACLInfoDTO{
|
||||
{OrgId: 1, DashboardId: 2, UserId: 1, Permission: models.PERMISSION_EDIT},
|
||||
}
|
||||
}).Return(nil)
|
||||
@@ -430,9 +430,9 @@ func TestDashboardAPIEndpoint(t *testing.T) {
|
||||
setting.ViewersCanEdit = true
|
||||
|
||||
dashboardService := dashboards.NewFakeDashboardService(t)
|
||||
dashboardService.On("GetDashboardAclInfoList", mock.Anything, mock.AnythingOfType("*models.GetDashboardAclInfoListQuery")).Run(func(args mock.Arguments) {
|
||||
q := args.Get(1).(*models.GetDashboardAclInfoListQuery)
|
||||
q.Result = []*models.DashboardAclInfoDTO{
|
||||
dashboardService.On("GetDashboardACLInfoList", mock.Anything, mock.AnythingOfType("*models.GetDashboardACLInfoListQuery")).Run(func(args mock.Arguments) {
|
||||
q := args.Get(1).(*models.GetDashboardACLInfoListQuery)
|
||||
q.Result = []*models.DashboardACLInfoDTO{
|
||||
{OrgId: 1, DashboardId: 2, UserId: 1, Permission: models.PERMISSION_VIEW},
|
||||
}
|
||||
}).Return(nil)
|
||||
@@ -470,9 +470,9 @@ func TestDashboardAPIEndpoint(t *testing.T) {
|
||||
setting.ViewersCanEdit = true
|
||||
|
||||
dashboardService := dashboards.NewFakeDashboardService(t)
|
||||
dashboardService.On("GetDashboardAclInfoList", mock.Anything, mock.AnythingOfType("*models.GetDashboardAclInfoListQuery")).Run(func(args mock.Arguments) {
|
||||
q := args.Get(1).(*models.GetDashboardAclInfoListQuery)
|
||||
q.Result = []*models.DashboardAclInfoDTO{
|
||||
dashboardService.On("GetDashboardACLInfoList", mock.Anything, mock.AnythingOfType("*models.GetDashboardACLInfoListQuery")).Run(func(args mock.Arguments) {
|
||||
q := args.Get(1).(*models.GetDashboardACLInfoListQuery)
|
||||
q.Result = []*models.DashboardACLInfoDTO{
|
||||
{OrgId: 1, DashboardId: 2, UserId: 1, Permission: models.PERMISSION_ADMIN},
|
||||
}
|
||||
}).Return(nil)
|
||||
@@ -523,9 +523,9 @@ func TestDashboardAPIEndpoint(t *testing.T) {
|
||||
|
||||
setUpInner := func() {
|
||||
dashboardService := dashboards.NewFakeDashboardService(t)
|
||||
dashboardService.On("GetDashboardAclInfoList", mock.Anything, mock.AnythingOfType("*models.GetDashboardAclInfoListQuery")).Run(func(args mock.Arguments) {
|
||||
q := args.Get(1).(*models.GetDashboardAclInfoListQuery)
|
||||
q.Result = []*models.DashboardAclInfoDTO{
|
||||
dashboardService.On("GetDashboardACLInfoList", mock.Anything, mock.AnythingOfType("*models.GetDashboardACLInfoListQuery")).Run(func(args mock.Arguments) {
|
||||
q := args.Get(1).(*models.GetDashboardACLInfoListQuery)
|
||||
q.Result = []*models.DashboardACLInfoDTO{
|
||||
{OrgId: 1, DashboardId: 2, UserId: 1, Permission: models.PERMISSION_VIEW},
|
||||
}
|
||||
}).Return(nil)
|
||||
@@ -568,12 +568,12 @@ func TestDashboardAPIEndpoint(t *testing.T) {
|
||||
dashOne := models.NewDashboard("dash")
|
||||
dashOne.Id = 2
|
||||
dashOne.FolderId = 1
|
||||
dashOne.HasAcl = false
|
||||
dashOne.HasACL = false
|
||||
|
||||
dashTwo := models.NewDashboard("dash")
|
||||
dashTwo.Id = 4
|
||||
dashTwo.FolderId = 3
|
||||
dashTwo.HasAcl = false
|
||||
dashTwo.HasACL = false
|
||||
})
|
||||
|
||||
t.Run("Post dashboard response tests", func(t *testing.T) {
|
||||
@@ -740,7 +740,7 @@ func TestDashboardAPIEndpoint(t *testing.T) {
|
||||
sqlmock := mockstore.SQLStoreMock{}
|
||||
setUp := func() {
|
||||
dashSvc := dashboards.NewFakeDashboardService(t)
|
||||
dashSvc.On("GetDashboardAclInfoList", mock.Anything, mock.AnythingOfType("*models.GetDashboardAclInfoListQuery")).Return(nil)
|
||||
dashSvc.On("GetDashboardACLInfoList", mock.Anything, mock.AnythingOfType("*models.GetDashboardACLInfoListQuery")).Return(nil)
|
||||
guardian.InitLegacyGuardian(&sqlmock, dashSvc)
|
||||
}
|
||||
|
||||
@@ -769,7 +769,7 @@ func TestDashboardAPIEndpoint(t *testing.T) {
|
||||
t.Run("when user does have permission", func(t *testing.T) {
|
||||
role := models.ROLE_ADMIN
|
||||
postDiffScenario(t, "When calling POST on", "/api/dashboards/calculate-diff", "/api/dashboards/calculate-diff", cmd, role, func(sc *scenarioContext) {
|
||||
// This test shouldn't hit GetDashboardAclInfoList, so no setup needed
|
||||
// This test shouldn't hit GetDashboardACLInfoList, so no setup needed
|
||||
sc.dashboardVersionService = fakeDashboardVersionService
|
||||
callPostDashboard(sc)
|
||||
assert.Equal(t, 200, sc.resp.Code)
|
||||
@@ -782,7 +782,7 @@ func TestDashboardAPIEndpoint(t *testing.T) {
|
||||
fakeDash := models.NewDashboard("Child dash")
|
||||
fakeDash.Id = 2
|
||||
fakeDash.FolderId = folderID
|
||||
fakeDash.HasAcl = false
|
||||
fakeDash.HasACL = false
|
||||
|
||||
dashboardService := dashboards.NewFakeDashboardService(t)
|
||||
dashboardService.On("GetDashboard", mock.Anything, mock.AnythingOfType("*models.GetDashboardQuery")).Run(func(args mock.Arguments) {
|
||||
@@ -819,7 +819,7 @@ func TestDashboardAPIEndpoint(t *testing.T) {
|
||||
t.Run("Given dashboard in general folder being restored should restore to general folder", func(t *testing.T) {
|
||||
fakeDash := models.NewDashboard("Child dash")
|
||||
fakeDash.Id = 2
|
||||
fakeDash.HasAcl = false
|
||||
fakeDash.HasACL = false
|
||||
|
||||
dashboardService := dashboards.NewFakeDashboardService(t)
|
||||
dashboardService.On("GetDashboard", mock.Anything, mock.AnythingOfType("*models.GetDashboardQuery")).Run(func(args mock.Arguments) {
|
||||
@@ -865,9 +865,9 @@ func TestDashboardAPIEndpoint(t *testing.T) {
|
||||
q := args.Get(1).(*models.GetDashboardQuery)
|
||||
q.Result = &models.Dashboard{Id: 1, Data: dataValue}
|
||||
}).Return(nil)
|
||||
dashboardService.On("GetDashboardAclInfoList", mock.Anything, mock.AnythingOfType("*models.GetDashboardAclInfoListQuery")).Run(func(args mock.Arguments) {
|
||||
q := args.Get(1).(*models.GetDashboardAclInfoListQuery)
|
||||
q.Result = []*models.DashboardAclInfoDTO{{OrgId: testOrgID, DashboardId: 1, UserId: testUserID, Permission: models.PERMISSION_EDIT}}
|
||||
dashboardService.On("GetDashboardACLInfoList", mock.Anything, mock.AnythingOfType("*models.GetDashboardACLInfoListQuery")).Run(func(args mock.Arguments) {
|
||||
q := args.Get(1).(*models.GetDashboardACLInfoListQuery)
|
||||
q.Result = []*models.DashboardACLInfoDTO{{OrgId: testOrgID, DashboardId: 1, UserId: testUserID, Permission: models.PERMISSION_EDIT}}
|
||||
}).Return(nil)
|
||||
guardian.InitLegacyGuardian(mockSQLStore, dashboardService)
|
||||
|
||||
|
||||
@@ -73,7 +73,7 @@ type GetDashboardPermissionsParams struct {
|
||||
type PostDashboardPermissionsParams struct {
|
||||
// in:body
|
||||
// required:true
|
||||
Body dtos.UpdateDashboardAclCommand
|
||||
Body dtos.UpdateDashboardACLCommand
|
||||
// in:path
|
||||
DashboardID int64
|
||||
}
|
||||
@@ -82,7 +82,7 @@ type PostDashboardPermissionsParams struct {
|
||||
type PostDashboardPermissionsWithUIDParams struct {
|
||||
// in:body
|
||||
// required:true
|
||||
Body dtos.UpdateDashboardAclCommand
|
||||
Body dtos.UpdateDashboardACLCommand
|
||||
// in:path
|
||||
// required:true
|
||||
// description: The dashboard UID
|
||||
@@ -92,5 +92,5 @@ type PostDashboardPermissionsWithUIDParams struct {
|
||||
// swagger:response getDashboardPermissionsResponse
|
||||
type GetDashboardPermissionsResponse struct {
|
||||
// in: body
|
||||
Body []*models.DashboardAclInfoDTO `json:"body"`
|
||||
Body []*models.DashboardACLInfoDTO `json:"body"`
|
||||
}
|
||||
|
||||
@@ -109,7 +109,7 @@ type PostDashboardPermissionsParam struct {
|
||||
FolderUID string `json:"folder_uid"`
|
||||
// in:body
|
||||
// required:true
|
||||
Body dtos.UpdateDashboardAclCommand
|
||||
Body dtos.UpdateDashboardACLCommand
|
||||
}
|
||||
|
||||
// swagger:parameters getFolderByID
|
||||
|
||||
+3
-3
@@ -3,12 +3,12 @@ package dtos
|
||||
import "github.com/grafana/grafana/pkg/models"
|
||||
|
||||
// swagger:model
|
||||
type UpdateDashboardAclCommand struct {
|
||||
Items []DashboardAclUpdateItem `json:"items"`
|
||||
type UpdateDashboardACLCommand struct {
|
||||
Items []DashboardACLUpdateItem `json:"items"`
|
||||
}
|
||||
|
||||
// swagger:model
|
||||
type DashboardAclUpdateItem struct {
|
||||
type DashboardACLUpdateItem struct {
|
||||
UserID int64 `json:"userId"`
|
||||
TeamID int64 `json:"teamId"`
|
||||
Role *models.RoleType `json:"role,omitempty"`
|
||||
|
||||
@@ -24,7 +24,7 @@ type DashboardMeta struct {
|
||||
UpdatedBy string `json:"updatedBy"`
|
||||
CreatedBy string `json:"createdBy"`
|
||||
Version int `json:"version"`
|
||||
HasAcl bool `json:"hasAcl"`
|
||||
HasACL bool `json:"hasAcl" xorm:"has_acl"`
|
||||
IsFolder bool `json:"isFolder"`
|
||||
FolderId int64 `json:"folderId"`
|
||||
FolderUid string `json:"folderUid"`
|
||||
|
||||
@@ -11,7 +11,7 @@ type Folder struct {
|
||||
Uid string `json:"uid"`
|
||||
Title string `json:"title"`
|
||||
Url string `json:"url"`
|
||||
HasAcl bool `json:"hasAcl"`
|
||||
HasACL bool `json:"hasAcl" xorm:"has_acl"`
|
||||
CanSave bool `json:"canSave"`
|
||||
CanEdit bool `json:"canEdit"`
|
||||
CanAdmin bool `json:"canAdmin"`
|
||||
|
||||
+1
-1
@@ -164,7 +164,7 @@ func (hs *HTTPServer) toFolderDto(c *models.ReqContext, g guardian.DashboardGuar
|
||||
Uid: folder.Uid,
|
||||
Title: folder.Title,
|
||||
Url: folder.Url,
|
||||
HasAcl: folder.HasAcl,
|
||||
HasACL: folder.HasACL,
|
||||
CanSave: canSave,
|
||||
CanEdit: canEdit,
|
||||
CanAdmin: canAdmin,
|
||||
|
||||
@@ -28,12 +28,12 @@ func (hs *HTTPServer) GetFolderPermissionList(c *models.ReqContext) response.Res
|
||||
return apierrors.ToFolderErrorResponse(dashboards.ErrFolderAccessDenied)
|
||||
}
|
||||
|
||||
acl, err := g.GetAcl()
|
||||
acl, err := g.GetACL()
|
||||
if err != nil {
|
||||
return response.Error(500, "Failed to get folder permissions", err)
|
||||
}
|
||||
|
||||
filteredAcls := make([]*models.DashboardAclInfoDTO, 0, len(acl))
|
||||
filteredACLs := make([]*models.DashboardACLInfoDTO, 0, len(acl))
|
||||
for _, perm := range acl {
|
||||
if perm.UserId > 0 && dtos.IsHiddenUser(perm.UserLogin, c.SignedInUser, hs.Cfg) {
|
||||
continue
|
||||
@@ -52,14 +52,14 @@ func (hs *HTTPServer) GetFolderPermissionList(c *models.ReqContext) response.Res
|
||||
perm.Url = models.GetDashboardFolderUrl(perm.IsFolder, perm.Uid, perm.Slug)
|
||||
}
|
||||
|
||||
filteredAcls = append(filteredAcls, perm)
|
||||
filteredACLs = append(filteredACLs, perm)
|
||||
}
|
||||
|
||||
return response.JSON(http.StatusOK, filteredAcls)
|
||||
return response.JSON(http.StatusOK, filteredACLs)
|
||||
}
|
||||
|
||||
func (hs *HTTPServer) UpdateFolderPermissions(c *models.ReqContext) response.Response {
|
||||
apiCmd := dtos.UpdateDashboardAclCommand{}
|
||||
apiCmd := dtos.UpdateDashboardACLCommand{}
|
||||
if err := web.Bind(c.Req, &apiCmd); err != nil {
|
||||
return response.Error(http.StatusBadRequest, "bad request data", err)
|
||||
}
|
||||
@@ -82,9 +82,9 @@ func (hs *HTTPServer) UpdateFolderPermissions(c *models.ReqContext) response.Res
|
||||
return apierrors.ToFolderErrorResponse(dashboards.ErrFolderAccessDenied)
|
||||
}
|
||||
|
||||
var items []*models.DashboardAcl
|
||||
var items []*models.DashboardACL
|
||||
for _, item := range apiCmd.Items {
|
||||
items = append(items, &models.DashboardAcl{
|
||||
items = append(items, &models.DashboardACL{
|
||||
OrgID: c.OrgId,
|
||||
DashboardID: folder.Id,
|
||||
UserID: item.UserID,
|
||||
@@ -116,7 +116,7 @@ func (hs *HTTPServer) UpdateFolderPermissions(c *models.ReqContext) response.Res
|
||||
}
|
||||
|
||||
if !hs.AccessControl.IsDisabled() {
|
||||
old, err := g.GetAcl()
|
||||
old, err := g.GetACL()
|
||||
if err != nil {
|
||||
return response.Error(500, "Error while checking dashboard permissions", err)
|
||||
}
|
||||
@@ -127,14 +127,14 @@ func (hs *HTTPServer) UpdateFolderPermissions(c *models.ReqContext) response.Res
|
||||
}
|
||||
|
||||
if err := hs.DashboardService.UpdateDashboardACL(c.Req.Context(), folder.Id, items); err != nil {
|
||||
if errors.Is(err, models.ErrDashboardAclInfoMissing) {
|
||||
err = models.ErrFolderAclInfoMissing
|
||||
if errors.Is(err, models.ErrDashboardACLInfoMissing) {
|
||||
err = models.ErrFolderACLInfoMissing
|
||||
}
|
||||
if errors.Is(err, models.ErrDashboardPermissionDashboardEmpty) {
|
||||
err = models.ErrFolderPermissionFolderEmpty
|
||||
}
|
||||
|
||||
if errors.Is(err, models.ErrFolderAclInfoMissing) || errors.Is(err, models.ErrFolderPermissionFolderEmpty) {
|
||||
if errors.Is(err, models.ErrFolderACLInfoMissing) || errors.Is(err, models.ErrFolderPermissionFolderEmpty) {
|
||||
return response.Error(409, err.Error(), err)
|
||||
}
|
||||
|
||||
|
||||
@@ -56,8 +56,8 @@ func TestFolderPermissionAPIEndpoint(t *testing.T) {
|
||||
assert.Equal(t, 404, sc.resp.Code)
|
||||
}, mockSQLStore)
|
||||
|
||||
cmd := dtos.UpdateDashboardAclCommand{
|
||||
Items: []dtos.DashboardAclUpdateItem{
|
||||
cmd := dtos.UpdateDashboardACLCommand{
|
||||
Items: []dtos.DashboardACLUpdateItem{
|
||||
{UserID: 1000, Permission: models.PERMISSION_ADMIN},
|
||||
},
|
||||
}
|
||||
@@ -89,8 +89,8 @@ func TestFolderPermissionAPIEndpoint(t *testing.T) {
|
||||
assert.Equal(t, 403, sc.resp.Code)
|
||||
}, mockSQLStore)
|
||||
|
||||
cmd := dtos.UpdateDashboardAclCommand{
|
||||
Items: []dtos.DashboardAclUpdateItem{
|
||||
cmd := dtos.UpdateDashboardACLCommand{
|
||||
Items: []dtos.DashboardACLUpdateItem{
|
||||
{UserID: 1000, Permission: models.PERMISSION_ADMIN},
|
||||
},
|
||||
}
|
||||
@@ -116,7 +116,7 @@ func TestFolderPermissionAPIEndpoint(t *testing.T) {
|
||||
guardian.MockDashboardGuardian(&guardian.FakeDashboardGuardian{
|
||||
CanAdminValue: true,
|
||||
CheckPermissionBeforeUpdateValue: true,
|
||||
GetAclValue: []*models.DashboardAclInfoDTO{
|
||||
GetACLValue: []*models.DashboardACLInfoDTO{
|
||||
{OrgId: 1, DashboardId: 1, UserId: 2, Permission: models.PERMISSION_VIEW},
|
||||
{OrgId: 1, DashboardId: 1, UserId: 3, Permission: models.PERMISSION_EDIT},
|
||||
{OrgId: 1, DashboardId: 1, UserId: 4, Permission: models.PERMISSION_ADMIN},
|
||||
@@ -134,7 +134,7 @@ func TestFolderPermissionAPIEndpoint(t *testing.T) {
|
||||
callGetFolderPermissions(sc, hs)
|
||||
assert.Equal(t, 200, sc.resp.Code)
|
||||
|
||||
var resp []*models.DashboardAclInfoDTO
|
||||
var resp []*models.DashboardACLInfoDTO
|
||||
err := json.Unmarshal(sc.resp.Body.Bytes(), &resp)
|
||||
require.NoError(t, err)
|
||||
|
||||
@@ -143,8 +143,8 @@ func TestFolderPermissionAPIEndpoint(t *testing.T) {
|
||||
assert.Equal(t, models.PERMISSION_VIEW, resp[0].Permission)
|
||||
}, mockSQLStore)
|
||||
|
||||
cmd := dtos.UpdateDashboardAclCommand{
|
||||
Items: []dtos.DashboardAclUpdateItem{
|
||||
cmd := dtos.UpdateDashboardACLCommand{
|
||||
Items: []dtos.DashboardACLUpdateItem{
|
||||
{UserID: 1000, Permission: models.PERMISSION_ADMIN},
|
||||
},
|
||||
}
|
||||
@@ -186,8 +186,8 @@ func TestFolderPermissionAPIEndpoint(t *testing.T) {
|
||||
folderResponse := &models.Folder{Id: 1, Uid: "uid", Title: "Folder"}
|
||||
folderService.On("GetFolderByUID", mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(folderResponse, nil).Once()
|
||||
|
||||
cmd := dtos.UpdateDashboardAclCommand{
|
||||
Items: []dtos.DashboardAclUpdateItem{
|
||||
cmd := dtos.UpdateDashboardACLCommand{
|
||||
Items: []dtos.DashboardACLUpdateItem{
|
||||
{UserID: 1000, Permission: models.PERMISSION_ADMIN},
|
||||
},
|
||||
}
|
||||
@@ -206,14 +206,14 @@ func TestFolderPermissionAPIEndpoint(t *testing.T) {
|
||||
|
||||
t.Run("When trying to update team or user permissions with a role", func(t *testing.T) {
|
||||
role := models.ROLE_ADMIN
|
||||
cmds := []dtos.UpdateDashboardAclCommand{
|
||||
cmds := []dtos.UpdateDashboardACLCommand{
|
||||
{
|
||||
Items: []dtos.DashboardAclUpdateItem{
|
||||
Items: []dtos.DashboardACLUpdateItem{
|
||||
{UserID: 1000, Permission: models.PERMISSION_ADMIN, Role: &role},
|
||||
},
|
||||
},
|
||||
{
|
||||
Items: []dtos.DashboardAclUpdateItem{
|
||||
Items: []dtos.DashboardACLUpdateItem{
|
||||
{TeamID: 1000, Permission: models.PERMISSION_ADMIN, Role: &role},
|
||||
},
|
||||
},
|
||||
@@ -251,8 +251,8 @@ func TestFolderPermissionAPIEndpoint(t *testing.T) {
|
||||
folderResponse := &models.Folder{Id: 1, Uid: "uid", Title: "Folder"}
|
||||
folderService.On("GetFolderByUID", mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(folderResponse, nil).Once()
|
||||
|
||||
cmd := dtos.UpdateDashboardAclCommand{
|
||||
Items: []dtos.DashboardAclUpdateItem{
|
||||
cmd := dtos.UpdateDashboardACLCommand{
|
||||
Items: []dtos.DashboardACLUpdateItem{
|
||||
{UserID: 1000, Permission: models.PERMISSION_ADMIN},
|
||||
},
|
||||
}
|
||||
@@ -283,25 +283,25 @@ func TestFolderPermissionAPIEndpoint(t *testing.T) {
|
||||
guardian.MockDashboardGuardian(&guardian.FakeDashboardGuardian{
|
||||
CanAdminValue: true,
|
||||
CheckPermissionBeforeUpdateValue: true,
|
||||
GetAclValue: []*models.DashboardAclInfoDTO{
|
||||
GetACLValue: []*models.DashboardACLInfoDTO{
|
||||
{OrgId: 1, DashboardId: 1, UserId: 2, UserLogin: "hiddenUser", Permission: models.PERMISSION_VIEW},
|
||||
{OrgId: 1, DashboardId: 1, UserId: 3, UserLogin: testUserLogin, Permission: models.PERMISSION_EDIT},
|
||||
{OrgId: 1, DashboardId: 1, UserId: 4, UserLogin: "user_1", Permission: models.PERMISSION_ADMIN},
|
||||
},
|
||||
GetHiddenAclValue: []*models.DashboardAcl{
|
||||
GetHiddenACLValue: []*models.DashboardACL{
|
||||
{OrgID: 1, DashboardID: 1, UserID: 2, Permission: models.PERMISSION_VIEW},
|
||||
},
|
||||
})
|
||||
|
||||
var gotItems []*models.DashboardAcl
|
||||
var gotItems []*models.DashboardACL
|
||||
|
||||
folderResponse := &models.Folder{Id: 1, Uid: "uid", Title: "Folder"}
|
||||
folderService.On("GetFolderByUID", mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(folderResponse, nil).Twice()
|
||||
dashboardStore.On("UpdateDashboardACL", mock.Anything, mock.Anything, mock.Anything).Run(func(args mock.Arguments) {
|
||||
gotItems = args.Get(2).([]*models.DashboardAcl)
|
||||
gotItems = args.Get(2).([]*models.DashboardACL)
|
||||
}).Return(nil).Once()
|
||||
|
||||
var resp []*models.DashboardAclInfoDTO
|
||||
var resp []*models.DashboardACLInfoDTO
|
||||
mockSQLStore := mockstore.NewSQLStoreMock()
|
||||
loggedInUserScenarioWithRole(t, "When calling GET on", "GET", "/api/folders/uid/permissions", "/api/folders/:uid/permissions", models.ROLE_ADMIN, func(sc *scenarioContext) {
|
||||
callGetFolderPermissions(sc, hs)
|
||||
@@ -317,13 +317,13 @@ func TestFolderPermissionAPIEndpoint(t *testing.T) {
|
||||
assert.Equal(t, models.PERMISSION_ADMIN, resp[1].Permission)
|
||||
}, mockSQLStore)
|
||||
|
||||
cmd := dtos.UpdateDashboardAclCommand{
|
||||
Items: []dtos.DashboardAclUpdateItem{
|
||||
cmd := dtos.UpdateDashboardACLCommand{
|
||||
Items: []dtos.DashboardACLUpdateItem{
|
||||
{UserID: 1000, Permission: models.PERMISSION_ADMIN},
|
||||
},
|
||||
}
|
||||
for _, acl := range resp {
|
||||
cmd.Items = append(cmd.Items, dtos.DashboardAclUpdateItem{
|
||||
cmd.Items = append(cmd.Items, dtos.DashboardACLUpdateItem{
|
||||
UserID: acl.UserId,
|
||||
Permission: acl.Permission,
|
||||
})
|
||||
|
||||
@@ -235,10 +235,10 @@ func createFolderScenario(t *testing.T, desc string, url string, routePattern st
|
||||
cmd models.CreateFolderCommand, fn scenarioFunc) {
|
||||
setUpRBACGuardian(t)
|
||||
t.Run(fmt.Sprintf("%s %s", desc, url), func(t *testing.T) {
|
||||
aclMockResp := []*models.DashboardAclInfoDTO{}
|
||||
aclMockResp := []*models.DashboardACLInfoDTO{}
|
||||
dashSvc := &dashboards.FakeDashboardService{}
|
||||
dashSvc.On("GetDashboardAclInfoList", mock.Anything, mock.AnythingOfType("*models.GetDashboardAclInfoListQuery")).Run(func(args mock.Arguments) {
|
||||
q := args.Get(1).(*models.GetDashboardAclInfoListQuery)
|
||||
dashSvc.On("GetDashboardACLInfoList", mock.Anything, mock.AnythingOfType("*models.GetDashboardACLInfoListQuery")).Run(func(args mock.Arguments) {
|
||||
q := args.Get(1).(*models.GetDashboardACLInfoListQuery)
|
||||
q.Result = aclMockResp
|
||||
}).Return(nil)
|
||||
store := mockstore.NewSQLStoreMock()
|
||||
|
||||
@@ -155,7 +155,7 @@ func TestOrgUsersAPIEndpoint_LegacyAccessControl_FolderAdmin(t *testing.T) {
|
||||
require.NotNil(t, folder)
|
||||
|
||||
// Grant our test Viewer with permission to admin the folder
|
||||
acls := []*models.DashboardAcl{
|
||||
acls := []*models.DashboardACL{
|
||||
{
|
||||
DashboardID: folder.Id,
|
||||
OrgID: testOrgID,
|
||||
|
||||
Reference in New Issue
Block a user