Enforce policy limits when policies are created in yaml mode
Summary
Users can use yaml mode in the policy editor to enable policies despite there being policy limits
Steps to reproduce
- Upload a GitLab Ultimate license
- Navigate to a group/project => Secure => Policies
- Create 5 enabled policies of one type and 1 disabled policy of the same type
- Navigate to the group/project => Secure => Policies => Select the disabled policy => Edit policy
- Notice the
enabledradio buttons are disabled - Navigate to yaml mode and enable the policy
- Save the policy
Example Project
What is the current bug behavior?
The policy MR is created
What is the expected correct behavior?
The policy MR is not created and an error shows
Relevant logs and/or screenshots
| Scenario | Screenshot |
|---|---|
Disabled enabled radio button |
|
| Save policy past limit with yaml mode | save_policy_past_limits_small |
Possible fixes
Originally we had a frontend solution where we disabled the the submit button in this case to prevent users from saving it, but we removed it because it was not pajamas compliant.
So the possible solutions are:
- We check the policy type count on save on the backend and throw an error
- We check the policy type count on save on the frontend and throw an error
- Re-implement the disabling of the save button
Edited by Alexander Turinske
