Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RHCLOUD-27273] Enforce correct value/operation pairings #1418

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
13 changes: 13 additions & 0 deletions rbac/management/role/serializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,19 @@ def validate_attributeFilter(self, value):
message = f"attributeFilter operation must be one of {ALLOWED_OPERATIONS}"
error = {key: [_(message)]}
raise serializers.ValidationError(error)
else:
values = value.get("value")
error = False
if not isinstance(values, list) and op == "in":
key = "format"
message = "attributeFilter operation 'in' expects a List value"
error = {key: [_(message)]}
elif isinstance(values, list) and op == "equals":
key = "format"
message = "attributeFilter operation 'equals' expects a String value"
error = {key: [_(message)]}
if error:
raise serializers.ValidationError(error)
return value

class Meta:
Expand Down
Loading
Loading