mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
fix typos in api, acl to permissions
This commit is contained in:
parent
3df8ae2306
commit
9889c92083
@ -26,7 +26,7 @@ func GetDashboardPermissionList(c *middleware.Context) Response {
|
|||||||
|
|
||||||
acl, err := guardian.GetAcl()
|
acl, err := guardian.GetAcl()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ApiError(500, "Failed to get dashboard acl", err)
|
return ApiError(500, "Failed to get dashboard permissions", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, perm := range acl {
|
for _, perm := range acl {
|
||||||
@ -82,5 +82,5 @@ func UpdateDashboardPermissions(c *middleware.Context, apiCmd dtos.UpdateDashboa
|
|||||||
return ApiError(500, "Failed to create permission", err)
|
return ApiError(500, "Failed to create permission", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return ApiSuccess("Dashboard acl updated")
|
return ApiSuccess("Dashboard permissions updated")
|
||||||
}
|
}
|
||||||
|
@ -54,7 +54,7 @@ func TestDashboardPermissionApiEndpoint(t *testing.T) {
|
|||||||
// 4. user is an org editor AND has no permissions for the dashboard
|
// 4. user is an org editor AND has no permissions for the dashboard
|
||||||
|
|
||||||
Convey("When user is org admin", func() {
|
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) {
|
loggedInUserScenarioWithRole("When calling GET on", "GET", "/api/dashboards/id/1/permissions", "/api/dashboards/id/:dashboardsId/permissions", m.ROLE_ADMIN, func(sc *scenarioContext) {
|
||||||
Convey("Should be able to access ACL", func() {
|
Convey("Should be able to access ACL", func() {
|
||||||
sc.handlerFunc = GetDashboardPermissionList
|
sc.handlerFunc = GetDashboardPermissionList
|
||||||
sc.fakeReqWithParams("GET", sc.url, map[string]string{}).exec()
|
sc.fakeReqWithParams("GET", sc.url, map[string]string{}).exec()
|
||||||
@ -69,7 +69,7 @@ func TestDashboardPermissionApiEndpoint(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) {
|
loggedInUserScenarioWithRole("When calling GET on", "GET", "/api/dashboards/id/2/permissions", "/api/dashboards/id/:dashboardId/permissions", m.ROLE_ADMIN, func(sc *scenarioContext) {
|
||||||
getDashboardNotFoundError = m.ErrDashboardNotFound
|
getDashboardNotFoundError = m.ErrDashboardNotFound
|
||||||
sc.handlerFunc = GetDashboardPermissionList
|
sc.handlerFunc = GetDashboardPermissionList
|
||||||
sc.fakeReqWithParams("GET", sc.url, map[string]string{}).exec()
|
sc.fakeReqWithParams("GET", sc.url, map[string]string{}).exec()
|
||||||
@ -86,7 +86,7 @@ func TestDashboardPermissionApiEndpoint(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
postAclScenario("When calling POST on", "/api/dashboards/id/1/acl", "/api/dashboards/id/:dashboardId/acl", m.ROLE_ADMIN, cmd, func(sc *scenarioContext) {
|
postAclScenario("When calling POST on", "/api/dashboards/id/1/permissions", "/api/dashboards/id/:dashboardId/permissions", m.ROLE_ADMIN, cmd, func(sc *scenarioContext) {
|
||||||
getDashboardNotFoundError = m.ErrDashboardNotFound
|
getDashboardNotFoundError = m.ErrDashboardNotFound
|
||||||
CallPostAcl(sc)
|
CallPostAcl(sc)
|
||||||
So(sc.resp.Code, ShouldEqual, 404)
|
So(sc.resp.Code, ShouldEqual, 404)
|
||||||
@ -95,7 +95,7 @@ func TestDashboardPermissionApiEndpoint(t *testing.T) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
Convey("When user is org editor and has admin permission in the ACL", func() {
|
Convey("When user is org editor and has admin permission in the ACL", func() {
|
||||||
loggedInUserScenarioWithRole("When calling GET on", "GET", "/api/dashboards/id/1/acl", "/api/dashboards/id/:dashboardId/acl", m.ROLE_EDITOR, func(sc *scenarioContext) {
|
loggedInUserScenarioWithRole("When calling GET on", "GET", "/api/dashboards/id/1/permissions", "/api/dashboards/id/:dashboardId/permissions", m.ROLE_EDITOR, func(sc *scenarioContext) {
|
||||||
mockResult = append(mockResult, &m.DashboardAclInfoDTO{OrgId: 1, DashboardId: 1, UserId: 1, Permission: m.PERMISSION_ADMIN})
|
mockResult = append(mockResult, &m.DashboardAclInfoDTO{OrgId: 1, DashboardId: 1, UserId: 1, Permission: m.PERMISSION_ADMIN})
|
||||||
|
|
||||||
Convey("Should be able to access ACL", func() {
|
Convey("Should be able to access ACL", func() {
|
||||||
@ -113,7 +113,7 @@ func TestDashboardPermissionApiEndpoint(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
postAclScenario("When calling POST on", "/api/dashboards/id/1/acl", "/api/dashboards/id/:dashboardId/acl", m.ROLE_EDITOR, cmd, func(sc *scenarioContext) {
|
postAclScenario("When calling POST on", "/api/dashboards/id/1/permissions", "/api/dashboards/id/:dashboardId/permissions", m.ROLE_EDITOR, cmd, func(sc *scenarioContext) {
|
||||||
mockResult = append(mockResult, &m.DashboardAclInfoDTO{OrgId: 1, DashboardId: 1, UserId: 1, Permission: m.PERMISSION_ADMIN})
|
mockResult = append(mockResult, &m.DashboardAclInfoDTO{OrgId: 1, DashboardId: 1, UserId: 1, Permission: m.PERMISSION_ADMIN})
|
||||||
|
|
||||||
CallPostAcl(sc)
|
CallPostAcl(sc)
|
||||||
@ -129,7 +129,7 @@ func TestDashboardPermissionApiEndpoint(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
postAclScenario("When calling POST on", "/api/dashboards/id/1/acl", "/api/dashboards/id/:dashboardId/acl", m.ROLE_EDITOR, cmd, func(sc *scenarioContext) {
|
postAclScenario("When calling POST on", "/api/dashboards/id/1/permissions", "/api/dashboards/id/:dashboardId/permissions", m.ROLE_EDITOR, cmd, func(sc *scenarioContext) {
|
||||||
mockResult = append(mockResult, &m.DashboardAclInfoDTO{OrgId: 1, DashboardId: 1, UserId: 1, Permission: m.PERMISSION_ADMIN})
|
mockResult = append(mockResult, &m.DashboardAclInfoDTO{OrgId: 1, DashboardId: 1, UserId: 1, Permission: m.PERMISSION_ADMIN})
|
||||||
|
|
||||||
CallPostAcl(sc)
|
CallPostAcl(sc)
|
||||||
@ -140,7 +140,7 @@ func TestDashboardPermissionApiEndpoint(t *testing.T) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
Convey("When user is org viewer and has edit permission in the ACL", func() {
|
Convey("When user is org viewer and has edit permission in the ACL", func() {
|
||||||
loggedInUserScenarioWithRole("When calling GET on", "GET", "/api/dashboards/id/1/acl", "/api/dashboards/id/:dashboardId/acl", m.ROLE_VIEWER, func(sc *scenarioContext) {
|
loggedInUserScenarioWithRole("When calling GET on", "GET", "/api/dashboards/id/1/permissions", "/api/dashboards/id/:dashboardId/permissions", m.ROLE_VIEWER, func(sc *scenarioContext) {
|
||||||
mockResult = append(mockResult, &m.DashboardAclInfoDTO{OrgId: 1, DashboardId: 1, UserId: 1, Permission: m.PERMISSION_EDIT})
|
mockResult = append(mockResult, &m.DashboardAclInfoDTO{OrgId: 1, DashboardId: 1, UserId: 1, Permission: m.PERMISSION_EDIT})
|
||||||
|
|
||||||
// Getting the permissions is an Admin permission
|
// Getting the permissions is an Admin permission
|
||||||
@ -154,7 +154,7 @@ func TestDashboardPermissionApiEndpoint(t *testing.T) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
Convey("When user is org editor and not in the ACL", func() {
|
Convey("When user is org editor and not in the ACL", func() {
|
||||||
loggedInUserScenarioWithRole("When calling GET on", "GET", "/api/dashboards/id/1/acl", "/api/dashboards/id/:dashboardsId/acl", m.ROLE_EDITOR, func(sc *scenarioContext) {
|
loggedInUserScenarioWithRole("When calling GET on", "GET", "/api/dashboards/id/1/permissions", "/api/dashboards/id/:dashboardsId/permissions", m.ROLE_EDITOR, func(sc *scenarioContext) {
|
||||||
|
|
||||||
Convey("Should not be able to access ACL", func() {
|
Convey("Should not be able to access ACL", func() {
|
||||||
sc.handlerFunc = GetDashboardPermissionList
|
sc.handlerFunc = GetDashboardPermissionList
|
||||||
|
@ -99,5 +99,5 @@ func UpdateFolderPermissions(c *middleware.Context, apiCmd dtos.UpdateDashboardA
|
|||||||
return ApiError(500, "Failed to create permission", err)
|
return ApiError(500, "Failed to create permission", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return ApiSuccess("Folder acl updated")
|
return ApiSuccess("Folder permissions updated")
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user