RM8741
Route create was allowing routes to be created without doing sanity checking on gateway, cidr or subnet_id. This patch adds that and three relevant tests.
This commit is contained in:
@@ -135,6 +135,38 @@ class TestQuarkCreateRoutes(test_quark_plugin.TestQuarkPlugin):
|
||||
self.plugin.create_route(self.context,
|
||||
dict(route=create_route))
|
||||
|
||||
def test_create_route_no_gateway_raises(self):
|
||||
subnet = dict(id=2, ip_policy=[], cidr="192.168.0.0/24")
|
||||
create_route = dict(id=1, cidr="192.168.0.0/24",
|
||||
subnet_id=subnet["id"])
|
||||
with self._stubs(create_route=create_route, find_routes=[],
|
||||
subnet=subnet):
|
||||
with self.assertRaises(
|
||||
exceptions.BadRequest):
|
||||
self.plugin.create_route(self.context,
|
||||
dict(route=create_route))
|
||||
|
||||
def test_create_route_no_cidr_raises(self):
|
||||
subnet = dict(id=2, ip_policy=[], cidr="192.168.0.0/24")
|
||||
create_route = dict(id=1, gateway="192.168.0.1",
|
||||
subnet_id=subnet["id"])
|
||||
with self._stubs(create_route=create_route, find_routes=[],
|
||||
subnet=subnet):
|
||||
with self.assertRaises(
|
||||
exceptions.BadRequest):
|
||||
self.plugin.create_route(self.context,
|
||||
dict(route=create_route))
|
||||
|
||||
def test_create_route_no_subnet_raises(self):
|
||||
subnet = dict(id=2, ip_policy=[], cidr="192.168.0.0/24")
|
||||
create_route = dict(id=1, cidr="192.168.0.0/24", gateway="192.168.0.1")
|
||||
with self._stubs(create_route=create_route, find_routes=[],
|
||||
subnet=subnet):
|
||||
with self.assertRaises(
|
||||
exceptions.BadRequest):
|
||||
self.plugin.create_route(self.context,
|
||||
dict(route=create_route))
|
||||
|
||||
|
||||
class TestQuarkDeleteRoutes(test_quark_plugin.TestQuarkPlugin):
|
||||
@contextlib.contextmanager
|
||||
|
Reference in New Issue
Block a user