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:
Gabriel MABILLE
2023-11-03 17:49:11 +01:00
committed by GitHub
parent c98add6e5a
commit bf363b3234
6 changed files with 13 additions and 13 deletions

View File

@@ -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:"-"`

View File

@@ -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

View File

@@ -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) {

View File

@@ -6825,7 +6825,7 @@
"type": "boolean",
"example": false
},
"isExternal": {
"isManaged": {
"type": "boolean",
"example": false
},
@@ -6880,7 +6880,7 @@
"type": "boolean",
"example": false
},
"isExternal": {
"isManaged": {
"type": "boolean",
"example": false
},

View File

@@ -18710,7 +18710,7 @@
"type": "boolean",
"example": false
},
"isExternal": {
"isManaged": {
"type": "boolean",
"example": false
},
@@ -18765,7 +18765,7 @@
"type": "boolean",
"example": false
},
"isExternal": {
"isManaged": {
"type": "boolean",
"example": false
},

View File

@@ -9631,7 +9631,7 @@
"example": false,
"type": "boolean"
},
"isExternal": {
"isManaged": {
"example": false,
"type": "boolean"
},
@@ -9686,7 +9686,7 @@
"example": false,
"type": "boolean"
},
"isExternal": {
"isManaged": {
"example": false,
"type": "boolean"
},