dashboards: revert logic of returning 404 in dashboard api if it's a folder for now
This commit is contained in:
@@ -138,10 +138,6 @@ func getDashboardHelper(orgId int64, slug string, id int64, uid string) (*m.Dash
|
|||||||
return nil, ApiError(404, "Dashboard not found", err)
|
return nil, ApiError(404, "Dashboard not found", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if query.Result.IsFolder {
|
|
||||||
return nil, ApiError(404, "Dashboard not found", m.ErrDashboardNotFound)
|
|
||||||
}
|
|
||||||
|
|
||||||
return query.Result, nil
|
return query.Result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -206,11 +202,6 @@ func PostDashboard(c *middleware.Context, cmd m.SaveDashboardCommand) Response {
|
|||||||
// if new dashboard, use parent folder permissions instead
|
// if new dashboard, use parent folder permissions instead
|
||||||
if dashId == 0 {
|
if dashId == 0 {
|
||||||
dashId = cmd.FolderId
|
dashId = cmd.FolderId
|
||||||
} else {
|
|
||||||
_, rsp := getDashboardHelper(c.OrgId, "", dashId, "")
|
|
||||||
if rsp != nil {
|
|
||||||
return rsp
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
guardian := guardian.NewDashboardGuardian(dashId, c.OrgId, c.SignedInUser)
|
guardian := guardian.NewDashboardGuardian(dashId, c.OrgId, c.SignedInUser)
|
||||||
|
|||||||
@@ -33,79 +33,6 @@ var fakeRepo *fakeDashboardRepo
|
|||||||
// 2. and the dashboard is in a folder which does have an acl
|
// 2. and the dashboard is in a folder which does have an acl
|
||||||
|
|
||||||
func TestDashboardApiEndpoint(t *testing.T) {
|
func TestDashboardApiEndpoint(t *testing.T) {
|
||||||
Convey("Given a folder", t, func() {
|
|
||||||
fakeFolder := m.NewDashboardFolder("Folder")
|
|
||||||
fakeFolder.Id = 1
|
|
||||||
fakeFolder.HasAcl = false
|
|
||||||
|
|
||||||
bus.AddHandler("test", func(query *m.GetDashboardsBySlugQuery) error {
|
|
||||||
dashboards := []*m.Dashboard{fakeFolder}
|
|
||||||
query.Result = dashboards
|
|
||||||
return nil
|
|
||||||
})
|
|
||||||
|
|
||||||
var getDashboardQueries []*m.GetDashboardQuery
|
|
||||||
|
|
||||||
bus.AddHandler("test", func(query *m.GetDashboardQuery) error {
|
|
||||||
query.Result = fakeFolder
|
|
||||||
getDashboardQueries = append(getDashboardQueries, query)
|
|
||||||
return nil
|
|
||||||
})
|
|
||||||
|
|
||||||
cmd := m.SaveDashboardCommand{
|
|
||||||
Dashboard: simplejson.NewFromAny(map[string]interface{}{
|
|
||||||
"title": fakeFolder.Title,
|
|
||||||
"id": fakeFolder.Id,
|
|
||||||
}),
|
|
||||||
IsFolder: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
Convey("When user is an Org Editor", func() {
|
|
||||||
role := m.ROLE_EDITOR
|
|
||||||
|
|
||||||
loggedInUserScenarioWithRole("When calling GET on", "GET", "/api/dashboards/db/child-dash", "/api/dashboards/db/:slug", role, func(sc *scenarioContext) {
|
|
||||||
CallGetDashboard(sc)
|
|
||||||
So(sc.resp.Code, ShouldEqual, 404)
|
|
||||||
|
|
||||||
Convey("Should lookup dashboard by slug", func() {
|
|
||||||
So(getDashboardQueries[0].Slug, ShouldEqual, "child-dash")
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
loggedInUserScenarioWithRole("When calling GET on", "GET", "/api/dashboards/uid/abcdefghi", "/api/dashboards/uid/:uid", role, func(sc *scenarioContext) {
|
|
||||||
CallGetDashboard(sc)
|
|
||||||
So(sc.resp.Code, ShouldEqual, 404)
|
|
||||||
|
|
||||||
Convey("Should lookup dashboard by uid", func() {
|
|
||||||
So(getDashboardQueries[0].Uid, ShouldEqual, "abcdefghi")
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
postDashboardScenario("When calling POST on", "/api/dashboards", "/api/dashboards", role, cmd, func(sc *scenarioContext) {
|
|
||||||
CallPostDashboard(sc)
|
|
||||||
So(sc.resp.Code, ShouldEqual, 404)
|
|
||||||
})
|
|
||||||
|
|
||||||
loggedInUserScenarioWithRole("When calling DELETE on", "DELETE", "/api/dashboards/db/child-dash", "/api/dashboards/db/:slug", role, func(sc *scenarioContext) {
|
|
||||||
CallDeleteDashboard(sc)
|
|
||||||
So(sc.resp.Code, ShouldEqual, 404)
|
|
||||||
|
|
||||||
Convey("Should lookup dashboard by slug", func() {
|
|
||||||
So(getDashboardQueries[0].Slug, ShouldEqual, "child-dash")
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
loggedInUserScenarioWithRole("When calling DELETE on", "DELETE", "/api/dashboards/uid/abcdefghi", "/api/dashboards/uid/:uid", role, func(sc *scenarioContext) {
|
|
||||||
CallDeleteDashboardByUid(sc)
|
|
||||||
So(sc.resp.Code, ShouldEqual, 404)
|
|
||||||
|
|
||||||
Convey("Should lookup dashboard by uid", func() {
|
|
||||||
So(getDashboardQueries[0].Uid, ShouldEqual, "abcdefghi")
|
|
||||||
})
|
|
||||||
})
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
Convey("Given a dashboard with a parent folder which does not have an acl", t, func() {
|
Convey("Given a dashboard with a parent folder which does not have an acl", t, func() {
|
||||||
fakeDash := m.NewDashboard("Child dash")
|
fakeDash := m.NewDashboard("Child dash")
|
||||||
fakeDash.Id = 1
|
fakeDash.Id = 1
|
||||||
|
|||||||
Reference in New Issue
Block a user