Skip to content

Commit

Permalink
Merge branch 'gh_654' into 'quote_1005'
Browse files Browse the repository at this point in the history
Changing org while adding net results in 500 #654

See merge request gh/peeringdb/peeringdb!77
  • Loading branch information
grizz committed Jun 23, 2020
2 parents e0642d3 + 027d076 commit fcfef13
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
6 changes: 6 additions & 0 deletions peeringdb_server/validators.py
Expand Up @@ -97,6 +97,8 @@ def validate_address_space(prefix):


def validate_info_prefixes4(value):
if not value:
value = 0
if value > settings.DATA_QUALITY_MAX_PREFIX_V4_LIMIT:
raise ValidationError(
_("Maximum value allowed {}").format(
Expand All @@ -105,9 +107,12 @@ def validate_info_prefixes4(value):
)
if value < 0:
raise ValidationError(_("Negative value not allowed"))
return value


def validate_info_prefixes6(value):
if not value:
value = 0
if value > settings.DATA_QUALITY_MAX_PREFIX_V6_LIMIT:
raise ValidationError(
_("Maximum value allowed {}").format(
Expand All @@ -117,6 +122,7 @@ def validate_info_prefixes6(value):

if value < 0:
raise ValidationError(_("Negative value not allowed"))
return value


def validate_prefix_overlap(prefix):
Expand Down
4 changes: 4 additions & 0 deletions tests/test_validators.py
Expand Up @@ -102,6 +102,8 @@ def test_validate_info_prefixes4():
with pytest.raises(ValidationError):
validate_info_prefixes4(-1)
validate_info_prefixes4(500000)
assert validate_info_prefixes4(None) == 0
assert validate_info_prefixes4("") == 0


@override_settings(DATA_QUALITY_MAX_PREFIX_V6_LIMIT=500000)
Expand All @@ -114,6 +116,8 @@ def test_validate_info_prefixes6():
with pytest.raises(ValidationError):
validate_info_prefixes6(-1)
validate_info_prefixes6(500000)
assert validate_info_prefixes6(None) == 0
assert validate_info_prefixes6("") == 0


@override_settings(
Expand Down

0 comments on commit fcfef13

Please sign in to comment.