mirror of
https://github.com/peeringdb/peeringdb.git
synced 2024-05-11 05:55:09 +00:00
Gh 761 (#819)
* Make in_dfz a readonly field * add migrations for in_dfz noop, add validation error when trying to set in_dfz to false over api fix template layout * remove in_dfz from ixlanprefixinline admin * fix error message * black formatted Co-authored-by: egfrank <elliot@20c.com> Co-authored-by: Stefan Pratter <stefan@20c.com>
This commit is contained in:
@@ -384,7 +384,7 @@ class TestJSON(unittest.TestCase):
|
||||
"ixlan_id": SHARED["ixlan_r_ok"].id,
|
||||
"protocol": "IPv4",
|
||||
"prefix": "10.%d.10.0/23" % (self.PREFIX_COUNT + 1),
|
||||
"in_dfz": False,
|
||||
"in_dfz": True,
|
||||
}
|
||||
if "prefix" not in kwargs:
|
||||
self.PREFIX_COUNT += 1
|
||||
@@ -559,19 +559,19 @@ class TestJSON(unittest.TestCase):
|
||||
|
||||
# we test fail because of invalid data
|
||||
if "invalid" in test_failures:
|
||||
data_invalid = copy.copy(data)
|
||||
for k, v in list(test_failures["invalid"].items()):
|
||||
data_invalid[k] = v
|
||||
|
||||
with pytest.raises(InvalidRequestException) as excinfo:
|
||||
r = db.create(typ, data_invalid, return_response=True)
|
||||
# FIXME
|
||||
# The following lines will not be called since
|
||||
# the InvalidRequestException is raised
|
||||
# in the previous line
|
||||
for k, v in list(test_failures["invalid"].items()):
|
||||
self.assertIn(k, list(r.keys()))
|
||||
assert "400 Bad Request" in str(excinfo.value)
|
||||
tests = test_failures["invalid"]
|
||||
if not isinstance(tests, list):
|
||||
tests = [tests]
|
||||
|
||||
for test in tests:
|
||||
data_invalid = copy.copy(data)
|
||||
for k, v in list(test.items()):
|
||||
data_invalid[k] = v
|
||||
|
||||
with pytest.raises(InvalidRequestException) as excinfo:
|
||||
r = db.create(typ, data_invalid, return_response=True)
|
||||
assert "400 Bad Request" in str(excinfo.value)
|
||||
|
||||
# we test fail because of parent entity status
|
||||
if "status" in test_failures:
|
||||
@@ -636,13 +636,26 @@ class TestJSON(unittest.TestCase):
|
||||
|
||||
# we test fail because of invalid data
|
||||
if "invalid" in test_failures:
|
||||
data_invalid = copy.copy(orig)
|
||||
for k, v in list(test_failures["invalid"].items()):
|
||||
data_invalid[k] = v
|
||||
|
||||
with pytest.raises(InvalidRequestException) as excinfo:
|
||||
db.update(typ, **data_invalid)
|
||||
assert "400 Bad Request" in str(excinfo.value)
|
||||
tests = test_failures["invalid"]
|
||||
|
||||
# `invalid` test_failures can be a list to
|
||||
# test multiple instances of invalid values
|
||||
# however we also support passing a single
|
||||
# dict of fields, in which case we wrap
|
||||
# it in a list here.
|
||||
|
||||
if not isinstance(tests, list):
|
||||
tests = [tests]
|
||||
|
||||
for test in tests:
|
||||
data_invalid = copy.copy(orig)
|
||||
for k, v in list(test.items()):
|
||||
data_invalid[k] = v
|
||||
|
||||
with pytest.raises(InvalidRequestException) as excinfo:
|
||||
db.update(typ, **data_invalid)
|
||||
assert "400 Bad Request" in str(excinfo.value)
|
||||
|
||||
# we test fail because of permissions
|
||||
if "perms" in test_failures:
|
||||
@@ -1513,7 +1526,10 @@ class TestJSON(unittest.TestCase):
|
||||
"ixpfx",
|
||||
data,
|
||||
test_failures={
|
||||
"invalid": {"prefix": "127.0.0.0/8"},
|
||||
"invalid": [
|
||||
{"prefix": "127.0.0.0/8"},
|
||||
{"in_dfz": False}
|
||||
],
|
||||
"perms": {
|
||||
"prefix": "205.127.237.0/24",
|
||||
"ixlan_id": SHARED["ixlan_r_ok"].id,
|
||||
@@ -1527,19 +1543,16 @@ class TestJSON(unittest.TestCase):
|
||||
|
||||
SHARED["ixpfx_id"] = r_data["id"]
|
||||
|
||||
# self.assert_create(self.db_org_admin, "ixpfx", data, test_failures={
|
||||
# "invalid": {
|
||||
# "prefix": "206.126.236.0/25"
|
||||
# },
|
||||
# }, test_success=False)
|
||||
|
||||
self.assert_update(
|
||||
self.db_org_admin,
|
||||
"ixpfx",
|
||||
SHARED["ixpfx_id"],
|
||||
{"prefix": "206.127.236.0/26"},
|
||||
test_failures={
|
||||
"invalid": {"prefix": "NEEDS TO BE VALID PREFIX"},
|
||||
"invalid": [
|
||||
{"prefix": "NEEDS TO BE VALID PREFIX"},
|
||||
{"in_dfz": False}
|
||||
],
|
||||
"perms": {"ixlan_id": SHARED["ixlan_r_ok"].id},
|
||||
},
|
||||
)
|
||||
@@ -1592,6 +1605,7 @@ class TestJSON(unittest.TestCase):
|
||||
self.db_org_admin, "ixpfx", test_protected=SHARED["ixpfx_id"]
|
||||
)
|
||||
|
||||
|
||||
##########################################################################
|
||||
|
||||
def test_org_admin_002_POST_PUT_DELETE_netixlan(self):
|
||||
|
||||
Reference in New Issue
Block a user