Add expiration to ListServiceAccounts function (#17249)

This commit is contained in:
Kaan Kabalak
2023-06-02 16:17:26 -07:00
committed by GitHub
parent b210ea79bc
commit 0649aca219
4 changed files with 24 additions and 16 deletions
+7 -3
View File
@@ -1123,14 +1123,18 @@ func (a adminAPIHandlers) ListServiceAccounts(w http.ResponseWriter, r *http.Req
return
}
var serviceAccountsNames []string
var serviceAccountList []madmin.ServiceAccountInfo
for _, svc := range serviceAccounts {
serviceAccountsNames = append(serviceAccountsNames, svc.AccessKey)
expiryTime := svc.Expiration
serviceAccountList = append(serviceAccountList, madmin.ServiceAccountInfo{
AccessKey: svc.AccessKey,
Expiration: &expiryTime,
})
}
listResp := madmin.ListServiceAccountsResp{
Accounts: serviceAccountsNames,
Accounts: serviceAccountList,
}
data, err := json.Marshal(listResp)
+5 -1
View File
@@ -1329,7 +1329,11 @@ func (c *check) assertSvcAccAppearsInListing(ctx context.Context, madmClient *ma
if err != nil {
c.Fatalf("unable to list svc accounts: %v", err)
}
if !set.CreateStringSet(listResp.Accounts...).Contains(svcAK) {
var accessKeys []string
for _, item := range listResp.Accounts {
accessKeys = append(accessKeys, item.AccessKey)
}
if !set.CreateStringSet(accessKeys...).Contains(svcAK) {
c.Fatalf("service account did not appear in listing!")
}
}