Return empty array when no PATs for service account

What does this MR do and why?

Return empty array when no PATs for service account

All other access tokens endpoints return [] when the query returns not tokens.

Here we change the behavior of the group service account listing the personal access tokens (PATs).

From: { "message": "404 Personal access token(s) Not Found" }

To: []

In addition, we fix the frontend to replace the :id placeholder for the service account ID.

Endpoint behaviour comparison with not access tokens:

/personal_access_tokens

❯ curl --request GET --header "PRIVATE-TOKEN: $PAT" "https://gdk.test:3443/api/v4/personal_access_tokens?user_id=261" | jq

[]

/groups/:group_id/access_tokens

❯ curl --request GET --header "PRIVATE-TOKEN: $PAT" "https://gdk.test:3443/api/v4/groups/35/access_tokens" | jq

[]

/projects/:project_id/access_tokens

❯ curl --request GET --header "PRIVATE-TOKEN: $PAT" "https://gdk.test:3443/api/v4/projects/8/access_tokens" | jq

[]

/users/:user_id/impersonation_tokens

❯ curl --request GET --header "PRIVATE-TOKEN: $PAT" "https://gdk.test:3443/api/v4/users/1/impersonation_tokens" | jq

[]

/groups/:group_id/service_accounts/:user_id/personal_access_tokens

❯ curl --request GET --header "PRIVATE-TOKEN: $PAT" "https://gdk.test:3443/api/v4/groups/33/service_accounts/261/personal_access_tokens" | jq

{
  "message": "404 Personal access token(s) Not Found"
}

References

Screenshots or screen recordings

Before After
image image

How to set up and validate locally

  1. Follow this steps to setup the service account UI.
  2. Go to the group service account page.
  3. Create a service account.
  4. Click on Manage Access Tokens
  5. See that there is no error alert.

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Eduardo Sanz García

Merge request reports

Loading