diff --git a/pkg/api/api.go b/pkg/api/api.go index 24cf2832af0..84fd6f8f659 100644 --- a/pkg/api/api.go +++ b/pkg/api/api.go @@ -257,9 +257,9 @@ func (hs *HttpServer) registerRoutes() { folderUidRoute.Put("/", bind(m.UpdateFolderCommand{}), wrap(UpdateFolder)) folderUidRoute.Delete("/", wrap(DeleteFolder)) - folderUidRoute.Group("/permissions", func(folderAclRoute RouteRegister) { - folderAclRoute.Get("/", wrap(GetFolderPermissionList)) - folderAclRoute.Post("/", bind(dtos.UpdateDashboardAclCommand{}), wrap(UpdateFolderPermissions)) + folderUidRoute.Group("/permissions", func(folderPermissionRoute RouteRegister) { + folderPermissionRoute.Get("/", wrap(GetFolderPermissionList)) + folderPermissionRoute.Post("/", bind(dtos.UpdateDashboardAclCommand{}), wrap(UpdateFolderPermissions)) }) }) }) @@ -284,9 +284,9 @@ func (hs *HttpServer) registerRoutes() { dashIdRoute.Get("/versions/:id", wrap(GetDashboardVersion)) dashIdRoute.Post("/restore", bind(dtos.RestoreDashboardVersionCommand{}), wrap(RestoreDashboardVersion)) - dashIdRoute.Group("/acl", func(aclRoute RouteRegister) { - aclRoute.Get("/", wrap(GetDashboardAclList)) - aclRoute.Post("/", bind(dtos.UpdateDashboardAclCommand{}), wrap(UpdateDashboardAcl)) + dashIdRoute.Group("/permissions", func(dashboardPermissionRoute RouteRegister) { + dashboardPermissionRoute.Get("/", wrap(GetDashboardPermissionList)) + dashboardPermissionRoute.Post("/", bind(dtos.UpdateDashboardAclCommand{}), wrap(UpdateDashboardPermissions)) }) }) }) diff --git a/pkg/api/dashboard_acl.go b/pkg/api/dashboard_permission.go similarity index 92% rename from pkg/api/dashboard_acl.go rename to pkg/api/dashboard_permission.go index 13b29db78e6..18520fff262 100644 --- a/pkg/api/dashboard_acl.go +++ b/pkg/api/dashboard_permission.go @@ -10,7 +10,7 @@ import ( "github.com/grafana/grafana/pkg/services/guardian" ) -func GetDashboardAclList(c *middleware.Context) Response { +func GetDashboardPermissionList(c *middleware.Context) Response { dashId := c.ParamsInt64(":dashboardId") _, rsp := getDashboardHelper(c.OrgId, "", dashId, "") @@ -38,7 +38,7 @@ func GetDashboardAclList(c *middleware.Context) Response { return Json(200, acl) } -func UpdateDashboardAcl(c *middleware.Context, apiCmd dtos.UpdateDashboardAclCommand) Response { +func UpdateDashboardPermissions(c *middleware.Context, apiCmd dtos.UpdateDashboardAclCommand) Response { dashId := c.ParamsInt64(":dashboardId") _, rsp := getDashboardHelper(c.OrgId, "", dashId, "") diff --git a/pkg/api/dashboard_acl_test.go b/pkg/api/dashboard_permission_test.go similarity index 94% rename from pkg/api/dashboard_acl_test.go rename to pkg/api/dashboard_permission_test.go index d6b7e305daf..c29cb7688bf 100644 --- a/pkg/api/dashboard_acl_test.go +++ b/pkg/api/dashboard_permission_test.go @@ -12,8 +12,8 @@ import ( . "github.com/smartystreets/goconvey/convey" ) -func TestDashboardAclApiEndpoint(t *testing.T) { - Convey("Given a dashboard acl", t, func() { +func TestDashboardPermissionApiEndpoint(t *testing.T) { + Convey("Given a dashboard with permissions", t, func() { mockResult := []*m.DashboardAclInfoDTO{ {OrgId: 1, DashboardId: 1, UserId: 2, Permission: m.PERMISSION_VIEW}, {OrgId: 1, DashboardId: 1, UserId: 3, Permission: m.PERMISSION_EDIT}, @@ -56,7 +56,7 @@ func TestDashboardAclApiEndpoint(t *testing.T) { Convey("When user is org admin", func() { loggedInUserScenarioWithRole("When calling GET on", "GET", "/api/dashboards/id/1/acl", "/api/dashboards/id/:dashboardsId/acl", m.ROLE_ADMIN, func(sc *scenarioContext) { Convey("Should be able to access ACL", func() { - sc.handlerFunc = GetDashboardAclList + sc.handlerFunc = GetDashboardPermissionList sc.fakeReqWithParams("GET", sc.url, map[string]string{}).exec() So(sc.resp.Code, ShouldEqual, 200) @@ -71,7 +71,7 @@ func TestDashboardAclApiEndpoint(t *testing.T) { loggedInUserScenarioWithRole("When calling GET on", "GET", "/api/dashboards/id/2/acl", "/api/dashboards/id/:dashboardId/acl", m.ROLE_ADMIN, func(sc *scenarioContext) { getDashboardNotFoundError = m.ErrDashboardNotFound - sc.handlerFunc = GetDashboardAclList + sc.handlerFunc = GetDashboardPermissionList sc.fakeReqWithParams("GET", sc.url, map[string]string{}).exec() Convey("Should not be able to access ACL", func() { @@ -99,7 +99,7 @@ func TestDashboardAclApiEndpoint(t *testing.T) { mockResult = append(mockResult, &m.DashboardAclInfoDTO{OrgId: 1, DashboardId: 1, UserId: 1, Permission: m.PERMISSION_ADMIN}) Convey("Should be able to access ACL", func() { - sc.handlerFunc = GetDashboardAclList + sc.handlerFunc = GetDashboardPermissionList sc.fakeReqWithParams("GET", sc.url, map[string]string{}).exec() So(sc.resp.Code, ShouldEqual, 200) @@ -145,7 +145,7 @@ func TestDashboardAclApiEndpoint(t *testing.T) { // Getting the permissions is an Admin permission Convey("Should not be able to get list of permissions from ACL", func() { - sc.handlerFunc = GetDashboardAclList + sc.handlerFunc = GetDashboardPermissionList sc.fakeReqWithParams("GET", sc.url, map[string]string{}).exec() So(sc.resp.Code, ShouldEqual, 403) @@ -157,7 +157,7 @@ func TestDashboardAclApiEndpoint(t *testing.T) { loggedInUserScenarioWithRole("When calling GET on", "GET", "/api/dashboards/id/1/acl", "/api/dashboards/id/:dashboardsId/acl", m.ROLE_EDITOR, func(sc *scenarioContext) { Convey("Should not be able to access ACL", func() { - sc.handlerFunc = GetDashboardAclList + sc.handlerFunc = GetDashboardPermissionList sc.fakeReqWithParams("GET", sc.url, map[string]string{}).exec() So(sc.resp.Code, ShouldEqual, 403) @@ -204,7 +204,7 @@ func postAclScenario(desc string, url string, routePattern string, role m.RoleTy sc.context.OrgId = TestOrgID sc.context.OrgRole = role - return UpdateDashboardAcl(c, cmd) + return UpdateDashboardPermissions(c, cmd) }) sc.m.Post(routePattern, sc.defaultHandler)