Team: Add columns external_uid and is_provisioned to the team table (#103285)

* add columns external_id and is_provisioned to the team table

* generate openapi specs

* rename column to external_uid

* generate open api specs

* increase limit for external_uid to 256
This commit is contained in:
Mihai Doarna
2025-04-04 11:00:14 +03:00
committed by GitHub
parent f19e4f95d5
commit 10411361e7
15 changed files with 143 additions and 42 deletions
@@ -331,7 +331,12 @@ func TestApi_setTeamPermission(t *testing.T) {
server := setupTestServer(t, &user.SignedInUser{OrgID: 1, Permissions: map[int64]map[string][]string{1: accesscontrol.GroupScopesByActionContext(context.Background(), tt.permissions)}}, service)
// seed team
team, err := teamSvc.CreateTeam(context.Background(), "test", "test@test.com", 1)
teamCmd := team.CreateTeamCommand{
Name: "test",
Email: "test@test.com",
OrgID: 1,
}
team, err := teamSvc.CreateTeam(context.Background(), &teamCmd)
require.NoError(t, err)
assignTo := strconv.Itoa(int(tt.teamID))
@@ -520,7 +525,12 @@ func seedPermissions(t *testing.T, resourceID string, usrSvc user.Service, teamS
t.Helper()
// seed team 1 with "Edit" permission on dashboard 1
team, err := teamSvc.CreateTeam(context.Background(), "test", "test@test.com", 1)
teamCmd := team.CreateTeamCommand{
Name: "test",
Email: "test@test.com",
OrgID: 1,
}
team, err := teamSvc.CreateTeam(context.Background(), &teamCmd)
require.NoError(t, err)
_, err = service.SetTeamPermission(context.Background(), team.OrgID, team.ID, resourceID, "Edit")
require.NoError(t, err)
@@ -96,7 +96,12 @@ func TestService_SetTeamPermission(t *testing.T) {
})
// seed team
team, err := teamSvc.CreateTeam(context.Background(), "test", "test@test.com", 1)
teamCmd := team.CreateTeamCommand{
Name: "test",
Email: "test@test.com",
OrgID: 1,
}
team, err := teamSvc.CreateTeam(context.Background(), &teamCmd)
require.NoError(t, err)
var hookCalled bool
@@ -211,7 +216,12 @@ func TestService_SetPermissions(t *testing.T) {
// seed user
_, err := usrSvc.Create(context.Background(), &user.CreateUserCommand{Login: "user", OrgID: 1})
require.NoError(t, err)
_, err = teamSvc.CreateTeam(context.Background(), "team", "", 1)
teamCmd := team.CreateTeamCommand{
Name: "test",
OrgID: 1,
}
_, err = teamSvc.CreateTeam(context.Background(), &teamCmd)
require.NoError(t, err)
permissions, err := service.SetPermissions(context.Background(), 1, "1", tt.commands...)
@@ -19,6 +19,7 @@ import (
"github.com/grafana/grafana/pkg/services/org/orgimpl"
"github.com/grafana/grafana/pkg/services/quota/quotatest"
"github.com/grafana/grafana/pkg/services/supportbundles/supportbundlestest"
"github.com/grafana/grafana/pkg/services/team"
"github.com/grafana/grafana/pkg/services/team/teamimpl"
"github.com/grafana/grafana/pkg/services/user"
"github.com/grafana/grafana/pkg/services/user/userimpl"
@@ -155,9 +156,12 @@ func generateTeamsAndUsers(b *testing.B, store db.DB, cfg *setting.Cfg, users in
teamIds := make([]int64, 0)
for i := 0; i < numberOfTeams; i++ {
// Create team
teamName := fmt.Sprintf("%s%v", "team", i)
teamEmail := fmt.Sprintf("%s@example.org", teamName)
team, err := teamSvc.CreateTeam(context.Background(), teamName, teamEmail, 1)
teamCmd := team.CreateTeamCommand{
Name: fmt.Sprintf("%s%v", "team", i),
Email: fmt.Sprintf("%s%v@example.org", "team", i),
OrgID: 1,
}
team, err := teamSvc.CreateTeam(context.Background(), &teamCmd)
require.NoError(b, err)
teamId := team.ID
teamIds = append(teamIds, teamId)