mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
ServiceAccounts: Use isManaged in DTO instead of isExternal (#77634)
* ServiceAccounts: Use IsManaged in DTO instead of isExternal * Revert omitempty * Modify the other DTO * Swagger
This commit is contained in:
@@ -85,7 +85,7 @@ type ServiceAccountDTO struct {
|
||||
// example: false
|
||||
IsDisabled bool `json:"isDisabled" xorm:"is_disabled"`
|
||||
// example: false
|
||||
IsExternal bool `json:"isExternal,omitempty" xorm:"-"`
|
||||
IsManaged bool `json:"isManaged,omitempty" xorm:"-"`
|
||||
// example: Viewer
|
||||
Role string `json:"role" xorm:"role"`
|
||||
// example: 0
|
||||
@@ -157,7 +157,7 @@ type ServiceAccountProfileDTO struct {
|
||||
// example: []
|
||||
Teams []string `json:"teams" xorm:"-"`
|
||||
// example: false
|
||||
IsExternal bool `json:"isExternal,omitempty" xorm:"-"`
|
||||
IsManaged bool `json:"isManaged,omitempty" xorm:"-"`
|
||||
|
||||
Tokens int64 `json:"tokens,omitempty"`
|
||||
AccessControl map[string]bool `json:"accessControl,omitempty" xorm:"-"`
|
||||
|
||||
@@ -138,7 +138,7 @@ func (s *ServiceAccountsProxy) RetrieveServiceAccount(ctx context.Context, orgID
|
||||
}
|
||||
|
||||
if s.isProxyEnabled {
|
||||
sa.IsExternal = isExternalServiceAccount(sa.Login)
|
||||
sa.IsManaged = isExternalServiceAccount(sa.Login)
|
||||
}
|
||||
|
||||
return sa, nil
|
||||
@@ -175,7 +175,7 @@ func (s *ServiceAccountsProxy) SearchOrgServiceAccounts(ctx context.Context, que
|
||||
|
||||
if s.isProxyEnabled {
|
||||
for i := range sa.ServiceAccounts {
|
||||
sa.ServiceAccounts[i].IsExternal = isExternalServiceAccount(sa.ServiceAccounts[i].Login)
|
||||
sa.ServiceAccounts[i].IsManaged = isExternalServiceAccount(sa.ServiceAccounts[i].Login)
|
||||
}
|
||||
}
|
||||
return sa, nil
|
||||
|
||||
@@ -146,7 +146,7 @@ func TestProvideServiceAccount_crudServiceAccount(t *testing.T) {
|
||||
serviceMock.ExpectedServiceAccountProfile = tc.expectedServiceAccount
|
||||
sa, err := svc.RetrieveServiceAccount(context.Background(), testOrgId, testServiceAccountId)
|
||||
assert.NoError(t, err, tc.description)
|
||||
assert.Equal(t, tc.expectedIsExternal, sa.IsExternal, tc.description)
|
||||
assert.Equal(t, tc.expectedIsExternal, sa.IsManaged, tc.description)
|
||||
})
|
||||
}
|
||||
})
|
||||
@@ -164,8 +164,8 @@ func TestProvideServiceAccount_crudServiceAccount(t *testing.T) {
|
||||
res, err := svc.SearchOrgServiceAccounts(context.Background(), &serviceaccounts.SearchOrgServiceAccountsQuery{OrgID: 1})
|
||||
require.Len(t, res.ServiceAccounts, 2)
|
||||
require.NoError(t, err)
|
||||
require.False(t, res.ServiceAccounts[0].IsExternal)
|
||||
require.True(t, res.ServiceAccounts[1].IsExternal)
|
||||
require.False(t, res.ServiceAccounts[0].IsManaged)
|
||||
require.True(t, res.ServiceAccounts[1].IsManaged)
|
||||
})
|
||||
|
||||
t.Run("should update service account", func(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user