Commit c4a18030 by Torkel Ödegaard

refactoring more renaming

parent e0b9ba75
...@@ -18,7 +18,7 @@ func GetDashboardAcl(c *middleware.Context) Response { ...@@ -18,7 +18,7 @@ func GetDashboardAcl(c *middleware.Context) Response {
return dashboardGuardianResponse(err) return dashboardGuardianResponse(err)
} }
query := m.GetDashboardPermissionsQuery{DashboardId: dashId} query := m.GetDashboardAclInfoListQuery{DashboardId: dashId}
if err := bus.Dispatch(&query); err != nil { if err := bus.Dispatch(&query); err != nil {
return ApiError(500, "Failed to get Dashboard ACL", err) return ApiError(500, "Failed to get Dashboard ACL", err)
} }
......
...@@ -25,7 +25,7 @@ func TestDashboardAclApiEndpoint(t *testing.T) { ...@@ -25,7 +25,7 @@ func TestDashboardAclApiEndpoint(t *testing.T) {
{Id: 4, OrgId: 1, DashboardId: 1, UserGroupId: 2, Permissions: models.PERMISSION_READ_ONLY_EDIT}, {Id: 4, OrgId: 1, DashboardId: 1, UserGroupId: 2, Permissions: models.PERMISSION_READ_ONLY_EDIT},
} }
bus.AddHandler("test", func(query *models.GetDashboardPermissionsQuery) error { bus.AddHandler("test", func(query *models.GetDashboardAclInfoListQuery) error {
query.Result = dtoRes query.Result = dtoRes
return nil return nil
}) })
......
...@@ -83,7 +83,7 @@ type RemoveDashboardAclCommand struct { ...@@ -83,7 +83,7 @@ type RemoveDashboardAclCommand struct {
// //
// QUERIES // QUERIES
// //
type GetDashboardPermissionsQuery struct { type GetDashboardAclInfoListQuery struct {
DashboardId int64 DashboardId int64
Result []*DashboardAclInfoDTO Result []*DashboardAclInfoDTO
} }
......
...@@ -10,7 +10,7 @@ import ( ...@@ -10,7 +10,7 @@ import (
func init() { func init() {
bus.AddHandler("sql", SetDashboardAcl) bus.AddHandler("sql", SetDashboardAcl)
bus.AddHandler("sql", RemoveDashboardAcl) bus.AddHandler("sql", RemoveDashboardAcl)
bus.AddHandler("sql", GetDashboardPermissions) bus.AddHandler("sql", GetDashboardAclInfoList)
bus.AddHandler("sql", GetInheritedDashboardAcl) bus.AddHandler("sql", GetInheritedDashboardAcl)
} }
...@@ -107,7 +107,7 @@ func GetInheritedDashboardAcl(query *m.GetInheritedDashboardAclQuery) error { ...@@ -107,7 +107,7 @@ func GetInheritedDashboardAcl(query *m.GetInheritedDashboardAclQuery) error {
return x.SQL(rawSQL, query.DashboardId, query.DashboardId, query.OrgId).Find(&query.Result) return x.SQL(rawSQL, query.DashboardId, query.DashboardId, query.OrgId).Find(&query.Result)
} }
func GetDashboardPermissions(query *m.GetDashboardPermissionsQuery) error { func GetDashboardAclInfoList(query *m.GetDashboardAclInfoListQuery) error {
rawSQL := `SELECT rawSQL := `SELECT
da.id, da.id,
da.org_id, da.org_id,
......
...@@ -75,8 +75,8 @@ func TestDashboardAclDataAccess(t *testing.T) { ...@@ -75,8 +75,8 @@ func TestDashboardAclDataAccess(t *testing.T) {
}) })
So(err, ShouldBeNil) So(err, ShouldBeNil)
q1 := &m.GetDashboardPermissionsQuery{DashboardId: savedFolder.Id} q1 := &m.GetDashboardAclInfoListQuery{DashboardId: savedFolder.Id}
err = GetDashboardPermissions(q1) err = GetDashboardAclInfoList(q1)
So(err, ShouldBeNil) So(err, ShouldBeNil)
So(q1.Result[0].DashboardId, ShouldEqual, savedFolder.Id) So(q1.Result[0].DashboardId, ShouldEqual, savedFolder.Id)
So(q1.Result[0].Permissions, ShouldEqual, m.PERMISSION_EDIT) So(q1.Result[0].Permissions, ShouldEqual, m.PERMISSION_EDIT)
...@@ -102,8 +102,8 @@ func TestDashboardAclDataAccess(t *testing.T) { ...@@ -102,8 +102,8 @@ func TestDashboardAclDataAccess(t *testing.T) {
}) })
So(err, ShouldBeNil) So(err, ShouldBeNil)
q3 := &m.GetDashboardPermissionsQuery{DashboardId: savedFolder.Id} q3 := &m.GetDashboardAclInfoListQuery{DashboardId: savedFolder.Id}
err = GetDashboardPermissions(q3) err = GetDashboardAclInfoList(q3)
So(err, ShouldBeNil) So(err, ShouldBeNil)
So(len(q3.Result), ShouldEqual, 1) So(len(q3.Result), ShouldEqual, 1)
So(q3.Result[0].DashboardId, ShouldEqual, savedFolder.Id) So(q3.Result[0].DashboardId, ShouldEqual, savedFolder.Id)
...@@ -120,8 +120,8 @@ func TestDashboardAclDataAccess(t *testing.T) { ...@@ -120,8 +120,8 @@ func TestDashboardAclDataAccess(t *testing.T) {
}) })
So(err, ShouldBeNil) So(err, ShouldBeNil)
q3 := &m.GetDashboardPermissionsQuery{DashboardId: savedFolder.Id} q3 := &m.GetDashboardAclInfoListQuery{DashboardId: savedFolder.Id}
err = GetDashboardPermissions(q3) err = GetDashboardAclInfoList(q3)
So(err, ShouldBeNil) So(err, ShouldBeNil)
So(len(q3.Result), ShouldEqual, 0) So(len(q3.Result), ShouldEqual, 0)
}) })
...@@ -141,8 +141,8 @@ func TestDashboardAclDataAccess(t *testing.T) { ...@@ -141,8 +141,8 @@ func TestDashboardAclDataAccess(t *testing.T) {
}) })
So(err, ShouldBeNil) So(err, ShouldBeNil)
q1 := &m.GetDashboardPermissionsQuery{DashboardId: savedFolder.Id} q1 := &m.GetDashboardAclInfoListQuery{DashboardId: savedFolder.Id}
err = GetDashboardPermissions(q1) err = GetDashboardAclInfoList(q1)
So(err, ShouldBeNil) So(err, ShouldBeNil)
So(q1.Result[0].DashboardId, ShouldEqual, savedFolder.Id) So(q1.Result[0].DashboardId, ShouldEqual, savedFolder.Id)
So(q1.Result[0].Permissions, ShouldEqual, m.PERMISSION_EDIT) So(q1.Result[0].Permissions, ShouldEqual, m.PERMISSION_EDIT)
...@@ -158,8 +158,8 @@ func TestDashboardAclDataAccess(t *testing.T) { ...@@ -158,8 +158,8 @@ func TestDashboardAclDataAccess(t *testing.T) {
}) })
So(err, ShouldBeNil) So(err, ShouldBeNil)
q3 := &m.GetDashboardPermissionsQuery{DashboardId: savedFolder.Id} q3 := &m.GetDashboardAclInfoListQuery{DashboardId: savedFolder.Id}
err = GetDashboardPermissions(q3) err = GetDashboardAclInfoList(q3)
So(err, ShouldBeNil) So(err, ShouldBeNil)
So(len(q3.Result), ShouldEqual, 1) So(len(q3.Result), ShouldEqual, 1)
So(q3.Result[0].DashboardId, ShouldEqual, savedFolder.Id) So(q3.Result[0].DashboardId, ShouldEqual, savedFolder.Id)
...@@ -176,8 +176,8 @@ func TestDashboardAclDataAccess(t *testing.T) { ...@@ -176,8 +176,8 @@ func TestDashboardAclDataAccess(t *testing.T) {
}) })
So(err, ShouldBeNil) So(err, ShouldBeNil)
q3 := &m.GetDashboardPermissionsQuery{DashboardId: savedFolder.Id} q3 := &m.GetDashboardAclInfoListQuery{DashboardId: savedFolder.Id}
err = GetDashboardPermissions(q3) err = GetDashboardAclInfoList(q3)
So(err, ShouldBeNil) So(err, ShouldBeNil)
So(len(q3.Result), ShouldEqual, 0) So(len(q3.Result), ShouldEqual, 0)
}) })
......
...@@ -186,16 +186,16 @@ func TestAccountDataAccess(t *testing.T) { ...@@ -186,16 +186,16 @@ func TestAccountDataAccess(t *testing.T) {
So(err, ShouldBeNil) So(err, ShouldBeNil)
Convey("Should remove dependent permissions for deleted org user", func() { Convey("Should remove dependent permissions for deleted org user", func() {
permQuery := &m.GetDashboardPermissionsQuery{DashboardId: 1} permQuery := &m.GetDashboardAclInfoListQuery{DashboardId: 1}
err = GetDashboardPermissions(permQuery) err = GetDashboardAclInfoList(permQuery)
So(err, ShouldBeNil) So(err, ShouldBeNil)
So(len(permQuery.Result), ShouldEqual, 0) So(len(permQuery.Result), ShouldEqual, 0)
}) })
Convey("Should not remove dashboard permissions for same user in another org", func() { Convey("Should not remove dashboard permissions for same user in another org", func() {
permQuery := &m.GetDashboardPermissionsQuery{DashboardId: 2} permQuery := &m.GetDashboardAclInfoListQuery{DashboardId: 2}
err = GetDashboardPermissions(permQuery) err = GetDashboardAclInfoList(permQuery)
So(err, ShouldBeNil) So(err, ShouldBeNil)
So(permQuery.Result[0].OrgId, ShouldEqual, ac3.OrgId) So(permQuery.Result[0].OrgId, ShouldEqual, ac3.OrgId)
......
...@@ -103,8 +103,8 @@ func TestUserGroupCommandsAndQueries(t *testing.T) { ...@@ -103,8 +103,8 @@ func TestUserGroupCommandsAndQueries(t *testing.T) {
err = GetUserGroupById(query) err = GetUserGroupById(query)
So(err, ShouldEqual, m.ErrUserGroupNotFound) So(err, ShouldEqual, m.ErrUserGroupNotFound)
permQuery := &m.GetDashboardPermissionsQuery{DashboardId: 1} permQuery := &m.GetDashboardAclInfoListQuery{DashboardId: 1}
err = GetDashboardPermissions(permQuery) err = GetDashboardAclInfoList(permQuery)
So(err, ShouldBeNil) So(err, ShouldBeNil)
So(len(permQuery.Result), ShouldEqual, 0) So(len(permQuery.Result), ShouldEqual, 0)
......
...@@ -116,8 +116,8 @@ func TestUserDataAccess(t *testing.T) { ...@@ -116,8 +116,8 @@ func TestUserDataAccess(t *testing.T) {
So(len(query.Result), ShouldEqual, 1) So(len(query.Result), ShouldEqual, 1)
permQuery := &m.GetDashboardPermissionsQuery{DashboardId: 1} permQuery := &m.GetDashboardAclInfoListQuery{DashboardId: 1}
err = GetDashboardPermissions(permQuery) err = GetDashboardAclInfoList(permQuery)
So(err, ShouldBeNil) So(err, ShouldBeNil)
So(len(permQuery.Result), ShouldEqual, 0) So(len(permQuery.Result), ShouldEqual, 0)
......
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