Commit 13c6f37e by Alexander Zobnin

alerting: show alerts for user with Viewer role

changelog: add notes about closing #11167

remove changelog note

reformat alert_test.go
parent f5cf9263
...@@ -79,7 +79,7 @@ func GetAlerts(c *m.ReqContext) Response { ...@@ -79,7 +79,7 @@ func GetAlerts(c *m.ReqContext) Response {
DashboardIds: dashboardIDs, DashboardIds: dashboardIDs,
Type: string(search.DashHitDB), Type: string(search.DashHitDB),
FolderIds: folderIDs, FolderIds: folderIDs,
Permission: m.PERMISSION_EDIT, Permission: m.PERMISSION_VIEW,
} }
err := bus.Dispatch(&searchQuery) err := bus.Dispatch(&searchQuery)
......
...@@ -116,7 +116,7 @@ func HandleAlertsQuery(query *m.GetAlertsQuery) error { ...@@ -116,7 +116,7 @@ func HandleAlertsQuery(query *m.GetAlertsQuery) error {
} }
if query.User.OrgRole != m.ROLE_ADMIN { if query.User.OrgRole != m.ROLE_ADMIN {
builder.writeDashboardPermissionFilter(query.User, m.PERMISSION_EDIT) builder.writeDashboardPermissionFilter(query.User, m.PERMISSION_VIEW)
} }
builder.Write(" ORDER BY name ASC") builder.Write(" ORDER BY name ASC")
......
...@@ -2,7 +2,6 @@ package sqlstore ...@@ -2,7 +2,6 @@ package sqlstore
import ( import (
"testing" "testing"
"time" "time"
"github.com/grafana/grafana/pkg/components/simplejson" "github.com/grafana/grafana/pkg/components/simplejson"
...@@ -110,11 +109,12 @@ func TestAlertingDataAccess(t *testing.T) { ...@@ -110,11 +109,12 @@ func TestAlertingDataAccess(t *testing.T) {
}) })
Convey("Viewer cannot read alerts", func() { Convey("Viewer cannot read alerts", func() {
alertQuery := m.GetAlertsQuery{DashboardIDs: []int64{testDash.Id}, PanelId: 1, OrgId: 1, User: &m.SignedInUser{OrgRole: m.ROLE_VIEWER}} viewerUser := &m.SignedInUser{OrgRole: m.ROLE_VIEWER, OrgId: 1}
alertQuery := m.GetAlertsQuery{DashboardIDs: []int64{testDash.Id}, PanelId: 1, OrgId: 1, User: viewerUser}
err2 := HandleAlertsQuery(&alertQuery) err2 := HandleAlertsQuery(&alertQuery)
So(err2, ShouldBeNil) So(err2, ShouldBeNil)
So(alertQuery.Result, ShouldHaveLength, 0) So(alertQuery.Result, ShouldHaveLength, 1)
}) })
Convey("Alerts with same dashboard id and panel id should update", func() { Convey("Alerts with same dashboard id and panel id should update", func() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment