mirror of
https://github.com/grafana/grafana.git
synced 2024-11-28 03:34:15 -06:00
Chore: Remove DeleteUser from sqlstore (#59180)
* Remove DeleteUser from sqlstore * Use Delete instead of DeleteUser * Remove unused method
This commit is contained in:
parent
8761a71da2
commit
054d87e52e
@ -394,12 +394,6 @@ func getTeamSelectSQLBase(filteredUsers []string) string {
|
||||
` FROM team as team `
|
||||
}
|
||||
|
||||
func (ss *SQLStore) DeleteUser(ctx context.Context, cmd *models.DeleteUserCommand) error {
|
||||
return ss.WithTransactionalDbSession(ctx, func(sess *DBSession) error {
|
||||
return deleteUserInTransaction(ss, sess, cmd)
|
||||
})
|
||||
}
|
||||
|
||||
func (ss *SQLStore) DeleteUserInSession(ctx context.Context, sess *DBSession, cmd *models.DeleteUserCommand) error {
|
||||
return deleteUserInTransaction(ss, sess, cmd)
|
||||
}
|
||||
|
@ -420,15 +420,9 @@ func TestIntegrationUserDataAccess(t *testing.T) {
|
||||
require.Nil(t, err)
|
||||
|
||||
// When the user is deleted
|
||||
err = ss.DeleteUser(context.Background(), &models.DeleteUserCommand{UserId: users[1].ID})
|
||||
err = userStore.Delete(context.Background(), users[1].ID)
|
||||
require.Nil(t, err)
|
||||
|
||||
query1 := &org.GetOrgUsersQuery{OrgID: users[0].OrgID, User: usr}
|
||||
query1Result, err := userStore.getOrgUsersForTest(context.Background(), query1)
|
||||
require.Nil(t, err)
|
||||
|
||||
require.Len(t, query1Result, 1)
|
||||
|
||||
permQuery := &models.GetDashboardACLInfoListQuery{DashboardID: 1, OrgID: users[0].OrgID}
|
||||
err = userStore.getDashboardACLInfoList(permQuery)
|
||||
require.Nil(t, err)
|
||||
@ -492,16 +486,9 @@ func TestIntegrationUserDataAccess(t *testing.T) {
|
||||
require.EqualValues(t, query5Result.TotalCount, 5)
|
||||
|
||||
// the user is deleted
|
||||
err = ss.DeleteUser(context.Background(), &models.DeleteUserCommand{UserId: users[1].ID})
|
||||
err = userStore.Delete(context.Background(), users[1].ID)
|
||||
require.Nil(t, err)
|
||||
|
||||
// delete connected org users and permissions
|
||||
query2 := &org.GetOrgUsersQuery{OrgID: users[0].OrgID}
|
||||
query2Result, err := userStore.getOrgUsersForTest(context.Background(), query2)
|
||||
require.Nil(t, err)
|
||||
|
||||
require.Len(t, query2Result, 1)
|
||||
|
||||
permQuery = &models.GetDashboardACLInfoListQuery{DashboardID: 1, OrgID: users[0].OrgID}
|
||||
err = userStore.getDashboardACLInfoList(permQuery)
|
||||
require.Nil(t, err)
|
||||
@ -850,20 +837,6 @@ func updateDashboardACL(t *testing.T, sqlStore db.DB, dashboardID int64, items .
|
||||
return err
|
||||
}
|
||||
|
||||
func (ss *sqlStore) getOrgUsersForTest(ctx context.Context, query *org.GetOrgUsersQuery) ([]*org.OrgUserDTO, error) {
|
||||
result := make([]*org.OrgUserDTO, 0)
|
||||
err := ss.db.WithDbSession(ctx, func(dbSess *db.Session) error {
|
||||
sess := dbSess.Table("org_user")
|
||||
sess.Join("LEFT ", ss.dialect.Quote("user"), fmt.Sprintf("org_user.user_id=%s.id", ss.dialect.Quote("user")))
|
||||
sess.Where("org_user.org_id=?", query.OrgID)
|
||||
sess.Cols("org_user.org_id", "org_user.user_id", "user.email", "user.login", "org_user.role")
|
||||
|
||||
err := sess.Find(&result)
|
||||
return err
|
||||
})
|
||||
return result, err
|
||||
}
|
||||
|
||||
// This function was copied from pkg/services/dashboards/database to circumvent
|
||||
// import cycles. When this org-related code is refactored into a service the
|
||||
// tests can the real GetDashboardACLInfoList functions
|
||||
|
Loading…
Reference in New Issue
Block a user