Service Accounts: Polish service account detail page (#45846)
* ServiceAccounts: add teams to service account DTO * ServiceAccounts: Add team display to service accounts * ServiceAccounts: add AC metadata to detail route * ServiceAccounts: add role picker to detail page * ServiceAccounts: Add role to profile DTO * ServiceAccounts: remove wip mention of created by
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/grafana/grafana/pkg/models"
|
||||
"github.com/grafana/grafana/pkg/services/serviceaccounts"
|
||||
"github.com/grafana/grafana/pkg/services/serviceaccounts/tests"
|
||||
"github.com/grafana/grafana/pkg/services/sqlstore"
|
||||
@@ -76,7 +77,25 @@ func TestStore_RetrieveServiceAccount(t *testing.T) {
|
||||
} else {
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, c.user.Login, dto.Login)
|
||||
require.Len(t, dto.Teams, 0)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
func TestStore_RetrieveServiceAccountWithTeams(t *testing.T) {
|
||||
userToCreate := tests.TestUser{Login: "servicetestwithTeam@admin", IsServiceAccount: true}
|
||||
db, store := setupTestDatabase(t)
|
||||
user := tests.SetupUserServiceAccount(t, db, userToCreate)
|
||||
|
||||
team, err := store.sqlStore.CreateTeam("serviceTeam", "serviceTeam", user.OrgId)
|
||||
require.NoError(t, err)
|
||||
|
||||
err = store.sqlStore.AddTeamMember(user.Id, user.OrgId, team.Id, false, models.PERMISSION_VIEW)
|
||||
require.NoError(t, err)
|
||||
|
||||
dto, err := store.RetrieveServiceAccount(context.Background(), user.OrgId, user.Id)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, userToCreate.Login, dto.Login)
|
||||
require.Len(t, dto.Teams, 1)
|
||||
require.Equal(t, "serviceTeam", dto.Teams[0])
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user