diff --git a/pkg/api/dashboard.go b/pkg/api/dashboard.go index 016253cd22a..8fcc6eb5902 100644 --- a/pkg/api/dashboard.go +++ b/pkg/api/dashboard.go @@ -138,10 +138,6 @@ func getDashboardHelper(orgId int64, slug string, id int64, uid string) (*m.Dash 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 } @@ -206,11 +202,6 @@ func PostDashboard(c *middleware.Context, cmd m.SaveDashboardCommand) Response { // if new dashboard, use parent folder permissions instead if dashId == 0 { dashId = cmd.FolderId - } else { - _, rsp := getDashboardHelper(c.OrgId, "", dashId, "") - if rsp != nil { - return rsp - } } guardian := guardian.NewDashboardGuardian(dashId, c.OrgId, c.SignedInUser) diff --git a/pkg/api/dashboard_test.go b/pkg/api/dashboard_test.go index 129a891d06e..87e1eac4113 100644 --- a/pkg/api/dashboard_test.go +++ b/pkg/api/dashboard_test.go @@ -33,79 +33,6 @@ var fakeRepo *fakeDashboardRepo // 2. and the dashboard is in a folder which does have an acl 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() { fakeDash := m.NewDashboard("Child dash") fakeDash.Id = 1