Define states parameter in environments api interface
What does this MR do and why?
This merge request builds on the work from !87023 (merged) as explained by @shinya.maeda in #362070 (closed), to ensure states
parameter is defined in environments API interface which wasn't the case despite being documented!
It was working fine, regardless, because params
was passed to the EnvironmentsFinder
which shouldn't be the case mainly because API users shouldn't be allowed to pass arbitrary params, and also to keep consistent with other endpoints.
More test cases were also added to cover the changes introduced here.
How to set up and validate locally
- Start GDK locally, if it isn't up already:
gdk start
. - Make sure one of the projects on your local installation has multiple environments configured.
for valid state:
- In your terminal, send a request to the
/environments
endpoint (using your preferred method of API authentication) as follows:
echo -e | curl -v -H "Content-Type: application/json" -H "PRIVATE-TOKEN: YOUR_TOKEN" localhost:3000/api/v4/projects/:project_id/environments?states=available
- Validate that the response has status
200
and returns allavailable
environments.
for invalid state:
- In your terminal, send a request to the
/environments
endpoint (using your preferred method of API authentication) as follows:
echo -e | curl -v -H "Content-Type: application/json" -H "PRIVATE-TOKEN: YOUR_TOKEN" localhost:3000/api/v4/projects/:project_id/environments?states=test"
- Validate that the response has status
400
with the following error message:states does not have a valid value
.
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Edited by Ahmed Hemdan