We want to improve the GitLab integration by checking the validity of the configuration as early as possible.
Create and use a new API endpoint common for all 4 ALMs POST api/alm_settings/validate?key=xxx
Requires the 'Administer System' permission.
This endpoint will return an empty 200 code if everything is alright, or a 400 code with a message as plaintext detailing what issue is detected.
To validate that GitLab is properly configured, on the endpoint implementation, we want to verify the connectivity, the authentication, and the permissions. Here are the GitLab endpoints to call to achieve that:
- Url validation: %s/projects
- PAT validation: %s/user
- Read projects permission: %s/projects (with non-empty token)
- MR Write permission: Use the format markdown endpoint
When saving a configuration (be it new or edited), the modal hosting the form will be closed, and validation automatically triggered.
A call is made to api/alm_settings/validate?key=[configuration_key].
The configuration will be shown as "being validated", and then the status will be updated when we get a response.
- In case of success, we show a message and check mark with the status for each feature (PR decoration & import)
- In case of error, the reason ( best effort regarding its precision ) is clearly stated for the user, in order to help them fix whatever the issue is.
This validation can be manually triggered by pressing a button.
When loading the page, all existing configurations are re-validated following the above pattern, with the following exception:
- in case of success, no success message is displayed, only the valid status.