|
|
@@ -26,7 +26,11 @@ func TestDashboardFolderDataAccess(t *testing.T) {
|
|
|
|
|
|
Convey("and no acls are set", func() {
|
|
|
Convey("should return all dashboards", func() {
|
|
|
- query := &search.FindPersistedDashboardsQuery{SignedInUser: &m.SignedInUser{UserId: currentUser.Id, OrgId: 1}, OrgId: 1, DashboardIds: []int64{folder.Id, dashInRoot.Id}}
|
|
|
+ query := &search.FindPersistedDashboardsQuery{
|
|
|
+ SignedInUser: &m.SignedInUser{UserId: currentUser.Id, OrgId: 1, OrgRole: m.ROLE_VIEWER},
|
|
|
+ OrgId: 1,
|
|
|
+ DashboardIds: []int64{folder.Id, dashInRoot.Id},
|
|
|
+ }
|
|
|
err := SearchDashboards(query)
|
|
|
So(err, ShouldBeNil)
|
|
|
So(len(query.Result), ShouldEqual, 2)
|
|
|
@@ -40,7 +44,10 @@ func TestDashboardFolderDataAccess(t *testing.T) {
|
|
|
updateTestDashboardWithAcl(folder.Id, otherUser, m.PERMISSION_EDIT)
|
|
|
|
|
|
Convey("should not return folder", func() {
|
|
|
- query := &search.FindPersistedDashboardsQuery{SignedInUser: &m.SignedInUser{UserId: currentUser.Id, OrgId: 1}, OrgId: 1, DashboardIds: []int64{folder.Id, dashInRoot.Id}}
|
|
|
+ query := &search.FindPersistedDashboardsQuery{
|
|
|
+ SignedInUser: &m.SignedInUser{UserId: currentUser.Id, OrgId: 1, OrgRole: m.ROLE_VIEWER},
|
|
|
+ OrgId: 1, DashboardIds: []int64{folder.Id, dashInRoot.Id},
|
|
|
+ }
|
|
|
err := SearchDashboards(query)
|
|
|
So(err, ShouldBeNil)
|
|
|
So(len(query.Result), ShouldEqual, 1)
|
|
|
@@ -51,7 +58,11 @@ func TestDashboardFolderDataAccess(t *testing.T) {
|
|
|
updateTestDashboardWithAcl(folder.Id, currentUser.Id, m.PERMISSION_EDIT)
|
|
|
|
|
|
Convey("should be able to access folder", func() {
|
|
|
- query := &search.FindPersistedDashboardsQuery{SignedInUser: &m.SignedInUser{UserId: currentUser.Id, OrgId: 1}, OrgId: 1, DashboardIds: []int64{folder.Id, dashInRoot.Id}}
|
|
|
+ query := &search.FindPersistedDashboardsQuery{
|
|
|
+ SignedInUser: &m.SignedInUser{UserId: currentUser.Id, OrgId: 1, OrgRole: m.ROLE_VIEWER},
|
|
|
+ OrgId: 1,
|
|
|
+ DashboardIds: []int64{folder.Id, dashInRoot.Id},
|
|
|
+ }
|
|
|
err := SearchDashboards(query)
|
|
|
So(err, ShouldBeNil)
|
|
|
So(len(query.Result), ShouldEqual, 2)
|
|
|
@@ -87,7 +98,7 @@ func TestDashboardFolderDataAccess(t *testing.T) {
|
|
|
updateTestDashboardWithAcl(childDash.Id, otherUser, m.PERMISSION_EDIT)
|
|
|
|
|
|
Convey("should not return folder or child", func() {
|
|
|
- query := &search.FindPersistedDashboardsQuery{SignedInUser: &m.SignedInUser{UserId: currentUser.Id, OrgId: 1}, OrgId: 1, DashboardIds: []int64{folder.Id, childDash.Id, dashInRoot.Id}}
|
|
|
+ query := &search.FindPersistedDashboardsQuery{SignedInUser: &m.SignedInUser{UserId: currentUser.Id, OrgId: 1, OrgRole: m.ROLE_VIEWER}, OrgId: 1, DashboardIds: []int64{folder.Id, childDash.Id, dashInRoot.Id}}
|
|
|
err := SearchDashboards(query)
|
|
|
So(err, ShouldBeNil)
|
|
|
So(len(query.Result), ShouldEqual, 1)
|
|
|
@@ -98,7 +109,7 @@ func TestDashboardFolderDataAccess(t *testing.T) {
|
|
|
updateTestDashboardWithAcl(childDash.Id, currentUser.Id, m.PERMISSION_EDIT)
|
|
|
|
|
|
Convey("should be able to search for child dashboard but not folder", func() {
|
|
|
- query := &search.FindPersistedDashboardsQuery{SignedInUser: &m.SignedInUser{UserId: currentUser.Id, OrgId: 1}, OrgId: 1, DashboardIds: []int64{folder.Id, childDash.Id, dashInRoot.Id}}
|
|
|
+ query := &search.FindPersistedDashboardsQuery{SignedInUser: &m.SignedInUser{UserId: currentUser.Id, OrgId: 1, OrgRole: m.ROLE_VIEWER}, OrgId: 1, DashboardIds: []int64{folder.Id, childDash.Id, dashInRoot.Id}}
|
|
|
err := SearchDashboards(query)
|
|
|
So(err, ShouldBeNil)
|
|
|
So(len(query.Result), ShouldEqual, 2)
|
|
|
@@ -141,7 +152,7 @@ func TestDashboardFolderDataAccess(t *testing.T) {
|
|
|
|
|
|
Convey("and one folder is expanded, the other collapsed", func() {
|
|
|
Convey("should return dashboards in root and expanded folder", func() {
|
|
|
- query := &search.FindPersistedDashboardsQuery{FolderIds: []int64{rootFolderId, folder1.Id}, SignedInUser: &m.SignedInUser{UserId: currentUser.Id, OrgId: 1}, OrgId: 1}
|
|
|
+ query := &search.FindPersistedDashboardsQuery{FolderIds: []int64{rootFolderId, folder1.Id}, SignedInUser: &m.SignedInUser{UserId: currentUser.Id, OrgId: 1, OrgRole: m.ROLE_VIEWER}, OrgId: 1}
|
|
|
err := SearchDashboards(query)
|
|
|
So(err, ShouldBeNil)
|
|
|
So(len(query.Result), ShouldEqual, 4)
|
|
|
@@ -162,7 +173,7 @@ func TestDashboardFolderDataAccess(t *testing.T) {
|
|
|
|
|
|
Convey("should not return folder with acl or its children", func() {
|
|
|
query := &search.FindPersistedDashboardsQuery{
|
|
|
- SignedInUser: &m.SignedInUser{UserId: currentUser.Id, OrgId: 1},
|
|
|
+ SignedInUser: &m.SignedInUser{UserId: currentUser.Id, OrgId: 1, OrgRole: m.ROLE_VIEWER},
|
|
|
OrgId: 1,
|
|
|
DashboardIds: []int64{folder1.Id, childDash1.Id, childDash2.Id, dashInRoot.Id},
|
|
|
}
|
|
|
@@ -172,14 +183,14 @@ func TestDashboardFolderDataAccess(t *testing.T) {
|
|
|
So(query.Result[0].Id, ShouldEqual, dashInRoot.Id)
|
|
|
})
|
|
|
})
|
|
|
-
|
|
|
Convey("and a dashboard is moved from folder with acl to the folder without an acl", func() {
|
|
|
+
|
|
|
movedDash := moveDashboard(1, childDash1.Data, folder2.Id)
|
|
|
So(movedDash.HasAcl, ShouldBeFalse)
|
|
|
|
|
|
Convey("should return folder without acl and its children", func() {
|
|
|
query := &search.FindPersistedDashboardsQuery{
|
|
|
- SignedInUser: &m.SignedInUser{UserId: currentUser.Id, OrgId: 1},
|
|
|
+ SignedInUser: &m.SignedInUser{UserId: currentUser.Id, OrgId: 1, OrgRole: m.ROLE_VIEWER},
|
|
|
OrgId: 1,
|
|
|
DashboardIds: []int64{folder2.Id, childDash1.Id, childDash2.Id, dashInRoot.Id},
|
|
|
}
|
|
|
@@ -200,16 +211,17 @@ func TestDashboardFolderDataAccess(t *testing.T) {
|
|
|
|
|
|
Convey("should return folder without acl but not the dashboard with acl", func() {
|
|
|
query := &search.FindPersistedDashboardsQuery{
|
|
|
- SignedInUser: &m.SignedInUser{UserId: currentUser.Id, OrgId: 1},
|
|
|
+ SignedInUser: &m.SignedInUser{UserId: currentUser.Id, OrgId: 1, OrgRole: m.ROLE_VIEWER},
|
|
|
OrgId: 1,
|
|
|
DashboardIds: []int64{folder2.Id, childDash1.Id, childDash2.Id, dashInRoot.Id},
|
|
|
}
|
|
|
err := SearchDashboards(query)
|
|
|
So(err, ShouldBeNil)
|
|
|
- So(len(query.Result), ShouldEqual, 3)
|
|
|
+ So(len(query.Result), ShouldEqual, 4)
|
|
|
So(query.Result[0].Id, ShouldEqual, folder2.Id)
|
|
|
- So(query.Result[1].Id, ShouldEqual, childDash2.Id)
|
|
|
- So(query.Result[2].Id, ShouldEqual, dashInRoot.Id)
|
|
|
+ So(query.Result[1].Id, ShouldEqual, childDash1.Id)
|
|
|
+ So(query.Result[2].Id, ShouldEqual, childDash2.Id)
|
|
|
+ So(query.Result[3].Id, ShouldEqual, dashInRoot.Id)
|
|
|
})
|
|
|
})
|
|
|
})
|