Unverified Commit 02ff6ff7 authored by Martin Cech's avatar Martin Cech Committed by GitHub
Browse files

Merge pull request #14984 from davelopez/22.05_fix_invalid_quota_amount

[22.05] Fix invalid quota amount
parents bc962ad9 26777ccf
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -97,7 +97,7 @@ class QuotaManager:
            return None
        try:
            return util.size_to_bytes(amount)
        except AssertionError:
        except ValueError:
            return False

    def rename_quota(self, quota, params) -> str:
+15 −0
Original line number Diff line number Diff line
@@ -148,6 +148,21 @@ class QuotaIntegrationTestCase(integration_util.IntegrationTestCase):
        show_response = self._get(f"quotas/{quota_id}")
        self._assert_status_code_is(show_response, 400)

    def test_400_when_invalid_amount(self):
        invalid_amount = ""
        quota_name = "invalid-amount-id"
        payload = {
            "name": quota_name,
            "description": f"Quota {quota_name} description",
            "amount": invalid_amount,
            "operation": "=",
            "default": "no",
            "in_users": [],
            "in_groups": [],
        }
        create_response = self._post("quotas", data=payload, json=True)
        self._assert_status_code_is(create_response, 400)

    def _create_quota_with_name(self, quota_name: str, is_default: bool = False):
        payload = self._build_quota_payload_with_name(quota_name, is_default)
        create_response = self._post("quotas", data=payload, json=True)