|
@@ -53,6 +53,16 @@ func TestDashboardApiEndpoint(t *testing.T) {
|
|
|
So(sc.resp.Code, ShouldEqual, 403)
|
|
So(sc.resp.Code, ShouldEqual, 403)
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
|
|
+ loggedInUserScenarioWithRole("When calling GET on", "GET", "/api/dashboards/id/2/versions/1", "/api/dashboards/id/:dashboardId/versions/:id", role, func(sc *scenarioContext) {
|
|
|
|
|
+ CallGetDashboardVersion(sc)
|
|
|
|
|
+ So(sc.resp.Code, ShouldEqual, 403)
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+ loggedInUserScenarioWithRole("When calling GET on", "GET", "/api/dashboards/id/2/versions", "/api/dashboards/id/:dashboardId/versions", role, func(sc *scenarioContext) {
|
|
|
|
|
+ CallGetDashboardVersions(sc)
|
|
|
|
|
+ So(sc.resp.Code, ShouldEqual, 403)
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
postDashboardScenario("When calling POST on", "/api/dashboards", "/api/dashboards", role, cmd, func(sc *scenarioContext) {
|
|
postDashboardScenario("When calling POST on", "/api/dashboards", "/api/dashboards", role, cmd, func(sc *scenarioContext) {
|
|
|
CallPostDashboard(sc)
|
|
CallPostDashboard(sc)
|
|
|
So(sc.resp.Code, ShouldEqual, 403)
|
|
So(sc.resp.Code, ShouldEqual, 403)
|
|
@@ -75,6 +85,16 @@ func TestDashboardApiEndpoint(t *testing.T) {
|
|
|
So(sc.resp.Code, ShouldEqual, 403)
|
|
So(sc.resp.Code, ShouldEqual, 403)
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
|
|
+ loggedInUserScenarioWithRole("When calling GET on", "GET", "/api/dashboards/id/2/versions/1", "/api/dashboards/id/:dashboardId/versions/:id", role, func(sc *scenarioContext) {
|
|
|
|
|
+ CallGetDashboardVersion(sc)
|
|
|
|
|
+ So(sc.resp.Code, ShouldEqual, 403)
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+ loggedInUserScenarioWithRole("When calling GET on", "GET", "/api/dashboards/id/2/versions", "/api/dashboards/id/:dashboardId/versions", role, func(sc *scenarioContext) {
|
|
|
|
|
+ CallGetDashboardVersions(sc)
|
|
|
|
|
+ So(sc.resp.Code, ShouldEqual, 403)
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
postDashboardScenario("When calling POST on", "/api/dashboards", "/api/dashboards", role, cmd, func(sc *scenarioContext) {
|
|
postDashboardScenario("When calling POST on", "/api/dashboards", "/api/dashboards", role, cmd, func(sc *scenarioContext) {
|
|
|
CallPostDashboard(sc)
|
|
CallPostDashboard(sc)
|
|
|
So(sc.resp.Code, ShouldEqual, 403)
|
|
So(sc.resp.Code, ShouldEqual, 403)
|
|
@@ -98,6 +118,16 @@ func TestDashboardApiEndpoint(t *testing.T) {
|
|
|
So(sc.resp.Code, ShouldEqual, 200)
|
|
So(sc.resp.Code, ShouldEqual, 200)
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
|
|
+ loggedInUserScenarioWithRole("When calling GET on", "GET", "/api/dashboards/id/2/versions/1", "/api/dashboards/id/:dashboardId/versions/:id", role, func(sc *scenarioContext) {
|
|
|
|
|
+ CallGetDashboardVersion(sc)
|
|
|
|
|
+ So(sc.resp.Code, ShouldEqual, 200)
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+ loggedInUserScenarioWithRole("When calling GET on", "GET", "/api/dashboards/id/2/versions", "/api/dashboards/id/:dashboardId/versions", role, func(sc *scenarioContext) {
|
|
|
|
|
+ CallGetDashboardVersions(sc)
|
|
|
|
|
+ So(sc.resp.Code, ShouldEqual, 200)
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
postDashboardScenario("When calling POST on", "/api/dashboards", "/api/dashboards", role, cmd, func(sc *scenarioContext) {
|
|
postDashboardScenario("When calling POST on", "/api/dashboards", "/api/dashboards", role, cmd, func(sc *scenarioContext) {
|
|
|
CallPostDashboard(sc)
|
|
CallPostDashboard(sc)
|
|
|
So(sc.resp.Code, ShouldEqual, 200)
|
|
So(sc.resp.Code, ShouldEqual, 200)
|
|
@@ -149,6 +179,16 @@ func TestDashboardApiEndpoint(t *testing.T) {
|
|
|
So(sc.resp.Code, ShouldEqual, 403)
|
|
So(sc.resp.Code, ShouldEqual, 403)
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
|
|
+ loggedInUserScenarioWithRole("When calling GET on", "GET", "/api/dashboards/id/2/versions/1", "/api/dashboards/id/:dashboardId/versions/:id", role, func(sc *scenarioContext) {
|
|
|
|
|
+ CallGetDashboardVersion(sc)
|
|
|
|
|
+ So(sc.resp.Code, ShouldEqual, 403)
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+ loggedInUserScenarioWithRole("When calling GET on", "GET", "/api/dashboards/id/2/versions", "/api/dashboards/id/:dashboardId/versions", role, func(sc *scenarioContext) {
|
|
|
|
|
+ CallGetDashboardVersions(sc)
|
|
|
|
|
+ So(sc.resp.Code, ShouldEqual, 403)
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
postDashboardScenario("When calling POST on", "/api/dashboards", "/api/dashboards", role, cmd, func(sc *scenarioContext) {
|
|
postDashboardScenario("When calling POST on", "/api/dashboards", "/api/dashboards", role, cmd, func(sc *scenarioContext) {
|
|
|
CallPostDashboard(sc)
|
|
CallPostDashboard(sc)
|
|
|
So(sc.resp.Code, ShouldEqual, 403)
|
|
So(sc.resp.Code, ShouldEqual, 403)
|
|
@@ -177,6 +217,16 @@ func TestDashboardApiEndpoint(t *testing.T) {
|
|
|
So(sc.resp.Code, ShouldEqual, 403)
|
|
So(sc.resp.Code, ShouldEqual, 403)
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
|
|
+ loggedInUserScenarioWithRole("When calling GET on", "GET", "/api/dashboards/id/2/versions/1", "/api/dashboards/id/:dashboardId/versions/:id", role, func(sc *scenarioContext) {
|
|
|
|
|
+ CallGetDashboardVersion(sc)
|
|
|
|
|
+ So(sc.resp.Code, ShouldEqual, 403)
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+ loggedInUserScenarioWithRole("When calling GET on", "GET", "/api/dashboards/id/2/versions", "/api/dashboards/id/:dashboardId/versions", role, func(sc *scenarioContext) {
|
|
|
|
|
+ CallGetDashboardVersions(sc)
|
|
|
|
|
+ So(sc.resp.Code, ShouldEqual, 403)
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
postDashboardScenario("When calling POST on", "/api/dashboards", "/api/dashboards", role, cmd, func(sc *scenarioContext) {
|
|
postDashboardScenario("When calling POST on", "/api/dashboards", "/api/dashboards", role, cmd, func(sc *scenarioContext) {
|
|
|
CallPostDashboard(sc)
|
|
CallPostDashboard(sc)
|
|
|
So(sc.resp.Code, ShouldEqual, 403)
|
|
So(sc.resp.Code, ShouldEqual, 403)
|
|
@@ -209,6 +259,16 @@ func TestDashboardApiEndpoint(t *testing.T) {
|
|
|
So(sc.resp.Code, ShouldEqual, 200)
|
|
So(sc.resp.Code, ShouldEqual, 200)
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
|
|
+ loggedInUserScenarioWithRole("When calling GET on", "GET", "/api/dashboards/id/2/versions/1", "/api/dashboards/id/:dashboardId/versions/:id", role, func(sc *scenarioContext) {
|
|
|
|
|
+ CallGetDashboardVersion(sc)
|
|
|
|
|
+ So(sc.resp.Code, ShouldEqual, 200)
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+ loggedInUserScenarioWithRole("When calling GET on", "GET", "/api/dashboards/id/2/versions", "/api/dashboards/id/:dashboardId/versions", role, func(sc *scenarioContext) {
|
|
|
|
|
+ CallGetDashboardVersions(sc)
|
|
|
|
|
+ So(sc.resp.Code, ShouldEqual, 200)
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
postDashboardScenario("When calling POST on", "/api/dashboards", "/api/dashboards", role, cmd, func(sc *scenarioContext) {
|
|
postDashboardScenario("When calling POST on", "/api/dashboards", "/api/dashboards", role, cmd, func(sc *scenarioContext) {
|
|
|
CallPostDashboard(sc)
|
|
CallPostDashboard(sc)
|
|
|
So(sc.resp.Code, ShouldEqual, 200)
|
|
So(sc.resp.Code, ShouldEqual, 200)
|
|
@@ -241,6 +301,16 @@ func TestDashboardApiEndpoint(t *testing.T) {
|
|
|
So(sc.resp.Code, ShouldEqual, 403)
|
|
So(sc.resp.Code, ShouldEqual, 403)
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
|
|
+ loggedInUserScenarioWithRole("When calling GET on", "GET", "/api/dashboards/id/2/versions/1", "/api/dashboards/id/:dashboardId/versions/:id", role, func(sc *scenarioContext) {
|
|
|
|
|
+ CallGetDashboardVersion(sc)
|
|
|
|
|
+ So(sc.resp.Code, ShouldEqual, 403)
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+ loggedInUserScenarioWithRole("When calling GET on", "GET", "/api/dashboards/id/2/versions", "/api/dashboards/id/:dashboardId/versions", role, func(sc *scenarioContext) {
|
|
|
|
|
+ CallGetDashboardVersions(sc)
|
|
|
|
|
+ So(sc.resp.Code, ShouldEqual, 403)
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
postDashboardScenario("When calling POST on", "/api/dashboards", "/api/dashboards", role, cmd, func(sc *scenarioContext) {
|
|
postDashboardScenario("When calling POST on", "/api/dashboards", "/api/dashboards", role, cmd, func(sc *scenarioContext) {
|
|
|
CallPostDashboard(sc)
|
|
CallPostDashboard(sc)
|
|
|
So(sc.resp.Code, ShouldEqual, 403)
|
|
So(sc.resp.Code, ShouldEqual, 403)
|
|
@@ -262,6 +332,26 @@ func GetDashboardShouldReturn200(sc *scenarioContext) dtos.DashboardFullWithMeta
|
|
|
return dash
|
|
return dash
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+func CallGetDashboardVersion(sc *scenarioContext) {
|
|
|
|
|
+ bus.AddHandler("test", func(query *models.GetDashboardVersionQuery) error {
|
|
|
|
|
+ query.Result = &models.DashboardVersion{}
|
|
|
|
|
+ return nil
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+ sc.handlerFunc = GetDashboardVersion
|
|
|
|
|
+ sc.fakeReqWithParams("GET", sc.url, map[string]string{}).exec()
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+func CallGetDashboardVersions(sc *scenarioContext) {
|
|
|
|
|
+ bus.AddHandler("test", func(query *models.GetDashboardVersionsQuery) error {
|
|
|
|
|
+ query.Result = []*models.DashboardVersionDTO{}
|
|
|
|
|
+ return nil
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+ sc.handlerFunc = GetDashboardVersions
|
|
|
|
|
+ sc.fakeReqWithParams("GET", sc.url, map[string]string{}).exec()
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
func CallDeleteDashboard(sc *scenarioContext) {
|
|
func CallDeleteDashboard(sc *scenarioContext) {
|
|
|
bus.AddHandler("test", func(cmd *models.DeleteDashboardCommand) error {
|
|
bus.AddHandler("test", func(cmd *models.DeleteDashboardCommand) error {
|
|
|
return nil
|
|
return nil
|