Move SignedInUser to user service and RoleType and Roles to org (#53445)

* Move SignedInUser to user service and RoleType and Roles to org

* Use go naming convention for roles

* Fix some imports and leftovers

* Fix ldap debug test

* Fix lint

* Fix lint 2

* Fix lint 3

* Fix type and not needed conversion

* Clean up messages in api tests

* Clean up api tests 2
This commit is contained in:
idafurjes
2022-08-10 11:56:48 +02:00
committed by GitHub
parent 46004037e2
commit 6afad51761
278 changed files with 1758 additions and 1543 deletions

View File

@@ -6,6 +6,7 @@ import (
"testing"
"github.com/grafana/grafana/pkg/models"
"github.com/grafana/grafana/pkg/services/org"
"github.com/grafana/grafana/pkg/services/user"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
@@ -82,22 +83,22 @@ func populateDB(t *testing.T, sqlStore *SQLStore) {
getOrgByIdQuery := &models.GetOrgByIdQuery{Id: users[0].OrgID}
err := sqlStore.GetOrgById(context.Background(), getOrgByIdQuery)
require.NoError(t, err)
org := getOrgByIdQuery.Result
orga := getOrgByIdQuery.Result
// add 2nd user as editor
cmd := &models.AddOrgUserCommand{
OrgId: org.Id,
OrgId: orga.Id,
UserId: users[1].ID,
Role: models.ROLE_EDITOR,
Role: org.RoleEditor,
}
err = sqlStore.AddOrgUser(context.Background(), cmd)
require.NoError(t, err)
// add 3rd user as viewer
cmd = &models.AddOrgUserCommand{
OrgId: org.Id,
OrgId: orga.Id,
UserId: users[2].ID,
Role: models.ROLE_VIEWER,
Role: org.RoleViewer,
}
err = sqlStore.AddOrgUser(context.Background(), cmd)
require.NoError(t, err)
@@ -106,13 +107,13 @@ func populateDB(t *testing.T, sqlStore *SQLStore) {
getOrgByIdQuery = &models.GetOrgByIdQuery{Id: users[1].OrgID}
err = sqlStore.GetOrgById(context.Background(), getOrgByIdQuery)
require.NoError(t, err)
org = getOrgByIdQuery.Result
orga = getOrgByIdQuery.Result
// add 1st user as admin
cmd = &models.AddOrgUserCommand{
OrgId: org.Id,
OrgId: orga.Id,
UserId: users[0].ID,
Role: models.ROLE_ADMIN,
Role: org.RoleAdmin,
}
err = sqlStore.AddOrgUser(context.Background(), cmd)
require.NoError(t, err)