Chore: Make getUserOrgList private to sqlstore (#59654)
* make getUserOrgList private in sqlstore * make other identifiers private
This commit is contained in:
@@ -9,6 +9,8 @@ import (
|
||||
"github.com/grafana/grafana/pkg/infra/db"
|
||||
"github.com/grafana/grafana/pkg/models"
|
||||
"github.com/grafana/grafana/pkg/services/org"
|
||||
"github.com/grafana/grafana/pkg/services/org/orgimpl"
|
||||
"github.com/grafana/grafana/pkg/services/quota/quotaimpl"
|
||||
"github.com/grafana/grafana/pkg/services/quota/quotatest"
|
||||
"github.com/grafana/grafana/pkg/services/sqlstore"
|
||||
"github.com/grafana/grafana/pkg/services/tag/tagimpl"
|
||||
@@ -271,12 +273,15 @@ func createUser(t *testing.T, sqlStore *sqlstore.SQLStore, name string, role str
|
||||
sqlStore.Cfg.AutoAssignOrg = true
|
||||
sqlStore.Cfg.AutoAssignOrgId = 1
|
||||
sqlStore.Cfg.AutoAssignOrgRole = role
|
||||
|
||||
orgService, err := orgimpl.ProvideService(sqlStore, sqlStore.Cfg, quotaimpl.ProvideService(sqlStore, sqlStore.Cfg))
|
||||
require.NoError(t, err)
|
||||
|
||||
currentUserCmd := user.CreateUserCommand{Login: name, Email: name + "@test.com", Name: "a " + name, IsAdmin: isAdmin}
|
||||
currentUser, err := sqlStore.CreateUser(context.Background(), currentUserCmd)
|
||||
require.NoError(t, err)
|
||||
q1 := models.GetUserOrgListQuery{UserId: currentUser.ID}
|
||||
err = sqlStore.GetUserOrgList(context.Background(), &q1)
|
||||
orgs, err := orgService.GetUserOrgList(context.Background(), &org.GetUserOrgListQuery{UserID: currentUser.ID})
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, org.RoleType(role), q1.Result[0].Role)
|
||||
require.Equal(t, org.RoleType(role), orgs[0].Role)
|
||||
return *currentUser
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ func TestIntegrationDashboardFolderDataAccess(t *testing.T) {
|
||||
dashInRoot = insertTestDashboard(t, dashboardStore, "test dash 67", 1, 0, false, "prod", "webapp")
|
||||
childDash = insertTestDashboard(t, dashboardStore, "test dash 23", 1, folder.Id, false, "prod", "webapp")
|
||||
insertTestDashboard(t, dashboardStore, "test dash 45", 1, folder.Id, false, "prod")
|
||||
currentUser = CreateUser(t, sqlStore, "viewer", "Viewer", false)
|
||||
currentUser = createUser(t, sqlStore, "viewer", "Viewer", false)
|
||||
}
|
||||
|
||||
t.Run("Given one dashboard folder with two dashboards and one dashboard in the root folder", func(t *testing.T) {
|
||||
@@ -199,7 +199,7 @@ func TestIntegrationDashboardFolderDataAccess(t *testing.T) {
|
||||
childDash1 = insertTestDashboard(t, dashboardStore, "child dash 1", 1, folder1.Id, false, "prod")
|
||||
childDash2 = insertTestDashboard(t, dashboardStore, "child dash 2", 1, folder2.Id, false, "prod")
|
||||
|
||||
currentUser = CreateUser(t, sqlStore, "viewer", "Viewer", false)
|
||||
currentUser = createUser(t, sqlStore, "viewer", "Viewer", false)
|
||||
}
|
||||
|
||||
setup2()
|
||||
@@ -304,9 +304,9 @@ func TestIntegrationDashboardFolderDataAccess(t *testing.T) {
|
||||
folder2 = insertTestDashboard(t, dashboardStore, "2 test dash folder", 1, 0, true, "prod")
|
||||
insertTestDashboard(t, dashboardStore, "folder in another org", 2, 0, true, "prod")
|
||||
|
||||
adminUser = CreateUser(t, sqlStore, "admin", "Admin", true)
|
||||
editorUser = CreateUser(t, sqlStore, "editor", "Editor", false)
|
||||
viewerUser = CreateUser(t, sqlStore, "viewer", "Viewer", false)
|
||||
adminUser = createUser(t, sqlStore, "admin", "Admin", true)
|
||||
editorUser = createUser(t, sqlStore, "editor", "Editor", false)
|
||||
viewerUser = createUser(t, sqlStore, "viewer", "Viewer", false)
|
||||
}
|
||||
|
||||
setup3()
|
||||
|
||||
@@ -782,22 +782,6 @@ func insertTestRule(t *testing.T, sqlStore sqlstore.Store, foderOrgID int64, fol
|
||||
require.NoError(t, err)
|
||||
}
|
||||
|
||||
func CreateUser(t *testing.T, sqlStore *sqlstore.SQLStore, name string, role string, isAdmin bool) user.User {
|
||||
t.Helper()
|
||||
sqlStore.Cfg.AutoAssignOrg = true
|
||||
sqlStore.Cfg.AutoAssignOrgId = 1
|
||||
sqlStore.Cfg.AutoAssignOrgRole = role
|
||||
currentUserCmd := user.CreateUserCommand{Login: name, Email: name + "@test.com", Name: "a " + name, IsAdmin: isAdmin}
|
||||
currentUser, err := sqlStore.CreateUser(context.Background(), currentUserCmd)
|
||||
|
||||
require.NoError(t, err)
|
||||
q1 := models.GetUserOrgListQuery{UserId: currentUser.ID}
|
||||
err = sqlStore.GetUserOrgList(context.Background(), &q1)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, org.RoleType(role), q1.Result[0].Role)
|
||||
return *currentUser
|
||||
}
|
||||
|
||||
func insertTestDashboard(t *testing.T, dashboardStore *DashboardStore, title string, orgId int64,
|
||||
folderId int64, isFolder bool, tags ...interface{}) *models.Dashboard {
|
||||
t.Helper()
|
||||
|
||||
Reference in New Issue
Block a user